public JMbr(string name, JArr v) { this.name = name; type = JType.Array; refv = v; numv = default(JNumber); }
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); }
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); }
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); }
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); }
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); }
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); }
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)); }
internal void Add(string name, JArr v) { Add(new JMbr(name, v)); }