예제 #1
0
        public IEnumerable <IReflectedDynamicClass> GetReflectedDynamicClasses()
        {
            var results                        = new List <ReflectedDynamicClass>();
            var controllerTypes                = _applicationMetadataProvider.MvcAssemblyTypes.Where(x => _namingConventionManager.IsController(x)).ToList();
            var entityMetadataTypes            = _applicationMetadataProvider.MetadataAssemblyTypes.Where(x => _customAttributeProviderManager.HasAttribute <DynamicEntityAttribute>(x)).ToList();
            var entityMetadataReflectedClasses = _reflectedLibraryManager.GetReflectedClasses(entityMetadataTypes).ToList();

            foreach (var entityMetaDataReflectedClass in entityMetadataReflectedClasses)
            {
                ReflectedDynamicClass reflectedDynamicClass = null;

                var dynamicEntityAttribute = entityMetaDataReflectedClass.Attributes.GetAttribute <DynamicEntityAttribute>();

                if (dynamicEntityAttribute.EntityType == null)
                {
                    reflectedDynamicClass = (ReflectedDynamicClass)entityMetaDataReflectedClass;
                }
                else
                {
                    reflectedDynamicClass = (ReflectedDynamicClass)_reflectedLibraryManager.GetReflectedClass(dynamicEntityAttribute.EntityType);
                    reflectedDynamicClass.MergeAttributes(entityMetaDataReflectedClass);
                }

                reflectedDynamicClass.ControllerReflectedClass = (ReflectedClass)GetControllerReflectedClass(controllerTypes, reflectedDynamicClass.Name);
                results.Add(reflectedDynamicClass);
            }

            return(results);
        }
예제 #2
0
        public IEnumerable <ApplicationControllerMetadata> Build()
        {
            var applicationControllerMetadatas = new List <ApplicationControllerMetadata>();

            foreach (var type in _applicationMetadataProvider.MvcAssemblyTypes.Where(x => _namingConventionManager.IsController(x)))
            {
                var applicationControllerMetadata = new ApplicationControllerMetadata(type.Name);
                applicationControllerMetadatas.Add(applicationControllerMetadata);
                var applicationControllerMethodMetadatas = _applicationControllerMethodMetadataBuilder.Build(applicationControllerMetadata, type);
                applicationControllerMetadata.ApplicationControllerMethods.AddRange(applicationControllerMethodMetadatas);
            }

            return(applicationControllerMetadatas);
        }