public EnhancedTimeSpanUnitConstraint(EnhancedTimeSpan unit) { if (EnhancedTimeSpan.Zero > unit) { throw new ArgumentException(DataStrings.ExceptionNegativeUnit, "unit"); } this.unit = unit; }
public override PropertyConstraintViolationError Validate(object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag) { EnhancedTimeSpan t = (value is TimeSpan) ? ((TimeSpan)value) : ((EnhancedTimeSpan)value); if (EnhancedTimeSpan.Zero != t % this.unit) { return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationDontMatchUnit(this.unit.ToString(), t.ToString()), propertyDefinition, value, this)); } return(null); }
public static bool TryParse(string expression, out Unlimited <T> result) { bool flag = false; result = Unlimited <T> .UnlimitedValue; if (StringComparer.OrdinalIgnoreCase.Compare(expression, "Unlimited") == 0) { return(true); } object obj = null; if (typeof(T) == typeof(ByteQuantifiedSize)) { ByteQuantifiedSize byteQuantifiedSize; flag = ByteQuantifiedSize.TryParse(expression, out byteQuantifiedSize); obj = byteQuantifiedSize; } else if (typeof(T) == typeof(int)) { int num; flag = int.TryParse(expression, out num); obj = num; } else if (typeof(T) == typeof(uint)) { uint num2; flag = uint.TryParse(expression, out num2); obj = num2; } else if (typeof(T) == typeof(TimeSpan)) { TimeSpan timeSpan; flag = TimeSpan.TryParse(expression, out timeSpan); obj = timeSpan; } else if (typeof(T) == typeof(EnhancedTimeSpan)) { EnhancedTimeSpan enhancedTimeSpan; flag = EnhancedTimeSpan.TryParse(expression, out enhancedTimeSpan); obj = enhancedTimeSpan; } if (flag && obj != null) { result = (T)((object)obj); } return(flag); }
private Unlimited(string expression) { this = default(Unlimited <T>); if (StringComparer.OrdinalIgnoreCase.Compare(expression, "Unlimited") == 0) { this.isUnlimited = true; return; } object obj; if (typeof(T) == typeof(ByteQuantifiedSize)) { obj = ByteQuantifiedSize.Parse(expression); } else if (typeof(T) == typeof(int)) { obj = int.Parse(expression); } else if (typeof(T) == typeof(uint)) { obj = uint.Parse(expression); } else if (typeof(T) == typeof(TimeSpan)) { obj = TimeSpan.Parse(expression); } else { if (!(typeof(T) == typeof(EnhancedTimeSpan))) { throw new InvalidOperationException(DataStrings.ExceptionParseNotSupported); } obj = EnhancedTimeSpan.Parse(expression); } this.isUnlimited = false; this.limitedValue = (T)((object)obj); }
public NullableEnhancedTimeSpanUnitConstraint(EnhancedTimeSpan unit) : base(unit) { }
internal static MbxPropertyDefinition EnhancedTimeSpanFromNullableInt64PropertyDefinition(string name, MbxPropertyDefinition rawPropertyDefinition, bool multivalued = false) { return(new MbxPropertyDefinition(name, PropTag.Null, ExchangeObjectVersion.Exchange2003, typeof(EnhancedTimeSpan), (multivalued ? PropertyDefinitionFlags.MultiValued : PropertyDefinitionFlags.None) | PropertyDefinitionFlags.Calculated, multivalued ? null : EnhancedTimeSpan.FromDays(90.0), PropertyDefinitionConstraint.None, PropertyDefinitionConstraint.None, new MbxPropertyDefinition[] { rawPropertyDefinition }, (IPropertyBag propertyBag) => (propertyBag[rawPropertyDefinition] == null) ? default(EnhancedTimeSpan) : new TimeSpan((long)propertyBag[rawPropertyDefinition]), delegate(object value, IPropertyBag propertyBag) { propertyBag[rawPropertyDefinition] = ((TimeSpan)value).Ticks; })); }
public UnlimitedEnhancedTimeSpanUnitConstraint(EnhancedTimeSpan unit) : base(unit) { }