Exemplo n.º 1
0
 public HaystackGrid()
 {
     Meta           = new HaystackDictionary();
     _columns       = new List <HaystackColumn>();
     _rows          = new List <HaystackRow>();
     _columnsByName = new Dictionary <string, HaystackColumn>();
 }
Exemplo n.º 2
0
        public HaystackHistoryItem(HaystackDictionary dictionary)
        {
            if (dictionary is null)
            {
                throw new ArgumentNullException(nameof(dictionary));
            }

            TimeStamp = (HaystackDateTime)dictionary["ts"];
            Value     = dictionary.ContainsKey("val") ? dictionary["val"] : null;
        }
Exemplo n.º 3
0
        public HaystackGrid(HaystackDictionary[] rows, HaystackDictionary meta = null)
        {
            var columnNames = rows
                              .SelectMany(row => row.Keys)
                              .Distinct()
                              .ToArray();

            _columns = columnNames
                       .Select((name, idx) => new HaystackColumn(idx, name))
                       .ToList();
            _columnsByName = _columns.ToDictionary(col => col.Name);

            _rows = rows
                    .Select(row => new HaystackRow(this, columnNames.Select(col => row.ContainsKey(col) ? row[col] : null).ToArray()))
                    .ToList();

            Meta = meta ?? new HaystackDictionary();
        }
Exemplo n.º 4
0
 public static HDict Map(HaystackDictionary value)
 {
     return(new HDict(value));
 }
Exemplo n.º 5
0
 public HaystackGrid(HaystackHistoryItem[] historyItems, HaystackDictionary meta = null)
 {
     _columns = new[] { new HaystackColumn(0, "ts"), new HaystackColumn(1, "val") }.ToList();
     _rows    = historyItems.Select(item => new HaystackRow(this, item.TimeStamp, item.Value)).ToList();
     Meta     = meta ?? new HaystackDictionary();
 }
Exemplo n.º 6
0
        public HaystackGrid(List <HaystackColumn> columns, List <HaystackValue[]> rowData, HaystackDictionary meta = null)
        {
            var duplicates = columns
                             .GroupBy(col => col.Name)
                             .Where(grp => grp.Count() > 1)
                             .Select(grp => grp.Key)
                             .ToArray();

            if (duplicates.Any())
            {
                throw new ArgumentException($"Detected duplicate column(s): {string.Join(", ", duplicates)}");
            }
            _columns       = columns;
            _columnsByName = _columns.ToDictionary(col => col.Name);

            _rows = rowData.Select(row => new HaystackRow(this, row)).ToList();

            Meta = meta ?? new HaystackDictionary();
        }
Exemplo n.º 7
0
 public HDict(HaystackDictionary source)
 {
     Source = source;
 }
Exemplo n.º 8
0
 public HDict(IDictionary <string, HVal> map)
 {
     Source = new HaystackDictionary(map.ToDictionary(kv => kv.Key, kv => M.Map(kv.Value)));
 }