I'm trying to call a third part API method which signature looks like
object Load(XamlXmlReader reader);
Then given this sample xaml
<Foo xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:barns="clr-namespace:Bar;assembly=Bar"
Property="Value">
<Root>
<Element1 />
<Element2>
<SubElement>
<barns:Sample />
</SubElement>
</Element2>
</Root>
</Foo>
I need the to provide to the api a XamlXmlReader that load from, lets say, [line 7, column 12] until [line 9, column 25]
<SubElement>
<barns:Sample />
</SubElement>
The final Xaml readed by the reader should be
<Foo xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:barns="clr-namespace:Bar;assembly=Bar"
Property="Value">
<SubElement>
<barns:Sample />
</SubElement>
</Foo>
Are there any function that does this kind of reading?
If I have to roll my own, any suggestions or resources besides generating another file with this content manually from raw string, that may help?(I'm not familiar with XamlXmlReader)
What is IXamlLineInfo
and XamlXmlReaderSettings.ProvideLineInfo
about?
Thanks
This is the solution I found, it uses linq to XML, feel free to suggest improvements.
I needed to insert some other elements to the xml in my application. This is the core snippet, you would be able to use linq to xml to query easily anything you want to add to the final XML.