コード例 #1
0
        private GuiElementInfo BuildGuiElementInfo(IGuiElement guiElement)
        {
            var info = new GuiElementInfo(guiElement.Id, guiElement.GetType().Name);

            info.ChildElements = guiElement.ChildElements.ToArray().Select(BuildGuiElementInfo).ToArray();
            return(info);
        }
コード例 #2
0
        public static string GetGuiElementPath(IGuiElement element)
        {
            var path = "";

            while (element != null)
            {
                path    = element.GetType().Name + (path == "" ? "" : "." + path);
                element = element.GetParent();
            }
            return(path);
        }
コード例 #3
0
        private GuiElementPropertyInfo[] BuildGuiElementPropertyInfos(IGuiElement guiElement)
        {
            var properties = guiElement.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);

            var infos = new List <GuiElementPropertyInfo>();

            foreach (var prop in properties)
            {
                var attr = prop.GetCustomAttribute <DebuggerVisibleAttribute>(true);
                if (attr == null)
                {
                    continue;
                }
                if (!attr.Visible)
                {
                    continue;
                }

                if (typeof(IGuiElement).IsAssignableFrom(prop.PropertyType))
                {
                    continue;
                }

                object val = null;
                try
                {
                    val = prop.GetValue(guiElement);
                }
                catch (Exception ex)
                {
                    val = "Exception - " + ex.Message;
                }

                //infos.Add(new GuiElementPropertyInfo()
                //{
                //	Name        = prop.Name,
                //	Type        = prop.PropertyType,
                //	Value       = val,
                //	StringValue = val?.ToString()
                //});

                var propType = prop.PropertyType;


                if (propType.Assembly != typeof(IGuiDebuggerService).Assembly)
                {
                    propType = typeof(string);
                    val      = val?.ToString();
                }

                infos.Add(new GuiElementPropertyInfo()
                {
                    Name        = prop.Name,
                    Type        = propType,
                    Value       = val,
                    StringValue = val?.ToString()
                });
            }

            return(infos.ToArray());
        }