c# - Read custom configuration section which is having same nested element -
c# - Read custom configuration section which is having same nested element -
want create custom configuration section need read same nested element.
if see in below sample xml, setting element can repeat nested level.
would body please tell me how define entity read kind of nested construction nested element name same?
note: please create sure need read collection of same nested element can repeated multiple times. e.g. 'setting'
<customconfigsection> <setting source=""> <setting from="web1" to="web2" source="" /> <setting from="web3" to="web4" source="" /> <setting from="web5" to="web5" source="" /> <setting from="web7" to="web6" source="" /> <setting from="domain2" to="" source=""> <setting from="web1" to="web2" source="" /> <setting from="web1" to="web2" source="" /> <setting from="web1" to="web2" source="" /> </setting> <setting> <customconfigsection>
you can using configurationsection:
public class somesettings : configurationsection { private somesettings() { } [configurationproperty("fillcolor", defaultvalue="cyan")] public system.drawing.color fillcolor { { homecoming (system.drawing.color)this["fillcolor"]; } set { this["fillcolor"] = value; } } [configurationproperty("textsize", defaultvalue="8.5")] public float textsize { { homecoming (float)this["textsize"]; } set { this["textsize"] = value; } } [configurationproperty("fillopacity", defaultvalue="40")] public byte fillopacity { { homecoming (byte)this["fillopacity"]; } set { this["fillopacity"] = value; } } }
web.config:
<configuration> <configsections> <section name="somesettings" type="myapp.somesettings, somesettings" /> </configsections> <somesettings fillcolor="lightblue" textsize="9.5" fillopacity="50" /> </configuration>
here total article in code project
c# .net xml configuration web-config
Comments
Post a Comment