Esempio n. 1
0
 public void AddOrUpdateState <TKey, TValue>(KeyValueState <TKey, TValue> keyValueState)
 {
     lock (_states)
     {
         var key = keyValueState.Id.ToString();
         if (!_states.ContainsKey(key))
         {
             _states.Add(key, keyValueState.State);
         }
         else
         {
             _states[key] = keyValueState.State;
         }
         _parent?.AddOrUpdateState(keyValueState);
     }
 }
Esempio n. 2
0
        public StateNode(States parent, StateNode parentNode, KeyValueState <string, string> value, JTokenType type,
                         bool isLeafNode)
            : base(parent)
        {
            _id         = Guid.NewGuid();
            _parentNode = parentNode;
            _value      = value;
            _type       = type;
            _isLeafNode = isLeafNode;
            _childNodes = new List <StateNode>();

            _value.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "State" && InvalidStates.Contains(_value.State))
                {
                    foreach (var child in _childNodes)
                    {
                        child.Value.State = _value.State;
                    }
                }
            };
        }