Example #1
0
        public static ElementBuilder CreateInput(InputType inputType, string inputClass = null, string name = null, string value = null, string content = null)
        {
            var input = new ElementBuilder("input");

            input.AddAttribute("type", inputType.ToString());

            if (!string.IsNullOrEmpty(inputClass))
            {
                input.AddAttribute("class", inputClass);
            }

            if (!string.IsNullOrEmpty(name))
            {
                input.AddAttribute("name", name);
            }

            if (!string.IsNullOrEmpty(value))
            {
                input.AddAttribute("value", value);
            }

            if (!string.IsNullOrEmpty(content))
            {
                input.AddContent(content);
            }
            return(input);
        }
Example #2
0
    public static void Main()
    {
        // create elements using static methods trough HTMLDispatcher class
        Console.WriteLine(HTMLDispatcher.CreateImage("pics/logo.png", "site logo", "resizable"));
        Console.WriteLine();

        Console.WriteLine(HTMLDispatcher.CreateURL("site.com", "Site link", "Click here"));
        Console.WriteLine();

        Console.WriteLine(HTMLDispatcher.CreateInput("radio", "group", "married"));
        Console.WriteLine();

        // create elements with ElementBuilder class instance 
        ElementBuilder div = new ElementBuilder("div");

        div.AddAttribute("class", "clearfix");
        div.AddAttribute("id", "homebox");
        div.AddContent("Text goes here.");
        div.AddContent(" More text added here.");

        Console.WriteLine(div.ToString());
        Console.WriteLine();

        Console.WriteLine(div * 2);
    }
Example #3
0
        public static ElementBuilder CreateUrl(string urlSource, string urlClass = null, string titleText = null, string urlText = null, string content = null)
        {
            var htmlUrl = new ElementBuilder("a");

            htmlUrl.AddAttribute("href", urlSource);

            if (!string.IsNullOrEmpty(urlClass))
            {
                htmlUrl.AddAttribute("class", urlClass);
            }

            if (!string.IsNullOrEmpty(titleText))
            {
                htmlUrl.AddAttribute("title", titleText);
            }

            if (!string.IsNullOrEmpty(urlText))
            {
                htmlUrl.AddAttribute("text", urlText);
            }

            if (!string.IsNullOrEmpty(content))
            {
                htmlUrl.AddContent(content);
            }

            return(htmlUrl);
        }
Example #4
0
 public static string CreateImage(string imageSource, string alt, string title)
 {
     ElementBuilder eb = new ElementBuilder("img");
     eb.AddAttribute("src", imageSource);
     eb.AddAttribute("alt", alt);
     eb.AddAttribute("title", title);
     return eb.Element;
 }
Example #5
0
 public static string CreateURL(string url, string title, string text)
 {
     ElementBuilder eb = new ElementBuilder("a");
     eb.AddAttribute("href", url);
     eb.AddAttribute("title", title);
     eb.AddContent(text);
     return eb.Element;
 }
Example #6
0
 public static string CreateInput(string inputType, string name, string value)
 {
     ElementBuilder eb = new ElementBuilder("input");
     eb.AddAttribute("type", inputType);
     eb.AddAttribute("name", name);
     eb.AddAttribute("value", value);
     return eb.Element;
 }
Example #7
0
 public static string CreateImage(string source, string alt, string title)
 {
     ElementBuilder image = new ElementBuilder("img");
     image.AddAttribute("src", source);
     image.AddAttribute("alt", alt);
     image.AddAttribute("title", title);
     return image.ToString();
 }
 public static string CreateURL(string url, string title, string text)
 {
     ElementBuilder a = new ElementBuilder("a");
     a.AddAttribute("href", url);
     a.AddAttribute("title", title);
     a.AddAttribute("text", text);
     return a.ToString();
 }
Example #9
0
 public static string CreateImage(string src, string alt, string title)
 {
     ElementBuilder element = new ElementBuilder("img");
     element.AddAttribute("src", src);
     element.AddAttribute("alt", alt);
     element.AddAttribute("title", title);
     return element.ToString();
 }
Example #10
0
 public static string CreateURL(string url, string title, string text)
 {
     var anchor = new ElementBuilder("a");
     anchor.AddAttribute("href", url);
     anchor.AddAttribute("title", title);
     anchor.AddContent(text);
     return anchor.ToString();
 }
Example #11
0
 public static ElementBuilder CreateImage(string imgSrc, string alt, string title)
 {
     var img = new ElementBuilder("img");
     img.AddAttribute("title", title);
     img.AddAttribute("alt", alt);
     img.AddAttribute("src", imgSrc);
     return img;
 }
 public static ElementBuilder CreateURL(string url, string title, string text)
 {
     ElementBuilder aTag = new ElementBuilder("a");
     aTag.AddAttribute("href", url);
     aTag.AddAttribute("title", title);
     aTag.AddContent(text);
     return aTag;
 }
 public static ElementBuilder CreateImage(string imgSource, string imageAlt, string title)
 {
     ElementBuilder image = new ElementBuilder("img");
     image.AddAttribute("src", imgSource);
     image.AddAttribute("title", title);
     image.AddAttribute("alt", imageAlt);
     return image;
 }
 public static ElementBuilder CreateInput(string inputType,string inputName,string inputValue)
 {
     ElementBuilder inputField = new ElementBuilder("input");
     inputField.AddAttribute("type", inputType);
     inputField.AddAttribute("name", inputName);
     inputField.AddAttribute("value", inputValue);
     return inputField;
 }
Example #15
0
 public static string CreateInput(string type, string name, string value)
 {
     var input = new ElementBuilder("input");
     input.AddAttribute("type", type);
     input.AddAttribute("name", name);
     input.AddAttribute("value", value);
     return input.ToString();
 }
Example #16
0
 public static string CreateURL(string url, string title, string text)
 {
     ElementBuilder urlElement = new ElementBuilder("a");
     urlElement.AddAttribute("href", url);
     urlElement.AddAttribute("title", title);
     urlElement.AddContent(text);
     return urlElement.ToString();
 }
Example #17
0
 public static string CreateImage(string source, string alternative, string title)
 {
     var img = new ElementBuilder("img");
     img.AddAttribute("src", source);
     img.AddAttribute("alt", alternative);
     img.AddAttribute("title", title);
     return img.ToString();
 }
Example #18
0
        public static ElementBuilder CreateImage(string imgSrc, string alt, string title)
        {
            var img = new ElementBuilder("img");

            img.AddAttribute("title", title);
            img.AddAttribute("alt", alt);
            img.AddAttribute("src", imgSrc);
            return(img);
        }
Example #19
0
        public static ElementBuilder CreateInput(string type = "button", string name = "name", string value = "")
        {
            ElementBuilder input = new ElementBuilder("input");
            input.AddAttribute("type", type);
            input.AddAttribute("name", name);
            input.AddAttribute("value", value);

            return input;
        }
Example #20
0
    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);
        return(img.ToString());
    }
        public static ElementBuilder CreateImageURL(string href, string title, string text)
        {
            var a = new ElementBuilder("a", true);
            a.AddAttribute("href", href);
            a.AddAttribute("title", title);
            a.AddContent(text);

            return a;
        }
    public static string CreateURL(string url, string text, string title)
    {
        ElementBuilder element = new ElementBuilder("a");

        element.AddAttribute("href", url);
        element.AddContent(text);
        element.AddAttribute("title", title);
        return(element * 1);
    }
Example #23
0
        public static string CreateInput(string type, string name, string value)
        {
            ElementBuilder elem = new ElementBuilder("input");
            elem.AddAttribute("type", type);
            elem.AddAttribute("name", name);
            elem.AddContent(value);

            return elem.ToString();
        }
Example #24
0
        public static ElementBuilder CreateImage(string source, string alt, string title)
        {
            var element = new ElementBuilder("img");
            element.AddAttribute("src", source);
            element.AddAttribute("alt", alt);
            element.AddAttribute("title", title);

            return element;
        }
Example #25
0
        public static ElementBuilder CreateInput(string type = "button", string name = "name", string value = "")
        {
            ElementBuilder input = new ElementBuilder("input");

            input.AddAttribute("type", type);
            input.AddAttribute("name", name);
            input.AddAttribute("value", value);
            return(input);
        }
Example #26
0
        public static ElementBuilder CreateUrl(string url, string title, string text)
        {
            ElementBuilder link = new ElementBuilder("a");

            link.AddAttribute("href", url);
            link.AddAttribute("title", title);
            link.AddContent(text);
            return(link);
        }
Example #27
0
       public static string CreateImage(string imgSrc, string alt, string title){

           ElementBuilder img = new ElementBuilder("img", true);
           img.AddAttribute("src", imgSrc);
           img.AddAttribute("alt", alt);
           img.AddAttribute("title", title);

           return img.ToString();
       }
Example #28
0
        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);
            return(element.ToString());
        }
Example #29
0
    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);
        return(input.ToString());
    }
Example #30
0
        public static ElementBuilder CreateUrl(string url, string title, string text)
        {
            ElementBuilder link = new ElementBuilder("a");
            link.AddAttribute("href", url);
            link.AddAttribute("title", title);
            link.AddContent(text);

            return link;
        }
    public static ElementBuilder CreateInput(string inputType, string inputName, string inputValue)
    {
        ElementBuilder inputField = new ElementBuilder("input");

        inputField.AddAttribute("type", inputType);
        inputField.AddAttribute("name", inputName);
        inputField.AddAttribute("value", inputValue);
        return(inputField);
    }
Example #32
0
    public static string CreateURL(string url, string title, string text)
    {
        ElementBuilder a = new ElementBuilder("a");

        a.AddAttribute("href", url);
        a.AddAttribute("title", title);
        a.AddAttribute("text", text);
        return(a.ToString());
    }
    public static ElementBuilder CreateImage(string imgSource, string imageAlt, string title)
    {
        ElementBuilder image = new ElementBuilder("img");

        image.AddAttribute("src", imgSource);
        image.AddAttribute("title", title);
        image.AddAttribute("alt", imageAlt);
        return(image);
    }
    public static ElementBuilder CreateURL(string url, string title, string text)
    {
        ElementBuilder aTag = new ElementBuilder("a");

        aTag.AddAttribute("href", url);
        aTag.AddAttribute("title", title);
        aTag.AddContent(text);
        return(aTag);
    }
Example #35
0
        public static string CreateURL(string url, string title, string text)
        {
            ElementBuilder anchor = new ElementBuilder("a");

            anchor.AddAttribute("url", url);
            anchor.AddAttribute("title", title);
            anchor.AddContent(text);

            return(anchor.ToString());
        }
        public static string CreateImage(string imageSource, string alt, string title)
        {
            ElementBuilder img = new ElementBuilder("img");
            img.AddAttribute("src", imageSource);
            img.AddAttribute("alt", alt);
            img.AddAttribute("title", title);
            img.CloseSelf(true);

            return img.ToString();
        }
Example #37
0
        public static string CreateInput(string inputType, string name, string text)
        {
            ElementBuilder input = new ElementBuilder("input");

            input.AddAttribute("type", inputType);
            input.AddAttribute("name", name);
            input.AddContent(text);

            return input.ToString();
        }
Example #38
0
        public static string CreateURL(string url, string title, string text)
        {
            ElementBuilder url0 = new ElementBuilder("URL");

            url0.AddAttribute("url", url);
            url0.AddAttribute("title", title);
            url0.AddAttribute("text", text);

            return(url0.ToString());
        }
Example #39
0
        public static string CreateInput(string inputType, string name, string value)
        {
            ElementBuilder input = new ElementBuilder("URL");

            input.AddAttribute("url", inputType);
            input.AddAttribute("title", name);
            input.AddAttribute("text", value);

            return(input.ToString());
        }
Example #40
0
        public static string CreateImage(string imageSource, string alt, string title)
        {
            ElementBuilder image = new ElementBuilder("Image");

            image.AddAttribute("imagesource", imageSource);
            image.AddAttribute("alt", alt);
            image.AddAttribute("title", title);

            return(image.ToString());
        }
Example #41
0
        public static ElementBuilder CreateInput(string type, string name, string value)
        {
            var element = new ElementBuilder("input");

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

            return element;
        }
        public static string CreateURL(string url, string title, string text)
        {
            var link = new ElementBuilder("a");

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

            return(link.ToString());
        }
Example #43
0
    public static string CreateURL(string url, string title, string text)
    {
        ElementBuilder address = new ElementBuilder("a");

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

        return(address.ToString());
    }
Example #44
0
        public static string CreateInput(string inputType, string name, string text)
        {
            ElementBuilder input = new ElementBuilder("input");

            input.AddAttribute("type", inputType);
            input.AddAttribute("name", name);
            input.AddContent(text);

            return(input.ToString());
        }
Example #45
0
        public static ElementBuilder CreateImageURL(string href, string title, string text)
        {
            var a = new ElementBuilder("a", true);

            a.AddAttribute("href", href);
            a.AddAttribute("title", title);
            a.AddContent(text);

            return(a);
        }
Example #46
0
        public static ElementBuilder CreateInput(string type, string name, string value)
        {
            var input = new ElementBuilder("input", true);

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

            return(input);
        }
Example #47
0
 static void Main()
 {
     ElementBuilder div = new ElementBuilder("div");
     div.AddAttribute("id", "page");
     div.AddAttribute("class", "big");
     div.AddContent("<p>Hello</p>");
     Console.WriteLine(div * 2 +
         HTMLDispatcher.CreateImage("img.jpg", "alt", "title") +
         HTMLDispatcher.CreateURL("www.softuni.bg", "title", "text") +
         HTMLDispatcher.CreateInput("type", "name", "value"));
 }
Example #48
0
        public static ElementBuilder CreateImage(string imageSource, string alt, string title = null)
        {
            ElementBuilder image = new ElementBuilder("img");
            image.AddAttribute("src", imageSource);
            image.AddAttribute("alt", alt);
            if (title != null)
            {
                image.AddAttribute("title", title);
            }

            return image;
        }
    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);
        string tag   = element * 1;
        Regex  regex = new Regex(@"<[^>]+>");
        Match  match = regex.Match(tag);

        return(match.Value);
    }
    public static string CreateInput(string type, string name, string value)
    {
        ElementBuilder element = new ElementBuilder("input");

        element.AddAttribute("type", type);
        element.AddAttribute("name", name);
        element.AddAttribute("value", value);
        string tag   = element * 1;
        Regex  regex = new Regex(@"<[^>]+>");
        Match  match = regex.Match(tag);

        return(match.Value);
    }
 static void Main()
 {
     ElementBuilder div = new ElementBuilder("div");
     div.CloseTag(true);
     div.AddAttribute("id", "page");
     div.AddAttribute("class", "big");
     div.AddContent("<p>Hello</p>");
     Console.WriteLine(div * 3);
    
     Console.WriteLine(HTMLDispatcher.CreateImage("imageS.jpg", "test s", "selfi"));
     Console.WriteLine(HTMLDispatcher.CreateInput("submit", "Submit", "text"));
     Console.WriteLine(HTMLDispatcher.CreateURL("https://softuni.bg/", "www.softuni.bg", "softuni.bg"));
 }
Example #52
0
    static void Main()
    {
        ElementBuilder div = new ElementBuilder("div");

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

        Console.WriteLine(HTMLDispatcher.CreateImage("imageS.jpg", "test s", "selfi"));
        Console.WriteLine(HTMLDispatcher.CreateInput("submit", "Submit", "text"));
        Console.WriteLine(HTMLDispatcher.CreateURL("https://softuni.bg/", "www.softuni.bg", "softuni.bg"));
    }
Example #53
0
 public 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 * 2);
     Console.WriteLine();
     Console.WriteLine(HTMLDispatcher.CreateImage("http://softuni.bg/design/logo.png", "Logo", "Test"));
     Console.WriteLine();
     Console.WriteLine(HTMLDispatcher.CreateImageURL("http://abv.bg", "bla", "WTF"));
     Console.WriteLine();
     Console.WriteLine(HTMLDispatcher.CreateInput("text", "bla", "WTF"));
 }
Example #54
0
    static void Main()
    {
        Console.WriteLine("Please add the name of the element you want to create:");
        string         name    = Console.ReadLine();
        ElementBuilder element = new ElementBuilder(name);

        Console.WriteLine("You created the element " + element.Element);
        string value;

        while (true)
        {
            Console.WriteLine("Would you like to enter an attribute? Y/N");
            string checker = Console.ReadLine();
            if (checker == "N" || checker == "n")
            {
                break;
            }
            Console.WriteLine("Please enter the attribute type");
            string attribute = Console.ReadLine();
            Console.WriteLine("Please enter the attribute value");
            value = Console.ReadLine();
            element.AddAttribute(attribute, value);
        }
        Console.WriteLine("The current element is " + element.Element);
        Console.WriteLine("Please add content or press enter to continue. Please note you can't add content if it has already been set:");
        string content = Console.ReadLine();

        element.AddContent(content);
        Console.WriteLine("The current element is " + element.Element);
        Console.WriteLine("How many times do you want to print the element?");
        uint multiplier = uint.Parse(Console.ReadLine());

        Console.WriteLine(element * multiplier);
        Console.WriteLine("Now we are creating an img tag. Please enter img source:");
        string source = Console.ReadLine();

        Console.WriteLine("Please enter img alt:");
        string alt = Console.ReadLine();

        Console.WriteLine("Please enter img title:");
        string title = Console.ReadLine();

        Console.WriteLine(HTMLDispatcher.CreateImage(source, alt, title));
        Console.WriteLine("Now we are creating URL. Please enter the link:");
        source = Console.ReadLine();
        Console.WriteLine("Please enter the text:");
        string text = Console.ReadLine();

        Console.WriteLine("Please enter title:");
        title = Console.ReadLine();
        Console.WriteLine(HTMLDispatcher.CreateURL(source, text, title));
        Console.WriteLine("Now we are creating input. Please enter input type:");
        string type = Console.ReadLine();

        Console.WriteLine("Please enter input name:");
        name = Console.ReadLine();
        Console.WriteLine("Please enter input value:");
        value = Console.ReadLine();
        Console.WriteLine(HTMLDispatcher.CreateInput(type, name, value));
    }
Example #55
0
        static void Main(string[] args)
        {
            ElementBuilder div = new ElementBuilder("div");
            div.AddAttribute("id", "page");
            div.AddAttribute("class", "big");
            div.AddContent("<p>Hello</p>");

            System.Console.WriteLine(div * 2);

            string img = HTMLDispatcher.CreateImage("smiley.jpg", "Smiley Face", "Title");
            System.Console.WriteLine(img);

            string url = HTMLDispatcher.CreateURL("www.google.bg", "google", "GOOGLE");
            System.Console.WriteLine(url);

            string input = HTMLDispatcher.CreateInput("button", "hi", "HELLO");
            System.Console.WriteLine(input);
        }
Example #56
0
        public static ElementBuilder CreateURL(string url, string text)
        {
            var element = new ElementBuilder("a");

            element.AddAttribute("href", url);
            element.AddContent(text);

            return element;
        }
        /// <summary>
        /// Gets the code for interface attribute.
        /// </summary>
        /// <returns>
        /// The code for the interface attribute.
        /// </returns>
        public string CreateCodeForInterfaceAttribute()
        {
            var eb = new ElementBuilder();
            var attributeSection           = eb.AddAttributeSection(null);
            var attribute                  = eb.AddAttribute(attributeSection, ContractClassAttributeName);
            var contractClassTypeReference = new TypeReferenceExpression(this.CreateContractClassName());

            eb.AddArgument(attribute, new TypeOfExpression(contractClassTypeReference));
            return(eb.GenerateCode(this.TextDocument.Language));
        }
 private string GetSource(string text)
 {
     var methodName = CreateMethodName(text);
     ElementBuilder eb = new ElementBuilder();
     var method = eb.AddMethod(CodeRush.Source.ActiveClass, "void", methodName);
     method.Visibility = MemberVisibility.Public;
     var testSection = eb.AddAttributeSection(method);
     eb.AddAttribute(testSection, "Test");
     method.AddSupportElement(testSection);
     eb.AddMethodCall(method, "Assert.Fail", new[] { "\"Not Implemented\"" });
     string source = CodeRush.Language.GenerateElement(testSection) + CodeRush.Language.GenerateElement(method);
     return source;
 }
Example #59
0
        public static ElementBuilder CreateImage(string imageSource, string imgClass = null, string alternativeText = null, string titleText = null)
        {
            var img = new ElementBuilder("img");

            img.AddAttribute("src", imageSource);

            if (!string.IsNullOrEmpty(imgClass))
            {
                img.AddAttribute("class", imgClass);
            }

            if (!string.IsNullOrEmpty(alternativeText))
            {
                img.AddAttribute("alt", alternativeText);
            }

            if (!string.IsNullOrEmpty(titleText))
            {
                img.AddAttribute("title", titleText);
            }

            return(img);
        }