ChrisMissal / Formo

Formo allows you to use your configuration file as a dynamic object. Turn your web.config or application settings into a rich, dynamic object.
http://chrismissal.com/Formo/
MIT License
259 stars 33 forks source link

Allow inheriting class to override ConfigurationManager.GetSection #21

Closed gmasselli closed 11 years ago

gmasselli commented 11 years ago

How would you feel about providing a protected method that handles the ConfigurationManager invocation so it could be replaced by an inheriting class? Example:

        public Configuration(string sectionName, CultureInfo cultureInfo, IEnumerable<TypeConverter> customConverters = null)
        {
            _sectionName = sectionName ?? AppSettingsSectionName;
            _section = GetSection(_sectionName);
            _cultureInfo = cultureInfo ?? CultureInfo.CurrentCulture;
            if (customConverters != null)
            {
                conversions.AddRange(customConverters);
            }
        }

        protected virtual NameValueCollection GetSection(string sectionName)
        {
            return (NameValueCollection)ConfigurationManager.GetSection(sectionName);
        }

This would allow the inheriting class to supply its own implementation for populating the NameValueCollection.

ChrisMissal commented 11 years ago

I'm not opposed to this change, I just don't know how it would be leveraged. Do you have an example?

ChrisMissal commented 11 years ago

Does this change work for what you need? 78c4d1df92ec13e3a2dd24a4125c1dd9cd87e7d2

gmasselli commented 11 years ago

Yes it does. Thank you.

On May 14, 2013, at 8:39 PM, Chris Missal notifications@github.com wrote:

Does this change work for what you need? 78c4d1d

— Reply to this email directly or view it on GitHub.

ChrisMissal commented 11 years ago

Great. I'll have to get this pushed out to NuGet. Look for that in the next day or two.

gmasselli commented 11 years ago

Thank you!

On May 21, 2013, at 1:06 PM, Chris Missal notifications@github.com wrote:

Great. I'll have to get this pushed out to NuGet. Look for that in the next day or two.

— Reply to this email directly or view it on GitHub.

ChrisMissal commented 11 years ago

New version has been pushed to NuGet: "Formo 1.3.0.33563"

https://nuget.org/packages/Formo/