Пример #1
0
 public static ModelPropertyBuilder <TOwner, TProperty> PropertyChanged <TOwner, TProperty>(
     this ModelPropertyBuilder <TOwner, TProperty> propertyBuilder,
     Action <PropertyChangedCallbackArgs <TOwner> > callback)
 {
     propertyBuilder.AddPropertyChanged(callback);
     return(propertyBuilder);
 }
Пример #2
0
 public static ModelPropertyBuilder <TOwner, TProperty> Calculate <TOwner, TProperty>(
     this ModelPropertyBuilder <TOwner, TProperty> propertyBuilder,
     Func <TOwner, TProperty> calculator)
 {
     propertyBuilder.SetCalculator(calculator);
     return(propertyBuilder);
 }
Пример #3
0
        internal static ModelProperty BuildUpProperty <TOwner, TProperty>(ModelPropertyBuilder <TOwner, TProperty> propertyBuilder)
        {
            var ownerType = typeof(TOwner);

            EnsureTypeDescriptionProviderCreated(ownerType);

            ModelProperty <TOwner> modelProperty;

            if (propertyBuilder.Calculator != null)
            {
                modelProperty = new CalculatedModelProperty <TOwner>(propertyBuilder.PropertyName, typeof(TProperty), o => propertyBuilder.Calculator((TOwner)o));
            }
            else
            {
                modelProperty = new InstanceModelProperty <TOwner>(propertyBuilder.PropertyName, typeof(TProperty), false);
            }

            foreach (var callback in propertyBuilder.Callback)
            {
                modelProperty.AddPropertyChanged(callback);
            }

            typeDescriptionProviders[ownerType].AddProperty(modelProperty);

            return(modelProperty);
        }
Пример #4
0
 public static ModelProperty Build <TOwner, TProperty>(this ModelPropertyBuilder <TOwner, TProperty> propertyBuilder)
 {
     return(ModelProperty.BuildUpProperty(propertyBuilder));
 }