コード例 #1
0
        private static void ShowVisualizer(IVisualizerObjectProvider objectProvider)
        {
            var data     = (IList)objectProvider.GetObject();
            var itemType = data.GetType().GetProperty("Item").PropertyType;

            if (itemType == typeof(string))
            {
                var prim = new List <PrimitiveListItem>();
                foreach (string strItem in data.Cast <string>())
                {
                    var pli = new PrimitiveListItem();
                    pli.Value = strItem;
                    prim.Add(pli);
                }
                ListDebuggerVisualizerClient.ShowVisualizerForm(prim, itemType.Name);
            }
            else if (itemType.IsPrimitive)
            {
                var prim = new List <PrimitiveListItem>();
                foreach (object objItem in data.Cast <object>())
                {
                    var pli = new PrimitiveListItem();
                    pli.Value = objItem.ToString();
                    prim.Add(pli);
                }
                ListDebuggerVisualizerClient.ShowVisualizerForm(prim, itemType.Name);
            }
            else
            {
                ListDebuggerVisualizerClient.ShowVisualizerForm(data, itemType.Name);
            }
        }
コード例 #2
0
        private static void ShowVisualizer(IVisualizerObjectProvider objectProvider)
        {
            CosturaUtility.Initialize();

            var    jsonStream = objectProvider.GetData();
            var    reader     = new StreamReader(jsonStream);
            string json       = reader.ReadToEnd();
            var    container  = Newtonsoft.Json.JsonConvert.DeserializeObject <VisualizerDataContainer>(json);

            if (container.TypeName == "string")
            {
                var prim = new List <PrimitiveListItem>();

                foreach (string strItem in container.Data.Cast <string>())
                {
                    var listItem = new PrimitiveListItem();
                    listItem.Value = strItem;
                    prim.Add(listItem);
                }

                ListDebuggerVisualizerClient.ShowVisualizerForm(prim, container.TypeName);
            }
            else if (container.IsPrimitive)
            {
                var primitiveList = new List <PrimitiveListItem>();
                foreach (object objItem in container.Data.Cast <object>())
                {
                    var primitiveListItem = new PrimitiveListItem();
                    primitiveListItem.Value = objItem?.ToString() ?? "";
                    primitiveList.Add(primitiveListItem);
                }

                ListDebuggerVisualizerClient.ShowVisualizerForm(primitiveList, container.TypeName);
            }
            else
            {
                ListDebuggerVisualizerClient.ShowVisualizerForm(container.Data, container.TypeName);
            }
        }