public override object CreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) { PropertyConstraint email = (PropertyConstraint)propertyValues["EmailConstraint"]; PropertyConstraint future = (PropertyConstraint)propertyValues["FutureConstraint"]; PropertyConstraint length = (PropertyConstraint)propertyValues["LengthConstraint"]; PropertyConstraint notEmpty = (PropertyConstraint)propertyValues["NotEmptyConstraint"]; PropertyConstraint notNull = (PropertyConstraint)propertyValues["NotNullConstraint"]; PropertyConstraint notNullOrEmpty = (PropertyConstraint)propertyValues["NotNullOrEmptyConstraint"]; PropertyConstraint past = (PropertyConstraint)propertyValues["PastConstraint"]; PropertyConstraint range = (PropertyConstraint)propertyValues["RangeConstraint"]; PropertyConstraint regex = (PropertyConstraint)propertyValues["RegexConstraint"]; //PropertyConstrainTypes constrainTypes = (PropertyConstrainTypes) propertyValues["ConstrainTypes"]; OrmPropertyConstraints result = new OrmPropertyConstraints(); result.UpdateConstraint(email); result.UpdateConstraint(future); result.UpdateConstraint(length); result.UpdateConstraint(notEmpty); result.UpdateConstraint(notNull); result.UpdateConstraint(notNullOrEmpty); result.UpdateConstraint(past); result.UpdateConstraint(range); result.UpdateConstraint(regex); //result.ConstrainTypes = constrainTypes; return(result); }
public OrmPropertyConstraints Merge(OrmPropertyConstraints otherConstraints, MergeConflictAction mergeConflictAction) { OrmPropertyConstraints merged = new OrmPropertyConstraints(); foreach (var constraint in this.AllConstraints) { PropertyConstrainType constrainType = constraint.ConstrainType; PropertyConstraint otherConstraint = otherConstraints[constrainType]; PropertyConstraint mergedConstraint = (PropertyConstraint)constraint.MergeChanges(otherConstraint, mergeConflictAction); merged.UpdateConstraint(mergedConstraint); } return(merged); }