예제 #1
0
        public void WriteHtml(ReflectionDumper buffer, int numTabs = 0, bool diffMode = false)
        {
            string paramsTag = "Parameters";

            if (diffMode)
            {
                paramsTag += " change";
            }

            int closingTabs = 0;

            buffer.OpenClassTag(paramsTag, numTabs);

            if (Count > 0)
            {
                buffer.NextLine();

                foreach (Parameter parameter in this)
                {
                    parameter.WriteHtml(buffer, numTabs + 1);
                }

                closingTabs = numTabs;
            }

            buffer.CloseClassTag(closingTabs);
        }
예제 #2
0
        public void WriteHtml(ReflectionDumper buffer, int numTabs = 0)
        {
            buffer.OpenClassTag("Parameter", numTabs);
            buffer.NextLine();

            // Write Type
            Type.WriteHtml(buffer, numTabs + 1);

            // Write Name
            string nameLbl = "ParamName";

            if (Default != null)
            {
                nameLbl += " default";
            }

            buffer.WriteElement(nameLbl, Name, numTabs + 1);

            // Write Default
            if (Default != null)
            {
                string typeLbl = Type.GetSignature();
                string typeName;

                if (typeLbl.Contains("<") && typeLbl.EndsWith(">"))
                {
                    typeName = $"{Type.Category}";
                }
                else
                {
                    typeName = Type.Name;
                }

                if (Type.Category == TypeCategory.DataType && typeName != "Function")
                {
                    buffer.WriteElement("ClassName Type", typeName, numTabs + 1);
                    buffer.WriteElement("Name", "new", numTabs + 1);
                    buffer.WriteElement("Parameters", null, numTabs + 1);
                }
                else
                {
                    if (Type.Category == TypeCategory.Enum)
                    {
                        typeName = "String";
                    }

                    buffer.WriteElement("ParamDefault " + typeName, Default, numTabs + 1);
                }
            }

            buffer.CloseClassTag(numTabs);
        }
예제 #3
0
        public void WriteDiffHtml(ReflectionDumper buffer)
        {
            string diffType = $"{Type}";

            if (Type == DiffType.Add)
            {
                diffType += "e";
            }

            diffType += "d";

            if (HasParent)
            {
                diffType += " child";
            }

            buffer.OpenClassTag(diffType, stack, "div");
            buffer.NextLine();

            switch (Type)
            {
            case DiffType.Change:
            {
                // Check if we should keep this on one line, based on the text version.
                string textSignature = WriteDiffTxt();
                bool   multiline     = textSignature.Contains(NL);

                // Write what we changed.
                buffer.WriteElement("WhatChanged", Field, stack + 1);

                // Write what was changed.
                Target.WriteHtml(buffer, stack + 1, false);

                // Changed From, Changed To.
                From.WriteHtml(buffer, multiline);
                To.WriteHtml(buffer, multiline);

                break;
            }

            case DiffType.Rename:
            {
                // Write what we're renaming.
                buffer.OpenClassTag(Field, stack + 1);
                buffer.WriteElement("String", Target.Name, stack + 2);
                buffer.CloseClassTag(stack + 1);

                // Write its new name.
                To.WriteHtml(buffer);
                break;
            }

            case DiffType.Merge:
            {
                // Write the elements that are being merged.
                From.WriteHtml(buffer, false, 0, new Descriptor.HtmlConfig()
                    {
                        TagType = "li",
                        NumTabs = stack + 2,
                    });

                // Write what they merged into.
                buffer.OpenClassTag("MergeListInto", stack + 1);
                buffer.NextLine();

                To.WriteHtml(buffer, false, 1, new Descriptor.HtmlConfig()
                    {
                        TagType = "li",
                        NumTabs = stack + 3,
                    });

                buffer.CloseClassTag(stack + 1);
                break;
            }

            case DiffType.Move:
            {
                string descType = Target.DescriptorType;
                string name     = $" {Target.Name}";

                buffer.WriteElement(descType, name, stack);

                From.WriteHtml(buffer, true);
                To.WriteHtml(buffer, true);

                break;
            }

            default:
            {
                string descType = Target.DescriptorType;
                bool   detailed = (Type == DiffType.Add);

                if (Field != descType)
                {
                    if (Context != null && Context is Tags)
                    {
                        Tags   tags     = Context as Tags;
                        string tagClass = "TagChange";

                        if (tags.Count == 1)
                        {
                            tagClass += " singular";
                        }

                        if (Type == DiffType.Add)
                        {
                            tagClass += " to";
                        }
                        else
                        {
                            tagClass += " from";
                        }

                        buffer.OpenClassTag(tagClass, stack + 1);
                        buffer.NextLine();

                        tags.WriteHtml(buffer, stack + 2);
                        buffer.CloseClassTag(stack + 1);

                        detailed = false;
                    }
                    else
                    {
                        buffer.WriteElement("Field", Field, stack + 1);
                    }
                }

                buffer.OpenClassTag("Target", stack + 1);
                buffer.NextLine();

                Target.WriteHtml(buffer, stack + 2, detailed);
                buffer.CloseClassTag(stack + 1);

                break;
            }
            }

            if (children.Count > 0)
            {
                children.Sort();
                children.ForEach(child => child.WriteDiffHtml(buffer));
            }

            buffer.CloseClassTag(stack, "div");
        }
        public void WriteHtml(ReflectionDumper buffer, bool multiline = false, int extraTabs = 0, Descriptor.HtmlConfig config = null)
        {
            if (config == null)
            {
                config = new Descriptor.HtmlConfig();
            }

            int numTabs;

            if (multiline)
            {
                buffer.OpenClassTag(Name, extraTabs + 1, "div");
                buffer.NextLine();

                buffer.OpenClassTag("ChangeList", extraTabs + 2);
                numTabs = 3;
            }
            else
            {
                buffer.OpenClassTag(Name, extraTabs + 1);
                numTabs = 2;
            }

            numTabs += extraTabs;

            if (config.NumTabs == 0)
            {
                config.NumTabs = numTabs;
            }

            buffer.NextLine();
            PreformatList();

            foreach (object change in this)
            {
                if (change is Parameters)
                {
                    var parameters = change as Parameters;
                    parameters.WriteHtml(buffer, numTabs, true);
                }
                else if (change is LuaType)
                {
                    var type = change as LuaType;
                    type.WriteHtml(buffer, numTabs);
                }
                else if (change is Descriptor)
                {
                    var desc = change as Descriptor;
                    desc.WriteHtml(buffer, config);
                }
                else
                {
                    string value;

                    if (change is Security)
                    {
                        var security = change as Security;
                        value = security.Describe(true);
                    }
                    else
                    {
                        value = change.ToString();
                    }

                    string tagClass;

                    if (value.Contains("🧬"))
                    {
                        tagClass = "ThreadSafety";
                    }
                    else if (value.StartsWith("["))
                    {
                        tagClass = "Serialization";
                    }
                    else if (value.StartsWith("{"))
                    {
                        tagClass = "Security";
                    }
                    else if (value.StartsWith("\""))
                    {
                        tagClass = "String";
                    }
                    else
                    {
                        tagClass = change.GetType().Name;
                    }

                    if (tagClass == "Security" && value.Contains("None"))
                    {
                        tagClass += " darken";
                    }

                    buffer.WriteElement(tagClass, value, numTabs);
                }
            }

            buffer.CloseClassTag(numTabs - 1);

            if (multiline)
            {
                buffer.CloseClassTag(1, "div");
            }
        }
예제 #5
0
        public void WriteHtml(ReflectionDumper buffer, HtmlConfig config = null)
        {
            if (config == null)
            {
                config = new HtmlConfig();
            }

            int    numTabs = config.NumTabs;
            string tagType = config.TagType;

            bool detailed = config.Detailed;
            bool diffMode = config.DiffMode;

            var tokens = GetTokens(detailed);

            tokens.Remove("DescriptorType");

            string schema   = GetSchema(detailed);
            string tagClass = DescriptorType;

            if (!diffMode && Tags.Contains("Deprecated"))
            {
                tagClass += " deprecated"; // The CSS will strike-through this.
            }
            if (!diffMode && DescriptorType != "Class" && DescriptorType != "Enum")
            {
                tagClass += " child";
            }

            buffer.OpenClassTag(tagClass, numTabs, tagType);
            buffer.NextLine();

            int search = 0;

            while (true)
            {
                int openToken = schema.IndexOf('{', search);

                if (openToken < 0)
                {
                    break;
                }

                int closeToken = schema.IndexOf('}', openToken);

                if (closeToken < 0)
                {
                    break;
                }

                string token = schema.Substring(openToken + 1, closeToken - openToken - 1);

                if (tokens.ContainsKey(token))
                {
                    if (token == "Tags")
                    {
                        Tags.WriteHtml(buffer, numTabs + 1);
                    }
                    else if (token == "Parameters" || token.EndsWith("Type"))
                    {
                        Type type = GetType();

                        foreach (FieldInfo info in type.GetFields())
                        {
                            if (info.FieldType == typeof(Parameters) && token == "Parameters")
                            {
                                var parameters = info.GetValue(this) as Parameters;
                                parameters.WriteHtml(buffer, numTabs + 1);
                                break;
                            }
                            else if (info.FieldType == typeof(LuaType) && token.EndsWith("Type"))
                            {
                                var luaType = info.GetValue(this) as LuaType;
                                luaType.WriteHtml(buffer, numTabs + 1);
                                break;
                            }
                        }
                    }
                    else
                    {
                        string value = tokens[token]
                                       .ToString()
                                       .Replace("<", "&lt;")
                                       .Replace(">", "&gt;")
                                       .Trim();

                        if (value.Length > 0)
                        {
                            if (token == "ClassName")
                            {
                                token += " " + DescriptorType;
                            }

                            buffer.WriteElement(token, value, numTabs + 1);
                        }
                    }
                }

                search = closeToken + 1;
            }

            buffer.CloseClassTag(numTabs, tagType);
        }