Posted 19 years ago
by Marianne
I have read (and copied) some code from posts on here that reference deserializing macros from xml but I'm unable to get the macro to actually run. Here is my code
I've tried both the macro.Execute and the RaiseEditCommand functions but the macro is never run. What am I missing? Thanks.
MacroCommand macro = new MacroCommand();
MemoryStream memoryStream = new MemoryStream();
//StringReader sr = new StringReader(xmlData);
//XmlTextReader xmlTextReader = new XmlTextReader(sr);
StreamWriter w = new StreamWriter(memoryStream, System.Text.Encoding.Default);
w.Write(xmlData); // xmlData is a valid variable that contains the xml macro data
w.Flush();
memoryStream.Position = 0;
XmlTextReader xmlTextReader = new XmlTextReader(memoryStream);
macro.ReadFromXml(xmlTextReader);
//macro.Execute(new EditCommandContext(f.ActiveSyntaxEditor.SelectedView.Selection, false));
f.ActiveSyntaxEditor.SelectedView.RaiseEditCommand(macro);
w.Close();
xmlTextReader.Close();
memoryStream = null;
------------------------------- Marianne