public static PartConstraintCollection Create <T>(Func <Type, OpenXmlElementData> dataFactory, Type type) where T : IConstraintAttribute { var collection = new PartConstraintCollection(); foreach (var constraint in type.GetTypeInfo().GetCustomAttributes(inherit: false).OfType <T>()) { collection.Add(new PartConstraintRule(dataFactory(constraint.ConstraintType).Info, constraint.MinOccursIsNonZero, constraint.MaxOccursGreatThanOne)); } if (collection.Count == 0) { return(Instance); } collection._writeable = false; return(collection); }
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); }
public OpenXmlPartData(Type type, Func <Type, OpenXmlElementData> dataFactory) { _constraints = new Lazy <PartConstraintCollection>(() => PartConstraintCollection.Create <PartConstraintAttribute>(dataFactory, type), true); _dataParts = new Lazy <PartConstraintCollection>(() => PartConstraintCollection.Create <DataPartConstraintAttribute>(dataFactory, type), true); }
public OpenXmlPartData(Type type) { _constraints = new Lazy <PartConstraintCollection>(() => PartConstraintCollection.Create <PartConstraintAttribute>(type), true); _dataParts = new Lazy <PartConstraintCollection>(() => PartConstraintCollection.Create <DataPartConstraintAttribute>(type), true); }