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 access sectionName parameter #19

Closed gmasselli closed 11 years ago

gmasselli commented 11 years ago

Love the project, BTW. :)

When inheriting from Configuration no access is provided to the cstor parameter sectionName. The CloudConfiguration doesn't appear to use it, but it would be useful in other implementations.

ChrisMissal commented 11 years ago

Thanks! :tada: Are you subclassing Configuration and wanting to use it? I'm trying to think how it would be used if exposed as protected or public.

gmasselli commented 11 years ago

Yes, I am subclassing the Configuration class by following the Cloud example. Locally I've exposed it as protected and then set it in the cstor:

SectionName = sectionName ?? AppSettingsSectionName;
_section = (NameValueCollection)ConfigurationManager.GetSection(SectionName);
gmasselli commented 11 years ago

Should we be concerned about a property name collision with a configuration key called "SectionName"? Would it be better to expose this as a method than a property?

ChrisMissal commented 11 years ago

Yeah, I want to avoid public members on Formo.Configuration as much as possible. Correct me if I'm wrong, but couldn't we just use protected readonly string _sectionName? That way subclasses can expose it however they wish?

gmasselli commented 11 years ago

Yes, I like that option better than a public member.

ChrisMissal commented 11 years ago

This is on a pre-release nuget package: http://nuget.org/packages/Formo/1.3.0-pre