Example #1
0
 // values
 public static string Value(this xElement element)
 {
     if (element == null)
     {
         return(null);
     }
     return(element.Value);
 }
Example #2
0
 // names
 public static string Name(this xElement element)
 {
     if (element == null)
     {
         return(null);
     }
     return(element.Name);
 }
Example #3
0
        internal static T Convert <T>(xElement element, TryParse <T> parser, T defaultValue)
        {
            T value;

            if (element != null && parser(element.Value, out value))
            {
                return(value);
            }
            return(defaultValue);
        }
Example #4
0
        public static xAttributes Attributes(this xElement element)
        {
            if (element == null)
            {
                return(sEmptyAttributes);
            }
            var attributes = element.XElement.Attributes();

            return(new xAttributes(attributes.Select(i => new xAttribute(element._Document, element, i))));
        }
Example #5
0
        public static TEnum AsEnum <TEnum>(this xElement element, TEnum defaultValue)
            where TEnum : struct
        {
            TEnum value;

            if (element != null && Enum.TryParse(element.Value, true, out value))
            {
                return(value);
            }
            return(defaultValue);
        }
Example #6
0
        public static xAttributes Attributes(this xElement element, string name)
        {
            aError.CheckNull(name, "name");
            if (element == null)
            {
                return(sEmptyAttributes);
            }
            var attributes = element.XElement.Attributes(name);

            return(new xAttributes(attributes.Select(i => new xAttribute(element._Document, element, i))));
        }
Example #7
0
        // attributes
        public static xAttribute Attribute(this xElement element, string name)
        {
            if (element == null)
            {
                return(null);
            }
            if (!element.HasAttributes)
            {
                return(null);
            }
            var attribute = element.XElement.Attribute(name);

            if (attribute == null)
            {
                return(null);
            }
            return(new xAttribute(element._Document, element, attribute));
        }
Example #8
0
 internal xObject(xDocument document, xElement parent)
 {
     mDocument = document;
     mParent   = parent;
 }
Example #9
0
 internal xElement(xDocument document, xElement parent, XElement element)
     : base(document, parent, element)
 {
     mElement = element;
 }
Example #10
0
 // explicit casts
 public static TEnum AsEnum <TEnum>(this xElement element)
     where TEnum : struct
 {
     return(AsEnum(element, default(TEnum)));
 }
Example #11
0
 internal xAttribute(xDocument document, xElement parent, XAttribute attribute)
     : base(document, parent)
 {
     aError.CheckNull(attribute, "attribute");
     mAttribute = attribute;
 }