Example #1
0
        public void Refresh()
        {
            // clear ListView
            listView.ItemsSource = null;
            ScrollViewer listViewScroller = listView.GetScrollViewer();

            if (listViewScroller != null)
            {
                listViewScroller.ScrollToVerticalOffset(0);
            }
            Value shownValue = null;

            ICSharpCode.NRefactory.Ast.Expression shownExpr = null;
            try     {
                shownExpr  = debuggerService.GetExpression(txtExpression.Text);
                shownValue = shownExpr.Evaluate(debuggerService.DebuggedProcess);
            } catch (GetValueException) {
                // display ex.Message
            }
            if (shownValue != null && !shownValue.IsNull)
            {
                GridValuesProvider gridValuesProvider;
                // Value is IList
                DebugType iListType, listItemType;
                if (shownValue.Type.ResolveIListImplementation(out iListType, out listItemType))
                {
                    gridValuesProvider = CreateListValuesProvider(shownExpr, iListType, listItemType);
                }
                else
                {
                    // Value is IEnumerable
                    DebugType iEnumerableType, itemType;
                    if (shownValue.Type.ResolveIEnumerableImplementation(out iEnumerableType, out itemType))
                    {
                        // original

                        /*var lazyListViewWrapper = new LazyItemsControl<ObjectValue>(this.listView, initialIEnumerableItemsCount);
                         * var enumerableValuesProvider = new EnumerableValuesProvider(val.ExpressionTree, iEnumerableType, itemType);
                         * lazyListViewWrapper.ItemsSource = new VirtualizingIEnumerable<ObjectValue>(enumerableValuesProvider.ItemsSource);
                         * gridValuesProvider = enumerableValuesProvider;*/
                        DebugType debugListType;
                        var       debugListExpression = DebuggerHelpers.CreateDebugListExpression(shownExpr, itemType, out debugListType);
                        gridValuesProvider = CreateListValuesProvider(debugListExpression, debugListType, itemType);
                    }
                    else
                    {
                        // Value cannot be displayed in GridVisualizer
                        return;
                    }
                }

                IList <MemberInfo> itemTypeMembers = gridValuesProvider.GetItemTypeMembers();
                InitializeColumns((GridView)this.listView.View, itemTypeMembers);
                this.columnHider       = new GridViewColumnHider((GridView)this.listView.View);
                cmbColumns.ItemsSource = this.columnHider.HideableColumns;
            }
        }
        public void Refresh()
        {
            try {
                // clear ListView
                listView.ItemsSource = null;
                ScrollViewer listViewScroller = listView.GetScrollViewer();
                if (listViewScroller != null)
                {
                    listViewScroller.ScrollToVerticalOffset(0);
                }
                Value shownValue = null;
                ICSharpCode.NRefactory.Ast.Expression shownExpr = null;
                try     {
                    shownExpr  = debuggerService.GetExpression(txtExpression.Text);
                    shownValue = shownExpr.Evaluate(debuggerService.DebuggedProcess);
                } catch (GetValueException e) {
                    MessageService.ShowMessage(e.Message);
                }
                if (shownValue != null && !shownValue.IsNull)
                {
                    GridValuesProvider gridValuesProvider;
                    // Value is IList
                    DebugType iListType, listItemType;
                    if (shownValue.Type.ResolveIListImplementation(out iListType, out listItemType))
                    {
                        gridValuesProvider = CreateListValuesProvider(shownExpr.CastToIList(), listItemType);
                    }
                    else
                    {
                        // Value is IEnumerable
                        DebugType iEnumerableType, itemType;
                        if (shownValue.Type.ResolveIEnumerableImplementation(out iEnumerableType, out itemType))
                        {
                            DebugType debugListType;
                            var       debugListExpression = DebuggerHelpers.CreateDebugListExpression(shownExpr, itemType, out debugListType);
                            gridValuesProvider = CreateListValuesProvider(debugListExpression, itemType);
                        }
                        else
                        {
                            // Not IList or IEnumerable<T> - can't be displayed in GridVisualizer
                            return;
                        }
                    }

                    IList <MemberInfo> itemTypeMembers = gridValuesProvider.GetItemTypeMembers();
                    InitializeColumns((GridView)this.listView.View, itemTypeMembers);
                    this.columnHider       = new GridViewColumnHider((GridView)this.listView.View);
                    cmbColumns.ItemsSource = this.columnHider.HideableColumns;
                }
            } catch (GetValueException e) {
                MessageService.ShowMessage(e.Message);
            } catch (DebuggerVisualizerException e) {
                MessageService.ShowMessage(e.Message);
            }
        }
Example #3
0
		/// <summary>
		/// Checks whether given expression's type is supported by the graph builder.
		/// </summary>
		/// <param name="expr">Expression to be checked.</param>
		private void checkIsOfSupportedType(Expression expr)
		{
			DebugType typeOfValue = expr.Evaluate(debuggerService.DebuggedProcess).Type;
			if (typeOfValue.IsArray)
			{
				throw new DebuggerVisualizerException("Arrays are not supported yet");
			}
		}
		/// <summary>
		/// Evaluates System.Collections.ICollection.Count property on given object.
		/// </summary>
		/// <exception cref="GetValueException">Evaluating System.Collections.ICollection.Count on targetObject failed.</exception>
		public static int GetIListCount(Expression targetObject)
		{
			Value list = targetObject.Evaluate(WindowsDebugger.CurrentProcess);
			var iCollectionInterface = list.Type.GetInterface(typeof(ICollection).FullName);
			if (iCollectionInterface == null)
				throw new GetValueException(targetObject, targetObject.PrettyPrint() + " does not implement System.Collections.ICollection");
			PropertyInfo countProperty = iCollectionInterface.GetProperty("Count");
			// Do not get string representation since it can be printed in hex
			return (int)list.GetPropertyValue(countProperty).PrimitiveValue;
		}