protected virtual void Populate(Enum schema) { this.schema = schema; if (schema == null) { // reset reflective properties to defaults this.Category = XmpCategory.External; this.Description = null; this.Name = null; this.Namespace = null; this.Quantity = XmpQuantity.Single; this.ValueType = XmpBasicType.Unknown; return; } string name; FieldInfo fieldInfo; Type type = AttributeUtility.GetEnumInfo(schema, out name, out fieldInfo); // check for property info on property enum only XmpPropertyAttribute xp = AttributeUtility .FindAttributes <XmpPropertyAttribute>(fieldInfo) .FirstOrDefault(); if (xp == null) { this.Category = XmpCategory.External; this.Name = name; this.Quantity = XmpQuantity.Single; this.ValueType = XmpBasicType.Unknown; } else { this.Category = xp.Category; this.Name = String.IsNullOrEmpty(xp.Name) ? name : xp.Name; this.Quantity = xp.Quantity; this.ValueType = xp.ValueType; } // check for namespace on property enum, then on type XmpNamespaceAttribute xns = AttributeUtility .FindAttributes <XmpNamespaceAttribute>(fieldInfo, type) .FirstOrDefault() ?? XmpNamespaceAttribute.Empty; this.Namespace = xns.Namespace; this.Prefix = xns.PreferredPrefix; // check for description on property enum only this.Description = AttributeUtility .FindAttributes <DescriptionAttribute>(fieldInfo) .Select(d => d.Description) .FirstOrDefault(); string valueTypeName; FieldInfo valueTypeInfo; AttributeUtility.GetEnumInfo(this.ValueType, out valueTypeName, out valueTypeInfo); }
private IEnumerable <string> GetQueryForSchema(Enum schema) { if (schema is ExifSchema) { yield return("/app1/{ushort=0}/exif/{ushort=" + schema.ToString("D") + "}"); yield return("/app1/ifd/exif/{ushort=" + schema.ToString("D") + "}"); } else if (schema is ExifTiffSchema) { yield return("/app1/{ushort=0}/{ushort=" + schema.ToString("D") + "}"); yield return("/app1/ifd/{ushort=" + schema.ToString("D") + "}"); } string name; FieldInfo fieldInfo; Type type = AttributeUtility.GetEnumInfo(schema, out name, out fieldInfo); // check for namespace on property enum, then on type XmpNamespaceAttribute xns = AttributeUtility .FindAttributes <XmpNamespaceAttribute>(fieldInfo, type) .FirstOrDefault() ?? XmpNamespaceAttribute.Empty; // check for property info on property enum only XmpPropertyAttribute xp = AttributeUtility .FindAttributes <XmpPropertyAttribute>(fieldInfo) .FirstOrDefault(); if (xp != null && !String.IsNullOrEmpty(xp.Name)) { name = xp.Name; } if (xns == null || !xns.Prefixes.Any()) { yield return("/xmp/" + name); } else { foreach (string prefix in xns.Prefixes) { yield return("/xmp/" + prefix + ':' + name); } } }