70 lines
3.2 KiB
C#
70 lines
3.2 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: Microsoft.VisualStudio.Debugger.IEnumerableVisualizer.IEnumerableVisualizerSource
|
|
// Assembly: IEnumerableVisualizer.DebuggeeSide, Version=18.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
|
|
// MVID: CFD2027C-E4DB-4399-B4DA-641D6C32082D
|
|
// Assembly location: C:\Program Files\Microsoft Visual Studio\18\Professional\Common7\IDE\CommonExtensions\Platform\Debugger\Visualizers\net2.0\IEnumerableVisualizer.DebuggeeSide.dll
|
|
|
|
using Microsoft.VisualStudio.DebuggerVisualizers;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
|
|
namespace Microsoft.VisualStudio.Debugger.IEnumerableVisualizer;
|
|
|
|
public class IEnumerableVisualizerSource : VisualizerObjectSource
|
|
{
|
|
private static readonly Dictionary<object, IEnumerableObjectHandler> DataObjectHandlerDictionary = new Dictionary<object, IEnumerableObjectHandler>();
|
|
private static IEnumerableObjectHandler CurrentObjectHandler = (IEnumerableObjectHandler)null;
|
|
|
|
public static object GetObjectAt(int tableIndex, int rowIndex, int columnIndex)
|
|
{
|
|
return CurrentObjectHandler?.GetObjectAt(tableIndex, rowIndex, columnIndex) ?? (object)null;
|
|
}
|
|
|
|
public virtual void TransferData(object obj, Stream fromVisualizer, Stream toVisualizer)
|
|
{
|
|
IEnumerableObjectHandler dataObjectHandler;
|
|
if (DataObjectHandlerDictionary.ContainsKey(obj))
|
|
{
|
|
dataObjectHandler = DataObjectHandlerDictionary[obj];
|
|
dataObjectHandler.Refresh();
|
|
}
|
|
else
|
|
{
|
|
dataObjectHandler = CreateDataObjectHandler(obj);
|
|
DataObjectHandlerDictionary[obj] = dataObjectHandler;
|
|
}
|
|
CurrentObjectHandler = dataObjectHandler;
|
|
fromVisualizer.Seek(0L, SeekOrigin.Begin);
|
|
IDeserializableObject deserializableObject = VisualizerObjectSource.GetDeserializableObject(fromVisualizer);
|
|
Type type = (Type)null;
|
|
if (!deserializableObject.IsBinaryFormat)
|
|
{
|
|
string stringPropertyValue = deserializableObject.GetJsonStringPropertyValue("TypeName");
|
|
if (!Utils.SupportedCommands.TryGetValue(stringPropertyValue, out type))
|
|
throw new ArgumentException($"Unknown Command: {stringPropertyValue}. Cannot send command to debuggee-side visualizer.");
|
|
}
|
|
ICommunicatorCommand communicatorCommand = (ICommunicatorCommand)deserializableObject.ToObject(type);
|
|
if (communicatorCommand.TypeName.Equals("GetTableListCommand", StringComparison.InvariantCulture))
|
|
dataObjectHandler.InitializeDataSource();
|
|
SendResult(communicatorCommand.HandleCommand(dataObjectHandler), toVisualizer);
|
|
}
|
|
|
|
private IEnumerableObjectHandler CreateDataObjectHandler(object obj)
|
|
{
|
|
return new IEnumerableObjectHandler(obj);
|
|
}
|
|
|
|
public virtual object CreateReplacementObject(object obj, Stream serializedObject)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
public virtual void GetData(object obj, Stream dataStream) => throw new NotSupportedException();
|
|
|
|
private void SendResult(CommunicatorResult result, Stream toVisualizer)
|
|
{
|
|
VisualizerObjectSource.Serialize(toVisualizer, (object)result);
|
|
}
|
|
}
|