Пример #1
0
        private static C8Tuple GetRow(C8xSchema schema, string buff)
        {
            var fields = buff.Split(',');
            if (fields.Length != schema.Count + 1 )
            {
                throw new ArgumentException("Column count error");
            }
            var msgTimeStamp = Epoch.AddTicks(long.Parse(fields[0]) * 10).ToLocalTime();
            var row = new C8Tuple(schema,msgTimeStamp);

            for (int ii = 0; ii < schema.Count; ii++)
            {
                var t = schema.ColumnTypes[ii];
                string item = fields[ii+1]; // one extra for Timestamp that we skip here
                object val = item;
                if (t == typeof(DateTime))
                {
                    val = Epoch.AddTicks(long.Parse(item) * 10).ToLocalTime();
                }
                else if (t == typeof(bool))
                {
                    val = bool.Parse(item);
                }
                else if (t == typeof(int))
                {
                    val = int.Parse(item);
                }
                else if (t == typeof(double))
                {
                    val = double.Parse(item);
                }
                else if (t == typeof(long))
                {
                    val = long.Parse(item);
                }
                row[ii] = val;
            }
            return row;
        }
Пример #2
0
 public Out_2C8Tuple(C8Tuple tpl)
     : base(tpl)
 {
 }
Пример #3
0
 PSObject Extracted(C8Tuple tuple)
 {
     PSObject pso = new PSObject(tuple);
     for (int ii = 0; ii < tuple.columnNames.Length; ii++)
     {
         string name = tuple.columnNames[ii];
         string getter = String.Format("$this[\"{0}\"]", name);
         string setter = String.Format("$this[\"{0}\"] = $value", name);
         pso.Properties.Add(new PSScriptProperty(name, this.InvokeCommand.NewScriptBlock(getter), this.InvokeCommand.NewScriptBlock(setter)));
     }
     return pso;
 }