I'm writing my own debugger visualiser. All works great to show up to visualiser with the data.
Now I add the code for more clearness:
public class MyVisualiserObjectSource : VisualizerObjectSource
{
public override void GetData(object target, Stream outgoingData)
{
string data= target as string;
var writer = new StreamWriter(outgoingData);
writer.Write(data);
writer.Flush();
}
}
public class MyVirtualizer : DialogDebuggerVisualizer
{
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
var streamReader = new StreamReader(objectProvider.GetData());
string data = streamReader.ReadToEnd();
using (var form = new MyVirtualizerForm(data))
{
windowService.ShowDialog(form);
}
}
}
The string here is passed to the visualizer and show my own form. It works. But now I want to pass back the modified data from the form to the variable.
How do I do that?
Edit:
I found out that I need to override the TransferData
method in VisualizerObjectSource
. But in the MSDN is no detail information about how I implement this correctly.
Can someone help me please?
Edit 2:
I looked with IL-Spy what TransferData
method does. It throws an exception.
So I override the method. But it is still not working. In the incomingData
is the modified string from the Form
. But I do not get back this value into the variable :(
public class StringVisualiserObjectSource : VisualizerObjectSource
{
public override void GetData(object target, Stream outgoingData)
{
var data = target as string;
var writer = new StreamWriter(outgoingData);
writer.Write(data);
writer.Flush();
}
public override void TransferData(object target, Stream incomingData, Stream outgoingData)
{
incomingData.CopyTo(outgoingData);
}
}