Exemple #1
0
        public static XElement AddElement(this XElement element, string name, object value, XmlSemanticAnnotation annotation, bool annotateName = false)
        {
            annotation.AppliesToName = annotateName;
            var child = new XElement(name);

            element.Add(child);

            child.AddAnnotation(annotation);

            return(element);
        }
Exemple #2
0
        public static XElement AddAttribute(this XElement element, string name, object value, XmlSemanticAnnotation annotation = null, bool annotateName = false)
        {
            var attribute = element.Attribute(name);

            value = value.ToString().Replace('<', LessThanAlt).Replace('>', GreaterThanAlt);

            if (attribute == null)
            {
                attribute = new XAttribute(name, value);
                element.Add(attribute);
            }

            if (annotation != null)
            {
                annotation.AppliesToName = annotateName;
                attribute.AddAnnotation(annotation);
            }

            return(element);
        }