
Thanks that gave me a bit of a hint in the right direction but I was unable to load saved macros using the ReadFromXML call.
It appears (to me - and I am usually doing something wrong) there is a bug in the MacroAction.ReadFromXML() call.
If I have code like:
Dim Content = "<?xml version=""1.0"" encoding=""utf-16""?><MacroAction><EditAction AssemblyName=""ActiproSoftware.SyntaxEditor.Silverlight"" TypeName=""ActiproSoftware.Windows.Controls.SyntaxEditor.EditActions.TypingAction"" Text=""a"" Overwrite=""False"" /><EditAction AssemblyName=""ActiproSoftware.SyntaxEditor.Silverlight"" TypeName=""ActiproSoftware.Windows.Controls.SyntaxEditor.EditActions.TypingAction"" Text=""s"" Overwrite=""False"" /><EditAction AssemblyName=""ActiproSoftware.SyntaxEditor.Silverlight"" TypeName=""ActiproSoftware.Windows.Controls.SyntaxEditor.EditActions.TypingAction"" Text=""d"" Overwrite=""False"" /><EditAction AssemblyName=""ActiproSoftware.SyntaxEditor.Silverlight"" TypeName=""ActiproSoftware.Windows.Controls.SyntaxEditor.EditActions.TypingAction"" Text=""f"" Overwrite=""False"" /><EditAction AssemblyName=""ActiproSoftware.SyntaxEditor.Silverlight"" TypeName=""ActiproSoftware.Windows.Controls.SyntaxEditor.EditActions.TypingAction"" Text=""a"" Overwrite=""False"" /><EditAction AssemblyName=""ActiproSoftware.SyntaxEditor.Silverlight"" TypeName=""ActiproSoftware.Windows.Controls.SyntaxEditor.EditActions.TypingAction"" Text=""s"" Overwrite=""False"" /><EditAction AssemblyName=""ActiproSoftware.SyntaxEditor.Silverlight"" TypeName=""ActiproSoftware.Windows.Controls.SyntaxEditor.EditActions.TypingAction"" Text=""d"" Overwrite=""False"" /><EditAction AssemblyName=""ActiproSoftware.SyntaxEditor.Silverlight"" TypeName=""ActiproSoftware.Windows.Controls.SyntaxEditor.EditActions.TypingAction"" Text=""f"" Overwrite=""False"" /></MacroAction>"
Using sr As StringReader = New StringReader(content)
Using xr As XmlReader = XmlReader.Create(sr)
Dim x As New MacroAction
x.ReadFromXml(xr)
End Using
End Using
It will not work. Examining the properties of x after the x.ReadFromXML(xr) line shows:
{ActiproSoftware.Windows.Controls.SyntaxEditor.EditActions.MacroAction}
CanRecordInMacro: False
Count: 0
Item: In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.
Key: "Macro"
Results: Expanding will process the collection
Where in this case "Count" should be 8
I traced this down to inside the ReadFromXML() call there should be an extra "XMLReader.Read()" call before checking the XMLReader.Depth and then the attempt to determine the type for creation of TypingAction with Activator.CreateInstance() fails because the System.Type can not be determined.
I had to modify the type.GetType() call to be able to find the type and return it.
So in the end to get this to work I had to write my own ReadFromXML() call.
I have a small project I can upload if you are interested in the fix. Or maybe let me know if I am just doing something stupid in the above example.
Thanks,
-Al