internal void AddDerivedOptions(EditorOptions derived) { // Get rid of the expired refs DerivedEditorOptions.RemoveAll(weakref => !weakref.IsAlive); DerivedEditorOptions.Add(new WeakReference(derived)); }
private void RaiseChangedEvent(EditorOptionDefinition definition) { // First, send out local events, but only if the change is valid in this scope if (Scope == null || definition.IsApplicableToScope(Scope)) { var tempEvent = OptionChanged; if (tempEvent != null) { tempEvent(this, new EditorOptionChangedEventArgs(definition.Name)); } } // Get rid of the expired refs DerivedEditorOptions.RemoveAll(weakref => !weakref.IsAlive); // Now, notify a copy of the derived options (since an event might modify the DerivedEditorOptions). foreach (var weakRef in new FrugalList <WeakReference>(DerivedEditorOptions)) { EditorOptions derived = weakRef.Target as EditorOptions; if (derived != null) { derived.OnParentOptionChanged(definition); } } }
internal void RemovedDerivedOptions(EditorOptions derived) { foreach (var weakRef in DerivedEditorOptions) { if (weakRef.Target == derived) { DerivedEditorOptions.Remove(weakRef); break; } } }
internal EditorOptions(EditorOptions parent, IPropertyOwner scope, EditorOptionsFactoryService factory) { _parent = parent; _factory = factory; this.Scope = scope; this.OptionsSetLocally = new HybridDictionary(); if (parent != null) { parent.AddDerivedOptions(this); } }
private void CheckForCycle() { EditorOptions parent = _parent; HashSet <EditorOptions> visited = new HashSet <EditorOptions>(); while (parent != null) { if (visited.Contains(parent)) { throw new ArgumentException("Cycles are not allowed in the Parent chain."); } visited.Add(parent); parent = parent._parent; } }