public void Init() { originalXml = "<root>\r\n" + "\t<child>\r\n" + "\t</child>\r\n" + "</root>"; textEditor = new MockTextEditor(); textEditor.OptionsConvertTabsToSpaces = false; textEditor.OptionsIndentationSize = 4; textEditor.OptionsIndentationString = "\t"; textEditor.Document.Text = originalXml; // Insert new xml as child element of <child>. // Insert position is just before the start of </root> end element. WixDocumentEditor editor = new WixDocumentEditor(textEditor); string xmlToInsert = "<new-child>\r\n" + "</new-child>\r\n"; int line = 3; int column = 2; editor.InsertIndented(line, column, xmlToInsert); document = textEditor.Document; }
public void Init() { textEditor = new MockTextEditor(); textEditor.Document.Text = GetWixXml(); string replacementXml = "<NewElement>\r\n" + "</NewElement>"; wixDocumentEditor = new WixDocumentEditor(textEditor); replacementRegion = wixDocumentEditor.ReplaceElement("TARGETDIR", "Directory", replacementXml); }
public void Init() { originalXml = "<root>\r\n" + "\t<child>\r\n" + "\t</child>\r\n" + "</root>"; textEditor = new MockTextEditor(); textEditor.OptionsConvertTabsToSpaces = false; textEditor.OptionsIndentationSize = 4; textEditor.OptionsIndentationString = "\t"; document = textEditor.Document; textEditor.Document.Text = originalXml; // Replace the <child> element WixDocumentEditor editor = new WixDocumentEditor(textEditor); string xmlToInsert = "<new-child>\r\n" + "</new-child>"; int line = 2; int column = 2; int endLine = 3; // End column is the column containing the '>' of the </child> element. int endColumn = 9; var region = new DomRegion(line, column, endLine, endColumn); WixDocumentLineSegment lineSegment = WixDocumentLineSegment.ConvertRegionToSegment(textEditor.Document, region); initialDocumentRegionText = textEditor.Document.GetText(lineSegment.Offset, lineSegment.Length); editor.Replace(region, xmlToInsert); }