This project is read-only.

Go deeper

At the moment, the configuration subsystem consists of the following classes:

  • ConfigSettings – entry point to the configuration. It is a singleton instance: 

This class tries to use application.config file as main settings storage. After this it tries to load the list of defines configs and merges them using some rules

  • ConfigSection – wraps xml node/attribute The exposed members are mentioned below:
  •  
    • GetSection/GetSections – returns one/multiply ConfigSection 
    • GetString – returns value as string
    • GetInt – returns value as integer
    • GetBool – returns  value as bool
    • GetType – returns value as System.Type
    • GetInstance – returns value as instance of type T

These members receive the xpath value as parameter. Unfortunately, this isn’t string which represents any XPath expression. The reason of that is WP7 doesn’t support XPath (Jan 2012). Actually, it is a simple XPath expression with limitations.

  • ConfigElement – encapsulates xml processing operations 

Here is the example which shows how to use the configuration:

ConfigSection bootstrappers = ConfigSettings.Instance.GetSection("system/bootstrapping/bootstrappers/bootstrapper ");
List<IBootstrapperPlugin> tasks = new List<IBootstrapperPlugin>();
foreach (var bootsrappersSection in bootstrappers)
{
    _trace.Info(_category, String.Format("create '{0}' of type '{1}'", bootsrappersSection.GetString("@name"), bootsrappersSection.GetString("@type")));
    var plugin = bootsrappersSection.GetInstance<IBootstrapperPlugin>("@type", bootsrappersSection);
    tasks.Add(plugin);
}

Last edited Feb 11, 2012 at 10:02 PM by Ilya_Builuk, version 5

Comments

No comments yet.