private void LoadAnalyticsData() { if (File.Exists(this.FileName)) { using (FileStream input = new FileStream(this.FileName, FileMode.Open)) { using (BinaryReader binaryReader = new BinaryReader(input)) { try { int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { string key = binaryReader.ReadString(); AnalyticsDataType dataType = (AnalyticsDataType)binaryReader.ReadByte(); Type type = this.FromDataType(dataType); AnalyticsCollection analyticsCollection = this.FindTable(key, dataType, true); analyticsCollection.Load(binaryReader); } } catch { } } } } }
private void RegisterEvent(string key, long timestamp, object obj, Type type) { AnalyticsDataType dataType = this.FromType(type); AnalyticsCollection analyticsCollection = this.FindTable(key, dataType, true); lock (analyticsCollection) { analyticsCollection.Add(timestamp, obj); this.changed = true; } }
private Type FromDataType(AnalyticsDataType dataType) { switch (dataType) { case AnalyticsDataType.None: return(typeof(object)); case AnalyticsDataType.String: return(typeof(string)); case AnalyticsDataType.SByte: return(typeof(sbyte)); case AnalyticsDataType.Short: return(typeof(short)); case AnalyticsDataType.Int: return(typeof(int)); case AnalyticsDataType.Long: return(typeof(long)); case AnalyticsDataType.Byte: return(typeof(byte)); case AnalyticsDataType.UShort: return(typeof(ushort)); case AnalyticsDataType.UInt: return(typeof(uint)); case AnalyticsDataType.ULong: return(typeof(ulong)); case AnalyticsDataType.Float: return(typeof(float)); case AnalyticsDataType.Double: return(typeof(double)); case AnalyticsDataType.Decimal: return(typeof(decimal)); case AnalyticsDataType.Bool: return(typeof(bool)); default: return(null); } }
private AnalyticsCollection FindTable(string key, AnalyticsDataType dataType, bool canCreate) { lock (this._collections) { AnalyticsCollection analyticsCollection = null; if (this._collections.ContainsKey(key)) { analyticsCollection = this._collections[key]; } if (analyticsCollection == null & canCreate) { analyticsCollection = new AnalyticsCollection(key, dataType); this._collections[key] = analyticsCollection; } return(analyticsCollection); } }
public void IterateEntries <T>(string key, Action <DateTime, T> visitor) { Type typeFromHandle = typeof(T); AnalyticsDataType dataType = this.FromType(typeFromHandle); AnalyticsCollection analyticsCollection = this.FindTable(key, dataType, false); if (analyticsCollection != null) { lock (analyticsCollection) { foreach (KeyValuePair <long, object> value in analyticsCollection.values) { visitor(value.Key.ToDateTime(), (T)value.Value); } } } }
private AnalyticsDataColumnHeader(JObject obj) : base(obj) { Name = obj.GetString("name"); ColumnType = obj.GetEnum <AnalyticsColumnType>("columnType"); DataType = obj.GetEnum <AnalyticsDataType>("dataType"); }
public AnalyticsCollection(string name, AnalyticsDataType dataType) { this.name = name; this.dataType = dataType; }