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);
        }