/// <summary> /// Get the default Event Recording Configuration /// </summary> /// <returns></returns> public static RecorderSetting GetDefaultRecordingConfig() { RecorderSetting config = new RecorderSetting { // Set Individual Event Events = (from e in EventType.GetInstance().GetKeyValuePairList() select new RecordEntitySetting() { Type = RecordEntityType.Event, Id = e.Key, Name = e.Value, IsRecorded = false }).ToList(), // Set properties Properties = (from e in PropertyType.GetInstance().GetKeyValuePairList() select new RecordEntitySetting() { Type = RecordEntityType.Property, Id = e.Key, Name = e.Value, IsRecorded = false }).ToList(), // Set Global event IsListeningFocusChangedEvent = true, // Individual Event Scope ListenScope = TreeScope.TreeScope_Subtree }; return(config); }
public static RecorderSetting LoadConfiguration(string path) { // Get Recorder configuration from local location. but if it is not available, get it from default location. RecorderSetting config = new RecorderSetting(); config = RecorderSetting.LoadFromJSON <RecorderSetting>(path); if (config == null) { config = RecorderSetting.GetDefaultRecordingConfig(); config.SerializeInJSON(path); } else { // check whether there is any new events to be added into configuration. var events = EventType.GetInstance(); var ms = from e in events.GetKeyValuePairList() where IsNotInList(e.Key, config.Events) select e; if (ms.Count() != 0) { foreach (var m in ms) { config.Events.Add(new RecordEntitySetting() { Id = m.Key, Name = m.Value, IsRecorded = false, Type = RecordEntityType.Event, }); } config.SerializeInJSON(path); } config.IsListeningAllEvents = false; } return(config); }