public void ClearAddInSetting(StyleCopAddIn addIn, string propertyName) { Param.RequireNotNull(addIn, "addIn"); Param.RequireValidString(propertyName, "propertyName"); this.ClearAddInSettingInternal(addIn, propertyName); }
public bool IsAddInSettingOverwritten(StyleCopAddIn addIn, string propertyName, PropertyValue localProperty) { Param.RequireNotNull(addIn, "addIn"); Param.RequireValidString(propertyName, "propertyName"); if (this.parentSettings == null) { return false; } PropertyValue parentProperty = null; PropertyCollection addInSettings = this.parentSettings.GetAddInSettings(addIn); if (addInSettings != null) { parentProperty = addInSettings[propertyName]; } if (parentProperty != null) { return IsSettingOverwritten(localProperty, parentProperty); } if (localProperty.HasDefaultValue) { return !localProperty.IsDefault; } return true; }
private void InitializePropertyState(StyleCopAddIn addIn, BooleanProperty property) { BooleanProperty setting = addIn.GetSetting(this.tabControl.MergedSettings, property.PropertyName) as BooleanProperty; if (setting == null) { property.Value = property.DefaultValue; } else { property.Value = setting.Value; } }
private void ApplyRules(StyleCopAddIn addIn, TreeNode parentNode) { foreach (TreeNode node in parentNode.Nodes) { Rule tag = node.Tag as Rule; if (tag == null) { this.ApplyRules(addIn, node); } else { addIn.SetSetting(this.tabControl.LocalSettings, new BooleanProperty(addIn, tag.Name + "#Enabled", node.Checked)); } } }
private void ApplyProperties(StyleCopAddIn addIn) { ICollection<BooleanProperty> is2 = null; if (this.properties.TryGetValue(addIn, out is2)) { foreach (BooleanProperty property in is2) { addIn.SetSetting(this.tabControl.LocalSettings, property); } } }
/// <summary> /// Stores the properties for the given add-in. /// </summary> /// <param name="addIn">The add-in.</param> private void StoreAddinProperties(StyleCopAddIn addIn) { Param.AssertNotNull(addIn, "addIn"); ICollection<PropertyDescriptor> addInPropertyDescriptors = addIn.PropertyDescriptors; if (addInPropertyDescriptors != null && addInPropertyDescriptors.Count > 0) { List<BooleanProperty> storedProperties = new List<BooleanProperty>(addInPropertyDescriptors.Count); foreach (PropertyDescriptor propertyDescriptor in addInPropertyDescriptors) { if (propertyDescriptor.PropertyType == PropertyType.Boolean && propertyDescriptor.DisplaySettings) { PropertyDescriptor<bool> booleanPropertyDescriptor = (PropertyDescriptor<bool>)propertyDescriptor; // Ensure that the property has a friendly name and a description. if (string.IsNullOrEmpty(propertyDescriptor.FriendlyName)) { throw new ArgumentException(Strings.PropertyFriendlyNameNotSet); } if (string.IsNullOrEmpty(propertyDescriptor.Description)) { throw new ArgumentException(Strings.PropertyDescriptionNotSet); } BooleanProperty storedProperty = new BooleanProperty( booleanPropertyDescriptor, booleanPropertyDescriptor.DefaultValue); this.InitializePropertyState(addIn, storedProperty); storedProperties.Add(storedProperty); } } this.properties.Add(addIn, storedProperties.ToArray()); } }
internal void SetAddInSettingInternal(StyleCopAddIn addIn, PropertyValue property) { AddInPropertyCollection addInSettings = this.GetAddInSettings(addIn); if (addInSettings == null) { addInSettings = new AddInPropertyCollection(addIn); this.SetAddInSettings(addInSettings); } addInSettings.Add(property); }
public AddInPropertyCollection GetAddInSettings(StyleCopAddIn addIn) { AddInPropertyCollection propertys; Param.RequireNotNull(addIn, "addIn"); if (this.GetPropertyCollectionDictionary(addIn).TryGetValue(addIn.Id, out propertys)) { return propertys; } return null; }
/// <summary> /// Sets a setting for the given add-in. /// </summary> /// <param name="addIn">The add-in.</param> /// <param name="property">The setting property to set.</param> internal void SetAddInSettingInternal(StyleCopAddIn addIn, PropertyValue property) { Param.AssertNotNull(addIn, "addIn"); Param.AssertNotNull(property, "property"); AddInPropertyCollection properties = this.GetAddInSettings(addIn); if (properties == null) { properties = new AddInPropertyCollection(addIn); this.SetAddInSettings(properties); } properties.Add(property); }
/// <summary> /// Clears a setting for the given add-in. /// </summary> /// <param name="addIn">The add-in.</param> /// <param name="propertyName">The name of the property to clear.</param> internal void ClearAddInSettingInternal(StyleCopAddIn addIn, string propertyName) { Param.AssertNotNull(addIn, "addIn"); Param.AssertValidString(propertyName, "propertyName"); PropertyCollection properties = this.GetAddInSettings(addIn); if (properties != null) { properties.Remove(propertyName); if (properties.Count == 0) { Dictionary<string, AddInPropertyCollection> collection = this.GetPropertyCollectionDictionary(addIn); collection.Remove(addIn.Id); } } }
/// <summary> /// Gets the settings for the given add-in. /// </summary> /// <param name="addIn">The add-in.</param> /// <returns>Returns the add-in settings or null if there are no settings for the add-in.</returns> public AddInPropertyCollection GetAddInSettings(StyleCopAddIn addIn) { Param.RequireNotNull(addIn, "addIn"); Dictionary<string, AddInPropertyCollection> collection = this.GetPropertyCollectionDictionary(addIn); AddInPropertyCollection settingsForAddIn; if (collection.TryGetValue(addIn.Id, out settingsForAddIn)) { return settingsForAddIn; } return null; }
public bool IsAddInSettingOverwritten(StyleCopAddIn addIn, string propertyName, PropertyValue localProperty) { Param.RequireNotNull(addIn, "addIn"); Param.RequireValidString(propertyName, "propertyName"); Param.Ignore(localProperty); if (this.parentSettings == null) { return false; } // Try to find this property in the parent settings file. PropertyValue parentProperty = null; PropertyCollection parentParserProperties = this.parentSettings.GetAddInSettings(addIn); if (parentParserProperties != null) { parentProperty = parentParserProperties[propertyName]; } if (parentProperty == null) { // If there is no parent setting, then the parent is set to the default. If the local setting // is not set to the default, then we consider that the local setting is overriding the parent setting. return !localProperty.HasDefaultValue || !localProperty.IsDefault; } // Compare the local and parent properties. return IsSettingOverwritten(localProperty, parentProperty); }
/// <summary> /// Initializes a new instance of the AddInPropertyCollection class. /// </summary> /// <param name="addIn">An analyzer or parser add-in.</param> internal AddInPropertyCollection(StyleCopAddIn addIn) { Param.AssertNotNull(addIn, "addIn"); this.addIn = addIn; }
/// <summary> /// Applies settings for rules under the given node. /// </summary> /// <param name="addIn">The addin owning the rules.</param> /// <param name="parentNode">The parent node of the rules.</param> private void ApplyRules(StyleCopAddIn addIn, TreeNode parentNode) { Param.AssertNotNull(addIn, "addIn"); Param.AssertNotNull(parentNode, "parentNode"); foreach (TreeNode node in parentNode.Nodes) { Rule rule = node.Tag as Rule; if (rule == null) { this.ApplyRules(addIn, node); } else { addIn.SetSetting( this.tabControl.LocalSettings, new BooleanProperty(addIn, rule.Name + "#Enabled", node.Checked)); } } }
/// <summary> /// Applies the properties for the given add-in. /// </summary> /// <param name="addIn">The add-in.</param> private void ApplyProperties(StyleCopAddIn addIn) { Param.AssertNotNull(addIn, "addIn"); ICollection<BooleanProperty> addInProperties = null; if (this.properties.TryGetValue(addIn, out addInProperties)) { foreach (BooleanProperty property in addInProperties) { addIn.SetSetting(this.tabControl.LocalSettings, property); } } }
private void StoreAddinProperties(StyleCopAddIn addIn) { ICollection<Microsoft.StyleCop.PropertyDescriptor> propertyDescriptors = addIn.PropertyDescriptors; if ((propertyDescriptors != null) && (propertyDescriptors.Count > 0)) { List<BooleanProperty> list = new List<BooleanProperty>(propertyDescriptors.Count); foreach (Microsoft.StyleCop.PropertyDescriptor descriptor in propertyDescriptors) { if ((descriptor.PropertyType == PropertyType.Boolean) && descriptor.DisplaySettings) { PropertyDescriptor<bool> propertyDescriptor = (PropertyDescriptor<bool>) descriptor; if (string.IsNullOrEmpty(descriptor.FriendlyName)) { throw new ArgumentException(Strings.PropertyFriendlyNameNotSet); } if (string.IsNullOrEmpty(descriptor.Description)) { throw new ArgumentException(Strings.PropertyDescriptionNotSet); } BooleanProperty property = new BooleanProperty(propertyDescriptor, propertyDescriptor.DefaultValue); this.InitializePropertyState(addIn, property); list.Add(property); } } this.properties.Add(addIn, list.ToArray()); } }
public bool IsParserSettingOverwritten(StyleCopAddIn addIn, string propertyName) { Param.RequireNotNull(addIn, "addIn"); Param.RequireValidString(propertyName, "propertyName"); if (this.localSettings == null) { return false; } PropertyCollection addInSettings = this.localSettings.GetAddInSettings(addIn); if (addInSettings == null) { return false; } PropertyValue localProperty = addInSettings[propertyName]; if (localProperty == null) { return false; } return this.IsAddInSettingOverwritten(addIn, propertyName, localProperty); }
/// <summary> /// Gets the correct property collection dictionary depending on whether the given add-in /// is a parser or an analyzer. /// </summary> /// <param name="addIn">The add-in.</param> /// <returns>Returns the correct dictionary.</returns> private Dictionary<string, AddInPropertyCollection> GetPropertyCollectionDictionary(StyleCopAddIn addIn) { Param.AssertNotNull(addIn, "addIn"); Dictionary<string, AddInPropertyCollection> collection = this.parserSettings; if (addIn is SourceAnalyzer) { collection = this.analyzerSettings; } return collection; }
public PropertyValue GetAddInSetting(StyleCopAddIn addIn, string propertyName) { Param.RequireNotNull(addIn, "addIn"); Param.RequireValidString(propertyName, "propertyName"); PropertyCollection addInSettings = this.GetAddInSettings(addIn); if (addInSettings != null) { return addInSettings[propertyName]; } return null; }
internal AddInPropertyCollection(StyleCopAddIn addIn) { this.addIn = addIn; }
internal void ClearAddInSettingInternal(StyleCopAddIn addIn, string propertyName) { PropertyCollection addInSettings = this.GetAddInSettings(addIn); if (addInSettings != null) { addInSettings.Remove(propertyName); if (addInSettings.Count == 0) { this.GetPropertyCollectionDictionary(addIn).Remove(addIn.Id); } } }
public void SetAddInSetting(StyleCopAddIn addIn, PropertyValue property) { Param.RequireNotNull(addIn, "addIn"); Param.RequireNotNull(property, "property"); this.SetAddInSettingInternal(addIn, property); }
private Dictionary<string, AddInPropertyCollection> GetPropertyCollectionDictionary(StyleCopAddIn addIn) { Dictionary<string, AddInPropertyCollection> parserSettings = this.parserSettings; if (addIn is SourceAnalyzer) { parserSettings = this.analyzerSettings; } return parserSettings; }
/// <summary> /// Sets the check state for the given property. /// </summary> /// <param name="addIn">The addin that owns the property.</param> /// <param name="property">The property.</param> private void InitializePropertyState(StyleCopAddIn addIn, BooleanProperty property) { Param.AssertNotNull(addIn, "addIn"); Param.AssertNotNull(property, "property"); BooleanProperty mergedProperty = addIn.GetSetting(this.tabControl.MergedSettings, property.PropertyName) as BooleanProperty; if (mergedProperty == null) { property.Value = property.DefaultValue; } else { property.Value = mergedProperty.Value; } }