/// <summary> /// Initializes a new instance of the <see cref="T:TomsToolbox.ObservableCollections.ObservableExtensions.ObservableSelectImpl`2" /> class. /// </summary> /// <param name="sourceCollection">The source collection to wrap.</param> /// <param name="itemGeneratorExpression">The item generator to generate the wrapper for each item.</param> public ObservableSelectImpl([NotNull, ItemCanBeNull] IList <TSource> sourceCollection, [NotNull] Expression <Func <TSource, TTarget> > itemGeneratorExpression) : base(sourceCollection, itemGeneratorExpression.Compile()) { _propertyName = PropertySupport.TryExtractPropertyName(itemGeneratorExpression); _sourceReference = new WeakReference <IList <TSource> >(sourceCollection); if (_propertyName == null) { return; } sourceCollection.ForEach(item => AttachItemEvents(item as INotifyPropertyChanged)); }
/// <summary> /// Initializes a new instance of the <see cref="T:TomsToolbox.ObservableCollections.ObservableExtensions.ObservableSelectImpl`2" /> class. /// </summary> /// <param name="sourceCollection">The source collection to wrap.</param> /// <param name="itemGeneratorExpression">The item generator to generate the wrapper for each item.</param> public ObservableSelectImpl([NotNull, ItemCanBeNull] IList <TSource> sourceCollection, [NotNull] Expression <Func <TSource, TTarget> > itemGeneratorExpression) : base(sourceCollection, itemGeneratorExpression.Compile()) { _propertyName = PropertySupport.TryExtractPropertyName(itemGeneratorExpression); _sourceReference = new TomsToolbox.Core.WeakReference <IList <TSource> >(sourceCollection); if (_propertyName == null) { return; } _propertyChangeEventListeners = GeneratePropertyChangeEventListeners(sourceCollection); }