1public void AddImport(string importString)
2 {
3 XmlDocument ownerDocument = this._codeSnippetNode.OwnerDocument;
4 XmlElement newChild = ownerDocument.CreateElement("Import", this._nsMgr.LookupNamespace("ns1"));
5 newChild.InnerText = importString;
6 XmlNode node = this._codeSnippetNode.SelectSingleNode("descendant::ns1:Snippet//ns1:Imports", this._nsMgr);
7 if (node == null)
8 {
9 XmlNode node2 = this._codeSnippetNode.SelectSingleNode("descendant::ns1:Snippet", this._nsMgr);
10 node = ownerDocument.CreateElement("Imports", this._nsMgr.LookupNamespace("ns1"));
11 node = node2.PrependChild(node);
12 }
13 node.AppendChild(newChild);
14 this._imports.Add(importString);
15 }