Beispiel #1
0
 internal Property(object name, Type valueType, object defaultValue, bool readOnly, PaintDotNet.PropertySystem.ValueValidationFailureResult vvfResult)
 {
     this.sync            = new object();
     this.eventAddAllowed = true;
     if (defaultValue != null)
     {
         Type c = defaultValue.GetType();
         if (!valueType.IsAssignableFrom(c))
         {
             throw new ArgumentOutOfRangeException("valueType", $"defaultValue is not of type specified in constructor. valueType.Name = {valueType.Name}, defaultValue.GetType().Name = {defaultValue.GetType().Name}");
         }
     }
     if (name.GetType().IsValueType)
     {
         this.originalNameValue = (System.ValueType)name;
     }
     this.name         = name.ToString();
     this.valueType    = valueType;
     this.ourValue     = defaultValue;
     this.defaultValue = defaultValue;
     this.readOnly     = readOnly;
     switch (vvfResult)
     {
     case PaintDotNet.PropertySystem.ValueValidationFailureResult.Ignore:
     case PaintDotNet.PropertySystem.ValueValidationFailureResult.Clamp:
     case PaintDotNet.PropertySystem.ValueValidationFailureResult.ThrowException:
         this.vvfResult = vvfResult;
         return;
     }
     throw ExceptionUtil.InvalidEnumArgumentException <PaintDotNet.PropertySystem.ValueValidationFailureResult>(vvfResult, "vvfResult");
 }
Beispiel #2
0
 internal Property(Property cloneMe, Property sentinelNotUsed)
 {
     this.sync            = new object();
     this.eventAddAllowed = true;
     sentinelNotUsed.NoOp();
     this.name = cloneMe.name;
     this.originalNameValue = cloneMe.originalNameValue;
     this.valueType         = cloneMe.valueType;
     this.ourValue          = cloneMe.ourValue;
     this.defaultValue      = cloneMe.defaultValue;
     this.readOnly          = cloneMe.readOnly;
     this.vvfResult         = cloneMe.vvfResult;
 }