0

the goal is to define initial hierarchy over a configuration. the desired design is:

<Nodes>
  <Node Name = "a">
     <ChildNodeNames>
        b, c
     </ChildNodeNames>
  </Node>

  <Node Name = "b">
     <ChildNodeNames/>
  </Node>
  <Node Name = "c">
     <ChildNodeNames/>
  </Node>

</Node>

theoretically it should be very similar to System.Configuration.NameValueFileSectionHandler type

<Company.appSettings>
    <add key="1" value="a" />
    <add key="2" value="b" />
    <add key="3" value="c" />
  </Company.appSettings>

but how to:

  1. adopt to the goal and put into config file
  2. get the "Nodes" section from the config and recieve an object that contains a collection of Node?

Here is a nice solution, but it does not solve the second aspect of the question (How to get a List<string> collection of values from app.config in WPF?)

Community
  • 1
  • 1
Yaugen Vlasau
  • 2,148
  • 1
  • 17
  • 38
  • write your own custom config section, [here's](http://haacked.com/archive/2007/03/12/custom-configuration-sections-in-3-easy-steps.aspx/) a guide – Jonesopolis Apr 15 '14 at 14:16
  • can you give me a hint how to add a Enumeration or Collection property to the customSection? – Yaugen Vlasau Apr 15 '14 at 14:18

1 Answers1

0

found a link that helped me to implement desired concept: http://msdn.microsoft.com/query/dev11.query?appId=Dev11IDEF1&l=EN-US&k=k(System.Configuration.ConfigurationCollectionAttribute);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.5);k(DevLang-csharp)&rd=true

Unfortunatelly some peaces of code are not complete. So for example there is no definition of BaseGet

Possible implementation:

public UrlConfigElement  BaseGet(string key) 
{
    return this.OfType<UrlConfigElement>().First( e => e.Name == key);
}
Yaugen Vlasau
  • 2,148
  • 1
  • 17
  • 38