static void Main()
        {
            var div = new ElementBuilder("div");
            div.AddAttribute("id", "page");
            div.AddAttribute("class", "big");
            div.AddContent("<p>Hello</p>");
            Console.WriteLine(div * 3);
            Console.WriteLine();

            var p = new ElementBuilder("p");
            p.AddAttribute("style", "font-size: 5px;");
            Console.WriteLine(p);
            Console.WriteLine();

            p.AddContent("This is a paragraph");
            Console.WriteLine(p);
            Console.WriteLine();

            Console.WriteLine(p * 15);
            Console.WriteLine();

            var image = HTMLDispatcher.CreateImage(@"http://www.google.bg", "missing", "Google");
            Console.WriteLine(image);
            Console.WriteLine();

            var link = HTMLDispatcher.CreateURL(@"https://facebook.com", "Facebook", "Click me!");
            Console.WriteLine(link);
            Console.WriteLine();

            var input = HTMLDispatcher.CreateInput("radio", "gender", "0");
            Console.WriteLine(input);
            Console.WriteLine();
        }
 public static string CreateImage(string imageSource, string alt, string title)
 {
     ElementBuilder imageElement = new ElementBuilder("img");
     imageElement.AddAttribute("src", imageSource);
     imageElement.AddAttribute("alt", alt);
     imageElement.AddAttribute("title", title);
     return imageElement.ToString();
 }
 public static string CreateURL(string url, string title, string text)
 {
     ElementBuilder urlElement = new ElementBuilder("a");
     urlElement.AddAttribute("url", url);
     urlElement.AddAttribute("title", title);
     urlElement.AddAttribute("text", text);
     return urlElement.ToString();
 }
 public static string CreateInput(string type, string name, string value)
 {
     ElementBuilder inputElement = new ElementBuilder("input");
     inputElement.AddAttribute("type", type);
     inputElement.AddAttribute("name", name);
     inputElement.AddAttribute("value", value);
     return inputElement.ToString();
 }
        public static string CreateImage(string imageSource, string alt, string title)
        {
            ElementBuilder imageElement = new ElementBuilder("img");

            imageElement.AddAttribute("src", imageSource);
            imageElement.AddAttribute("alt", alt);
            imageElement.AddAttribute("title", title);
            return(imageElement.ToString());
        }
        public static string CreateInput(string type, string name, string value)
        {
            ElementBuilder inputElement = new ElementBuilder("input");

            inputElement.AddAttribute("type", type);
            inputElement.AddAttribute("name", name);
            inputElement.AddAttribute("value", value);
            return(inputElement.ToString());
        }
        public static string CreateURL(string url, string title, string text)
        {
            ElementBuilder urlElement = new ElementBuilder("a");

            urlElement.AddAttribute("url", url);
            urlElement.AddAttribute("title", title);
            urlElement.AddAttribute("text", text);
            return(urlElement.ToString());
        }
示例#8
0
        public static void CreateInput(string type, string name, string value)
        {
            ElementBuilder input = new ElementBuilder("input");

            input.AddAttribute("type", type);
            input.AddAttribute("name", name);
            input.AddAttribute("value", value);

            Console.WriteLine(input);
        }
示例#9
0
        public static void CreateURL(string url, string title, string text)
        {
            ElementBuilder link = new ElementBuilder("a");

            link.AddAttribute("href", url);
            link.AddAttribute("title", title);
            link.AddContent(text);

            Console.WriteLine(link);
        }
示例#10
0
        public static void CreateImage(string imgSource, string alt, string title)
        {
            ElementBuilder img = new ElementBuilder("img");

            img.AddAttribute("source", imgSource);
            img.AddAttribute("alt", alt);
            img.AddAttribute("title", title);

            Console.WriteLine(img);
        }
示例#11
0
        static void Main(string[] args)
        {
            ElementBuilder element = new ElementBuilder("div");

            element.AddAttribute("id", "page");
            element.AddAttribute("class", "big");
            element.AddContent("<p>Hello</p>");
            Console.WriteLine(element * 2);

            HTMLDispatcher.CreateImage("../../../Sottuni.jpeg", "QQWW3", "Softuni");
            Console.WriteLine();
            HTMLDispatcher.CreateURL("www.softuni.bg", "The best University", "SoftUni");
            Console.WriteLine();
            HTMLDispatcher.CreateInput("submit", "Submit", "Send");
        }
        public static ElementBuilder operator *(ElementBuilder currentElement, int count)
        {
            if (count <= 0)
            {
                throw new ArgumentOutOfRangeException("count", "Count should be greater than zero.");
            }

            var newElement = new ElementBuilder(currentElement.Tag)
            {
                Attributes = currentElement.Attributes,
                Content    = currentElement.Content
            };

            newElement.Repetitions  *= count;
            newElement.IsSelfClosing = currentElement.IsSelfClosing;

            return(newElement);
        }
        static void Main()
        {
            var div = new ElementBuilder("div");

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

            var p = new ElementBuilder("p");

            p.AddAttribute("style", "font-size: 5px;");
            Console.WriteLine(p);
            Console.WriteLine();

            p.AddContent("This is a paragraph");
            Console.WriteLine(p);
            Console.WriteLine();

            Console.WriteLine(p * 15);
            Console.WriteLine();

            var image = HTMLDispatcher.CreateImage(@"http://www.google.bg", "missing", "Google");

            Console.WriteLine(image);
            Console.WriteLine();

            var link = HTMLDispatcher.CreateURL(@"https://facebook.com", "Facebook", "Click me!");

            Console.WriteLine(link);
            Console.WriteLine();

            var input = HTMLDispatcher.CreateInput("radio", "gender", "0");

            Console.WriteLine(input);
            Console.WriteLine();
        }
示例#14
0
        static void Main()
        {
            ElementBuilder div = new ElementBuilder("div");
            div.AddAttribute("id", "page");
            div.AddAttribute("class", "big");
            div.AddAttribute("style", "background-color: pink; border-bottom: 5px solid black; margin: auto; width: 200px");
            div.AddContent("<p>Hello</p>");
            Console.WriteLine(div * 2);

            string image = HTMLDispatcher.CreateImage("/cat.png", "cat", "Cat");
            string url = HTMLDispatcher.CreateURL("http://www.someurl.com", "some url", "some text");
            string input = HTMLDispatcher.CreateInput("field", "Name", "Some Name");

            Console.WriteLine(div);
            Console.WriteLine(image);
            Console.WriteLine(url);
            Console.WriteLine(input);

            using (StreamWriter sw = new StreamWriter("index.html"))
            {
                sw.WriteLine(div);
            }
        }
        public static ElementBuilder operator *(ElementBuilder currentElement, int count)
        {
            if (count <= 0)
            {
                throw new ArgumentOutOfRangeException("count", "Count should be greater than zero.");
            }

            var newElement = new ElementBuilder(currentElement.Tag)
            {
                Attributes = currentElement.Attributes,
                Content = currentElement.Content
            };
            newElement.Repetitions *= count;
            newElement.IsSelfClosing = currentElement.IsSelfClosing;

            return newElement;
        }