Reputation: 2591
I want insert a custom snippet into an XML file from code within an extension package.
Does anybody know how to get an IVsExpansion object when I have an IWpfTextView, ITextBuffer or ITextDocument?
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.textmanager.interop.ivsexpansion.aspx
Can somebody help me please?
Upvotes: 0
Views: 429
Reputation: 26
Did you also post this the other day on the MSDN VS Extensibility forum? If so I answered there with a possible approach (I haven't tried it and I am not an editor dev):
http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/c43699d3-4ed1-4a68-b1c8-d207efc98a04
In short I believe you can use the IVsEditorAdapterFactoryService to map from ITextBuffer -> IVsTextBuffer, and MSDN says IVsExpansion is implemented by the same object that implements IVsTextBuffer so if you cast the IVsTextBuffer to IVsExpansion it should succeed.
Ryan
Upvotes: 1