Esempio n. 1
0
 protected AspxTag(string prefix, string controlName, TagAttributes attributes, Location location)
     : base(location)
 {
     Prefix      = prefix;
     ControlName = controlName;
     Attributes  = attributes;
 }
 private void WriteAttributes(TagAttributes attributes)
 {
     if (attributes.IsRunAtServer)
     {
         writer.Write(" runat=\"server\"");
     }
     if (!attributes.Id.IsNullOrEmpty())
     {
         writer.Write($" id=\"{attributes.Id}\"");
     }
     foreach (var pair in attributes)
     {
         writer.Write(" ");
         writer.Write(pair.Key);
         writer.Write("=\"");
         writer.Write(pair.Value);
         writer.Write("\"");
     }
 }
Esempio n. 3
0
 void IParserEventListener.OnDirective(Location location, string name, TagAttributes attributes) =>
 currentNode.AddChild(new AspxNode.AspxDirective(name.ToUpperInvariant(), attributes, location));
Esempio n. 4
0
        void IParserEventListener.OnTag(Location location, TagType tagType, string name, TagAttributes attributes)
        {
            switch (tagType)
            {
            case TagType.Close:
            {
                string prefix;
                string controlName;
                if (IsAspxTag(name, out prefix, out controlName))
                {
                    // find opening pair tag until the root
                    for (var node = currentNode; !(node is AspxNode.Root); node = node.Parent)
                    {
                        var casted = node as AspxNode.OpenAspxTag;
                        if (casted != null && casted.Prefix == prefix && casted.ControlName == controlName)
                        {
                            currentNode = casted.Parent;
                            break;
                        }
                    }
                    currentNode.AddChild(new AspxNode.CloseAspxTag(prefix, controlName, location));
                }
                else
                {
                    // find closing pair tag no further than first opening ASPX tag
                    for (var node = currentNode; !(node is AspxNode.OpenAspxTag || node is AspxNode.Root); node = node.Parent)
                    {
                        var casted = node as AspxNode.OpenHtmlTag;
                        if (casted != null && casted.Name == name)
                        {
                            currentNode = casted.Parent;
                            break;
                        }
                    }
                    currentNode.AddChild(new AspxNode.CloseHtmlTag(name, location));
                }
                break;
            }

            case TagType.SelfClosing:
            {
                string prefix;
                string controlName;
                var    newNode = IsAspxTag(name, out prefix, out controlName)
                        ? (AspxNode) new AspxNode.SelfClosingAspxTag(prefix, controlName, attributes, location)
                        : new AspxNode.SelfClosingHtmlTag(name, attributes, location);

                currentNode.AddChild(newNode);
                break;
            }

            case TagType.Open:
            {
                string prefix;
                string controlName;
                var    newNode = IsAspxTag(name, out prefix, out controlName)
                        ? (AspxNode) new AspxNode.OpenAspxTag(prefix, controlName, attributes, location)
                        : new AspxNode.OpenHtmlTag(name, attributes, location);

                currentNode.AddChild(newNode);
                currentNode = newNode;
                break;
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(tagType), tagType, null);
            }
        }
Esempio n. 5
0
 public SelfClosingHtmlTag(string name, TagAttributes attributes, Location location)
     : base(name, attributes, location)
 {
 }
Esempio n. 6
0
 public OpenHtmlTag(string name, TagAttributes attributes, Location location)
     : base(name, attributes, location)
 {
 }
Esempio n. 7
0
 protected HtmlTag(string name, TagAttributes attributes, Location location)
     : base(location)
 {
     Name       = name;
     Attributes = attributes;
 }
Esempio n. 8
0
 public AspxDirective(string name, TagAttributes attributes, Location location)
     : base(location)
 {
     Name       = name;
     Attributes = attributes;
 }
Esempio n. 9
0
 public SelfClosingAspxTag(string prefix, string controlName, TagAttributes attributes, Location location)
     : base(prefix, controlName, attributes, location)
 {
 }