This project is read-only.

Configuration

Configuration is the heart of the framework code and provides the way to:

  • control of application executing flow
  • create loosely-coupled classes
  • support plugin architecture
  • simplify unit testing

Let`s have a look at application.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configs>
    <config include="fwk.system.config" location="file" optional="false" />
    <config include="securebox.views.config" location="file" optional="false" />
    <config include="securebox.data.config" location="file" optional="false" />
  </configs>
</configuration>

As you can see, the configuration is stored as xml file in which there are defined other configuration files (from version 0.5.1). This approach helps to group the configuration for different subsystem in different files. For example, fwk.system.config file contains information about configuration of framework:

<?xml version="1.0" encoding="utf-8" ?>
<settings environment="release">
  <system>
    <container type="PhoneCore.Framework.Container,PhoneCore.Framework">
      <types />
    </container>
    <!-- bootstrapping -->
    <bootstrapping>
      <bootstrappers>
        <bootstrapper name="Core" type="PhoneCore.Framework.Bootstrap.CoreBootstrapperPlugin, PhoneCore.Framework">
          <services>
            <navigation type="PhoneCore.Framework.Navigation.NavigationService, PhoneCore.Framework" />
            <fileSystem type="PhoneCore.Framework.Storage.IsolatedStorageFileService, PhoneCore.Framework" />
            <settings type="PhoneCore.Framework.Storage.IsolatedStorageSettingService, PhoneCore.Framework" />
          </services>
        </bootstrapper>
        <bootstrapper name="Init" type="SecureBox.UI.Infrastructure.Plugins.InitPlugin, SecureBox.UI" />
        <bootstrapper name="DataContext" type="SecureBox.UI.Infrastructure.Plugins.DataContextPlugin, SecureBox.UI"  />
        <bootstrapper name="PassGen" type="SecureBox.UI.Infrastructure.Plugins.PassGenPlugin, SecureBox.UI"  />
      </bootstrappers>
    </bootstrapping>
    <navigation>
      <service />
    </navigation>
    <diagnostic>
      <!-- trace subsystem-->
      <traces>
        <trace name="default" type="PhoneCore.Framework.Diagnostic.Tracing.DefaultTrace, PhoneCore.Framework">
          <storage connectionString="Data Source=isostore:/tracedb.sdf">
            <init>
              <types>
                <type name="Info" />
                <type name="Warn" />
                <type name="Error" />
                <type name="Fatal" />
              </types>
            </init>
          </storage>
          <level>1</level>
          <controller type="PhoneCore.Framework.Diagnostic.Tracing.DefaultTraceController, PhoneCore.Framework"
                      template="Resources/Templates/DefaultTraceReport.txt" />
        </trace>
      </traces>
    </diagnostic>
  </system>
</settings>

The securebox.views.config file contains the settings of views and view models which are specific for SecureBox application:

<?xml version="1.0" encoding="utf-8" ?>
<settings environment="release">
  <views>
    <!-- page mapping -->
    <pageMapping>
      <resolver type="SecureBox.UI.Infrastructure.PageResolver, SecureBox.UI" />
      <pages>
        <page name="Startup">
          <uri type="relative" address="/ViewPage/StartupViewPage.xaml" />
          <viewModel type="SecureBox.UI.ViewModel.StartupViewPageModel, SecureBox.UI" />
        </page>
        <page name="Library">
          <uri type="relative" address="/ViewPage/LibraryViewPage.xaml" />
          <viewModel type="SecureBox.UI.ViewModel.LibraryViewPageModel, SecureBox.UI" />
        </page>
      <!-- cut -->
      </pages>
    </pageMapping>
  </views>
</settings>

Let's look at the main settings:

  • system/container – configures the settings of dependency injection container, attribute name specify the type of using container
  • system/bootstrapping - defines the tasks for bootstrapper service which should be run only once, e.g. :
    • register types in container
    • initialize page mapping
  • system/diagnostic/tracing - defines the tracing subsystem
  • views/pageMapping – defines mapping between pages and its view models

User can define custom settings/configs and easily access them into the code using ConfigSettings members described in details here.

Environment

When configuration is starting to merge, it reads environment attribute from settings node:

<settings environment="release">
  <system />
</settings>

If environmen is defined, the configs will be filter by this value. It will be useful for changing of functionality depending of "environment", e.g.:

  • testing
  • development
  • trial
  • full

Last edited Feb 11, 2012 at 9:44 PM by Ilya_Builuk, version 6

Comments

No comments yet.