This is the correct pattern used to create such a reader to read a file:
string fileName =
using (XmlReader reader = XmlReader.Create(fileName)) {
}
The class
XmlReader
is abstract. The concrete implementation will be chosen by the choice of one of those
Create
factory methods and their parameters. If you are curious what is the runtime type of your reader, use
reader.GetType()
.
By the way, your "manual" and hard-coded way of dealing with XML is bad. It's much better to use serialization in the form of
Data Contract:
http://msdn.microsoft.com/en-us/library/ms733127%28v=vs.110%29.aspx[
^].
To use Data Contracts, you don't have to use WCF itself.
—SA