Ejemplo n.º 1
0
        internal void AddDerivedOptions(EditorOptions derived)
        {
            // Get rid of the expired refs
            DerivedEditorOptions.RemoveAll(weakref => !weakref.IsAlive);

            DerivedEditorOptions.Add(new WeakReference(derived));
        }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
 internal void RemovedDerivedOptions(EditorOptions derived)
 {
     foreach (var weakRef in DerivedEditorOptions)
     {
         if (weakRef.Target == derived)
         {
             DerivedEditorOptions.Remove(weakRef);
             break;
         }
     }
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        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;
            }
        }