public PartConstraintRule( PartTypeInfo info, bool minOccursIsNonZero, bool maxOccursGreatThanOne) { _info = info; MinOccursIsNonZero = minOccursIsNonZero; MaxOccursGreatThanOne = maxOccursGreatThanOne; }
public static PartConstraintCollection Create <T>(Type type) where T : IConstraintAttribute { var collection = new PartConstraintCollection(); foreach (var constraint in type.GetTypeInfo().GetCustomAttributes(inherit: true).OfType <T>()) { collection.Add(new PartConstraintRule(PartTypeInfo.Create(constraint.ConstraintType), constraint.MinOccursIsNonZero, constraint.MaxOccursGreatThanOne)); } if (collection.Count == 0) { return(Instance); } collection._writeable = false; return(collection); }