Exemple #1
0
 public ICollection <IReflectedClass> BuildApplicationEntityMetadataReflectedClasses()
 {
     return(_reflectedClassManager.GetReflectedClasses(_applicationMetadataProvider.MetadataAssemblyTypes,
                                                       x => x.IsPublic,
                                                       x => !x.IsAbstract,
                                                       x => _customAttributeProviderManager.HasAttribute <DynamicEntityAttribute>(x)
                                                       ).ToList());
 }
        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);
        }