public ActiveSelectValue(IActiveValue <TValue> value, Func <TValue, TResult> mutator, IEnumerable <string> propertiesToWatch)
        {
            _mutator = mutator;

            _valueWatcher = new ValueWatcher <TValue>(value, propertiesToWatch);
            _valueWatcher.ValueOrValuePropertyChanged += () => Value = _mutator.Invoke(_valueWatcher.Value);

            Value = _mutator.Invoke(_valueWatcher.Value);
        }
Exemplo n.º 2
0
        private ActiveJoin(ActiveListJoinBehaviour joinBehaviour, IActiveList <KeyValuePair <TKey, TLeft> > left, IActiveLookup <TKey, TRight> right, IActiveValue <TParameter> parameter, Func <JoinOption <TLeft>, JoinOption <TRight>, TParameter, TResult> resultSelector, IEnumerable <string> leftResultSelectorPropertiesToWatch, IEnumerable <string> rightResultSelectorPropertiesToWatch, IEnumerable <string> resultSelectorParameterPropertiesToWatch)
        {
            _joinBehaviour  = joinBehaviour;
            _parameter      = parameter;
            _resultSelector = resultSelector;

            _leftResultSelectorPropertiesToWatch  = leftResultSelectorPropertiesToWatch;
            _rightResultSelectorPropertiesToWatch = rightResultSelectorPropertiesToWatch;

            if (parameter != null)
            {
                _parameterWatcher = new ValueWatcher <TParameter>(parameter, resultSelectorParameterPropertiesToWatch);
                _parameterWatcher.ValueOrValuePropertyChanged += () => OnParameterChanged();
            }

            _leftJoiners  = new QuickList <ActiveListJoinerData <TLeft, TRight, TResult, TKey> >();
            _rightJoiners = new QuickList <ActiveListJoinerData <TLeft, TRight, TResult, TKey> >();
            _joinerLookup = new Dictionary <TKey, ActiveListJoinerSet <TLeft, TRight, TResult, TKey> >();

            _leftItems = new CollectionWrapper <KeyValuePair <TKey, TLeft> >(left);
            _leftItems.ItemModified += (s, i, v) => OnLeftReplaced(i, v, v);
            _leftItems.ItemAdded    += (s, i, v) => OnLeftAdded(i, v);
            _leftItems.ItemRemoved  += (s, i, v) => OnLeftRemoved(i, v);
            _leftItems.ItemReplaced += (s, i, o, n) => OnLeftReplaced(i, o, n);
            _leftItems.ItemMoved    += (s, o, n, v) => OnLeftMoved(o, n, v);
            _leftItems.ItemsReset   += s => FullReset();

            _rightItems = right;

            _rightGroups = new CollectionWrapper <IActiveGrouping <TKey, TRight> >(right);
            _rightGroups.ItemModified += (s, i, v) => OnRightReplaced(i, v, v);
            _rightGroups.ItemAdded    += (s, i, v) => OnRightAdded(i, v);
            _rightGroups.ItemRemoved  += (s, i, v) => OnRightRemoved(i, v);
            _rightGroups.ItemReplaced += (s, i, o, n) => OnRightReplaced(i, o, n);
            _rightGroups.ItemMoved    += (s, o, n, v) => OnRightMoved(o, n, v);
            _rightGroups.ItemsReset   += s => FullReset();

            _resultList = new ObservableList <TResult>();
            _resultList.PropertyChanged += (s, e) =>
            {
                if (!_fullResetInProgress)
                {
                    NotifyOfPropertyChange(e);
                }
            };
            _resultList.CollectionChanged += (s, e) =>
            {
                if (!_fullResetInProgress)
                {
                    NotifyOfCollectionChange(e);
                }
            };

            FullReset();
        }
Exemplo n.º 3
0
        private void HookChangeEvent(ref ValueWatcher watcher, Delegate value, string path, Action <ValueWatcher, string> changeAction)
        {
            lock (eventLock)
            {
                if (watcher == null)
                {
                    watcher = new ValueWatcher(this, path, changeAction);
                }

                watcher.Event = Delegate.Combine(watcher.Event, value);
            }
        }
        public ActiveRepeat(IActiveValue <TValue> value, IActiveValue <int> count)
        {
            _resultList = new ObservableList <TValue, TValue>(i => i);
            _resultList.CollectionChanged += (s, e) => NotifyOfCollectionChange(e);
            _resultList.PropertyChanged   += (s, e) => NotifyOfPropertyChange(e);

            _valueWatcher = new ValueWatcher <TValue>(value, null);
            _valueWatcher.ValueOrValuePropertyChanged += ValueChanged;

            _countWatcher = new ValueWatcher <int>(count, null);
            _countWatcher.ValueOrValuePropertyChanged += CountChanged;

            CountChanged();
        }
        public ActiveRange(IActiveValue <int> start, IActiveValue <int> count)
        {
            _resultList = new ObservableList <int, int>(i => i);
            _resultList.CollectionChanged += (s, e) => NotifyOfCollectionChange(e);
            _resultList.PropertyChanged   += (s, e) => NotifyOfPropertyChange(e);

            _startWatcher = new ValueWatcher <int>(start, null);
            _startWatcher.ValueOrValuePropertyChanged += StartChanged;

            _countWatcher = new ValueWatcher <int>(count, null);
            _countWatcher.ValueOrValuePropertyChanged += CountChanged;

            CountChanged();
        }
Exemplo n.º 6
0
        public GameState(Process game, GameOffsets offsets)
        {
            this.GameProcess = game;
            this.GameOffsets = offsets;

            RawTickCount             = new ValueWatcher <int>(0);
            PlayerViewEntityIndex    = new ValueWatcher <int>(0);
            PlayerFlags              = new ValueWatcher <FL>(new FL());
            PlayerPosition           = new ValueWatcher <Vector3f>(new Vector3f());
            PlayerParentEntityHandle = new ValueWatcher <int>(0);
            HostState   = new ValueWatcher <HostState>(SourceSplit.HostState.NewGame);
            SignOnState = new ValueWatcher <SignOnState>(SourceSplit.SignOnState.None);
            ServerState = new ValueWatcher <ServerState>(SourceSplit.ServerState.Dead);
        }
Exemplo n.º 7
0
        public ActiveListListenerBase(IActiveList <TSource> source, IActiveValue <TParameter> parameter, IEnumerable <string> sourcePropertiesToWatch = null, IEnumerable <string> parameterPropertiesToWatch = null)
        {
            _sourceList = new CollectionWrapper <TSource>(source, sourcePropertiesToWatch?.ToArray());
            _sourceList.ItemModified += (s, i, v) => ItemModified(i, v);
            _sourceList.ItemAdded    += (s, i, v) => OnAdded(i, v);
            _sourceList.ItemRemoved  += (s, i, v) => OnRemoved(i, v);
            _sourceList.ItemReplaced += (s, i, o, n) => OnReplaced(i, o, n);
            _sourceList.ItemMoved    += (s, o, n, v) => OnMoved(o, n, v);
            _sourceList.ItemsReset   += s => OnReset(s);

            if (parameter != null)
            {
                _parameterWatcher = new ValueWatcher <TParameter>(parameter, parameterPropertiesToWatch);
                _parameterWatcher.ValueOrValuePropertyChanged += () => OnParameterChanged();
            }
        }
Exemplo n.º 8
0
        private void UnhookChangeEvent(ref ValueWatcher watcher, Delegate value)
        {
            lock (eventLock)
            {
                if (watcher == null)
                {
                    return;
                }

                watcher.Event = Delegate.Remove(watcher.Event, value);
                if (watcher.Event == null)
                {
                    watcher.Stop();
                    watcher = null;
                }
            }
        }