Пример #1
0
 public Filtering(
     INotifyCollectionChanged source,
     Expression <Func <TSourceItem, bool> > predicateExpression,
     int initialCapacity = 0) : this(predicateExpression, Utils.getCapacity(source), initialCapacity)
 {
     _source = source;
 }
Пример #2
0
 public AnyComputing(
     IReadScalar <INotifyCollectionChanged> sourceScalar,
     Expression <Func <TSourceItem, bool> > predicateExpression)
     : this(predicateExpression, Utils.getCapacity(sourceScalar))
 {
     _sourceScalar = sourceScalar;
 }
 public StringsConcatenating(
     INotifyCollectionChanged source,
     string separator = "") : this(Utils.getCapacity(source))
 {
     _source    = source;
     _separator = separator;
 }
Пример #4
0
        protected override void processSource()
        {
            if (_sourceReadAndSubscribed)
            {
                _source.CollectionChanged -= handleSourceCollectionChanged;

                if (_sourceAsINotifyPropertyChanged != null)
                {
                    _sourceAsINotifyPropertyChanged.PropertyChanged -=
                        ((ISourceIndexerPropertyTracker)this).HandleSourcePropertyChanged;
                    _sourceAsINotifyPropertyChanged = null;
                }

                _sourceCopy = new List <TSourceItem>(Utils.getCapacity(_sourceScalar, _source));
                _sourceReadAndSubscribed = false;
            }

            Utils.changeSource(ref _source, _sourceScalar, _downstreamConsumedComputings, _consumers, this,
                               out _sourceAsList, true);

            if (_source != null && _isActive)
            {
                Utils.initializeFromHasChangeMarker(
                    out _sourceAsIHasChangeMarker,
                    _sourceAsList,
                    ref _lastProcessedSourceChangeMarker,
                    ref _sourceAsINotifyPropertyChanged,
                    (ISourceIndexerPropertyTracker)this);

                _source.CollectionChanged += handleSourceCollectionChanged;
                _sourceReadAndSubscribed   = true;
            }

            recalculateValue(true);
        }
 public StringsConcatenating(
     IReadScalar <INotifyCollectionChanged> sourceScalar,
     string separator = "") : this(Utils.getCapacity(sourceScalar))
 {
     _sourceScalar = sourceScalar;
     _separator    = separator;
 }
 public StringsConcatenating(
     INotifyCollectionChanged source,
     IReadScalar <string> separatorScalar) : this(Utils.getCapacity(source))
 {
     _source          = source;
     _separatorScalar = separatorScalar;
 }
Пример #7
0
 public Filtering(
     IReadScalar <INotifyCollectionChanged> sourceScalar,
     Expression <Func <TSourceItem, bool> > predicateExpression,
     int initialCapacity = 0) : this(predicateExpression, Utils.getCapacity(sourceScalar), initialCapacity)
 {
     _sourceScalar = sourceScalar;
 }
Пример #8
0
 public AnyComputing(
     INotifyCollectionChanged source,
     Expression <Func <TSourceItem, bool> > predicateExpression)
     : this(predicateExpression, Utils.getCapacity(source))
 {
     _source = source;
 }
 public MinimazingOrMaximazing(
     IReadScalar <INotifyCollectionChanged> sourceScalar,
     MinimazingOrMaximazingMode mode,
     IComparer <TSourceItem> comparer = null) : this(mode, Utils.getCapacity(sourceScalar))
 {
     _sourceScalar = sourceScalar;
     _comparer     = comparer;
 }
 public MinimazingOrMaximazing(
     INotifyCollectionChanged source,
     MinimazingOrMaximazingMode mode,
     IComparer <TSourceItem> comparer = null) : this(mode, Utils.getCapacity(source))
 {
     _source   = source;
     _comparer = comparer;
 }
Пример #11
0
 public Crossing(
     INotifyCollectionChanged outerSource,
     INotifyCollectionChanged innerSource) : base(Utils.getCapacity(outerSource) * Utils.getCapacity(innerSource))
 {
     _outerSource = outerSource;
     _innerSource = innerSource;
     initializeFromSources();
 }
        private void processSource(bool replaceSource)
        {
            if (_sourceReadAndSubscribed)
            {
                _valueStringBuilder.Clear();

                int capacity = _sourceScalar != null?Utils.getCapacity(_sourceScalar) : Utils.getCapacity(_source);

                _resultRangePositions = new RangePositions <RangePosition>(new List <RangePosition>(capacity * 2));

                if (replaceSource)
                {
                    Utils.unsubscribeSource(
                        _source,
                        ref _sourceAsINotifyPropertyChanged,
                        this,
                        handleSourceCollectionChanged);
                }

                _sourceReadAndSubscribed = false;
            }

            if (replaceSource)
            {
                Utils.replaceSource(ref _source, _sourceScalar, _downstreamConsumedComputings, _consumers, this,
                                    out _sourceAsList, true);
            }

            if (_isActive)
            {
                if (_source != null)
                {
                    if (replaceSource)
                    {
                        Utils.subscribeSource(
                            out _sourceAsIHasTickTackVersion,
                            _sourceAsList,
                            ref _lastProcessedSourceTickTackVersion,
                            ref _sourceAsINotifyPropertyChanged,
                            (ISourceIndexerPropertyTracker)this,
                            _source,
                            handleSourceCollectionChanged);
                    }

                    _sourceReadAndSubscribed = true;
                    recalculateValue();
                }
                else
                {
                    setValue(string.Empty);
                }
            }
            else
            {
                setDefaultValue();
            }
        }
Пример #13
0
 public Casting(
     IReadScalar <INotifyCollectionChanged> sourceScalar) : base(Utils.getCapacity(sourceScalar))
 {
     _sourceScalar = sourceScalar;
     _sourceScalarPropertyChangedEventHandler     = handleSourceScalarValueChanged;
     _sourceScalarWeakPropertyChangedEventHandler = new WeakPropertyChangedEventHandler(_sourceScalarPropertyChangedEventHandler);
     _sourceScalar.PropertyChanged += _sourceScalarWeakPropertyChangedEventHandler.Handle;
     initializeFromSource();
 }
Пример #14
0
 public MinimazingOrMaximazing(
     IReadScalar <INotifyCollectionChanged> sourceScalar,
     MinimazingOrMaximazingMode mode,
     IReadScalar <IComparer <TSourceItem> > comparerScalar = null,
     TSourceItem defaultValue = default(TSourceItem)) : this(mode, Utils.getCapacity(sourceScalar))
 {
     _sourceScalar   = sourceScalar;
     _comparerScalar = comparerScalar;
     _defaultValue   = defaultValue;
 }
Пример #15
0
        public Crossing(
            INotifyCollectionChanged outerSource,
            IReadScalar <INotifyCollectionChanged> innerSourceScalar) : base(Utils.getCapacity(outerSource) * Utils.getCapacity(innerSourceScalar))
        {
            _outerSource       = outerSource;
            _innerSourceScalar = innerSourceScalar;
            initializeInnerSourceScalar();

            initializeFromSources();
        }
Пример #16
0
		public Ordering(
			IReadScalar<INotifyCollectionChanged> sourceScalar,
			Expression<Func<TSourceItem, TOrderingValue>> orderingValueSelectorExpression,
			ListSortDirection sortDirection = ListSortDirection.Ascending,
			IComparer<TOrderingValue> comparer= null) : this(orderingValueSelectorExpression, Utils.getCapacity(sourceScalar))
		{
			_sourceScalar = sourceScalar;
			_sortDirection = sortDirection;
			_comparer = comparer ?? Comparer<TOrderingValue>.Default;
		}
Пример #17
0
        public Concatenating(
            INotifyCollectionChanged sources) : base(calculateCapacity(sources))
        {
            int capacity = Utils.getCapacity(sources);

            _itemInfos            = new List <ItemInfo>(capacity);
            _sourceRangePositions = new RangePositions <ItemInfo>(_itemInfos);

            _sources = sources;
            initializeFromSources();
        }
Пример #18
0
        public Crossing(
            IReadScalar <INotifyCollectionChanged> outerSourceScalar,
            INotifyCollectionChanged innerSource) : base(Utils.getCapacity(outerSourceScalar) * Utils.getCapacity(innerSource))
        {
            _outerSourceScalar = outerSourceScalar;
            initializeOuterSourceScalar();

            _innerSource = innerSource;

            initializeFromSources();
        }
Пример #19
0
        //public IOrdering<TSourceItem> Parent => null;
        //#endregion

        void IOrderingInternal <TSourceItem> .AddThenOrdering(IThenOrdering <TSourceItem> thenOrdering)
        {
            _thenOrderingsCount++;
            _thenOrderings = _thenOrderings ?? new List <IThenOrderingInternal <TSourceItem> >(4);
            _thenOrderings.Add((IThenOrderingInternal <TSourceItem>)thenOrdering);

            if (_thenOrderingsCount == 1)
            {
                _equalOrderingValueRangePositions = new RangePositions <RangePosition>(
                    new List <RangePosition>(
                        _sourceScalar != null
                                                        ? Utils.getCapacity(_sourceScalar)
                                                        : Utils.getCapacity(_source)));

                int           equalOrderingValueItemsCount = 0;
                RangePosition rangePosition = null;

                int count = Count;
                for (int orderedIndex = 0; orderedIndex < count; orderedIndex++)
                {
                    if (orderedIndex > 0)
                    {
                        int previousOrderedIndex = orderedIndex - 1;
                        if (_comparer.Compare(
                                getOrderingValue(_orderedItemInfos[orderedIndex].ItemInfo, this[orderedIndex]),
                                getOrderingValue(_orderedItemInfos[previousOrderedIndex].ItemInfo, this[previousOrderedIndex])) == 0)
                        {
                            equalOrderingValueItemsCount++;
                            _orderedItemInfos[orderedIndex].RangePosition = rangePosition;
                        }
                        else
                        {
                            // ReSharper disable once PossibleNullReferenceException
                            rangePosition.Length = equalOrderingValueItemsCount;
                            rangePosition        = _equalOrderingValueRangePositions.Add(1);
                            _orderedItemInfos[orderedIndex].RangePosition = rangePosition;
                            equalOrderingValueItemsCount = 1;
                        }
                    }
                    else
                    {
                        rangePosition = _equalOrderingValueRangePositions.Add(1);
                        equalOrderingValueItemsCount = 1;
                        _orderedItemInfos[orderedIndex].RangePosition = rangePosition;
                    }
                }

                if (count > 0)
                {
                    // ReSharper disable once PossibleNullReferenceException
                    rangePosition.Length = equalOrderingValueItemsCount;
                }
            }
        }
Пример #20
0
 public Filtering(
     IReadScalar <INotifyCollectionChanged> sourceScalar,
     Expression <Func <TSourceItem, bool> > predicateExpression,
     int capacity = 0) : this(predicateExpression, Utils.getCapacity(sourceScalar), capacity)
 {
     _sourceScalar = sourceScalar;
     _sourceScalarPropertyChangedEventHandler     = handleSourceScalarValueChanged;
     _sourceScalarWeakPropertyChangedEventHandler = new WeakPropertyChangedEventHandler(_sourceScalarPropertyChangedEventHandler);
     _sourceScalar.PropertyChanged += _sourceScalarWeakPropertyChangedEventHandler.Handle;
     initializeFromSource();
 }
Пример #21
0
        public StringsConcatenating(
            IReadScalar <INotifyCollectionChanged> sourceScalar,
            string separator = "") : this(Utils.getCapacity(sourceScalar))
        {
            _sourceScalar = sourceScalar;
            initializeSourceScalar();

            _separator = separator;

            initializeSeparator();
            initializeFromSource();
        }
Пример #22
0
        public StringsConcatenating(
            INotifyCollectionChanged source,
            IReadScalar <string> separatorScalar = null) : this(Utils.getCapacity(source))
        {
            _source = source;

            _separatorScalar = separatorScalar;
            initializeSeparatorScalar();

            initializeSeparator();
            initializeFromSource();
        }
Пример #23
0
        public MinimazingOrMaximazing(
            INotifyCollectionChanged source,
            MinimazingOrMaximazingMode mode,
            IComparer <TSourceItem> comparer = null,
            TSourceItem defaultValue         = default(TSourceItem)) : this(mode, Utils.getCapacity(source))
        {
            _source = source;

            _comparer = comparer ?? Comparer <TSourceItem> .Default;

            _defaultValue = defaultValue;

            initializeFromSource();
        }
Пример #24
0
        public Concatenating(
            IReadScalar <INotifyCollectionChanged> sourcesScalar) : base(calculateCapacity(sourcesScalar.Value))
        {
            int capacity = Utils.getCapacity(sourcesScalar);

            _itemInfos            = new List <ItemInfo>(capacity);
            _sourceRangePositions = new RangePositions <ItemInfo>(_itemInfos);

            _sourcesScalar = sourcesScalar;
            _sourcesScalarPropertyChangedEventHandler     = handleSourcesScalarValueChanged;
            _sourcesScalarWeakPropertyChangedEventHandler = new WeakPropertyChangedEventHandler(_sourcesScalarPropertyChangedEventHandler);
            _sourcesScalar.PropertyChanged += _sourcesScalarWeakPropertyChangedEventHandler.Handle;
            initializeFromSources();
        }
Пример #25
0
        protected override void initializeFromSource()
        {
            if (_sourceInitialized)
            {
                _valueStringBuilder.Clear();

                int capacity = _sourceScalar != null?Utils.getCapacity(_sourceScalar) : Utils.getCapacity(_source);

                _resultRangePositions = new RangePositions <RangePosition>(new List <RangePosition>(capacity * 2));

                _source.CollectionChanged -= handleSourceCollectionChanged;

                if (_sourceAsINotifyPropertyChanged != null)
                {
                    _sourceAsINotifyPropertyChanged.PropertyChanged -=
                        ((ISourceIndexerPropertyTracker)this).HandleSourcePropertyChanged;
                    _sourceAsINotifyPropertyChanged = null;
                }

                _sourceInitialized = false;
            }


            Utils.changeSource(ref _source, _sourceScalar, _downstreamConsumedComputings, _consumers, this,
                               ref _sourceAsList, true);

            if (_source != null && _isActive)
            {
                Utils.initializeFromHasChangeMarker(
                    out _sourceAsIHasChangeMarker,
                    _sourceAsList,
                    ref _lastProcessedSourceChangeMarker,
                    ref _sourceAsINotifyPropertyChanged,
                    (ISourceIndexerPropertyTracker)this);

                _source.CollectionChanged += handleSourceCollectionChanged;
                _sourceInitialized         = true;
                recalculateValue();
            }
            else
            {
                _valueStringBuilder.Clear();
                setValue(String.Empty);
            }
        }
        private void processSource(bool replaceSource)
        {
            if (_sourceReadAndSubscribed)
            {
                if (replaceSource)
                {
                    Utils.unsubscribeSource(
                        _source,
                        ref _sourceAsINotifyPropertyChanged,
                        this,
                        handleSourceCollectionChanged);
                }

                _sourceCopy = new List <TSourceItem>(Utils.getCapacity(_sourceScalar, _source));
                _sourceReadAndSubscribed = false;
            }

            if (replaceSource)
            {
                Utils.replaceSource(ref _source, _sourceScalar, _downstreamConsumedComputings, _consumers, this,
                                    out _sourceAsList, true);
            }

            if (_source != null && _isActive)
            {
                if (replaceSource)
                {
                    Utils.subscribeSource(
                        out _sourceAsIHasTickTackVersion,
                        _sourceAsList,
                        ref _lastProcessedSourceTickTackVersion,
                        ref _sourceAsINotifyPropertyChanged,
                        (ISourceIndexerPropertyTracker)this,
                        _source,
                        handleSourceCollectionChanged);
                }

                _sourceReadAndSubscribed = true;
            }

            recalculateValue(true);
        }
Пример #27
0
 public Casting(
     INotifyCollectionChanged source) : base(Utils.getCapacity(source))
 {
     _source = source;
     _thisAsSourceCollectionChangeProcessor = this;
 }
Пример #28
0
 public Casting(
     IReadScalar <INotifyCollectionChanged> sourceScalar) : base(Utils.getCapacity(sourceScalar))
 {
     _sourceScalar = sourceScalar;
     _thisAsSourceCollectionChangeProcessor = this;
 }
Пример #29
0
 public CollectionProcessingVoid(
     INotifyCollectionChanged source,
     Action <TSourceItem, CollectionProcessingVoid <TSourceItem> > newItemProcessor  = null,
     Action <TSourceItem, CollectionProcessingVoid <TSourceItem> > oldItemProcessor  = null,
     Action <TSourceItem, CollectionProcessingVoid <TSourceItem> > moveItemProcessor = null) : this(newItemProcessor, oldItemProcessor, moveItemProcessor, Utils.getCapacity(source))
 {
     _source = source;
     _thisAsSourceCollectionChangeProcessor = this;
 }
Пример #30
0
 public CollectionProcessingVoid(
     IReadScalar <INotifyCollectionChanged> sourceScalar,
     Action <TSourceItem, CollectionProcessingVoid <TSourceItem> > newItemProcessor  = null,
     Action <TSourceItem, CollectionProcessingVoid <TSourceItem> > oldItemProcessor  = null,
     Action <TSourceItem, CollectionProcessingVoid <TSourceItem> > moveItemProcessor = null) : this(newItemProcessor, oldItemProcessor, moveItemProcessor, Utils.getCapacity(sourceScalar))
 {
     _sourceScalar = sourceScalar;
     _thisAsSourceCollectionChangeProcessor = this;
 }