예제 #1
0
 public IReferInstance Refence(string name, string source, string sourceField, string target, string targetField)
 {
     if (string.IsNullOrEmpty(source))
     {
         return(this);
     }
     if (string.IsNullOrEmpty(name))
     {
         name = "t" + (++_asIndex);
     }
     if (_root[name] != null)
     {
         return(this);
     }
     if (string.IsNullOrEmpty(sourceField))
     {
         sourceField = "id";
     }
     if (string.IsNullOrEmpty(target))
     {
         sourceField = "$self";
     }
     if (string.IsNullOrEmpty(targetField))
     {
         sourceField = name + "Id";
     }
     _root.Add(new ReferEntry(name, source, sourceField, target, targetField));
     return(this);
 }
예제 #2
0
 void Parse_Object(Refer refer, NodeValue jsonValue)
 {
     string[] pairs = new string[5];
     foreach (System.Reflection.PropertyInfo propertyInfo in jsonValue.ValueType.GetProperties())
     {
         string key = propertyInfo.Name;
         if (string.Equals(key, "by", StringComparison.OrdinalIgnoreCase))
         {
             Parse_Pairs(pairs, 3, new NodeValue(propertyInfo.GetValue(jsonValue.Value, new object[0])));
         }
         else
         {
             pairs[0] = key;
             Parse_Pairs(pairs, 1, new NodeValue(propertyInfo.GetValue(jsonValue.Value, new object[0])));
         }
     }
     refer.Add(Create_Pairs(pairs));
 }
예제 #3
0
 void Parse_Dictionary(Refer refer, NodeValue jsonValue)
 {
     string[] pairs = new string[5];
     foreach (object item in (System.Collections.IEnumerable)jsonValue.Value)
     {
         string key = FastWrapper.Get(item, "Key") as string;
         if (string.IsNullOrEmpty(key))
         {
             continue;
         }
         object value = FastWrapper.Get(item, "Value");
         if (string.Equals(key, "by", StringComparison.OrdinalIgnoreCase))
         {
             Parse_Pairs(pairs, 3, new NodeValue(value));
         }
         else
         {
             pairs[0] = key;
             Parse_Pairs(pairs, 1, new NodeValue(value));
         }
     }
     refer.Add(Create_Pairs(pairs));
 }