开发者

Creating a typed configuration class using MS Enterprise Library 5.0

开发者 https://www.devze.com 2023-01-22 02:51 出处:网络
I have a ASP.Net 4.0 web application for which I need to create typed configuration class. What I mean is as follows:

I have a ASP.Net 4.0 web application for which I need to create typed configuration class. What I mean is as follows:

class SettingsClass
{
    int count;
    string name;
    decimal amount;
}

Should map to the configuration file as:

<MyAppSettings>
    <xmlSerializationSection type="...">
        <SettingsClass>
            <count>2<count>
            <name&g开发者_开发百科t;Moiz</name>
            <decimal>10.66</decimal>
        </SettingsClass>
    </xmlSerializationSection>
</MyAppSettings>

The configuration file was identified in the web.config as follows by a configuration section (Read ColorSettings as MyAppSettings)

Creating a typed configuration class using MS Enterprise Library 5.0

This was straight forward in ASP.Net 2.0 and Enterprise library 1.0

I am trying to achieve the same thing in ASP.Net 4.0 and Enterprise Library 5.0. However, the Enterprise Library Console of 5.0 does not work the same way as the Enterprise Library Configuration tool of 1.0.

I wanted to know how I should be going about in .Net 4.0 and Ent Lib 5.0 to achieve this same requirement. Is there a better means by which configuration can be handled for typed class in .Net 4.0/ent lib 5.0?


XML configuration changed radically (and not really for the better) in .NET 2.0. You're going to want to look at the System.Configuration namespace and the classes there. This is no longer an enterprise library question, but really one about the framework itself.

0

精彩评论

暂无评论...
验证码 换一张
取 消