why not linqpad's code use xml-CDATA ?

why not linqpad's code use xml-CDATA ?
is it more code to analysis of it?

e.g :

Comments

  • edited November 27
    A .linq file consists of a header in XML, followed by the query text. The query text is not part of the XML document - it exists outside of it, after the XML root element's closing tag.

    This makes it easy to edit the query using an ordinary text editor, as nothing needs to be escaped.

    You can parse a .linq file as follows:
    string data = File.ReadAllText (@"...");
    
    XmlParserContext context = new XmlParserContext (null, null, null, XmlSpace.None);
    Stream s = new MemoryStream (Encoding.UTF8.GetBytes (data));
    XmlTextReader reader = new XmlTextReader (s, XmlNodeType.Element, context);
    reader.MoveToContent ();
    XmlReader r2 = reader.ReadSubtree ();
    StringBuilder sb = new StringBuilder ();
    using (XmlWriter w = XmlWriter.Create (sb)) w.WriteNode (r2, true);
    var xe = XElement.Parse (sb.ToString ()).Dump ("Header");
    int lineNumber = reader.LineNumber;
    
    StringReader sr = new StringReader (data);
    for (int i = 0; i < lineNumber; i++) sr.ReadLine ();
    sr.ReadToEnd ().Trim ().Dump ("Query");
Sign In or Register to comment.