public static string CreateInput(string inputType, string name, string value)
        {
            ElementBuilder element = new ElementBuilder("input");

            element.AddAttribute("input Type", inputType);
            element.AddAttribute("name", name);
            element.AddAttribute("value", value);
            StringBuilder sb = new StringBuilder();

            sb.Append(element.ElementOpener);
            sb.Append(element.AttributeField + ">");
            return(sb.ToString());
        }
        public static string CreateImage(string imageSource, string alt, string title)
        {
            ElementBuilder element = new ElementBuilder("img");

            element.AddAttribute("src", imageSource);
            element.AddAttribute("alt", alt);
            element.AddAttribute("title", title);
            StringBuilder sb = new StringBuilder();

            sb.Append(element.ElementOpener);
            sb.Append(element.AttributeField + ">");
            return(sb.ToString());
        }
        public static string CreateURL(string url, string title, string text)
        {
            ElementBuilder element = new ElementBuilder("a");

            element.AddAttribute("url", url);
            element.AddAttribute("title", title);
            element.AddContent(text);
            StringBuilder sb = new StringBuilder();

            sb.Append(element.ElementOpener);
            sb.Append(element.AttributeField + ">");
            sb.Append(element.ContentField);
            sb.Append(element.ElementCloser);
            return(sb.ToString());
        }
示例#4
0
        static void Main(string[] args)
        {
            //elemBuilder class test zone
            ElementBuilder hehe = new ElementBuilder("div");

            hehe.AddAttribute("id", "page");
            hehe.AddAttribute("class", "cenzura");
            hehe.AddContent("gaaasimu");
            //overloaded * operator
            Console.WriteLine(hehe * 2);

            //static classes
            Console.WriteLine(HTMLDispatcher.CreateImage("dir.bg", "404", "EmptyPillow"));
            Console.WriteLine(HTMLDispatcher.CreateURL("kaldata.bg", "shano site", "KALDATA.BG"));
            Console.WriteLine(HTMLDispatcher.CreateInput("text", "FirstName", "Gosho ot P."));
        }