public static IEnumerable <PropertyInfo> GetSettableProperties(this ISettingsProviderClass settingsProvider, params SettingsAvailability[] availabilities) { return(settingsProvider.GetType().GetProperties() .Where(info => info.GetAttributes <SettingsPropertyAttribute>(false).Any() && (availabilities == null || availabilities.Length == 0 || availabilities.Contains(info.GetAttributes <SettingsPropertyAttribute>(false).First().Availability)) && info.CanWrite && (info.PropertyType.IsEnum || allowedTypes.Contains(info.PropertyType)))); }
internal static SettingsKey GetSettingsKey(PropertyInfo propertyInfo, ISettingsProviderClass settingsProvider, ISolutionProjectModel solutionProject = null) { if (solutionProject == null) { return(new SettingsKey(string.Format("{0}_{1}", settingsProvider.GetType().FullName, propertyInfo.Name))); } string key = "_" + solutionProject.SolutionFileName + solutionProject.ItemPath.GetHashCode(); return(new SettingsKey(string.Format("{0}_{1}{2}", settingsProvider.GetType().FullName, propertyInfo.Name, key))); }
private static UIElement GetUIElement(PropertyInfo propertyInfo, ISettingsProviderClass settingsProvider) { var settingsService = CheckoutAndBuild2Package.GetGlobalService <SettingsService>(); var attribute = propertyInfo.GetAttributes <SettingsPropertyAttribute>(false).First(); SettingsKey settingsKey = GetSettingsKey(propertyInfo, settingsProvider); object defaultValue = null; DefaultValueAttribute defaultValueAttribute = propertyInfo.GetAttributes <DefaultValueAttribute>(false).FirstOrDefault(); if (defaultValueAttribute != null) { defaultValue = defaultValueAttribute.Value; } return(EditorTemplates.GetUIElement(propertyInfo, settingsService, settingsKey, defaultValue, attribute)); }
public static IEnumerable <UIElement> GetUIElements(this ISettingsProviderClass settingsProvider, IOperationService specificService, params SettingsAvailability[] availabilities) { return(settingsProvider.GetSettableProperties(availabilities).Where(info => info.IsForService(specificService)). Select(propertyInfo => GetUIElement(propertyInfo, settingsProvider))); }