public void Apply(ControllerModel controller)
 {
     if (controller.ControllerType.GetGenericTypeDefinition() == typeof(CrudController <,>))
     {
         var entityType = controller.ControllerType.GenericTypeArguments[0];
         var dtoType    = controller.ControllerType.GenericTypeArguments[1];
         FeatureAttribute featureAttribute = (FeatureAttribute)Attribute.GetCustomAttribute(dtoType, typeof(FeatureAttribute));
         controller.ControllerName = string.IsNullOrEmpty(featureAttribute.Name) ? dtoType.Name : featureAttribute.Name;
     }
 }
Beispiel #2
0
        public void PopulateFeature(IEnumerable <ApplicationPart> parts, ControllerFeature feature)
        {
            foreach (var dtoType in IncludedEntities.Types)
            {
                var typeName = dtoType.Name + "Controller";
                FeatureAttribute featureAttribute = (FeatureAttribute)Attribute.GetCustomAttribute(dtoType, typeof(FeatureAttribute));

                if (!feature.Controllers.Any(t => t.Name == typeName))
                {
                    var controllerType = typeof(CrudController <,>).MakeGenericType(featureAttribute.EntityType, dtoType.AsType()).GetTypeInfo();
                    feature.Controllers.Add(controllerType);
                }
            }
        }