Exemple #1
0
        private static void ConfigureViewModelProperty(PropertyInfo propInfo, ViewModelSettings vm,
                                                       List <Type> entities)
        {
            MemberDefinition propDef;

            if (PropertyInfoParser.IsPropertyIList(propInfo))
            {
                propDef = PropertyInfoParser.BuildCollectionDefinition(propInfo);
            }
            else
            {
                propDef = PropertyInfoParser.BuildPropertyDefinition(propInfo);
            }

            var attr = propInfo.GetCustomAttribute <ViewModelPropertyAttribute>();

            if (attr != null)
            {
                ApplyViewModelPropertyAttribute(propDef, attr);
            }

            // submit namespaces used by this property as usings
            var deps = propDef.Dependencies();

            foreach (var ns in deps)
            {
                vm.usings.Add(ns);
            }

            // collections
            if (propDef is CollectionDefinition)
            {
                ConfigureCollectionProperty(propInfo, vm, entities, propDef);
            }
            // entities
            else if (entities.Any(e => e.Name == propDef.PropertyType()))
            {
                ConfigureEntityProperty(propInfo, vm, entities, propDef);
            }

            // add or update this member on its view model settings
            SettingsBuilder.IncludeMemberDefinition(propDef, vm);
        }