protected override void OnOverrideLayerChanged(int layerIndex, ObservableCollectionX <StratabaseListInsertion <TElement> > oldValue, ObservableCollectionX <StratabaseListInsertion <TElement> > newValue) { if (oldValue != null) { oldValue.CollectionChanged -= this.OnStorageCollectionChanged; } this.TrackChanges(newValue); }
internal ObservableCollectionX <StratabaseListInsertion <TElement> > GetOverrideChanges(int layerIndex, bool generateIfNonExistant = false) { if (!this.ODAM.TryGetOverrideValue(layerIndex, this.PropertyName, out ObservableCollectionX <StratabaseListInsertion <TElement> > changes) && generateIfNonExistant) { changes = new ObservableCollectionX <StratabaseListInsertion <TElement> >(); this.ODAM.SetOverrideValue(layerIndex, this.PropertyName, changes); } return(changes); }
/// <summary> /// This is kind of weird, but I wanted it to live here. Essentially Strabase may know the template type as a type during construction /// and need to create list insertion data, but since the classes are typed that is tricky. Using extension methods to call this indirectly /// allows us to more cleanly and in a more unified location, generate the list insertions. /// </summary> internal static object GenerateStorageForBaselineListAccess(object[] elements) { ObservableCollectionX <StratabaseListInsertion <TElement> > data = new ObservableCollectionX <StratabaseListInsertion <TElement> >(); for (int index = 0; index < elements.Length; ++index) { var target = (TElement)elements[index]; data.Add(new StratabaseListInsertion <TElement>(StratabaseListInsertion <TElement> .kBaseline, index, target)); } return(data); }
private void TrackChanges(ObservableCollectionX <StratabaseListInsertion <TElement> > changes) { if (changes == null) { return; } // Sign up for collection changes changes.CollectionChanged -= this.OnStorageCollectionChanged; changes.CollectionChanged += this.OnStorageCollectionChanged; foreach (StratabaseListInsertion <TElement> item in changes) { this.Insert(item); } }