/// <summary> /// Creates a new instance of the <see cref="ToolkitClassification"/> class. /// </summary> public ToolkitClassification(string category = "", ExtensionVisibility createVisibility = ExtensionVisibility.Expanded, ExtensionVisibility customizeVisibility = ExtensionVisibility.Expanded) { Guard.NotNull(() => category, category); this.category = category; this.createVisibility = createVisibility; this.customizeVisibility = customizeVisibility; }
/// <summary> /// Gets the value of the <see cref="ExtensionVisibility"/> attribute. /// </summary> /// <param name="content">The content element</param> /// <param name="attributeName">The name of the expected attribute.</param> /// <param name="defaultValue">The default value to use if the attribute is not found</param> /// <returns>The value of the attribute if found, else the value of the <paramref name="defaultValue"/> </returns> public static ExtensionVisibility GetVisibilityAttributeValue(this IExtensionContent content, string attributeName, ExtensionVisibility defaultValue) { var attributeValuePair = content.Attributes.FirstOrDefault(attr => attr.Key.Equals(attributeName, StringComparison.OrdinalIgnoreCase)); if (attributeValuePair.Equals(default(KeyValuePair<string, string>))) { return defaultValue; } ExtensionVisibility visibilityResult; if (Enum.TryParse<ExtensionVisibility>(attributeValuePair.Value, true, out visibilityResult)) { return visibilityResult; } else { return defaultValue; } }
/// <summary> /// Gets the value of the <see cref="ExtensionVisibility"/> attribute. /// </summary> /// <param name="content">The content element</param> /// <param name="attributeName">The name of the expected attribute.</param> /// <param name="defaultValue">The default value to use if the attribute is not found</param> /// <returns>The value of the attribute if found, else the value of the <paramref name="defaultValue"/> </returns> public static ExtensionVisibility GetVisibilityAttributeValue(this IExtensionContent content, string attributeName, ExtensionVisibility defaultValue) { var attributeValuePair = content.Attributes.FirstOrDefault(attr => attr.Key.Equals(attributeName, StringComparison.OrdinalIgnoreCase)); if (attributeValuePair.Equals(default(KeyValuePair <string, string>))) { return(defaultValue); } ExtensionVisibility visibilityResult; if (Enum.TryParse <ExtensionVisibility>(attributeValuePair.Value, true, out visibilityResult)) { return(visibilityResult); } else { return(defaultValue); } }