public void Initialize(Type tp, string filter, bool showEverything, Type context)
        {
            this.FindControl <MyExpandable>("expander").ExpandedChanged += ExpandedChanged;

            InputTextBox headerBox;

            StackPanel headerContainer = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            headerContainer.Children.Add(new InputTextBox()
            {
                FontSize = 12, Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.5, 0, 0), MyReadOnly = true, FontStyle = Avalonia.Media.FontStyle.Italic, Text = "Structure: "
            });
            headerContainer.Children.Add(headerBox = new InputTextBox()
            {
                FontSize = 12, Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.5, 0, 0), MyReadOnly = true, FontStyle = Avalonia.Media.FontStyle.Italic, Foreground = Brush.Parse("#2B91BC"), FontWeight = Avalonia.Media.FontWeight.Bold
            });

            this.FindControl <MyExpandable>("expander").Header = headerContainer;

            headerBox.Text = tp.Name;
            ToolTip.SetTip(headerBox, tp.FullName);

            List <MemberInfo> memberList = new List <MemberInfo>();

            MemberInfo[] members = tp.GetMembers(BindingFlags.Default | BindingFlags.Instance | BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic);


            int propInd = 0;
            int step    = Math.Max(1, members.Length / 100);

            foreach (System.Reflection.MemberInfo prop in members)
            {
                if (string.IsNullOrEmpty(filter) || prop.Name.ToLower().Contains(filter.ToLower()))
                {
                    memberList.Add(prop);
                }
                propInd++;
            }

            memberList = new List <System.Reflection.MemberInfo>(memberList.NaturalSort());

            bool hasMethods = false;
            bool hasProps   = false;
            bool hasEvents  = false;
            bool hasTypes   = false;
            bool hasUnknown = false;

            for (int i = 0; i < memberList.Count; i++)
            {
                int index = i;

                if (memberList[i].MemberType == System.Reflection.MemberTypes.Constructor || memberList[i].MemberType == System.Reflection.MemberTypes.Method)
                {
                    bool isAccessible = false;

                    if (memberList[i].MemberType == System.Reflection.MemberTypes.Constructor)
                    {
                        ConstructorInfo info = (ConstructorInfo)memberList[i];

                        isAccessible = info.IsPublic || (context != null && ((info.IsPrivate && info.DeclaringType == context) || (info.IsFamily && info.DeclaringType.IsAssignableFrom(context)) || (info.IsAssembly && info.DeclaringType.Assembly == context.Assembly) || (info.IsFamilyOrAssembly && (info.DeclaringType.IsAssignableFrom(context) || info.DeclaringType.Assembly == context.Assembly))));
                    }
                    else
                    {
                        MethodInfo info = (MethodInfo)memberList[i];

                        isAccessible = info.IsPublic || (context != null && ((info.IsPrivate && info.DeclaringType == context) || (info.IsFamily && info.DeclaringType.IsAssignableFrom(context)) || (info.IsAssembly && info.DeclaringType.Assembly == context.Assembly) || (info.IsFamilyOrAssembly && (info.DeclaringType.IsAssignableFrom(context) || info.DeclaringType.Assembly == context.Assembly))));
                    }

                    if (showEverything || isAccessible)
                    {
                        MethodStructure str = new MethodStructure(memberList[index], isAccessible);

                        this.FindControl <ReducedExpander>("methodsExpander").ChildrenContainer.RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });

                        Grid.SetRow(str, this.FindControl <ReducedExpander>("methodsExpander").ChildrenContainer.Children.Count);
                        this.FindControl <ReducedExpander>("methodsExpander").ChildrenContainer.Children.Add(str);

                        hasMethods = true;
                    }
                }
                else if (memberList[i].MemberType == System.Reflection.MemberTypes.Field || memberList[i].MemberType == System.Reflection.MemberTypes.Property)
                {
                    bool isAccessible = false;

                    if (memberList[i].MemberType == System.Reflection.MemberTypes.Field)
                    {
                        FieldInfo info = (FieldInfo)memberList[i];

                        isAccessible = info.IsPublic || (context != null && ((info.IsPrivate && info.DeclaringType == context) || (info.IsFamily && info.DeclaringType.IsAssignableFrom(context)) || (info.IsAssembly && info.DeclaringType.Assembly == context.Assembly) || (info.IsFamilyOrAssembly && (info.DeclaringType.IsAssignableFrom(context) || info.DeclaringType.Assembly == context.Assembly))));
                    }
                    else
                    {
                        PropertyInfo pInfo = (PropertyInfo)memberList[i];

                        if (pInfo.GetMethod != null)
                        {
                            MethodInfo info = pInfo.GetMethod;

                            isAccessible = info.IsPublic || (context != null && ((info.IsPrivate && info.DeclaringType == context) || (info.IsFamily && info.DeclaringType.IsAssignableFrom(context)) || (info.IsAssembly && info.DeclaringType.Assembly == context.Assembly) || (info.IsFamilyOrAssembly && (info.DeclaringType.IsAssignableFrom(context) || info.DeclaringType.Assembly == context.Assembly))));
                        }
                        else if (pInfo.SetMethod != null)
                        {
                            MethodInfo info = pInfo.SetMethod;

                            isAccessible = info.IsPublic || (context != null && ((info.IsPrivate && info.DeclaringType == context) || (info.IsFamily && info.DeclaringType.IsAssignableFrom(context)) || (info.IsAssembly && info.DeclaringType.Assembly == context.Assembly) || (info.IsFamilyOrAssembly && (info.DeclaringType.IsAssignableFrom(context) || info.DeclaringType.Assembly == context.Assembly))));
                        }
                        else
                        {
                            isAccessible = false;
                        }
                    }

                    if (showEverything || isAccessible)
                    {
                        PropertyStructure str = new PropertyStructure(memberList[index], isAccessible);

                        this.FindControl <ReducedExpander>("propsExpander").ChildrenContainer.RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });

                        Grid.SetRow(str, this.FindControl <ReducedExpander>("propsExpander").ChildrenContainer.Children.Count);
                        this.FindControl <ReducedExpander>("propsExpander").ChildrenContainer.Children.Add(str);
                        hasProps = true;
                    }
                }
                else if (memberList[i].MemberType == System.Reflection.MemberTypes.TypeInfo || memberList[i].MemberType == System.Reflection.MemberTypes.NestedType)
                {
                    bool isAccessible = false;

                    TypeInfo info = (TypeInfo)memberList[i];

                    isAccessible = info.IsPublic || info.IsNestedPublic || (context != null && ((info.IsNestedPrivate && info.DeclaringType == context) || (info.IsNestedFamily && info.DeclaringType.IsAssignableFrom(context)) || (info.IsNestedAssembly && info.DeclaringType.Assembly == context.Assembly) || (info.IsNestedFamORAssem && (info.DeclaringType.IsAssignableFrom(context) || info.DeclaringType.Assembly == context.Assembly))));

                    if (showEverything || isAccessible)
                    {
                        TypeStructure str = new TypeStructure((System.Reflection.TypeInfo)memberList[index], isAccessible);

                        this.FindControl <ReducedExpander>("typesExpander").ChildrenContainer.RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });

                        Grid.SetRow(str, this.FindControl <ReducedExpander>("typesExpander").ChildrenContainer.Children.Count);
                        this.FindControl <ReducedExpander>("typesExpander").ChildrenContainer.Children.Add(str);
                        hasTypes = true;
                    }
                }
                else if (memberList[i].MemberType == System.Reflection.MemberTypes.Event)
                {
                    bool isAccessible = false;


                    MethodInfo info = ((EventInfo)memberList[i]).AddMethod;

                    if (info != null)
                    {
                        isAccessible = info.IsPublic || (context != null && ((info.IsPrivate && info.DeclaringType == context) || (info.IsFamily && info.DeclaringType.IsAssignableFrom(context)) || (info.IsAssembly && info.DeclaringType.Assembly == context.Assembly) || (info.IsFamilyOrAssembly && (info.DeclaringType.IsAssignableFrom(context) || info.DeclaringType.Assembly == context.Assembly))));
                    }

                    if (showEverything || isAccessible)
                    {
                        EventStructure str = new EventStructure((System.Reflection.EventInfo)memberList[index], isAccessible);

                        this.FindControl <ReducedExpander>("eventsExpander").ChildrenContainer.RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });

                        Grid.SetRow(str, this.FindControl <ReducedExpander>("eventsExpander").ChildrenContainer.Children.Count);
                        this.FindControl <ReducedExpander>("eventsExpander").ChildrenContainer.Children.Add(str);
                        hasEvents = true;
                    }
                }
                else
                {
                    UnknownStructure str = new UnknownStructure(memberList[index]);

                    this.FindControl <ReducedExpander>("unknownExpander").ChildrenContainer.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = GridLength.Auto
                    });

                    Grid.SetRow(str, this.FindControl <ReducedExpander>("unknownExpander").ChildrenContainer.Children.Count);
                    this.FindControl <ReducedExpander>("unknownExpander").ChildrenContainer.Children.Add(str);
                    hasUnknown = true;
                }
            }

            Grid contentGrid = this.FindControl <Grid>("contentGrid");

            if (!hasMethods)
            {
                contentGrid.Children.Remove(this.FindControl <ReducedExpander>("methodsExpander"));
            }
            if (!hasProps)
            {
                contentGrid.Children.Remove(this.FindControl <ReducedExpander>("propsExpander"));
            }
            if (!hasEvents)
            {
                contentGrid.Children.Remove(this.FindControl <ReducedExpander>("eventsExpander"));
            }
            if (!hasTypes)
            {
                contentGrid.Children.Remove(this.FindControl <ReducedExpander>("typesExpander"));
            }
            if (!hasUnknown)
            {
                contentGrid.Children.Remove(this.FindControl <ReducedExpander>("unknownExpander"));
            }
        }
        public MethodStructure(MemberInfo mInfo, bool isAccessible)
        {
            InitializeComponent();

            if (!isAccessible)
            {
                this.FindControl <Grid>("notAccessibleIcon").IsVisible = true;
                ToolTip.SetTip(this.FindControl <Grid>("notAccessibleIcon"), "Not accessible");
            }

            if (mInfo.MemberType == MemberTypes.Method)
            {
                MethodInfo info = (MethodInfo)mInfo;
                this.FindControl <InputTextBox>("methodNameBox").Text = info.Name;

                if (info.IsStatic)
                {
                    this.FindControl <Grid>("staticIcon").IsVisible = true;
                    ToolTip.SetTip(this.FindControl <Grid>("staticIcon"), "Static");
                }

                if (info.ReturnType != typeof(void))
                {
                    this.FindControl <InputTextBox>("methodTypeBox").Text = info.ReturnType.Name;
                    ToolTip.SetTip(this.FindControl <InputTextBox>("methodTypeBox"), info.ReturnType.FullName);
                }
                else
                {
                    this.FindControl <InputTextBox>("methodTypeBox").Text       = "void";
                    this.FindControl <InputTextBox>("methodTypeBox").Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 255));
                }

                this.FindControl <StackPanel>("methodPanel").Children.Add(new InputTextBox()
                {
                    Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.5, 0, 0), MyReadOnly = true, Margin = new Thickness(0, 0, 0, 0), Text = "("
                });

                ParameterInfo[] parameters = info.GetParameters();
                for (int i = 0; i < parameters.Length; i++)
                {
                    InputTextBox bx = new InputTextBox()
                    {
                        Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.5, 0, 0), MyReadOnly = true, Text = parameters[i].ParameterType.Name, FontStyle = FontStyle.Italic, Foreground = new SolidColorBrush(Color.FromRgb(0x2B, 0x91, 0xBC)), Margin = new Thickness(i == 0 ? 0 : -4, 0, 0, 0)
                    };
                    ToolTip.SetTip(bx, parameters[i].ParameterType.FullName);
                    this.FindControl <StackPanel>("methodPanel").Children.Add(bx);
                    this.FindControl <StackPanel>("methodPanel").Children.Add(new InputTextBox()
                    {
                        Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.5, 0, 0), MyReadOnly = true, Text = " " + parameters[i].Name + (i < parameters.Length - 1 ? ", " : ""), Margin = new Thickness(-4, 0, 0, 0)
                    });;
                }

                this.FindControl <StackPanel>("methodPanel").Children.Add(new InputTextBox()
                {
                    Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.5, 0, 0), MyReadOnly = true, Text = ")", Margin = new Thickness(0, 0, 0, 0)
                });
            }
            else if (mInfo.MemberType == MemberTypes.Constructor)
            {
                ConstructorInfo info = (ConstructorInfo)mInfo;
                this.FindControl <InputTextBox>("methodNameBox").Text = info.Name;
                this.FindControl <InputTextBox>("methodTypeBox").Text = info.DeclaringType.Name;
                ToolTip.SetTip(this.FindControl <InputTextBox>("methodTypeBox"), info.DeclaringType.FullName);

                if (info.IsStatic)
                {
                    this.FindControl <Grid>("staticIcon").IsVisible = true;
                    ToolTip.SetTip(this.FindControl <Grid>("staticIcon"), "Static");
                }

                this.FindControl <StackPanel>("methodPanel").Children.Add(new InputTextBox()
                {
                    Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.5, 0, 0), MyReadOnly = true, Margin = new Thickness(0, 0, 0, 0), Text = "("
                });

                ParameterInfo[] parameters = info.GetParameters();
                for (int i = 0; i < parameters.Length; i++)
                {
                    InputTextBox bx = new InputTextBox()
                    {
                        Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.5, 0, 0), MyReadOnly = true, Text = parameters[i].ParameterType.Name, FontStyle = FontStyle.Italic, Foreground = new SolidColorBrush(Color.FromRgb(0x2B, 0x91, 0xBC)), Margin = new Thickness(i == 0 ? 0 : -4, 0, 0, 0)
                    };
                    ToolTip.SetTip(bx, parameters[i].ParameterType.FullName);
                    this.FindControl <StackPanel>("methodPanel").Children.Add(bx);
                    this.FindControl <StackPanel>("methodPanel").Children.Add(new InputTextBox()
                    {
                        Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.5, 0, 0), MyReadOnly = true, Text = " " + parameters[i].Name + (i < parameters.Length - 1 ? ", " : ""), Margin = new Thickness(-4, 0, 0, 0)
                    });
                }

                this.FindControl <StackPanel>("methodPanel").Children.Add(new InputTextBox()
                {
                    Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.5, 0, 0), MyReadOnly = true, Text = ")", Margin = new Thickness(0, 0, 0, 0)
                });
            }
        }
Ejemplo n.º 3
0
        public ErrorLine(Exception ex, bool isWarning = false)
        {
            InitializeComponent();

            this.FindControl <MyExpandable>("expander").ExpandedChanged += ExpandedChanged;

            InputTextBox headerBox;

            this.FindControl <MyExpandable>("expander").Header = headerBox = new InputTextBox()
            {
                FontSize = 12, Background = null, BorderThickness = new Thickness(0, 0, 0, 0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center, Margin = new Thickness(-5, 0, 0, 0), MyReadOnly = true, Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0))
            };

            if (isWarning)
            {
                this.FindControl <Canvas>("errorIcon").IsVisible   = false;
                this.FindControl <Canvas>("warningIcon").IsVisible = true;
                this.FindControl <Canvas>("background").Background = new SolidColorBrush(Color.FromRgb(255, 251, 230));
                this.FindControl <Canvas>("border1").Background    = new SolidColorBrush(Color.FromRgb(255, 245, 194));
                this.FindControl <Canvas>("border2").Background    = new SolidColorBrush(Color.FromRgb(255, 245, 194));
                headerBox.Foreground = new SolidColorBrush(Color.FromRgb(149, 127, 81));
            }

            headerBox.Text = ex.Message;

            if (ex is CompilationErrorException)
            {
                CompilationErrorException err = ((CompilationErrorException)ex);
                if (err.Diagnostics.Length == 1)
                {
                    headerBox.Text = err.GetType().Name + ": " + err.Diagnostics[0].GetMessage();

                    FileLinePositionSpan lineSpan = err.Diagnostics[0].Location.GetMappedLineSpan();

                    this.FindControl <InputTextBox>("locationBox").Text = "    " + err.Diagnostics[0].Id + " at " + lineSpan.Path + (!string.IsNullOrEmpty(lineSpan.Path) ? ":" : "") + (lineSpan.StartLinePosition.Line + 1).ToString() + ":" + (lineSpan.StartLinePosition.Character + 1).ToString();
                    this.FindControl <InputTextBox>("lineBox").Text     = "    " + err.Diagnostics[0].Location.SourceTree.GetText().Lines[lineSpan.StartLinePosition.Line].ToString().Replace("\t", "    ");
                    this.FindControl <InputTextBox>("positionBox").Text = "    " + new string(' ', err.Diagnostics[0].Location.SourceTree.GetText().Lines[lineSpan.StartLinePosition.Line].ToString().CountCharsUpToPosition(lineSpan.StartLinePosition.Character)) + "^";
                }
                else
                {
                    this.FindControl <Grid>("detailsGrid").Children.Clear();
                    this.FindControl <Grid>("detailsGrid").RowDefinitions.Clear();

                    headerBox.Text = err.GetType().Name + "[" + err.Diagnostics.Length.ToString() + "]";

                    for (int i = 0; i < err.Diagnostics.Length; i++)
                    {
                        this.FindControl <Grid>("detailsGrid").RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });
                        this.FindControl <Grid>("detailsGrid").RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });
                        this.FindControl <Grid>("detailsGrid").RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });
                        this.FindControl <Grid>("detailsGrid").RowDefinitions.Add(new RowDefinition()
                        {
                            Height = GridLength.Auto
                        });

                        InputTextBox message = new InputTextBox()
                        {
                            Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.2, 0, 0), MyReadOnly = true, Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0))
                        };
                        Grid.SetRow(message, i * 4);
                        Grid.SetColumn(message, 1);

                        message.Text = "• " + err.Diagnostics[i].GetMessage();

                        InputTextBox location = new InputTextBox()
                        {
                            Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.2, 0, 0), MyReadOnly = true
                        };
                        Grid.SetRow(location, i * 4 + 1);
                        Grid.SetColumn(location, 1);

                        FileLinePositionSpan lineSpan = err.Diagnostics[i].Location.GetMappedLineSpan();
                        location.Text = "    " + err.Diagnostics[i].Id + " at " + lineSpan.Path + (!string.IsNullOrEmpty(lineSpan.Path) ? ":" : "") + (lineSpan.StartLinePosition.Line + 1).ToString() + ":" + (lineSpan.StartLinePosition.Character + 1).ToString();

                        InputTextBox line = new InputTextBox()
                        {
                            Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.2, 0, 0), Margin = new Thickness(8, 4, 0, 0), MyReadOnly = true, Foreground = new SolidColorBrush(Color.FromRgb(0x3F, 0x48, 0xCC))
                        };
                        Grid.SetRow(line, i * 4 + 2);
                        Grid.SetColumn(line, 1);
                        line.Text = "    " + err.Diagnostics[i].Location.SourceTree.GetText().Lines[lineSpan.StartLinePosition.Line].ToString().Replace("\t", "    ");

                        InputTextBox position = new InputTextBox()
                        {
                            Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, Padding = new Thickness(0, 1.2, 0, 0), Margin = new Thickness(8, -5, 0, 0), MyReadOnly = true, Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0))
                        };
                        Grid.SetRow(position, i * 4 + 3);
                        Grid.SetColumn(position, 1);
                        position.Text = "    " + new string(' ', err.Diagnostics[i].Location.SourceTree.GetText().Lines[lineSpan.StartLinePosition.Line].ToString().CountCharsUpToPosition(lineSpan.StartLinePosition.Character)) + "^";

                        this.FindControl <Grid>("detailsGrid").Children.Add(message);
                        this.FindControl <Grid>("detailsGrid").Children.Add(location);
                        this.FindControl <Grid>("detailsGrid").Children.Add(line);
                        this.FindControl <Grid>("detailsGrid").Children.Add(position);
                    }
                }
            }
            else
            {
                headerBox.Text = ex.GetType().Name + ": " + ex.Message;

                this.FindControl <Grid>("detailsGrid").Children.Clear();
                this.FindControl <Grid>("detailsGrid").RowDefinitions.Clear();
                this.FindControl <Grid>("detailsGrid").ColumnDefinitions.Clear();
                this.FindControl <Grid>("detailsGrid").Margin = new Thickness(20, 0, 0, 0);
                this.FindControl <Grid>("detailsGrid").Children.Add(CSharpOutputLine.contentElement(ex));
            }
        }
Ejemplo n.º 4
0
        public static Control contentElement(dynamic outObj, bool log = false)
        {
            if (outObj is string)
            {
                InputTextBox outputBox = new InputTextBox()
                {
                    Foreground = new SolidColorBrush(Color.FromRgb(196, 26, 22)), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.5, 0, 0), Text = log ? outObj : (JsonConvert.SerializeObject(outObj))
                };
                return(outputBox);
            }
            else if (outObj is char)
            {
                string       serialized = JsonConvert.SerializeObject(outObj.ToString());
                InputTextBox outputBox  = new InputTextBox()
                {
                    Foreground = new SolidColorBrush(Color.FromRgb(196, 26, 22)), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.5, 0, 0), Text = "'" + serialized.Substring(1, serialized.Length - 2) + "'"
                };
                return(outputBox);
            }
            else if (outObj is long || outObj is int || outObj is double || outObj is decimal || outObj is ulong || outObj is uint || outObj is short || outObj is ushort || outObj is byte || outObj is sbyte || outObj is float)
            {
                InputTextBox outputBox = new InputTextBox()
                {
                    Foreground = new SolidColorBrush(Color.FromRgb(28, 0, 207)), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.5, 0, 0), Text = outObj.ToString(System.Globalization.CultureInfo.InvariantCulture)
                };

                return(outputBox);
            }
            else if (outObj is bool)
            {
                InputTextBox outputBox = new InputTextBox()
                {
                    Foreground = new SolidColorBrush(Color.FromRgb(28, 0, 207)), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.5, 0, 0), Text = outObj.ToString().ToLower()
                };

                return(outputBox);
            }
            else if (Object.ReferenceEquals(outObj, null))
            {
                InputTextBox outputBox = new InputTextBox()
                {
                    Foreground = new SolidColorBrush(Color.FromRgb(151, 151, 151)), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.5, 0, 0), Text = "null"
                };

                return(outputBox);
            }
            else if (isIEnumerable(outObj))
            {
                string enumerableType = "";

                foreach (Type interf in ((Type)outObj.GetType()).GetInterfaces())
                {
                    if (interf.IsGenericType && interf.GetGenericTypeDefinition() == typeof(IEnumerable <>))
                    {
                        foreach (Type tp in interf.GetGenericArguments())
                        {
                            enumerableType += tp.Name + ", ";
                        }
                    }
                }

                if (enumerableType.Length > 2)
                {
                    enumerableType = enumerableType.Substring(0, enumerableType.Length - 2);
                }

                Grid contentGrid = new Grid();
                contentGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });
                contentGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });
                contentGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
                contentGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });

                string contentText = "";

                int count = 0;

                foreach (dynamic dyn in outObj)
                {
                    contentText += getShortString(dyn) + ", ";
                    count++;
                    if (count >= 10)
                    {
                        break;
                    }
                }

                if (contentText.Length > 2)
                {
                    contentText = contentText.Substring(0, contentText.Length - 2);
                }

                int itemCount = -1;

                try
                {
                    itemCount = outObj.Count;
                }
                catch
                {
                    try
                    {
                        itemCount = outObj.Length;
                    }
                    catch
                    {
                        try
                        {
                            itemCount = outObj.Count();
                        }
                        catch
                        {
                        }
                    }
                }

                if (itemCount >= 10 || (itemCount < 0 && count >= 10))
                {
                    contentText += "…";
                }


                InputTextBox contentBox = new InputTextBox()
                {
                    Foreground = new SolidColorBrush(Color.FromRgb(151, 151, 151)), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.5, 0, 0), Text = "[" + contentText + "]"
                };
                Grid.SetColumn(contentBox, 1);
                contentGrid.Children.Add(contentBox);


                MyExpandable exp = new MyExpandable();

                InputTextBox outputBox = new InputTextBox()
                {
                    FontSize = 12, Foreground = new SolidColorBrush(Colors.Black), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.2, 0, 0), Text = outObj.GetType().Name + " : IEnumerable<" + enumerableType + ">[" + (itemCount >= 0 ? itemCount.ToString() : "") + "]: "
                };

                exp.Header = outputBox;
                contentGrid.Children.Add(exp);

                Grid arrayContentGrid = new Grid()
                {
                    Margin = new Thickness(20, 0, 0, 0), IsVisible = false
                };
                arrayContentGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });
                arrayContentGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });
                arrayContentGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });

                count = 0;

                foreach (dynamic dyn in outObj)
                {
                    int i = count;
                    arrayContentGrid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = GridLength.Auto
                    });

                    InputTextBox index = new InputTextBox()
                    {
                        FontSize = 12, Foreground = new SolidColorBrush(Color.FromRgb(163, 73, 164)), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right, Padding = new Thickness(0, 1.5, 0, 0), Text = i.ToString()
                    };
                    Grid.SetRow(index, i);
                    arrayContentGrid.Children.Add(index);

                    TextBlock colon = new TextBlock()
                    {
                        FontSize = 12, Foreground = new SolidColorBrush(Colors.Black), Background = null, FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Margin = new Thickness(0, 1.5, 3, 0), Text = ":"
                    };
                    Grid.SetRow(colon, i);
                    Grid.SetColumn(colon, 1);
                    arrayContentGrid.Children.Add(colon);

                    Control value = contentElement(dyn);

                    Grid.SetRow(value, i);
                    Grid.SetColumn(value, 2);
                    arrayContentGrid.Children.Add(value);

                    count++;
                }

                Grid.SetRow(arrayContentGrid, 1);

                contentGrid.Children.Add(arrayContentGrid);

                exp.ExpandedChanged += (s, e) =>
                {
                    arrayContentGrid.IsVisible = e.NewValue;
                    contentBox.IsVisible       = !e.NewValue;
                };

                return(contentGrid);
            }
            else if (outObj is Enum)
            {
                StackPanel tbr = new StackPanel()
                {
                    Orientation = Orientation.Horizontal
                };
                InputTextBox bx = new InputTextBox()
                {
                    Foreground = new SolidColorBrush(Color.FromRgb(0x2b, 0x91, 0xbc)), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.5, 0, 0), Text = outObj.GetType().Name, FontStyle = FontStyle.Italic
                };
                ToolTip.SetTip(bx, outObj.GetType().FullName);
                tbr.Children.Add(bx);
                tbr.Children.Add(new InputTextBox()
                {
                    Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.5, 0, 0), Text = ".", Margin = new Thickness(0, 0, 0, 0)
                });
                tbr.Children.Add(new InputTextBox()
                {
                    Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.5, 0, 0), Text = outObj.ToString(), Margin = new Thickness(0, 0, 0, 0)
                });
                return(tbr);
            }
            else
            {
                List <System.Reflection.MemberInfo> propertyList = new List <System.Reflection.MemberInfo>();

                List <string> propertyNames = new List <string>();

                foreach (System.Reflection.MemberInfo prop in ((Type)outObj.GetType()).GetMembers())
                {
                    if (prop.MemberType == System.Reflection.MemberTypes.Property || prop.MemberType == System.Reflection.MemberTypes.Field)
                    {
                        propertyList.Add(prop);
                        propertyNames.Add(prop.Name);
                    }
                }

                Grid contentGrid = new Grid();
                contentGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });
                contentGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });
                contentGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });
                contentGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = GridLength.Auto
                });

                string contentText = "";

                bool moreThan10Props = (from el in propertyList where (el.MemberType == MemberTypes.Field && !((FieldInfo)el).IsStatic) || (el.MemberType == MemberTypes.Property && !((((PropertyInfo)el).GetMethod != null && ((PropertyInfo)el).GetMethod.IsStatic) || (((PropertyInfo)el).SetMethod != null && ((PropertyInfo)el).SetMethod.IsStatic))) select el).Count() > 10;

                int nonStaticCount = 0;

                for (int i = 0; i < propertyList.Count && nonStaticCount < 10; i++)
                {
                    if (propertyList[i].MemberType == System.Reflection.MemberTypes.Property)
                    {
                        if (((PropertyInfo)propertyList[i]).PropertyType != typeof(System.Reflection.MethodBase) && !((((PropertyInfo)propertyList[i]).GetMethod != null && ((PropertyInfo)propertyList[i]).GetMethod.IsStatic) || (((PropertyInfo)propertyList[i]).SetMethod != null && ((PropertyInfo)propertyList[i]).SetMethod.IsStatic)))
                        {
                            contentText += propertyNames[i] + ": " + getShortString(((PropertyInfo)propertyList[i]).GetValue(outObj)) + ", ";
                            nonStaticCount++;
                        }
                    }
                    else if (propertyList[i].MemberType == MemberTypes.Field)
                    {
                        if (((FieldInfo)propertyList[i]).FieldType != typeof(System.Reflection.MethodBase) && !((FieldInfo)propertyList[i]).IsStatic)
                        {
                            contentText += propertyNames[i] + ": " + getShortString(((FieldInfo)propertyList[i]).GetValue(outObj)) + ", ";
                            nonStaticCount++;
                        }
                    }
                }

                if (contentText.Length > 2)
                {
                    contentText = contentText.Substring(0, contentText.Length - 2);
                }

                if (moreThan10Props)
                {
                    contentText += "…";
                }


                InputTextBox contentBox = new InputTextBox()
                {
                    Foreground = new SolidColorBrush(Color.FromRgb(151, 151, 151)), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.5, 0, 0), FontStyle = FontStyle.Italic, Text = "{" + contentText + "}"
                };
                Grid.SetColumn(contentBox, 1);
                contentGrid.Children.Add(contentBox);


                MyExpandable exp = new MyExpandable();

                InputTextBox outputBox = new InputTextBox()
                {
                    FontSize = 12, Foreground = new SolidColorBrush(Colors.Black), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Padding = new Thickness(0, 1.2, 0, 0), FontStyle = FontStyle.Italic, Text = outObj.GetType().Name + " "
                };



                exp.Header = outputBox;
                contentGrid.Children.Add(exp);

                Grid arrayContentGrid = new Grid()
                {
                    Margin = new Thickness(20, 0, 0, 0), IsVisible = false
                };
                arrayContentGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });
                arrayContentGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });
                arrayContentGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = GridLength.Auto
                });



                Grid.SetRow(arrayContentGrid, 1);

                contentGrid.Children.Add(arrayContentGrid);

                bool contentBuilt = false;

                exp.ExpandedChanged += (s, e) =>
                {
                    if (e.NewValue)
                    {
                        if (!contentBuilt)
                        {
                            contentBuilt = true;

                            try
                            {
                                int rowIndex = 0;

                                for (int i = 0; i < propertyList.Count; i++)
                                {
                                    Type fType = propertyList[i].MemberType == MemberTypes.Field ? ((FieldInfo)propertyList[i]).FieldType : ((PropertyInfo)propertyList[i]).PropertyType;

                                    bool isStatic = (propertyList[i].MemberType == MemberTypes.Field && ((FieldInfo)propertyList[i]).IsStatic);

                                    if (propertyList[i].MemberType == MemberTypes.Property)
                                    {
                                        isStatic = (((PropertyInfo)propertyList[i]).GetMethod != null && ((PropertyInfo)propertyList[i]).GetMethod.IsStatic) || (((PropertyInfo)propertyList[i]).SetMethod != null && ((PropertyInfo)propertyList[i]).SetMethod.IsStatic);
                                    }

                                    if (fType != typeof(System.Reflection.MethodBase) && !isStatic)
                                    {
                                        arrayContentGrid.RowDefinitions.Add(new RowDefinition()
                                        {
                                            Height = GridLength.Auto
                                        });
                                        InputTextBox index = new InputTextBox()
                                        {
                                            FontSize = 12, Foreground = new SolidColorBrush(Color.FromRgb(163, 73, 164)), Background = null, BorderThickness = new Thickness(0), FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, MyReadOnly = true, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Right, Padding = new Thickness(0, 1.5, 0, 0), Text = propertyNames[i]
                                        };
                                        Grid.SetRow(index, rowIndex);
                                        arrayContentGrid.Children.Add(index);

                                        TextBlock colon = new TextBlock()
                                        {
                                            FontSize = 12, Foreground = new SolidColorBrush(Colors.Black), Background = null, FontFamily = ScriptConsoleControl.RobotoMono, VerticalAlignment = Avalonia.Layout.VerticalAlignment.Top, HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Left, Margin = new Thickness(0, 1.5, 0, 0), Text = ":"
                                        };
                                        Grid.SetRow(colon, rowIndex);
                                        Grid.SetColumn(colon, 1);
                                        arrayContentGrid.Children.Add(colon);

                                        try
                                        {
                                            Control value = contentElement(propertyList[i].MemberType == MemberTypes.Field ? ((FieldInfo)propertyList[i]).GetValue(outObj) : ((PropertyInfo)propertyList[i]).GetValue(outObj));

                                            Grid.SetRow(value, rowIndex);
                                            Grid.SetColumn(value, 2);
                                            arrayContentGrid.Children.Add(value);
                                        }
                                        catch (Exception ex)
                                        {
                                            Control value = new ErrorLine(ex);
                                            Grid.SetRow(value, rowIndex);
                                            Grid.SetColumn(value, 2);
                                            arrayContentGrid.Children.Add(value);
                                        }
                                        rowIndex++;
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                arrayContentGrid.Children.Clear();
                                arrayContentGrid.RowDefinitions.Add(new RowDefinition()
                                {
                                    Height = GridLength.Auto
                                });
                                Control errVal = new ErrorLine(ex);
                                arrayContentGrid.ColumnDefinitions.Clear();
                                arrayContentGrid.Children.Add(errVal);
                            }
                        }

                        arrayContentGrid.IsVisible = true;
                        contentBox.IsVisible       = false;
                    }
                    else
                    {
                        arrayContentGrid.IsVisible = false;
                        contentBox.IsVisible       = true;
                    }
                };

                return(contentGrid);
            }
        }