[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] pnetlib/System/Configuration ConfigurationSettings
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] pnetlib/System/Configuration ConfigurationSettings.cs, 1.5, 1.6 |
Date: |
Mon, 24 Nov 2003 00:37:47 +0000 |
Update of /cvsroot/dotgnu-pnet/pnetlib/System/Configuration
In directory subversions:/tmp/cvs-serv18620/System/Configuration
Modified Files:
ConfigurationSettings.cs
Log Message:
Implement the search algorithm for "machine.config" files; install
system-independent fallback defaults in "machine.default".
Index: ConfigurationSettings.cs
===================================================================
RCS file:
/cvsroot/dotgnu-pnet/pnetlib/System/Configuration/ConfigurationSettings.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ConfigurationSettings.cs 23 Nov 2003 23:03:38 -0000 1.5
--- ConfigurationSettings.cs 24 Nov 2003 00:37:45 -0000 1.6
***************
*** 34,37 ****
--- 34,82 ----
using Platform;
+ /*
+
+ Layout of the configuration file for data accessible by this API:
+
+ <configuration>
+ <configSections>
+ <sectionGroup name="NAME">
+ <!-- sections and groups -->
+ </sectionGroup>
+
+ <section name="NAME" type="TYPE" [allowLocation="?"]
+ [allowDefinition="?"]>
+ </section>
+
+ <remove name="NAME"/>
+
+ <clear/>
+ </configSections>
+
+ <!-- actual settings sections -->
+ </configuration>
+
+ Configuration section names have the form "NAME1/NAME2/NAME3",
+ for each level down through the XML file.
+
+ The "configSections" tag defines the "schema" for the real configuration
+ data that follows. Each section name has a type associated with it, which
+ is the name of the handler for parsing settings in that section.
+
+ We load configuration files in the following order:
+
+ GLOBAL/machine.default
+ GLOBAL/machine.config
+ USER/machine.default
+ USER/machine.config
+ application.config
+
+ The "machine.default" files are unique to this implementation. They provide
+ the bulk of the schema definition data and fallback defaults for configuration
+ settings. The default files are expected to remain static across all
+ installations of the software, whereas "machine.config" files might change
+ from machine to machine.
+
+ */
+
public sealed class ConfigurationSettings
{
***************
*** 106,109 ****
--- 151,172 ----
}
+ // Check for a machine default file's existence in a directory.
+ private static String CheckForMachineDefault(String dir)
+ {
+ // Bail out if the directory was not
specified.
+ if(dir == null || dir.Length == 0)
+ {
+ return null;
+ }
+
+ // Build the full pathname and check
for its existence.
+ String pathname = Path.Combine(dir,
"machine.schema");
+ if(!File.Exists(pathname))
+ {
+ return null;
+ }
+ return pathname;
+ }
+
// Check for a machine configuration file's existence in a
directory.
private static String CheckForMachineConfig(String dir)
***************
*** 140,152 ****
try
{
! // Find the machine
configuration file.
! String machineConfigFile;
! machineConfigFile =
CheckForMachineConfig
(InfoMethods.GetUserStorageDir());
! if(machineConfigFile == null)
! {
! machineConfigFile =
CheckForMachineConfig
!
(InfoMethods.GetGlobalConfigDir());
! }
// Find the application's
configuration file.
--- 203,219 ----
try
{
! // Find the user/global machine
defaults files.
! String userDefaultFile,
globalDefaultFile;
! userDefaultFile =
CheckForMachineDefault
(InfoMethods.GetUserStorageDir());
! globalDefaultFile =
CheckForMachineDefault
!
(InfoMethods.GetGlobalConfigDir());
!
! // Find the user/global machine
configuration files.
! String userConfigFile,
globalConfigFile;
! userConfigFile =
CheckForMachineConfig
!
(InfoMethods.GetUserStorageDir());
! globalConfigFile =
CheckForMachineConfig
!
(InfoMethods.GetGlobalConfigDir());
// Find the application's
configuration file.
***************
*** 155,162 ****
.ConfigurationFile;
! // Load the configuration files.
! if(machineConfigFile != null)
{
! Load(machineConfigFile);
}
if(appConfigFile != null &&
File.Exists(appConfigFile))
--- 222,241 ----
.ConfigurationFile;
! // Load all of the
configuration files that we found.
! if(globalDefaultFile != null)
{
! Load(globalDefaultFile);
! }
! if(globalConfigFile != null)
! {
! Load(globalConfigFile);
! }
! if(userDefaultFile != null)
! {
! Load(userDefaultFile);
! }
! if(userConfigFile != null)
! {
! Load(userConfigFile);
}
if(appConfigFile != null &&
File.Exists(appConfigFile))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] pnetlib/System/Configuration ConfigurationSettings.cs, 1.5, 1.6,
Rhys Weatherley <address@hidden> <=
- Prev by Date:
[Dotgnu-pnet-commits] pnetlib/config - New directory
- Next by Date:
[Dotgnu-pnet-commits] pnetlib ChangeLog, 1.1515, 1.1516 Makefile.am, 1.30, 1.31 configure.in, 1.107, 1.108
- Previous by thread:
[Dotgnu-pnet-commits] pnetlib/config - New directory
- Next by thread:
[Dotgnu-pnet-commits] pnetlib ChangeLog, 1.1515, 1.1516 Makefile.am, 1.30, 1.31 configure.in, 1.107, 1.108
- Index(es):