public bool ClearOptionValue(string optionId) { if (this.Parent == null) { // Can't clear options on the Global options return(false); } if (OptionsSetLocally.Contains(optionId)) { object currentValue = OptionsSetLocally[optionId]; OptionsSetLocally.Remove(optionId); EditorOptionDefinition definition = _factory.GetOptionDefinitionOrThrow(optionId); object inheritedValue = this.GetOptionValue(definition); // See what the inherited option value was. If it isn't changing, // then we don't need to raise an event. if (!object.Equals(currentValue, inheritedValue)) { RaiseChangedEvent(definition); } return(true); } return(false); }
/// <summary> /// Get the given option from this (or its ancestors). The caller should have already checked to ensure /// the given option is valid in the scope being requested. /// </summary> /// <param name="definition">Definition of the option to find.</param> /// <returns>The option's current value.</returns> internal object GetOptionForChild(EditorOptionDefinition definition) { if (OptionsSetLocally.Contains(definition.Name)) { return(OptionsSetLocally[definition.Name]); } if (_parent == null) { return(definition.DefaultValue); } return(_parent.GetOptionForChild(definition)); }
public bool IsOptionDefined(string optionId, bool localScopeOnly) { if (localScopeOnly && (_parent != null)) //All options with valid definitions are set for the root. { return(OptionsSetLocally.Contains(optionId)); } EditorOptionDefinition definition = _factory.GetOptionDefinition(optionId); if ((definition != null) && (Scope == null || definition.IsApplicableToScope(Scope))) { return(true); } return(false); }
public bool IsOptionDefined <T>(EditorOptionKey <T> key, bool localScopeOnly) { if (localScopeOnly && (_parent != null)) //All options with valid definitions are set for the root. { return(OptionsSetLocally.Contains(key.Name)); } EditorOptionDefinition definition = _factory.GetOptionDefinition(key.Name); if ((definition != null) && (Scope == null || definition.IsApplicableToScope(Scope)) && definition.ValueType.IsEquivalentTo(typeof(T))) { return(true); } return(false); }