1. Asp. Net Configuration
Web. config contains various configurations of Asp. Net programs. Web. config contains two parts: Section Handler and Section Settings. You may want to say that the web. config contains the appsettings and connectionStrings which do not belong to these two parts. Otherwise, you can easily view the machine. config.
<ConfigSections>
<Section name = "etettings" type = "System. configuration. appSettingsSection, System. configuration, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a "restartOnExternalChanges =" false "requirePermission =" false "/>
<Section name = "connectionStrings" type = "System. Configuration. ConnectionStringsSection, System. Configuration, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a" requirePermission = "false"/>
...
It can be seen that the appSettings and connectionStrings in web. config are actually the settings of these two sections.
Ii. Custom Configuration
In such a scenario, the system should provide user friendly prompts, for example, hello. It is very appropriate for Chinese users, but not for English users. Therefore, we can design it as follows:
Public interface IHelloGenerator
{
String GenerateHello ();
}
Public class CnHelloGenerator: IHelloGenerator
{
# Region IHelloGenerator Members
Public string GenerateHello ()
{
Return "hello ";
}
# Endregion
}
Public class EnHelloGenerator: IHelloGenerator
{
# Region IHelloGenerator Members
Public string GenerateHello ()
{
Return "Hello ";
}
# Endregion
}
Define an interface to generate a greeting, and define a class to implement this interface for different languages to generate a specific greeting. In use, you can:
Class App
{
Static void Main ()
{
Var helloGenerator = CreateHelloGenerator ("cn ");
Console. WriteLine (helloGenerator. GenerateHello ());
}
Private static IHelloGenerator CreateHelloGenerator (string lang)
{
Var result = default (IHelloGenerator );
Switch (lang)
{
Case "en ":
Return new EnHelloGenerator ();
Case "cn ":
Return new CnHelloGenerator ();
}
Return result;
}
}
- Three pages in total:
- Previous Page
- 1
- 2
- 3
- Next Page