Using LLBLGen 2.6 Final Version
Using Adapter template
We need to make a setup program for our application that alters the configuration file. Since some of the items in the configuration file are customer-specific, we are trying to save those sections from the original configuration file and copy them into the new configuration file that we are installing. One of those customer-specific sections is the LLBLGen section: sqlServerCatalogNameOverwrites.
"sqlServerCatalogNameOverwrites" uses type of "NameValueSectionHandler":
<section name="sqlServerCatalogNameOverwrites" type="System.Configuration.NameValueSectionHandler"/>
NameValueSectionHandler appears to be a .NET 1.x type that can't be used with ConfigurationManager.GetSection(). You get a compilation error if you try to cast the GetSection() result to "NameValueSectionHandler".
NameValueSectionHandler catalogNameOverwritesSection = (NameValueSectionHandler)webConfig.GetSection("sqlServerCatalogNameOverwrites") as NameValueSectionHandler;
If you don't cast the result of GetSection:
ConfigurationSection catalogNameOverwritesSection = webConfig.GetSection("sqlServerCatalogNameOverwrites");
the debugger will say the result is of type "DefaultSection".
I can cast the result to "DefaultSection and eventually extract the raw XML code, but what I really wanted was a collection of Key/Value pairs since that is more user-friendly to work with.
DefaultSection catalogNameOverwritesSection = (DefaultSection)webConfig.GetSection("sqlServerCatalogNameOverwrites");
ElementInformation element = catalogNameOverwritesSection.ElementInformation;
SectionInformation sectionInfo = catalogNameOverwritesSection.SectionInformation;
string xml = sectionInfo.GetRawXml();
I'm curious, is there another type we can use for "sqlServerCatalogNameOverwrites" that derives from type "ConfigurationSection"? Has this been changed in later versions of LLBLGen?