Traitée Configuration Application Block

  • Wednesday, September 28, 2005 12:24 PM
     
     
    Hi

    When using the configuration access block; I simply want to access the configured XML file (for reading) via Xpath attributes; and not have to create a Type class for the configuration items.  Is it possible to get the Configuration Access Block to read in these types of xml config files and then access them accordingly?  For example:

    Given the following config file (assume the the linkage is already provided between the web.config and the file provided below):

    <?xml version="1.0" encoding="utf-8"?>
    <
    WebFormSettings
    >
     
    <xmlSerializerSection type=
    "Configuration.ValueData, SampleWebApplication, Version=1.0.2097.14491, Culture=neutral, PublicKeyToken=null">
        <ValueData
    >
         
    <Value>SomeValue</Value
    >
       
    </ValueData
    >
     
    </xmlSerializerSection
    >
    </
    WebFormSettings>

    I had to create a Class (called ValueData) to read the given config as shown below:

    ValueData configData = ConfigurationManager.GetConfiguration("WebFormSettings") as ValueData;

    Instead, I would prefer to access some config items via the following:

    string configData = ConfigurationManager.GetConfiguration("WebFormSettings/ValueData/Value") as string;

    Which in this case should return "SomeValue"

All Replies