/// <summary> /// Initializes a new instance of the <see cref="ReadonlyViewBase{TSource,TMapped}"/> class. /// </summary> /// <param name="source">The source collection.</param> /// <param name="mapper">The mapping function.</param> /// <param name="leaveOpen">True means that the <paramref name="source"/> is not disposed when this instance is disposed.</param> /// <param name="startEmpty">True means that the tracker is empty after the constructor.</param> protected ReadonlyViewBase(IEnumerable <TSource> source, Func <IEnumerable <TSource>, IEnumerable <TMapped> > mapper, bool leaveOpen, bool startEmpty = false) { Ensure.NotNull(mapper, nameof(mapper)); this.mapper = mapper; this.leaveOpen = leaveOpen; this.source = source ?? EmptySource; this.tracker = new CollectionSynchronizer <TMapped>(startEmpty ? mapper(EmptySource) : mapper(source)); }
protected SynchronizedEditableView(IList <T> source, IEnumerable <T> sourceItems) { Ensure.NotNull(source, nameof(source)); this.Source = source; this.Tracker = new CollectionSynchronizer <T>(sourceItems); }