Exemplo n.º 1
0
        private static InMemoryStateStore Load(XDocument doc)
        {
            var store = doc.Element("Store");
            var id    = store.Attribute("Id").Value;

            var res = new InMemoryStateStore(id);

            var categories = store.Elements("Category");

            foreach (var category in categories)
            {
                var categoryName = category.Attribute("Name").Value;

                var entries = category.Elements("Entry");
                foreach (var entry in entries)
                {
                    var keyName = entry.Attribute("Name").Value;
                    var base64  = entry.Nodes().OfType <XCData>().Single().Value;

                    var value = Convert.FromBase64String(base64);

                    res.AddOrUpdateItem(categoryName, keyName, value);
                }
            }

            return(res);
        }
Exemplo n.º 2
0
        public void AddOrUpdateItem(string category, string key, byte[] value)
        {
            if (category == null)
            {
                throw new ArgumentNullException(nameof(category));
            }
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            _stateStore.AddOrUpdateItem(category, key, value);
        }