XElement and XDocument both inherit XContainer, and so both produce compiling code when passed as an argument to the InMemoryConfigurationSource.SetConfigurationXml method. This flexibility is not reflected in the section retrieval code, however, as each concrete type has different starting node levels in Linq-to-XML queries, but InMemoryConfigurationSource only has one strategy for dealing with its XContainer; that strategy is only valid for XElement instances. Either some form of type-sensitive solution should be implemented, or the XContainer parameter should be changed to one or the other (XDocument or XElement).
XElement
andXDocument
both inheritXContainer
, and so both produce compiling code when passed as an argument to theInMemoryConfigurationSource.SetConfigurationXml
method. This flexibility is not reflected in the section retrieval code, however, as each concrete type has different starting node levels in Linq-to-XML queries, butInMemoryConfigurationSource
only has one strategy for dealing with itsXContainer
; that strategy is only valid forXElement
instances. Either some form of type-sensitive solution should be implemented, or theXContainer
parameter should be changed to one or the other (XDocument
orXElement
).