/// <summary>
        /// Returns a list of <see cref="SettingsPropertyDescriptor"/> objects describing each property belonging
        /// to a settings group.
        /// </summary>
        /// <remarks>
        /// The specified group must refer to a locally installed settings class.
        /// </remarks>
        public static List <SettingsPropertyDescriptor> ListSettingsProperties(SettingsGroupDescriptor group)
        {
            Platform.CheckForNullReference(group, "group");

            var settingsClass = Type.GetType(group.AssemblyQualifiedTypeName);

            if (settingsClass == null)
            {
                throw new SettingsException(string.Format("{0} is not a locally installed settings group.", group.Name));
            }

            return(CollectionUtils.Map(SettingsClassMetaDataReader.GetSettingsProperties(settingsClass),
                                       (PropertyInfo property) => new SettingsPropertyDescriptor(property)));
        }
        /// <summary>
        /// Returns a list of <see cref="SettingsPropertyDescriptor"/> objects describing each property belonging
        /// to a settings group.
        /// </summary>
        public static List <SettingsPropertyDescriptor> ListSettingsProperties(SettingsGroupDescriptor group)
        {
            Type settingsClass = Type.GetType(group.AssemblyQualifiedTypeName);

            return(CollectionUtils.Map <PropertyInfo, SettingsPropertyDescriptor, List <SettingsPropertyDescriptor> >(
                       SettingsClassMetaDataReader.GetSettingsProperties(settingsClass),
                       delegate(PropertyInfo p)
            {
                SettingsPropertyDescriptor info = new SettingsPropertyDescriptor(
                    SettingsClassMetaDataReader.GetName(p),
                    SettingsClassMetaDataReader.GetType(p).FullName,
                    SettingsClassMetaDataReader.GetDescription(p),
                    SettingsClassMetaDataReader.GetScope(p),
                    SettingsClassMetaDataReader.GetDefaultValue(p));
                return info;
            }));
        }
        ///<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);
            }
        }
Пример #4
0
 private static ICollection <PropertyInfo> GetProperties(Type settingsClass, SettingScope scope)
 {
     return(SettingsClassMetaDataReader.GetSettingsProperties(settingsClass, scope));
 }