Exemplo n.º 1
0
 private static void TranslateValues(Type settingsClass, SettingsPropertyValueCollection values)
 {
     foreach (SettingsPropertyValue value in values)
     {
         if (value.SerializedValue == null || (value.SerializedValue is string) && ((string)value.SerializedValue) == ((string)value.Property.DefaultValue))
         {
             value.SerializedValue = SettingsClassMetaDataReader.TranslateDefaultValue(settingsClass, (string)value.Property.DefaultValue);
         }
     }
 }
        ///<summary>
        ///Returns the collection of settings property values for the specified application instance and settings property group.
        ///</summary>
        ///
        ///<returns>
        ///A <see cref="T:System.Configuration.SettingsPropertyValueCollection"></see> containing the values for the specified settings property group.
        ///</returns>
        ///
        ///<param name="context">A <see cref="T:System.Configuration.SettingsContext"></see> describing the current application use.</param>
        ///<param name="props">A <see cref="T:System.Configuration.SettingsPropertyCollection"></see> containing the settings property group whose values are to be retrieved.</param><filterpriority>2</filterpriority>
        public override SettingsPropertyValueCollection GetPropertyValues(SettingsContext context, SettingsPropertyCollection props)
        {
            lock (_syncLock)
            {
                Type settingsClass = (Type)context["SettingsClassType"];

                SettingsPropertyValueCollection values = _sourceProvider.GetPropertyValues(context, props);
                foreach (SettingsPropertyValue value in values)
                {
                    if (value.SerializedValue == null || (value.SerializedValue is string) && ((string)value.SerializedValue) == ((string)value.Property.DefaultValue))
                    {
                        value.SerializedValue = SettingsClassMetaDataReader.TranslateDefaultValue(settingsClass,
                                                                                                  (string)value.Property.DefaultValue);
                    }
                }
                return(values);
            }
        }