Exemplo n.º 1
0
 public static ModelPropertiesCollectionBuilder <TOwner, TInstance> PropertyChanged <TOwner, TInstance>(
     this ModelPropertiesCollectionBuilder <TOwner, TInstance> propertiesBuilder,
     string propertyName,
     Action <PropertyChangedCallbackArgs <TOwner> > callback)
 {
     propertiesBuilder.AddPropertyChanged(propertyName, callback);
     return(propertiesBuilder);
 }
Exemplo n.º 2
0
 public static ModelPropertyCollection <TOwner, TInstance> Build <TOwner, TInstance>(this ModelPropertiesCollectionBuilder <TOwner, TInstance> propertiesBuilder)
 {
     return(ModelProperty.BuildUpCollection(propertiesBuilder));
 }
Exemplo n.º 3
0
        internal static ModelPropertyCollection <TOwner, TInstance> BuildUpCollection <TOwner, TInstance>(ModelPropertiesCollectionBuilder <TOwner, TInstance> propertiesBuilder)
        {
            var ownerType = typeof(TOwner);
            var modelType = typeof(TInstance);

            EnsureTypeDescriptionProviderCreated(ownerType);

            List <ModelProperty> newModelProperties = new List <ModelProperty>();

            foreach (var modelPropInfo in modelType.GetProperties())
            {
                InstanceModelProperty <TOwner> modelProp;

                if (propertiesBuilder.Mappings.ContainsKey(modelPropInfo.Name))
                {
                    modelProp = new MappedInstanceModelProperty <TOwner>(
                        modelPropInfo.Name,
                        propertiesBuilder.Mappings[modelPropInfo.Name],
                        !modelPropInfo.CanWrite,
                        modelPropInfo.PropertyType);
                }
                else
                {
                    modelProp = new InstanceModelProperty <TOwner>(
                        modelPropInfo.Name,
                        modelPropInfo.PropertyType,
                        !modelPropInfo.CanWrite);
                }

                if (propertiesBuilder.Callbacks.ContainsKey(modelPropInfo.Name))
                {
                    modelProp.AddPropertyChanged(propertiesBuilder.Callbacks[modelPropInfo.Name]);
                }

                foreach (var filter in propertiesBuilder.FilteredCallbacks)
                {
                    if (!filter.Filter(modelPropInfo.Name))
                    {
                        continue;
                    }

                    modelProp.AddPropertyChanged(filter.Callback);
                }

                newModelProperties.Add(modelProp);
                typeDescriptionProviders[ownerType].AddProperty(modelProp);
            }

            return(new ModelPropertyCollection <TOwner, TInstance>(newModelProperties));
        }