GetPropertyValues() public method

public GetPropertyValues ( SettingsContext context, SettingsPropertyCollection properties ) : SettingsPropertyValueCollection
context SettingsContext
properties SettingsPropertyCollection
return SettingsPropertyValueCollection
Exemplo n.º 1
0
        /// <summary>
        /// Updates application settings to reflect a more recent installation of the application.
        /// </summary>
        public override void Upgrade()
        {
            var oldSettingsProvider = new LocalFileSettingsProvider();
            var oldPropertyValues = oldSettingsProvider.GetPropertyValues(Context, Properties);

            foreach (SettingsPropertyValue oldPropertyValue in oldPropertyValues)
            {
                if (!Equals(this[oldPropertyValue.Name], oldPropertyValue.PropertyValue))
                {
                    this[oldPropertyValue.Name] = oldPropertyValue.PropertyValue;
                }
            }
        }
		public void GetUserScopedPropertyValues ()
		{
			SettingsAttributeDictionary dict = new SettingsAttributeDictionary ();
			UserScopedSettingAttribute attr = new UserScopedSettingAttribute ();
			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");
		}