Example #1
0
        private void UpdateSubscriptions()
        {
            foreach (var node in _previousContext.UsedNodes)
            {
                if (!_currentContext.UsedNodes.Contains(node))
                {
                    node.ValueChanged -= OnValueChanged;
                }
            }
            foreach (var collection in _previousContext.UsedCollections)
            {
                if (!_currentContext.UsedCollections.Contains(collection))
                {
                    collection.UntypedCollectionChanged -= OnValueChanged;
                }
            }

            foreach (var node in _currentContext.UsedNodes)
            {
                if (!_previousContext.UsedNodes.Contains(node))
                {
                    node.ValueChanged += OnValueChanged;
                }
            }
            foreach (var collection in _currentContext.UsedCollections)
            {
                if (!_previousContext.UsedCollections.Contains(collection))
                {
                    collection.UntypedCollectionChanged += OnValueChanged;
                }
            }

            _previousContext.Clear();
        }
Example #2
0
        private void Unsubscribe()
        {
            foreach (var node in _context.UsedNodes)
            {
                node.ValueChanged -= OnValueChanged;
            }

            foreach (var collection in _context.UsedCollections)
            {
                collection.CollectionChanged -= OnValueChanged;
            }

            _context.Clear();
        }
Example #3
0
        public void Dispose()
        {
            foreach (var node in _currentContext.UsedNodes)
            {
                node.ValueChanged -= OnValueChanged;
            }

            foreach (var collection in _currentContext.UsedCollections)
            {
                collection.UntypedCollectionChanged -= OnValueChanged;
            }

            (_previousContext, _currentContext) = (_currentContext, _previousContext);
            _currentContext.Clear();
            UpdateSubscriptions();
        }