1- using NetCoreStack . Common ;
1+ using Microsoft . AspNetCore . Mvc . Abstractions ;
2+ using Microsoft . AspNetCore . Mvc . ModelBinding ;
3+ using NetCoreStack . Contracts ;
4+ using NetCoreStack . Proxy . Extensions ;
5+ using System ;
26using System . Collections . Generic ;
3- using System . Reflection ;
47using System . Linq ;
5- using System ;
6- using NetCoreStack . Proxy . Extensions ;
7- using Microsoft . AspNetCore . Mvc . Routing ;
8- using Microsoft . AspNetCore . Mvc ;
98using System . Net . Http ;
10- using Microsoft . AspNetCore . Mvc . ModelBinding ;
11- using Microsoft . AspNetCore . Mvc . Abstractions ;
12- using NetCoreStack . Common . Extensions ;
9+ using System . Reflection ;
1310
1411namespace NetCoreStack . Proxy . Internal
1512{
@@ -32,16 +29,16 @@ private IList<ProxyDescriptor> GetProxyDescriptors()
3229 var descriptors = new List < ProxyDescriptor > ( ) ;
3330 foreach ( var proxyType in types )
3431 {
35- var path = proxyType . GetTypeInfo ( ) . GetCustomAttribute < ApiRouteAttribute > ( ) ;
36- if ( path == null )
32+ var pathAttr = proxyType . GetTypeInfo ( ) . GetCustomAttribute < ApiRouteAttribute > ( ) ;
33+ if ( pathAttr == null )
3734 throw new ArgumentNullException ( $ "{ nameof ( ApiRouteAttribute ) } required for Proxy - Api interface.") ;
3835
39- if ( ! path . RegionKey . HasValue ( ) )
40- throw new ArgumentOutOfRangeException ( $ "Specify the \" { nameof ( path . RegionKey ) } \" !") ;
36+ if ( ! pathAttr . RegionKey . HasValue ( ) )
37+ throw new ArgumentOutOfRangeException ( $ "Specify the \" { nameof ( pathAttr . RegionKey ) } \" !") ;
4138
42- var route = proxyType . Name . GetApiRawName ( path . Template ) ;
39+ var route = proxyType . Name . GetApiRawName ( pathAttr . RouteTemplate ) ;
4340
44- ProxyDescriptor descriptor = new ProxyDescriptor ( proxyType , path . RegionKey , route ) ;
41+ ProxyDescriptor descriptor = new ProxyDescriptor ( proxyType , pathAttr . RegionKey , route ) ;
4542
4643 var interfaces = proxyType . GetInterfaces ( )
4744 . Except ( new List < Type > { typeof ( IApiContract ) , typeof ( IDependency ) } ) . ToList ( ) ;
@@ -69,21 +66,12 @@ private IList<ProxyDescriptor> GetProxyDescriptors()
6966 proxyMethodDescriptor . Timeout = timeoutAttr . Timeout ;
7067
7168 var httpMethodAttribute = method . GetCustomAttributes ( inherit : true )
72- . OfType < HttpMethodAttribute > ( ) . FirstOrDefault ( ) ;
69+ . OfType < HttpMethodMarkerAttribute > ( ) . FirstOrDefault ( ) ;
7370
7471 if ( httpMethodAttribute != null )
7572 {
76- if ( httpMethodAttribute is HttpPostAttribute )
73+ if ( httpMethodAttribute is HttpPostMarkerAttribute )
7774 proxyMethodDescriptor . HttpMethod = HttpMethod . Post ;
78-
79- else if ( httpMethodAttribute is HttpGetAttribute )
80- proxyMethodDescriptor . HttpMethod = HttpMethod . Get ;
81-
82- else if ( httpMethodAttribute is HttpPutAttribute )
83- proxyMethodDescriptor . HttpMethod = HttpMethod . Put ;
84-
85- else if ( httpMethodAttribute is HttpDeleteAttribute )
86- proxyMethodDescriptor . HttpMethod = HttpMethod . Delete ;
8775 }
8876 else
8977 {
@@ -94,18 +82,6 @@ private IList<ProxyDescriptor> GetProxyDescriptors()
9482 proxyMethodDescriptor . Parameters = new List < ParameterDescriptor > ( ) ;
9583 foreach ( var parameter in method . GetParameters ( ) )
9684 {
97- //if (proxyMethodDescriptor.HttpMethod == HttpMethod.Get)
98- //{
99- // if (parameter.ParameterType.IsReferenceType() &&
100- // !typeof(IQueryStringTransferable).IsAssignableFrom(parameter.ParameterType))
101- // {
102- // throw new InvalidOperationException($"API methods that take a reference type parameter and are marked with HttpGet " +
103- // $"should be derived from the {nameof(IQueryStringTransferable)} " +
104- // $"or method should be marked as HttpPost. MethodName: \"{method.Name}\", " +
105- // $"ParameterType: \"{parameter.ParameterType.Name}\"");
106- // }
107- //}
108-
10985 proxyMethodDescriptor . Parameters . Add ( new ParameterDescriptor ( )
11086 {
11187 Name = parameter . Name ,
0 commit comments