Ejemplo n.º 1
0
        private static void BuildViewModelSettingsForEntity(Type entity, RenderSettings settings,
                                                            List <Type> allEntities)
        {
            var attr = entity.GetCustomAttribute <ViewModelAttribute>();
            var vms  = new ViewModelSettings();

            vms.EntityType(entity.Name);
            vms.EntityNamespace(entity.Namespace);
            vms.HasPublicEntity(entity.IsPublic);

            if (attr != null)
            {
                ApplyViewModelAttribute(vms, attr);
            }

            // add or update the view model on its namespace settings
            SettingsBuilder.IncludeViewModelSettings(settings, vms);

            // find and build view model rendering settings for all relevant properties in the entity
            var props = DiscoverViewModelProperties(vms, entity);

            foreach (var p in props)
            {
                ConfigureViewModelProperty(p, vms, allEntities);
            }
        }