public void AddStatePropertyInfo(PropertyInfo key, StatePropertyInfo value) { ArgumentUtility.CheckNotNull("key", key); ArgumentUtility.CheckNotNull("value", value); _stateProperties.Add(NormalizeProperty(key), value); }
private XmlElement CreateStatePropertyNode(XmlDocument document, StatePropertyInfo propertyInfo) { XmlElement propertyElement = document.CreateElement("stateProperty", _metadataSchema.SchemaUri); XmlAttribute propertyIdAttribute = document.CreateAttribute("id"); propertyIdAttribute.Value = propertyInfo.ID; XmlAttribute propertyNameAttribute = document.CreateAttribute("name"); propertyNameAttribute.Value = propertyInfo.Name; propertyElement.Attributes.Append(propertyIdAttribute); propertyElement.Attributes.Append(propertyNameAttribute); foreach (EnumValueInfo enumValueInfo in propertyInfo.Values) { propertyElement.AppendChild(CreateStatePropertyValueNode(document, enumValueInfo)); } return(propertyElement); }
public StatePropertyInfo GetMetadata(PropertyInfo property, MetadataCache cache) { ArgumentUtility.CheckNotNull("property", property); if (!property.PropertyType.IsEnum) { throw new ArgumentException( string.Format("The type of the property '{0}' in type '{1}' is not an enumerated type.", property.Name, property.DeclaringType.FullName), "property"); } if (!Attribute.IsDefined(property.PropertyType, typeof(SecurityStateAttribute), false)) { throw new ArgumentException(string.Format("The type of the property '{0}' in type '{1}' does not have the {2} applied.", property.Name, property.DeclaringType.FullName, typeof(SecurityStateAttribute).FullName), "property"); } ArgumentUtility.CheckNotNull("cache", cache); StatePropertyInfo info = cache.GetStatePropertyInfo(property); if (info == null) { info = new StatePropertyInfo(); info.Name = property.Name; PermanentGuidAttribute attribute = (PermanentGuidAttribute)Attribute.GetCustomAttribute(property, typeof(PermanentGuidAttribute), true); if (attribute != null) { info.ID = attribute.Value.ToString(); } info.Values = new List <EnumValueInfo> (_enumerationReflector.GetValues(property.PropertyType, cache).Values); cache.AddStatePropertyInfo(property, info); } return(info); }
private LocalizedName CreateLocalizedNameFromStatePropertyInfo(StatePropertyInfo propertyInfo, string text) { return(new LocalizedName(propertyInfo.ID, propertyInfo.Name, propertyInfo.Description)); }
private LocalizedName CreateLocalizedNameForState(StatePropertyInfo property, EnumValueInfo state, string text) { string description = property.Name + "|" + state.Name; return(new LocalizedName(property.ID + "|" + state.Value, property.Name + "|" + state.Name, description)); }
private XmlElement CreateStatePropertyRefElement(XmlDocument document, StatePropertyInfo propertyInfo) { return(CreateRefElement(document, "statePropertyRef", propertyInfo.ID)); }