private Dictionary <string, PropertyValueBuilder> GetPropertyDefaults <T>(params Action <DefaultOverride <T> >[] defaultOverrideActions)
        {
            var newPropertyDefaults = new Dictionary <string, PropertyValueBuilder>();

            foreach (var defaultOverrideAction in defaultOverrideActions)
            {
                var defaultOverrider = new DefaultOverride <T>();
                defaultOverrider.OnPropertyNameSet = propertyName =>
                {
                    newPropertyDefaults[propertyName] = EmptyPropertyValueBuilder.Instance;
                };
                defaultOverrider.OnPropertyValueSet = (propertyName, propertyValue) =>
                {
                    newPropertyDefaults[propertyName] = new SingleValuePropertyValueBuilder(propertyValue);
                };
                defaultOverrider.OnPropertyValueSetToAuto = (propertyName, propertyValueType) =>
                {
                    ThrowExceptionIfNotReferenceType(propertyValueType, propertyName);
                    newPropertyDefaults[propertyName] = new AutoBuildPropertyValueBuilder(propertyValueType, GetInstance);
                };
                defaultOverrideAction(defaultOverrider);
            }
            ;

            ThrowExceptionIfAnyInvalidProperties(typeof(T), newPropertyDefaults, isDefaultOverride: false);

            return(newPropertyDefaults);
        }
Example #2
0
 public DefaultOverrideValue(string propertyName,
                             Action <string, object> onPropertyValueSetCallback,
                             Action <string, Type> onPropertyValueSetToAutoBuildCallback,
                             DefaultOverride <T> parent)
 {
     _propertyName = propertyName;
     _onPropertyValueSetCallback            = onPropertyValueSetCallback;
     _onPropertyValueSetToAutoBuildCallback = onPropertyValueSetToAutoBuildCallback;
     _parent = parent;
 }