Example #1
0
        public void Save(string fileName)
        {
            var serializer = new DataContractJsonSerializer(typeof(MemoryStoreContainer));

            using (var stream = new FileStream(fileName, FileMode.Create, FileAccess.Write)){
                var container = new MemoryStoreContainer();
                container.AlertActions    = this.alertActions;
                container.RuleToActionMap = this.ruleToActionMap;
                container.LastId          = this.lastId;
                serializer.WriteObject(stream, container);
            }
        }
Example #2
0
        public void Load(string fileName)
        {
            var serializer = new DataContractJsonSerializer(typeof(MemoryStoreContainer));

            using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.Read)){
                MemoryStoreContainer loaded = (MemoryStoreContainer)serializer.ReadObject(stream);
                alertActions.Clear();
                foreach (var item in loaded.AlertActions)
                {
                    alertActions.Add(item.Key, item.Value);
                }
                ruleToActionMap.Clear();
                foreach (var item in loaded.RuleToActionMap)
                {
                    ruleToActionMap.Add(item.Key, item.Value);
                }
                lastId = loaded.LastId;
            }
        }