示例#1
0
        void UpdateOptions(EditorOptions oldParent)
        {
            if (oldParent != null)
            {
                for (int i = 0; i < oldParent.weakChildren.Count; i++)
                {
                    if (oldParent.weakChildren[i].Target == this)
                    {
                        oldParent.weakChildren.RemoveAt(i);
                        break;
                    }
                }
            }
            if (parent != null)
            {
                parent.weakChildren.Add(new WeakReference(this));
            }

            if (parent != null || oldParent != null)
            {
                foreach (var o in SupportedOptions)
                {
                    if (dict.ContainsKey(o.Name))
                    {
                        continue;
                    }
                    var oldValue = oldParent == null ? o.DefaultValue : oldParent.GetValueOrDefault(o.Name);
                    var newValue = parent == null ? o.DefaultValue : parent.GetValueOrDefault(o.Name);
                    if (!Equals(oldValue, newValue))
                    {
                        OnChanged(o.Name);
                    }
                }
            }
        }
示例#2
0
 public EditorOptions(EditorOptionsFactoryService service, EditorOptions parent, IPropertyOwner scope)
 {
     this.service = service;
     this.parent  = parent;
     dict         = new Dictionary <string, object>(StringComparer.Ordinal);
     weakChildren = new List <WeakReference>();
     this.scope   = scope;
     UpdateOptions(null);
 }
示例#3
0
 EditorOptionsFactoryService([ImportMany] IEnumerable <EditorOptionDefinition> editorOptionDefinitions)
 {
     this.editorOptionDefinitions = new Dictionary <string, EditorOptionDefinition>();
     foreach (var o in editorOptionDefinitions)
     {
         Debug.Assert(!this.editorOptionDefinitions.ContainsKey(o.Name));
         this.editorOptionDefinitions[o.Name] = o;
     }
     GlobalOptions = new EditorOptions(this, null, null);
     GlobalOptions.SetOptionValue(DefaultTextViewOptions.WordWrapStyleId, WordWrapStylesConstants.DefaultValue);
 }
 EditorOptionsFactoryService(IGlobalEditorOptions globalEditorOptions, [ImportMany] IEnumerable <EditorOptionDefinition> editorOptionDefinitions)
 {
     this.editorOptionDefinitions = new Dictionary <string, EditorOptionDefinition>();
     foreach (var o in editorOptionDefinitions)
     {
         Debug.Assert(!this.editorOptionDefinitions.ContainsKey(o.Name));
         this.editorOptionDefinitions[o.Name] = o;
     }
     GlobalOptions = new EditorOptions(this, null, null);
     globalEditorOptions.Initialize(GlobalOptions);
 }