public void GetApplicationScopedPropertyValues() { SettingsAttributeDictionary dict = new SettingsAttributeDictionary(); ApplicationScopedSettingAttribute attr = new ApplicationScopedSettingAttribute(); dict.Add(attr.GetType(), attr); LocalFileSettingsProvider prov = new LocalFileSettingsProvider(); SettingsContext ctx = new SettingsContext(); SettingsProperty p = new SettingsProperty("property", typeof(int), prov, false, 10, SettingsSerializeAs.Binary, dict, false, false); SettingsPropertyCollection col = new SettingsPropertyCollection(); SettingsPropertyValueCollection vals; col.Add(p); prov.Initialize(null, null); vals = prov.GetPropertyValues(ctx, col); Assert.IsNotNull(vals, "A1"); Assert.AreEqual(1, vals.Count, "A2"); }
/// <summary> /// Returns true if the property is decorated with a <see cref="ApplicationScopedSettingAttribute"/>. /// </summary> public static bool IsAppScoped(PropertyInfo property) { ApplicationScopedSettingAttribute a = CollectionUtils.FirstElement <ApplicationScopedSettingAttribute>( property.GetCustomAttributes(typeof(ApplicationScopedSettingAttribute), false)); return(a != null); }