private void ConfigureApiExplorer(ControllerModel controller) { if (controller.ApiExplorer.GroupName.IsNullOrEmpty()) { controller.ApiExplorer.GroupName = controller.ControllerName; } if (!controller.ApiExplorer.IsVisible.HasValue) { var controllerType = controller.ControllerType.AsType(); var daynamicWebApiServiceAttr = ReflectionExt.GetSingleAttributeOrDefault <DynamicWebApiAttribute> (controllerType.GetTypeInfo()); if (daynamicWebApiServiceAttr != null) { controller.ApiExplorer.IsVisible = daynamicWebApiServiceAttr.IsEnabledFor(controllerType) && daynamicWebApiServiceAttr.IsMetadataEnabledFor(controllerType); } else { controller.ApiExplorer.IsVisible = true; } } foreach (var action in controller.Actions) { ConfigureApiExplorer(action); } }
private static Quest LoggerQuest() { var logger = ServiceLocator.Current.GetInstance("ILogger"); return(new QuestBuilder() .WithTitle("Use a working Logger") .WithObjective("Use a working Logger, current logguer is {0}", logger == null ? "not defined" : logger.ToString()) .WithCondition(() => Task.FromResult(ReflectionExt.TryExecute(() => logger.Execute("Error", new object[] { "any" })))) .Build()); }
protected virtual void BuildModelFromDbContextType(MongoModelBuilder modelBuilder, Type dbContextType) { var collectionProperties = from property in dbContextType.GetTypeInfo().GetProperties(BindingFlags.Public | BindingFlags.Instance) where ReflectionExt.CanAssignableTo(property.PropertyType, typeof(IMongoCollection <>)) && typeof(IEntity).IsAssignableFrom(property.PropertyType.GenericTypeArguments[0]) select property; foreach (var collectionProperty in collectionProperties) { BuildModelFromDbContextCollectionProperty(modelBuilder, collectionProperty); } }
private void ConfigureSelector(string areaName, string controllerName, ActionModel action) { var nonDynamicWebApiAttr = ReflectionExt.GetSingleAttributeOrDefault <NonDynamicWebApiAttribute> (action.ActionMethod); if (nonDynamicWebApiAttr != null) { return; } RemoveEmptySelectors(action.Selectors); if (action.Selectors.Count <= 0) { AddApplicationServiceSelector(areaName, controllerName, action); } else { NormalizeSelectorRoutes(areaName, controllerName, action); } }
public void Apply(ApplicationModel application) { foreach (var controller in application.Controllers) { var controllerType = controller.ControllerType.AsType(); var daynamicWebApiServiceAttr = ReflectionExt.GetSingleAttributeOrDefault <DynamicWebApiAttribute> (controllerType.GetTypeInfo()); if (ImplementsDynamicWebApiInterface(controllerType)) { controller.ControllerName = controller.ControllerName.RemovePostFix(WebApiConsts.ControllerPostfixes.ToArray()); ConfigureApplicationService(controller, daynamicWebApiServiceAttr); } else { if (daynamicWebApiServiceAttr != null && daynamicWebApiServiceAttr.IsEnabledFor(controllerType)) { ConfigureApplicationService(controller, daynamicWebApiServiceAttr); } } } }