public void RemoveAttribute(string name) { if (HasAttribute(name)) { attributes.Remove(name); elementAttributes.Remove(name); } }
/// <summary> /// Convert custom attributes (that aren't found via reflection, e.g. width/height) into useable values /// </summary> /// <param name="attributes"></param> /// <returns></returns> protected AttributeDictionary HandleCustomAttributes(AttributeDictionary attributes) { var elementName = XmlLayoutUtilities.GetTagName(GetType()); //var elementName = this.GetType().Name.Replace("TagHandler", String.Empty); var customAttributes = attributes.Where(k => XmlLayoutUtilities.IsCustomAttribute(k.Key)).ToList(); foreach (var attribute in customAttributes) { var customAttribute = XmlLayoutUtilities.GetCustomAttribute(attribute.Key); if (customAttribute.RestrictToPermittedElementsOnly) { if (!customAttribute.PermittedElements.Contains(elementName, StringComparer.OrdinalIgnoreCase)) { continue; } } if (customAttribute.UsesConvertMethod) { attributes = XmlLayoutUtilities.MergeAttributes( attributes, customAttribute.Convert(attribute.Value, attributes.AsReadOnly(), this.currentXmlElement)); } if (customAttribute.UsesApplyMethod) { customAttribute.Apply(currentXmlElement, attribute.Value, attributes.AsReadOnly()); } if (customAttribute.UsesApplyMethod && !defaultAttributeValues.ContainsKey(attribute.Key)) { defaultAttributeValues.Add(attribute.Key, customAttribute.DefaultValue); } if (!customAttribute.KeepOriginalTag) { attributes.Remove(attribute.Key); } } return(attributes); }