Пример #1
0
        protected ViewAdapter(InputCollectionWrapper <Tin> input,
                              LinqContinuousCollection <Tout> output)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }

            _input  = input;
            _output = new OutputCollectionWrapper <Tout>(output);

            output.SourceAdapter = this;
            // Must be referenced by this instance:
            _collectionChangedDelegate = delegate(object sender, NotifyCollectionChangedEventArgs args)
            {
                OnInputCollectionChanged(args);
            };
            _propertyChangedDelegate = delegate(object sender, PropertyChangedEventArgs args)
            {
                OnCollectionItemPropertyChanged((Tin)sender, args.PropertyName);
            };
            new WeakCollectionChangedHandler(input.InnerAsNotifier, _collectionChangedDelegate);

            foreach (Tin item in this.InputCollection)
            {
                SubscribeToItem(item);
            }
        }
Пример #2
0
        protected SmartViewAdapter(InputCollectionWrapper <TInput> input,
                                   LinqContinuousCollection <TOutput> output,
                                   HashSet <string> monitoredProperties)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }

            _input  = input;
            _output = new OutputCollectionWrapper <TOutput>(output);
            _monitoredProperties = monitoredProperties;

            output.SourceAdapter = this;
            // Must be referenced by this instance:

            foreach (TInput item in _input.InnerAsList)
            {
                SubscribeToItem(item);
            }

            CollectionChangedEventManager.AddListener(
                _input.InnerAsNotifier, this);
        }