문제

What would be the best way to store a tree like the one below in app.config and how would I deserialize this information from it?

Tree
|-node1-
|       |-name - value
|       |-name - value
|       | ......
|-node2-
|       |-name - value
|       |-name - value
|       | ......
|-node3-
|       |-name - value
|       |-name - value
|       | ......

I can convert that tree to xml if that helps.

Thanks for any assistance in advance.

도움이 되었습니까?

해결책

Use a custom configuration section. For one way to do this, see Configuration Section Designer. You can do it manually, but you might like to play with CSD and see the code it generates.

다른 팁

You can extend .config with your own types. These can be elements containing other elements and attributes. This area does seem to be poorly documented but there are examples out there.

Start with the System.Configuration.ConfigurationElement class.

You can use and xml based document inside your app with .config extension( like NLog.config , ... ) and use a custom data provider to read the xml data and convert they to tree-like ds.

<Nodes>
    <Node Name="Node1" Value="Value1">
       <Node Name="Node1.1" Value="Value1.2">
       </Node>

       <Node Name="Node1.2" Value="Value1.2">
       </Node>
    </Node>

    <Node Name="Node2" Value="Value2">
    </Node>
</Nodes>

or you can use a custom config section

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top