Esempio n. 1
0
 public JMbr(string name, JArr v)
 {
     this.name = name;
     type      = JType.Array;
     refv      = v;
     numv      = default(JNumber);
 }
Esempio n. 2
0
        public bool Get <D>(string name, ref D[] v, int proj = 0x00ff) where D : IData, new()
        {
            try
            {
                int ord = reader.GetOrdinal(name);
                if (!reader.IsDBNull(ord))
                {
                    string    str   = reader.GetString(ord);
                    JsonParse parse = new JsonParse(str);
                    JArr      ja    = (JArr)parse.Parse();
                    int       len   = ja.Count;
                    v = new D[len];
                    for (int i = 0; i < len; i++)
                    {
                        JObj jo  = ja[i];
                        D    obj = new D();
                        obj.Read(jo, proj);

                        // add shard if any
                        IShardable sharded = obj as IShardable;
                        if (sharded != null)
                        {
                            sharded.Shard = service.Shard;
                        }

                        v[i] = obj;
                    }
                    return(true);
                }
            }
            catch
            {
            }
            return(false);
        }
Esempio n. 3
0
 public static D[] FileToArray <D>(string file, int proj = 0x00ff) where D : IData, new()
 {
     try
     {
         byte[] bytes = File.ReadAllBytes(file);
         JArr   ja    = (JArr) new JsonParse(bytes, bytes.Length).Parse();
         if (ja != null)
         {
             return(ja.ToArray <D>(proj));
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
     return(null);
 }
Esempio n. 4
0
 public bool Get(string name, ref JArr v)
 {
     try
     {
         int ord = reader.GetOrdinal(name);
         if (!reader.IsDBNull(ord))
         {
             string    str   = reader.GetString(ord);
             JsonParse parse = new JsonParse(str);
             v = (JArr)parse.Parse();
             return(true);
         }
     }
     catch
     {
     }
     return(false);
 }
Esempio n. 5
0
        public bool Get(string name, ref string[] v)
        {
            JMbr mbr;

            if (TryGet(name, out mbr))
            {
                JArr ja = mbr;
                if (ja != null)
                {
                    v = new string[ja.Count];
                    for (int i = 0; i < ja.Count; i++)
                    {
                        v[i] = ja[i];
                    }
                }
                return(true);
            }
            return(false);
        }
Esempio n. 6
0
 public DbParameters Put(string name, JArr v)
 {
     if (name == null)
     {
         name = Defaults[position++];
     }
     if (v == null)
     {
         coll.Add(new NpgsqlParameter(name, NpgsqlDbType.Jsonb)
         {
             Value = DBNull.Value
         });
     }
     else
     {
         coll.Add(new NpgsqlParameter(name, NpgsqlDbType.Jsonb)
         {
             Value = v.ToString()
         });
     }
     return(this);
 }
Esempio n. 7
0
        public bool Get <D>(string name, ref D[] v, int proj = 0x00ff) where D : IData, new()
        {
            JMbr mbr;

            if (TryGet(name, out 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);
        }
Esempio n. 8
0
        public static D[] StringToArray <D>(string v, int proj = 0x00ff) where D : IData, new()
        {
            JArr ja = (JArr) new JsonParse(v).Parse();

            return(ja.ToArray <D>(proj));
        }
Esempio n. 9
0
 internal void Add(string name, JArr v)
 {
     Add(new JMbr(name, v));
 }