NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

ConfigManager Members

Public:

Constructor

ConfigManager Constructor [To be supplied.]

Methods

Delete Overloaded. The Delete, DeleteItem and DeleteProperty methods allow configuration information to be deleted from a configuration store.

The Delete methods allow deletion of more than one configuration item at a time. They can be used to delete any configuration information, including singleton ConfigTypes, as long as configuration schema has been defined.

Other methods exist to delete a single configuration item (DeleteItem) or individual configuration properties (DeleteProperty).

DeleteItem The Delete, DeleteItem and DeleteProperty methods allow configuration information to be deleted from a configuration store.

The DeleteItem method allows deletion of one configuration item at a time. It can be used to delete any configuration information, including singleton ConfigTypes, as long as configuration schema has been defined.

Other methods exist to delete a single configuration item (DeleteItem) or individual configuration properties (DeleteProperty).

DeleteProperty Overloaded. Resets a configuration property to its default value.

It does not remove the configuration property from the configuration schema for a config type.

Equals (inherited from Object) Determines whether the specified Object is the same instance as the current Object. Subclasses are expected to override this method to support value equality (not reference equality).
Get Overloaded. System runtimes, modules that extend the system runtimes, applications, as well as administrative tools, can retrieve configuration information through the GetItem and GetProperty methods.

The Get methods return configuration information as collections of configuration items (IConfigCollection). They can be used to retrieve any configuration information, including singleton ConfigTypes, as long as configuration schema has been defined.

Other methods exist to retrieve singleton configuration items (GetItem) or individual configuration properties (GetProperty).

Example 1: Singleton property- AppDomain ShadowCopy

In this example, the configuration information consists of a single named value, which occurs exactly once in a configuration scope (file).

The NGWS runtime system setting for application domains (as used by the EXE host) consists of such singleton properties: there can be only one "ShadowCopy" flag for each application.

[C#]

using System.Configuration;
 
 // Reading a single value: Boolean ShadowCopy = (Boolean) 
 Boolean ShadowCopy = (Boolean) ConfigManager.GetProperty("AppDomain", "c:\myapp\foo.cfg", "ShadowCopy");

Example 2: Singleton Item- AppDomain

The AppDomain configuration consists of more than one property, but still each of the properties can appear at most once in a configuration scope (file).

The configuration system makes it easy to retrieve all properties in a ConfigType at once:

[C#]

using System.Configuration;
 using System.Configuration.Core;
 
 AppDomain appdomain = ConfigManager.GetItem("AppDomain", "c:\myapp\foo.cfg");
 
 if (appdomain.ShadowCopy) { ... } 
 String path = appdomain.SharedPath;

Example 3: Collection of items- Binding Policy

In this example, the configuration information is slightly more complex: every property in a ConfigType can actually occur more than once within a given configuration scope (file).

The NGWS runtime system setting for binding policy ("<BindingPolicy>"), is a good example of such a configuration setting: every assembly that could potentially be loaded into an application can have it's own binding redirection entry.

[C#]

using System.Configuration;
 using System.Configuration.Core;
 
 IConfigCollection bindings = ConfigManager.Get("BindingPolicy", "c:\myapp\foo.cfg");
 foreach (BindingPolicy bindingredir in bindings) {
   Console.WriteLine(bindingredir.Name+": "+bindingredir.Version);
 }

Example 4: Generic configuration reader

In some cases (administrative tools, generic applications), it is necessary to process arbitrary configuration information without prior knowledge. The configuration system provides schema (property names, types etc.) discovery mechanisms for sophisticated tools, but also lets simple tools read configuration information in a generic way, by letting a caller enumerate the available properties in a configuration item.

The example code below outputs an arbitrary set of configuration information, by only modifying the ConfigType and Selector passed to the ConfigManager.Get method:

[C#]

// Late bound, generic
 IConfigCollection collection = ConfigManager.Get( "BindingPolicy", "c:\myapp\foo.cfg");
 foreach (IConfigItem item in collection) {
   Console.WriteLine("");
   foreach (Object property in item) {
     Console.WriteLine( property ); 
   }
 }
GetEmptyConfigCollection Returns an empty configuration collection. It is used primarily for update, creation of deletion of configuration items.
GetEmptyConfigItem Returns an empty configuration item. It is used primarily for update, creation of deletion of configuration items.
GetHashCode (inherited from Object) Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetItem Overloaded. The Get, GetItem and GetProperty methods provide read access to configuration information.

The GetItem methods return configuration information as single configuration items (IConfigItem). They can only be used to retrieve singleton ConfigTypes. If more than one instance of this ConfigType exists (within the scope indicated by the Selector), the GetItem methods throw an exception.

Other methods exist to retrieve collections of configuration items (Get) or individual configuration properties (GetProperty).

GetProperty Overloaded. The Get, GetItem and GetProperty methods provide read access to configuration information.

The GetProperty methods return a single property value. They can only be used to retrieve properties for singleton ConfigTypes. If more than one instance of this ConfigType exists (within the scope indicated by the Selector), the GetItem methods throw an exception.

Other methods exist to retrieve an entire singleton configuration items (GetItem) or collections of configuration items (Get).

GetSelectorFromString Parses a selector string and creates the appropriate selector object for the string.
GetType (inherited from Object) Gets the Type of the Object.
Put Overloaded. The Put, PutItem and PutProperty methods provide write access to configuration information.

The Put methods allow writes to more than one configuration item at a time. They can be used to write any configuration information, including singleton ConfigTypes, as long as configuration schema has been defined.

Other methods exist to write singleton configuration items (PutItem) or individual configuration properties (PutProperty).

PutItem Overloaded. [To be supplied.]
PutProperty Overloaded. [To be supplied.]
ToString (inherited from Object) Returns a String that represents the current Object.

Protected:

Methods

Finalize (inherited from Object) Allows an Object to attempt to free resources and perform other cleanup operations before the Object is reclaimed by the Garbage Collector (GC). This method may be ignored by the runtime; therefore, necessary cleanup operations should be done elsewhere.
MemberwiseClone (inherited from Object) Creates a shallow copy of the current Object.

See Also

ConfigManager Class | System.Configuration Namespace