Пример #1
0
        static void Main(string[] args)
        {
            ElementBuilder div = new ElementBuilder("div");

            div.AddAttribute("id", "page");
            div.AddAttribute("class", "big");
            div.AddContent("<p>Hello</p>");

            Console.WriteLine(div);
            Console.WriteLine();
            Console.WriteLine(div * 2);
            Console.WriteLine();
            Console.WriteLine(div * 3);
            Console.WriteLine();

            string someImage = HTMLDispatcher.CreateImage("C:\\temp\\images\\SomeImage.jpg", "Some Image", "My Image");

            Console.WriteLine(someImage);
            Console.WriteLine();

            string someURL = HTMLDispatcher.CreateUrl("http://softuni.bg", "SoftUni.bg", "SoftUni");

            Console.WriteLine(someURL);
            Console.WriteLine();

            string someInput = HTMLDispatcher.CreateInput("button", "button", "Login");

            Console.WriteLine(someInput);
            Console.WriteLine();
        }
        public static string CreateUrl(string url, string title, string text)
        {
            ElementBuilder a = new ElementBuilder("a");

            a.AddAttribute("href", url);
            a.AddAttribute("title", title);
            a.AddContent(text);
            return(a.ToString());
        }
        public static string CreateInput(string type, string name, string value)
        {
            ElementBuilder input = new ElementBuilder("input");

            input.AddAttribute("type", type);
            input.AddAttribute("name", name);
            input.AddAttribute("value", value);
            input.IsImgOrInput(true);
            return(input.ToString());
        }
        public static string CreateImage(string src, string alt, string title)
        {
            ElementBuilder img = new ElementBuilder("img");

            img.AddAttribute("src", src);
            img.AddAttribute("alt", alt);
            img.AddAttribute("title", title);
            img.IsImgOrInput(true);
            return(img.ToString());
        }