コード例 #1
0
        internal override void StoreValue(Element element, object serialized, object source, TypeCache typeCache, Cache cache)
        {
            Node.Node node = element.EvalSingle(Query) as Node.Node;
            string value = (string) serialized;

            if (node == null && value != null && !String.IsNullOrEmpty(CreateQuery))
            {
                element.Eval(CreateQuery);
                node = element.EvalSingle(Query) as Node.Node;
            }
            else if (node != null && value == null)
            {
                node.Remove();
                return;
            }

            if (node != null)
            {
                node.Value = value;
            }
        }
コード例 #2
0
 internal override object FetchValue(Element element, object target, TypeCache typeCache, Cache cache)
 {
     object result = element.EvalSingle(Query);
     if (result == null) return null;
     Node.Node node = result as Node.Node;
     return GetObjectFromString(
         node != null ? node.Value : result.ToString(), Default, target, typeCache.Type, _typeConverter);
 }
コード例 #3
0
 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;
 }