Attribute() 공개 메소드

Gets the attribute with the specified name.
public Attribute ( string name ) : Attribute
name string The name of the attribute to get.
리턴 Attribute
 internal override object FetchValue(Element element, object target, TypeCache typeCache, Cache cache)
 {
     Node.Attribute attribute;
     if (!GetNodeFromQuery(Query, null, element, out attribute))
     {
         attribute = element.Attribute(Name);
     }
     return attribute == null ? null : GetObjectFromString(attribute.Value, Default, target, typeCache.Type, _typeConverter);
 }
        internal override void StoreValue(Element element, object serialized, object source, TypeCache typeCache, Cache cache)
        {
            Node.Attribute attribute;
            if (!GetNodeFromQuery(Query, CreateQuery, element, out attribute))
            {
                attribute = element.Attribute(Name);
            }
            else if (attribute == null)
            {
                return;
            }

            string value = (string) serialized;
            if (attribute == null && value != null)
            {
                element.InsertAttribute(Name, value);
            }
            else if (attribute != null && value == null)
            {
                attribute.Remove();
            }
            else if (attribute != null)
            {
                attribute.Value = value;
            }
        }
 private object FetchValue(Element item, string attributeName, string elementName, string query,
     bool arePersistentObjects, bool attach, TypeCache typeCache, TypeConverter typeConverter, Cache cache)
 {
     object value = null;
     if (!String.IsNullOrEmpty(attributeName))
     {
         Node.Attribute attribute = item.Attribute(attributeName);
         value = attribute == null ? null : GetObjectFromString(attribute.Value, null, null, typeCache.Type, typeConverter);
     }
     else
     {
         object result = !String.IsNullOrEmpty(query) ? item.EvalSingle(query)
             : item.Children.OfType<Element>().FirstOrDefault(e => e.Name.Equals(elementName));
         if (arePersistentObjects)
         {
             // Get, attach, and fetch the persistent object instance
             Element element = result as Element;
             if (element == null) throw new Exception("Persistent value node must be an element.");
             value = cache.GetObject(typeCache, element, attach);
         }
         else
         {
             Node.Node itemNode = result as Node.Node;
             value = GetObjectFromString(itemNode != null ? itemNode.Value
                 : result == null ? null : result.ToString(), null, null, typeCache.Type, typeConverter);
         }
     }
     return value;
 }