Framework Overview: C# and Windows Runtime
Framework Overview: C# and Windows Runtime
Framework Overview: C# and Windows Runtime
Framework Overview
Almost all the capabilities of the .NET Framework are exposed via a vast set of
managed types. These types are organized into hierarchical namespaces and packaged
into a set of assemblies, which together with the CLR comprise the .NET
platform.
Some of the .NET types are used directly by the CLR and are essential for the managed
hosting environment. These types reside in an assembly called mscorlib.dll and
include C#’s built-in types, as well as the basic collection classes, types for stream
processing, serialization, reflection, threading, and native interoperability (“mscorlib”
is an abbreviation for Multi-language Standard Common Object Runtime
Library”).
At a level above this are additional types that “flesh out” the CLR-level functionality,
providing features such as XML, networking, and LINQ. These reside in System.
dll, System.Xml.dll, and System.Core.dll, and together with mscorlib they provide
a rich programming environment upon which the rest of the Framework is built.
This “core framework” largely defines the scope of the rest of this book.
The remainder of the .NET Framework consists of applied APIs, most of which cover
three areas of functionality:
• User interface technologies
• Backend technologies
• Distributed system technologies
Table 5-1 shows the history of compatibility between each version of C#, the CLR,
and the .NET Framework. C# 5.0 targets CLR 4.5 which is unusual because it’s a
patched version of CLR 4.0. This means that applications targeting CLR 4.0 will
actually run on CLR 4.5 after you install the latter; hence Microsoft has taken
extreme care to ensure backward compatibility.
LINQ to XML
The .NET Framework provides a number of APIs for working with XML data. From
Framework 3.5, the primary choice for general-purpose XML document processing
is LINQ to XML. LINQ to XML comprises a lightweight LINQ-friendly XML document
object model, plus a set of supplementary query operators. LINQ to XML is
supported fully in the Metro profile.
In this chapter, we concentrate entirely on LINQ to XML. In Chapter 11, we cover
the more specialized XML types and APIs, including the forward-only reader/writer,
the types for working with schemas, stylesheets and XPaths, and the legacy
XmlDocument-based DOM.
The LINQ to XML DOM is extremely well designed and highly
performant. Even without LINQ, the LINQ to XML DOM is
valuable as a lightweight façade over the low-level XmlReader and
XmlWriter classes.
All LINQ to XML types are defined in the System.Xml.Linq namespace.
Architectural Overview
This section starts with a very brief introduction to the concept of a DOM, and then
explains the rationale behind LINQ to XML’s DOM.
What Is a DOM?
Consider the following XML file:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<customer id="123" status="archived">
<firstname>Joe</firstname>
<lastname>Bloggs</lastname>
</customer>