示例#1
0
文件: JMbr.cs 项目: skyiah/skyterm
 public JMbr(JObj v, string name = null)
 {
     this.name = name;
     type      = JType.Object;
     refv      = v;
     numv      = default;
 }
示例#2
0
 public void Put(string name, JObj v)
 {
     if (counts[level]++ > 0)
     {
         Add(',');
     }
     if (name != null)
     {
         Add('"');
         Add(name);
         Add('"');
         Add(':');
     }
     if (v == null)
     {
         Add("null");
     }
     else
     {
         counts[++level] = 0; // enter
         Add('{');
         v.Write(this);
         Add('}');
         level--; // exit
     }
 }
示例#3
0
文件: JObj.cs 项目: skyiah/skyterm
        public bool Get(string name, ref JObj v)
        {
            if (TryGetValue(name, out var mbr))
            {
                v = mbr;
                return(true);
            }

            return(false);
        }
示例#4
0
文件: JObj.cs 项目: skyiah/skyterm
        public bool Get <D>(string name, ref D v, byte proj = 0x0f) where D : IData, new()
        {
            if (TryGetValue(name, out var mbr))
            {
                JObj jobj = mbr;
                if (jobj != null)
                {
                    v = new D();
                    v.Read(jobj);
                }

                return(true);
            }

            return(false);
        }
示例#5
0
        public static D FileToObject <D>(string file, byte proj = 0x0f) where D : IData, new()
        {
            try
            {
                byte[] bytes = File.ReadAllBytes(file);
                JObj   jo    = (JObj) new JsonParser(bytes, bytes.Length).Parse();
                if (jo != null)
                {
                    return(jo.ToObject <D>(proj));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }

            return(default);
示例#6
0
文件: JObj.cs 项目: skyiah/skyterm
        public bool Get <D>(string name, ref D[] v, byte proj = 0x0f) where D : IData, new()
        {
            if (TryGetValue(name, out var mbr))
            {
                JArr ja = mbr;
                if (ja != null)
                {
                    v = new D[ja.Count];
                    for (int i = 0; i < ja.Count; i++)
                    {
                        JObj jo  = ja[i];
                        D    dat = new D();
                        dat.Read(jo);
                        v[i] = dat;
                    }
                }

                return(true);
            }

            return(false);
        }
示例#7
0
 public void Put(string name, JObj v)
 {
 }
示例#8
0
文件: XElem.cs 项目: skyiah/skyterm
 public bool Get(string name, ref JObj v)
 {
     throw new NotImplementedException();
 }
示例#9
0
        public bool Get(string name, ref long v)
        {
            JObj jo = elements[current];

            return(jo != null && jo.Get(name, ref v));
        }
示例#10
0
 public void Add(JObj elem)
 {
     Add(new JMbr(elem));
 }
示例#11
0
        public bool Get <D>(string name, ref D[] v, byte proj = 0x0f) where D : IData, new()
        {
            JObj jo = elements[current];

            return(jo != null && jo.Get(name, ref v));
        }
示例#12
0
        public bool Get(string name, ref ArraySegment <byte> v)
        {
            JObj jo = elements[current];

            return(jo != null && jo.Get(name, ref v));
        }
示例#13
0
文件: JObj.cs 项目: skyiah/skyterm
 public void Add(string name, JObj v)
 {
     Add <JMbr>(new JMbr(v, name));
 }
示例#14
0
文件: Form.cs 项目: skyiah/skyterm
 public bool Get(string name, ref JObj v)
 {
     return(false);
 }
示例#15
0
 public void Put(string name, JObj v)
 {
     throw new NotImplementedException();
 }
示例#16
0
        public static D StringToObject <D>(string v, byte proj = 0x0f) where D : IData, new()
        {
            JObj jo = (JObj) new JsonParser(v).Parse();

            return(jo.ToObject <D>(proj));
        }