public ViewState([NotNull] string key, State state=null)
        {
            if (key == null) throw new ArgumentNullException(nameof(key));

            Key = key;
            State = state;
        }
 public StateBucket(string type, string id, State state, DateTime timeStamp)
 {
     Key = new StateBucketKey(type,id);
     Type = type;
     Id = id;
     State = state;
     TimeStamp = timeStamp;
 }
        public void WriteComplexState()
        {
            var state = new State(1, "<<something weird<> which breaks xml {}");

            var store = new FileSettingsStore(new NullLogger());
            store.Save("wierdfile", state);

            var restored = store.Load("wierdfile");
            restored.Should().Be(state);
        }
        public void WriteState()
        {
            var state = new State(1, "Test");

            var store  = new FileSettingsStore(new NullLogger());
            store.Save("testfile",state);

            var restored = store.Load("testfile");
            restored.Should().Be(state);
        }
        public void Save(string key, State state)
        {
            var file = Path.Combine(Location, $"{key}.setting");

            //XDocument  and / or xmlTextWriter
            //write the version [should be an attribute]
            //write for the  version [should be an Element]

            throw new NotImplementedException();
        }
        public void Save(string key, State state)
        {
            var file = Path.Combine(Location, $"{key}.setting");

            _logger.Info($"Creating setting for {key}");

            var root = new XElement(new XElement(Structure.Root, new XAttribute(Structure.Version,state.Version)));
            root.Add(new XElement(Structure.State, state.Value));
            var doc = new XDocument(root);
            var fileText = doc.ToString();

            _logger.Info($"Writing value {fileText}");
            File.WriteAllText(file, fileText);

        }
Exemple #7
0
 public void Write(string type, string id, State state)
 {
     _cache.AddOrUpdate(new StateBucket(type, id, state,DateTime.UtcNow));
 }
 public void Restore(TailViewModel view, State state)
 {
     var converter = new TailViewToStateConverter();
     Restore(view,converter.Convert(state));
 }
 void IPersistentStateProvider.Restore(State state)
 {
     _stateProvider.Restore(state);
 }