I have been trying for the following section structure in my app.config
& lt I am; MyConfig & gt; & Lt; NewsfeedSite = "ABC" & gt; & Lt; Add name = "first" /> & Lt; / Newsfeed & gt; & Lt; NewsfeedSite = "Xyx" & gt; & Lt; Add name = "other" /> & Lt; / Newsfeed & gt; & Lt; / MyConfig & gt; I already have the MyConfig section working, but I'm unsure about how newsfeed collection should be coded , Or if this structure is also possible I have the following sections so far: [ConfigurationCollection (typeof (NewsFeedConfig)) Public class NewsFeedConfigCollection: ConfigurationElementCollection {Protected Override ConfigurationElement CreateNewElement (New) NewsFeedConfig Return (); } Secure Override Object GetElementKey {Return ((NewsfeedConfig (Element)). Name; } Receive {{return (Newsfeed) Boundgate (IDX) to this [int IDX] public newsfeed sign; }} Public class NewsFeedConfig: ConfigurationElement {{ConfigurationProperty ("name", IsKey = true, IsRequired = true)} public string name {{return return (string) base ["name"]; } Set {base ["name"] = value; }} [Configuration property ("source", isiadiere = true)] public string source {received {string} base ["source"]; } Set {base ["source"] = value; }}} However, it requires that all news feeds be under a news feed collection, and then I need to manually parse them by adding a site Property for each element is fine, but is it possible to do this in a way that XML will work to define above?
"itemprop =" text "> I think that you will find your answer here:
You Something like can restructure your xml:
& lt; MyConfig & gt; & Lt; Newsfeed site = "ABC" & gt; & Lt; Feed & gt; & Lt; Feed name = "first" /> & Lt; / Feed & gt; & Lt; / Newsfeed & gt; & Lt; Newsfeed site = "Xyx" & gt; & Lt; Feed & gt; & Lt; Feed Name = "Second" /> & Lt; Feed Name = "Third" /> & Lt; Feed Name = "Fourth" /> & Lt; / Feed & gt; & Lt; / Newsfeed & gt; & Lt; / MyConfig & gt;
Comments
Post a Comment