/// <summary> /// Builds the controller. /// This method must be called at last of the build operation. /// </summary> public void Build() { var controllerInfo = new DynamicApiControllerInfo( _serviceName, typeof(T), typeof(DynamicApiController <T>), typeof(AbpDynamicApiControllerInterceptor <T>), _filters ); foreach (var actionBuilder in _actionBuilders.Values) { if (actionBuilder.DontCreate) { continue; } if (_conventionalVerbs && !actionBuilder.Verb.HasValue) { actionBuilder.WithVerb(DynamicApiVerbHelper.GetConventionalVerbForMethodName(actionBuilder.ActionName)); } controllerInfo.Actions[actionBuilder.ActionName] = actionBuilder.BuildActionInfo(); } DynamicApiControllerManager.Register(controllerInfo); }
private HttpVerb GetNormalizedVerb(bool conventionalVerbs) { if (Verb != null) { return(Verb.Value); } var demo = Method.GetType(); if (Method.IsDefined(typeof(HttpGetAttribute))) { return(HttpVerb.Get); } if (Method.IsDefined(typeof(System.SerializableAttribute))) { } if (Method.IsDefined(typeof(HttpPostAttribute))) { return(HttpVerb.Post); } if (Method.IsDefined(typeof(HttpPutAttribute))) { return(HttpVerb.Put); } if (Method.IsDefined(typeof(HttpDeleteAttribute))) { return(HttpVerb.Delete); } if (Method.IsDefined(typeof(HttpPatchAttribute))) { return(HttpVerb.Patch); } if (Method.IsDefined(typeof(HttpOptionsAttribute))) { return(HttpVerb.Options); } if (Method.IsDefined(typeof(HttpHeadAttribute))) { return(HttpVerb.Head); } if (conventionalVerbs) { var conventionalVerb = DynamicApiVerbHelper.GetConventionalVerbForMethodName(ActionName); if (conventionalVerb == HttpVerb.Get && !HasOnlyPrimitiveIncludingNullableTypeParameters(Method)) { conventionalVerb = DynamicApiVerbHelper.GetDefaultHttpVerb(); } return(conventionalVerb); } return(DynamicApiVerbHelper.GetDefaultHttpVerb()); }
private HttpVerb GetNormalizedVerb(bool conventionalVerbs) { if (Verb != null) { return(Verb.Value); } if (_methodInfo.IsDefined(typeof(HttpGetAttribute))) { return(HttpVerb.Get); } if (_methodInfo.IsDefined(typeof(HttpPostAttribute))) { return(HttpVerb.Post); } if (_methodInfo.IsDefined(typeof(HttpPutAttribute))) { return(HttpVerb.Put); } if (_methodInfo.IsDefined(typeof(HttpDeleteAttribute))) { return(HttpVerb.Delete); } if (conventionalVerbs) { var conventionalVerb = DynamicApiVerbHelper.GetConventionalVerbForMethodName(ActionName); if (conventionalVerb == HttpVerb.Get && !HasOnlyPrimitiveIncludingNullableTypeParameters(_methodInfo)) { conventionalVerb = DynamicApiVerbHelper.GetDefaultHttpVerb(); } return(conventionalVerb); } return(DynamicApiVerbHelper.GetDefaultHttpVerb()); }