public static ElementSchemaLookup CreateLookup(Type type, PackageCache cache) { List <ElementInfo> lookup = null; foreach (var child in GetChildTypes(type)) { if (lookup == null) { lookup = new List <ElementInfo>(); } var schema = child.GetTypeInfo().GetCustomAttribute <SchemaAttrAttribute>(); if (schema == null) { throw new InvalidOperationException($"{child} does not contain schema information"); } var key = new ElementInfo(schema.NamespaceId, schema.Tag, cache.GetFactory <OpenXmlElement>(child)); lookup.Add(key); } if (lookup == null) { return(Empty); } lookup.Sort(ElementInfoComparer.Instance); return(new ElementSchemaLookup(lookup)); }
public T Create() { if (_activator is null) { lock (this) { if (_activator is null) { _activator = _cache.GetFactory <T>(_property.PropertyType); _cache = null; CleanUp(); } } } return(_activator()); }