コード例 #1
0
        private static HtmlControl TryCreateFromStateMachine(string tagName)
        {
            switch (tagName)
            {
                case "":
                    return new EmptyHtmlControl();

                case "a":
                    using (var a = new CustomHtmlAnchor())
                    {
                        a.Attributes["href"] = "";
                        return a;
                    }
                case "button":
                case "btn":
                    return new HtmlButton();

                case "input":
                    using (CustomHtmlInput input = new CustomHtmlInput())
                    {
                        input.Attributes["value"] = "";
                        input.Attributes["type"] = "";
                        return input;
                    }
                case "img":
                    using (var img = new CustomHtmlImage())
                    {
                        img.Attributes["src"] = string.Empty;
                        img.Attributes["alt"] = string.Empty;
                        return img;
                    }
                case "source":
                case "src":
                    return new HtmlGenericSelfClosing("source");

                case "meta":
                    return new CustomHtmlMeta();

                case "link":
                    return new CustomHtmlLink();

                case "abbr":
                case "acronym":
                    using (HtmlGenericControl abbr = new HtmlGenericControl(tagName))
                    {
                        abbr.Attributes["title"] = string.Empty;
                        return abbr;
                    }
                case "area":
                    using (BlockHtmlControl area = new BlockHtmlControl("area"))
                    {
                        area.Attributes["shape"] = string.Empty;
                        area.Attributes["coords"] = string.Empty;
                        area.Attributes["href"] = string.Empty;
                        area.Attributes["alt"] = string.Empty;
                        return area;
                    }
                case "iframe":
                case "ifr":
                    using (HtmlGenericControl iframe = new HtmlGenericControl("iframe"))
                    {
                        iframe.Attributes["src"] = string.Empty;
                        iframe.Attributes["frameborder"] = "0";
                        return iframe;
                    }
                case "param":
                    using (HtmlGenericSelfClosing param = new HtmlGenericSelfClosing("param"))
                    {
                        param.Attributes["name"] = string.Empty;
                        param.Attributes["value"] = string.Empty;
                        return param;
                    }
                case "section":
                case "sect":
                    return new BlockHtmlControl("section");

                case "article":
                case "art":
                    return new BlockHtmlControl("article");

                case "hgroup":
                case "hgr":
                    return new BlockHtmlControl("hgroup");

                case "header":
                case "hdr":
                    return new BlockHtmlControl("header");

                case "footer":
                case "ftr":
                    return new BlockHtmlControl("footer");

                case "adr":
                    return new BlockHtmlControl("address");

                case "dlg":
                    return new BlockHtmlControl("dialog");

                case "bq":
                    return new HtmlGenericControl("blockquote");

                case "acr":
                    return new HtmlGenericControl("acronym");

                case "prog":
                    return new HtmlGenericControl("progress");

                case "figure":
                case "fig":
                    return new BlockHtmlControl("figure");

                case "emb":
                    return new HtmlGenericControl("embed");

                case "object":
                case "obj":
                    return new BlockHtmlControl("object");

                case "cap":
                    return new HtmlGenericControl("caption");

                case "colg":
                    return new HtmlGenericControl("colgroup");

                case "fset":
                    return new BlockHtmlControl("fieldset");

                case "leg":
                    return new BlockHtmlControl("legend");

                case "optg":
                    return new HtmlGenericControl("optgroup");

                case "opt":
                    return new HtmlGenericControl("option");

                case "datag":
                    return new HtmlGenericControl("datagrid");

                case "datal":
                    return new HtmlGenericControl("datalist");

                case "textarea":
                case "tarea":
                    using (var textarea = new CustomHtmlTextArea())
                    {
                        textarea.ID = string.Empty;
                        textarea.Attributes["cols"] = string.Empty;
                        textarea.Attributes["rows"] = string.Empty;
                        return textarea;
                    }
                case "kg":
                    return new HtmlGenericControl("keygen");

                case "out":
                    return new HtmlGenericControl("output");

                case "html":
                case "head":
                case "body":
                case "div":
                case "table":
                case "tr":
                case "p":
                    return new BlockHtmlControl(tagName);

                case "br":
                case "hr":
                    return new HtmlGenericSelfClosing(tagName);
            }

            return null;
        }
コード例 #2
0
        private static HtmlControl TryCreateFromStateMachine(string tagName)
        {
            switch (tagName)
            {
            case "":
                return(new EmptyHtmlControl());

            case "a":
                using (var a = new CustomHtmlAnchor())
                {
                    a.Attributes["href"] = "";
                    return(a);
                }

            case "button":
            case "btn":
                return(new HtmlButton());

            case "input":
                using (CustomHtmlInput input = new CustomHtmlInput())
                {
                    input.Attributes["value"] = "";
                    input.Attributes["type"]  = "";
                    return(input);
                }

            case "img":
                using (var img = new CustomHtmlImage())
                {
                    img.Attributes["src"] = string.Empty;
                    img.Attributes["alt"] = string.Empty;
                    return(img);
                }

            case "source":
            case "src":
                return(new HtmlGenericSelfClosing("source"));

            case "meta":
                return(new CustomHtmlMeta());

            case "link":
                return(new CustomHtmlLink());

            case "abbr":
            case "acronym":
                using (HtmlGenericControl abbr = new HtmlGenericControl("acronym"))
                {
                    abbr.Attributes["title"] = string.Empty;
                    return(abbr);
                }

            case "area":
                using (BlockHtmlControl area = new BlockHtmlControl("area"))
                {
                    area.Attributes["shape"]  = string.Empty;
                    area.Attributes["coords"] = string.Empty;
                    area.Attributes["href"]   = string.Empty;
                    area.Attributes["alt"]    = string.Empty;
                    return(area);
                }

            case "iframe":
            case "ifr":
                using (HtmlGenericControl iframe = new HtmlGenericControl("iframe"))
                {
                    iframe.Attributes["src"]         = string.Empty;
                    iframe.Attributes["frameborder"] = "0";
                    return(iframe);
                }

            case "param":
                using (HtmlGenericSelfClosing param = new HtmlGenericSelfClosing("param"))
                {
                    param.Attributes["name"]  = string.Empty;
                    param.Attributes["value"] = string.Empty;
                    return(param);
                }

            case "section":
            case "sect":
                return(new BlockHtmlControl("section"));

            case "article":
            case "art":
                return(new BlockHtmlControl("article"));

            case "hgroup":
            case "hgr":
                return(new BlockHtmlControl("hgroup"));

            case "header":
            case "hdr":
                return(new BlockHtmlControl("header"));

            case "footer":
            case "ftr":
                return(new BlockHtmlControl("footer"));

            case "adr":
                return(new BlockHtmlControl("address"));

            case "dlg":
                return(new BlockHtmlControl("dialog"));

            case "bq":
                return(new HtmlGenericControl("blockquote"));

            case "acr":
                return(new HtmlGenericControl("acronym"));

            case "prog":
                return(new HtmlGenericControl("progress"));

            case "figure":
            case "fig":
                return(new BlockHtmlControl("figure"));

            case "emb":
                return(new HtmlGenericControl("embed"));

            case "object":
            case "obj":
                return(new BlockHtmlControl("object"));

            case "cap":
                return(new HtmlGenericControl("caption"));

            case "colg":
                return(new HtmlGenericControl("colgroup"));

            case "fset":
                return(new BlockHtmlControl("fieldset"));

            case "leg":
                return(new BlockHtmlControl("legend"));

            case "optg":
                return(new HtmlGenericControl("optgroup"));

            case "opt":
                return(new HtmlGenericControl("option"));

            case "datag":
                return(new HtmlGenericControl("datagrid"));

            case "datal":
                return(new HtmlGenericControl("datalist"));

            case "textarea":
            case "tarea":
                using (var textarea = new CustomHtmlTextArea())
                {
                    textarea.ID = string.Empty;
                    textarea.Attributes["cols"] = string.Empty;
                    textarea.Attributes["rows"] = string.Empty;
                    return(textarea);
                }

            case "kg":
                return(new HtmlGenericControl("keygen"));

            case "out":
                return(new HtmlGenericControl("output"));

            case "html":
            case "head":
            case "body":
            case "div":
            case "table":
            case "tr":
            case "p":
                return(new BlockHtmlControl(tagName));

            case "br":
            case "hr":
                return(new HtmlGenericSelfClosing(tagName));
            }

            return(null);
        }