Ejemplo n.º 1
0
        public void handlesBaseUri()
        {
            Tag tag = Tag.ValueOf("a");
            Attributes attribs = new Attributes();
            attribs.Add("relHref", "/foo");
            attribs.Add("absHref", "http://bar/qux");

            Element noBase = new Element(tag, "", attribs);
            Assert.AreEqual("", noBase.AbsUrl("relHref")); // with no base, should NOT fallback to href attrib, whatever it is
            Assert.AreEqual("http://bar/qux", noBase.AbsUrl("absHref")); // no base but valid attrib, return attrib

            Element withBase = new Element(tag, "http://foo/", attribs);
            Assert.AreEqual("http://foo/foo", withBase.AbsUrl("relHref")); // construct abs from base + rel
            Assert.AreEqual("http://bar/qux", withBase.AbsUrl("absHref")); // href is abs, so returns that
            Assert.AreEqual("", withBase.AbsUrl("noval"));

            Element dodgyBase = new Element(tag, "wtf://no-such-protocol/", attribs);
            Assert.AreEqual("http://bar/qux", dodgyBase.AbsUrl("absHref")); // base fails, but href good, so get that
            Assert.AreEqual("", dodgyBase.AbsUrl("relHref")); // base fails, only rel href, so return nothing 
        }
Ejemplo n.º 2
0
        private void SetAttribute(string name, string value)
        {
            if (Attributes.Contains(name))
            {
                Attributes[name] = value;
            }

            else
            {
                Attributes.Add(name, value);
            }
        }
Ejemplo n.º 3
0
 private void InitialiseAttributes()
 {
     Attributes.Add(new Attribute
     {
         Name       = "Title",
         IsRequired = false
     });
     Attributes.Add(new Attribute
     {
         Name       = "Email",
         IsRequired = false
     });
     Attributes.Add(new Attribute
     {
         Name       = "Phone",
         IsRequired = false
     });
     Attributes.Add(new Attribute
     {
         Name       = "AdditionalInfo",
         IsRequired = false
     });
     Attributes.Add(new Attribute
     {
         Name       = "AddressLine1",
         IsRequired = false
     });
     Attributes.Add(new Attribute
     {
         Name       = "AddressLine2",
         IsRequired = false
     });
     Attributes.Add(new Attribute
     {
         Name       = "PostalCode",
         IsRequired = false
     });
     Attributes.Add(new Attribute
     {
         Name       = "ProductImageId",
         IsRequired = false
     });
     Attributes.Add(new Attribute
     {
         Name       = "Price",
         IsRequired = false
     });
     Attributes.Add(new Attribute
     {
         Name       = "PriceType",
         IsRequired = false
     });
 }
Ejemplo n.º 4
0
        public Limit() : base("limit", false)
        {
            EffortAttribute   = new URDFAttribute("effort", true, null);
            VelocityAttribute = new URDFAttribute("velocity", true, null);
            LowerAttribute    = new URDFAttribute("lower", false, null);
            UpperAttribute    = new URDFAttribute("upper", false, null);

            Attributes.Add(LowerAttribute);
            Attributes.Add(UpperAttribute);
            Attributes.Add(EffortAttribute);
            Attributes.Add(VelocityAttribute);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Document"/> class.
 /// </summary>
 /// <param name="source">The source path of the document</param>
 public Document(string source)
 {
     if (!string.IsNullOrEmpty(source))
     {
         var directory = new FileInfo(source).Directory.FullName;
         Attributes.Add(new AttributeEntry("docdir", directory));
     }
     else
     {
         Attributes.Add(new AttributeEntry("docdir", Directory.GetCurrentDirectory()));
     }
 }
Ejemplo n.º 6
0
        public SafetyController() : base("safety_controller", false)
        {
            SoftUpperAttribute = new URDFAttribute("soft_upper", false, null);
            SoftLowerAttribute = new URDFAttribute("soft_lower", false, null);
            KPositionAttribute = new URDFAttribute("k_position", false, null);
            KVelocityAttribute = new URDFAttribute("k_velocity", true, 0.0);

            Attributes.Add(SoftUpperAttribute);
            Attributes.Add(SoftLowerAttribute);
            Attributes.Add(KPositionAttribute);
            Attributes.Add(KVelocityAttribute);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 在页面输出文本框前分配控件id和绑定值
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPreRender(System.EventArgs e)
        {
            base.Attributes.Add("name", this.UniqueID);
            base.Attributes.Add("value", CValue);

            //处理readonly
            if (this.ReadOnly)
            {
                Attributes.Add("readonly", "readonly");
            }
            base.OnPreRender(e);
        }
Ejemplo n.º 8
0
        public CustomRuntimeDefinedParameter(DynamicOption option) : base(option.Name, ActualParameterType(option.Type), new Collection <Attribute> {
            new ParameterAttribute()
        })
        {
            Options.Add(option);
            var values = option.PossibleValues.ToArray();

            if (!values.IsNullOrEmpty())
            {
                Attributes.Add(new ValidateSetAttribute(values));
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the MUMmerAttributes class.
        /// </summary>
        public MUMmerAttributes()
        {
            AlignmentInfo alignmentAttribute = new AlignmentInfo(
                Properties.Resource.LENGTH_OF_MUM_NAME,
                Properties.Resource.LENGTH_OF_MUM_DESCRIPTION,
                true,
                "20",
                AlignmentInfo.IntType,
                null);

            Attributes.Add(LengthOfMUM, alignmentAttribute);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Adds indexed attributes.
 /// </summary>
 /// <param name="attributes">The names of the attributes.</param>
 /// <returns>This instance for chaining.</returns>
 public IndexOptions AddAttributes(params string[] attributes)
 {
     foreach (var attribute in attributes)
     {
         ValidateAttribute(this, attribute);
     }
     foreach (var attribute in attributes)
     {
         Attributes.Add(attribute);
     }
     return(this);
 }
 public HassiumSqlDataReader(MySqlDataReader value)
 {
     Value = value;
     Attributes.Add("read", new InternalFunction(read, 0));
     Attributes.Add("get", new InternalFunction(get, 1));
     Attributes.Add("depth", new InternalFunction(x => value.Depth, 0, true));
     Attributes.Add("close", new InternalFunction(close, 0));
     Attributes.Add("dispose", new InternalFunction(dispose, 0));
     Attributes.Add("getString", new InternalFunction(getString, 1));
     Attributes.Add("nextResult", new InternalFunction(nextResult, 0));
     Attributes.Add("toString", new InternalFunction(toString, 0));
 }
Ejemplo n.º 12
0
        private void PopulateForm(HtmlFormDefinition formDefinition)
        {
            foreach (var attribute in formDefinition.Attributes)
            {
                Attributes.Add(attribute.Key, attribute.Value);
            }

            foreach (var control in formDefinition.Controls)
            {
                Controls.Add(control);
            }
        }
Ejemplo n.º 13
0
        public void PreRenderReworking()
        {
            if (!string.IsNullOrWhiteSpace(CssClassName))
            {
                CssClass = CssClassName;
            }

            if (CssStyleBld != null)
            {
                Attributes.Add("style", CssStyleBld.ToString());
            }
        }
Ejemplo n.º 14
0
        public Filter(string id, string name, IEnumerable <AttributeValue> attributes)
        {
            this.Id   = id;
            this.Name = name;

            InititalizeCollections();

            foreach (var a in (attributes ?? new AttributeValue[0]))
            {
                Attributes.Add(a);
            }
        }
Ejemplo n.º 15
0
// ---------------------------------------------------------------------------
        protected override void OnPreRender(EventArgs e)
        {
/* client-side validation => ValidationGroup */
            if (ValidationGroup != String.Empty)
            {
                Attributes.Add(ControlFactory.VALIDATION_GROUP_ATTR, ValidationGroup);
            }
            if (Text == String.Empty)
            {
                Text = "Submit";
            }
        }
Ejemplo n.º 16
0
 public void AddAttribute(string key, double value)
 {
     if (Attributes.ContainsKey(key))
     {
         return;
     }
     Attributes.Add(key, new EntityAttribute(value)
     {
         Key = key
     });
     RefreshProperties();
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Gets a value indicating whether an unknown attribute is encountered during deserialization.
        /// </summary>
        /// <returns>
        /// True when an unknown attribute is encountered while deserializing.
        /// </returns>
        /// <param name="name">The name of the unrecognized attribute.</param>
        /// <param name="value">The value of the unrecognized attribute.</param>
        protected override bool OnDeserializeUnrecognizedAttribute(string name, string value)
        {
            var property = new ConfigurationProperty(name, typeof(string), value);

            _properties.Add(property);

            base[property] = value;

            Attributes.Add(name, value);

            return(true);
        }
Ejemplo n.º 18
0
 private void AddAttributeCore(string name, string @namespace, string value)
 {
     if (Attributes.ContainsKey(name))
     {
         Attributes[name] = value;
     }
     else
     {
         Attributes.Add(name, value);
     }
     Namespaces.Add(@namespace);
 }
Ejemplo n.º 19
0
        public InterfaceInvokerClass(InterfaceGen iface, CodeGenerationOptions opt, CodeGeneratorContext context)
        {
            Name = $"{iface.Name}Invoker";

            IsInternal       = true;
            IsPartial        = true;
            UsePriorityOrder = true;

            Inherits = "global::Java.Lang.Object";
            Implements.Add(iface.Name);

            bool ji = opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1;

            if (ji)
            {
                Attributes.Add(new JniTypeSignatureAttr(iface.RawJniName, false));
            }
            else
            {
                Attributes.Add(new RegisterAttr(iface.RawJniName, noAcw: true, additionalProperties: iface.AdditionalAttributeString())
                {
                    UseGlobal = true
                });
            }

            Fields.Add(new PeerMembersField(opt, iface.RawJniName, $"{iface.Name}Invoker", false));

            if (!ji)
            {
                Properties.Add(new InterfaceHandleGetter());
            }

            Properties.Add(new JniPeerMembersGetter());

            if (!ji)
            {
                Properties.Add(new InterfaceThresholdClassGetter());
                Properties.Add(new ThresholdTypeGetter());
            }

            Fields.Add(new FieldWriter {
                Name = "class_ref", Type = TypeReferenceWriter.IntPtr, IsShadow = opt.BuildingCoreAssembly
            });

            Methods.Add(new GetObjectMethod(iface, opt));
            Methods.Add(new ValidateMethod(iface));
            Methods.Add(new DisposeMethod());

            Constructors.Add(new InterfaceInvokerConstructor(opt, iface, context));

            AddMemberInvokers(iface, new HashSet <string> (), opt, context);
        }
Ejemplo n.º 20
0
 private void InitialiseAttributes()
 {
     Attributes.Add(new Attribute
     {
         Name       = "FileId",
         IsRequired = false
     });
     Attributes.Add(new Attribute
     {
         Name       = "Name",
         IsRequired = false
     });
 }
Ejemplo n.º 21
0
        private SCIMRepresentationAttribute TryAddMetaAttribute()
        {
            var metaAttribute = Attributes.FirstOrDefault(a => a.SchemaAttribute.Name == SCIMConstants.StandardSCIMRepresentationAttributes.Meta);

            if (metaAttribute == null)
            {
                var metaSchemaAttribute = SCIMConstants.StandardSchemas.CommonSchema.Attributes.First();
                metaAttribute = new SCIMRepresentationAttribute(Guid.NewGuid().ToString(), metaSchemaAttribute);
                Attributes.Add(metaAttribute);
            }

            return(metaAttribute);
        }
Ejemplo n.º 22
0
        public HtmlElement AddId(string id)
        {
            if (IdAttribute != null)
            {
                IdAttribute.Value = id;
            }
            else
            {
                Attributes.Add(new HtmlId(id));
            }

            return(this);
        }
Ejemplo n.º 23
0
        public void AddAttribute(AttributeMetadata attributeMetadata)
        {
            FillAttributeAndRelationBase(attributeMetadata);

            if (attributeMetadata.IsKey)
            {
                _keyAttributes.Add(attributeMetadata);
            }

            _attributeDictionary.Add(attributeMetadata.Name, attributeMetadata);
            AddMemberInternal(attributeMetadata);
            Attributes.Add(attributeMetadata);
        }
Ejemplo n.º 24
0
    protected override void OnSpawn()
    {
        Attributes attributes = this.GetAttributes();

        if (attributes != null)
        {
            Element element = Element;
            foreach (AttributeModifier attributeModifier in element.attributeModifiers)
            {
                attributes.Add(attributeModifier);
            }
        }
    }
Ejemplo n.º 25
0
        /// <inheritdoc />
        /// <remarks>
        /// <paramref name="attribute"/>'s <see cref="TagHelperAttribute.Name"/> must not be <c>null</c>.
        /// </remarks>
        public void Add([NotNull] TagHelperAttribute attribute)
        {
            if (attribute.Name == null)
            {
                throw new ArgumentException(
                          Resources.FormatTagHelperAttributeList_CannotAddWithNullName(
                              typeof(TagHelperAttribute).FullName,
                              nameof(TagHelperAttribute.Name)),
                          nameof(attribute));
            }

            Attributes.Add(attribute);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Init"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            CellPadding = 0;
            CellPadding = 0;
            Border      = 0;
            Attributes.Add("class", "dragableBoxInner");

            CreateHeaderRow();
            CreateContentRow();
            CreateStatusRow();
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="zone">Zone to show.</param>
        private ZoneGraphicObject(Zone zone)
            : base(zone)
        {
            _zone = zone;
            _zone.PropertyChanged += new PropertyChangedEventHandler(_ZonePropertyChanged);

            ESRI.ArcGIS.Client.Geometry.Geometry geometry = _CreateGeometry(zone);
            Geometry = geometry;

            Attributes.Add(SymbologyContext.FILL_ATTRIBUTE_NAME, null);

            _CreateSymbol();
        }
Ejemplo n.º 28
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (useCollapsibleDataRole)
            {
                Attributes.Add("data-role", "collapsible");
                if (startCollapsed)
                {
                    Attributes.Add("data-collapsed", "true");
                }
            }
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Initialize m_DefaultAttributes and create the file.
 /// </summary>
 public virtual void Init()
 {
     InitLocation();
     m_DefaultAttributes = new Dictionary <string, object> {
         { "version", m_Version.OFVer },
         { "format", m_SaveFormat.ToString() },
         { "class", m_Class },
         { "location", m_Location },
         { "object", m_Name }
     };
     Attributes.Add("FoamFile", m_DefaultAttributes);
     CreateFile();
 }
Ejemplo n.º 30
0
        public void SetAttributeValue(string name, string value)
        {
            var attribute = GetAttribute(name);

            if (attribute != null)
            {
                attribute.Value = value;
            }
            else
            {
                Attributes.Add(new Attribute(name, value));
            }
        }
Ejemplo n.º 31
0
            public override bool Parse(QtParser parser)
            {
                uint flags = parser.GetUInt();

                Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.DropFrame, ((flags & 0x00000001) == 0) ? false : true));
                Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.TwentyFourHourMax, ((flags & 0x00000002) == 0) ? false : true));
                Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.NegativeTimesOK, ((flags & 0x00000004) == 0) ? false : true));
                Attributes.Add(new FormattedAttribute <LAttribute, bool>(LAttribute.Counter, ((flags & 0x00000008) == 0) ? false : true));

                this.TypedValue = string.Format("{0}", flags);

                return(this.Valid);
            }
Ejemplo n.º 32
0
        /** Write a .SF file with a digest of the specified manifest. */
        private static void writeSignatureFile(Manifest manifest, Stream out_)
        {
            Manifest sf = new Manifest();
            Attributes main = sf.MainAttributes;
            main.Add("Signature-Version", "1.0");
            main.Add("Created-By", "1.0 (Android SignApk)");

            DigestOutputStream digestStream = new DigestOutputStream("SHA1");
            StreamWriter print = new StreamWriter(digestStream, new UTF8Encoding());

            // Digest of the entire manifest
            manifest.Write(digestStream);
            print.Flush();
            main.Add("SHA1-Digest-Manifest", Convert.ToBase64String(digestStream.Hash));

            IDictionary<String, Attributes> entries = manifest.Entries;
            foreach (var entry in entries)
            {
                // Digest of the manifest stanza for this entry.
                print.Write("Name: " + entry.Key + "\r\n");
                foreach (var att in entry.Value)
                {
                    print.Write(att.Key + ": " + att.Value + "\r\n");
                }
                print.Write("\r\n");
                print.Flush();

                Attributes sfAttr = new Attributes();
                sfAttr.Add("SHA1-Digest", Convert.ToBase64String(digestStream.Hash));
                sf.Entries.Add(entry.Key, sfAttr);
            }

            sf.Write(out_);

            // A bug in the java.util.jar implementation of Android platforms
            // up to version 1.6 will cause a spurious IOException to be thrown
            // if the length of the signature file is a multiple of 1024 bytes.
            // As a workaround, add an extra CRLF in this case.
            if ((out_.Length % 1024) == 0)
            {
                var b = Encoding.UTF8.GetBytes("\r\n");
                out_.Write(b, 0, b.Length);
            }
        }
Ejemplo n.º 33
0
    public void UpdateCurrentAttributes()
    {
        currentAtt = new Attributes();
        currentAtt.Add(baseAtt);
        currentAtt.Add(equipAtt);
        currentAtt.Add(buffAtt);

        currentAtt.MovementSpeed = Mathf.Clamp(currentAtt.MovementSpeed, minMovementSpeed, maxMovementSpeed);
        currentAtt.AttackSpeed = Mathf.Clamp(currentAtt.AttackSpeed, minAttackSpeed, maxAttackSpeed);

        GetComponent<MovementFSM>().UpdateMovementSpeed(currentAtt.MovementSpeed);

        currentHP = Mathf.Clamp(currentHP, 0, currentAtt.Health);
        currentResource = Mathf.Clamp(currentResource, 0, currentAtt.Resource);
    }
Ejemplo n.º 34
0
        private ElementMeta CreateSafeElement(Element sourceEl)
        {
            string sourceTag = sourceEl.TagName();
            Attributes destAttrs = new Attributes();
            Element dest = new Element(Tag.ValueOf(sourceTag), sourceEl.BaseUri, destAttrs);
            int numDiscarded = 0;

            Attributes sourceAttrs = sourceEl.Attributes;
            foreach (NSoup.Nodes.Attribute sourceAttr in sourceAttrs)
            {
                if (_whitelist.IsSafeAttribute(sourceTag, sourceEl, sourceAttr))
                    destAttrs.Add(sourceAttr);
                else
                    numDiscarded++;
            }
            Attributes enforcedAttrs = _whitelist.GetEnforcedAttributes(sourceTag);

            foreach (NSoup.Nodes.Attribute item in enforcedAttrs)
            {
                destAttrs.Add(item);
            }

            return new ElementMeta(dest, numDiscarded);
        }
Ejemplo n.º 35
0
 public Attributes GetEnforcedAttributes(string tagName)
 {
     Attributes attrs = new Attributes();
     TagName tag = TagName.ValueOf(tagName);
     if (_enforcedAttributes.ContainsKey(tag))
     {
         Dictionary<AttributeKey, AttributeValue> keyVals = _enforcedAttributes[tag];
         foreach (KeyValuePair<AttributeKey, AttributeValue> entry in keyVals)
         {
             attrs.Add(entry.Key.ToString(), entry.Value.ToString());
         }
     }
     return attrs;
 }
Ejemplo n.º 36
0
        /**
         * Add a copy of the public key to the archive; this should
         * exactly match one of the files in_
         * /system/etc/security/otacerts.zip on the device.  (The same
         * cert can be extracted from the CERT.RSA file but this is much
         * easier to get at.)
         */
        private static void addOtacert(ZipOutputStream outputJar,
            X509Certificate2 certificate,
            DateTime timestamp,
            Manifest manifest)
        {
            HashAlgorithm md = HashAlgorithm.Create("SHA1");

            byte[] b = certificate.Export(X509ContentType.Cert);

            JarEntry je = new JarEntry(OTACERT_NAME);
            je.DateTime = timestamp;
            je.Size = b.Length;
            outputJar.PutNextEntry(je);
            outputJar.Write(b, 0, b.Length);

            Attributes attr = new Attributes();
            attr.Add("SHA1-Digest", Convert.ToBase64String(md.ComputeHash(b)));
            manifest.Entries.Add(OTACERT_NAME, attr);
        }
Ejemplo n.º 37
0
            public override bool Process(Token t, TreeBuilder tb)
            {
                switch (t.Type)
                {
                    case Token.TokenType.Character:
                        Token.Character c = t.AsCharacter();
                        if (c.Data.Equals(_nullString))
                        {
                            // todo confirm that check
                            tb.Error(this);
                            return false;
                        }
                        else if (IsWhitespace(c))
                        {
                            tb.ReconstructFormattingElements();
                            tb.Insert(c);
                        }
                        else
                        {
                            tb.ReconstructFormattingElements();
                            tb.Insert(c);
                            tb.FramesetOk(false);
                        }
                        break;
                    case Token.TokenType.Comment:
                        tb.Insert(t.AsComment());
                        break;
                    case Token.TokenType.Doctype:
                        tb.Error(this);
                        return false;
                    case Token.TokenType.StartTag:
                        Token.StartTag startTag = t.AsStartTag();
                        string name = startTag.Name();
                        if (name.Equals("html"))
                        {
                            tb.Error(this);
                            // merge attributes onto real html
                            Element html = tb.Stack.First.Value;
                            foreach (NSoup.Nodes.Attribute attribute in startTag.Attributes)
                            {
                                if (!html.HasAttr(attribute.Key))
                                {
                                    html.Attributes.Add(attribute);
                                }
                            }
                        }
                        else if (StringUtil.In(name, "base", "basefont", "bgsound", "command", "link", "meta", "noframes", "script", "style", "title"))
                        {
                            return tb.Process(t, InHead);
                        }
                        else if (name.Equals("body"))
                        {
                            tb.Error(this);
                            LinkedList<Element> stack = tb.Stack;
                            if (stack.Count == 1 || (stack.Count > 2 && !stack.ElementAt(1).NodeName.Equals("body")))
                            {
                                // only in fragment case
                                return false; // ignore
                            }
                            else
                            {
                                tb.FramesetOk(false);
                                Element body = stack.ElementAt(1);
                                foreach (NSoup.Nodes.Attribute attribute in startTag.Attributes)
                                {
                                    if (!body.HasAttr(attribute.Key))
                                    {
                                        body.Attributes.Add(attribute);
                                    }
                                }
                            }
                        }
                        else if (name.Equals("frameset"))
                        {
                            tb.Error(this);
                            LinkedList<Element> stack = tb.Stack;
                            if (stack.Count == 1 || (stack.Count > 2 && !stack.ElementAt(1).NodeName.Equals("body")))
                            {
                                // only in fragment case
                                return false; // ignore
                            }
                            else if (!tb.FramesetOk())
                            {
                                return false; // ignore frameset
                            }
                            else
                            {
                                Element second = stack.ElementAt(1);
                                if (second.Parent != null)
                                    second.Remove();
                                // pop up to html element

                                while (stack.Count > 1)
                                {
                                    stack.RemoveLast();
                                }

                                tb.Insert(startTag);
                                tb.Transition(InFrameset);
                            }
                        }
                        else if (StringUtil.In(name,
                              "address", "article", "aside", "blockquote", "center", "details", "dir", "div", "dl",
                              "fieldset", "figcaption", "figure", "footer", "header", "hgroup", "menu", "nav", "ol",
                              "p", "section", "summary", "ul"))
                        {
                            if (tb.InButtonScope("p"))
                            {
                                tb.Process(new Token.EndTag("p"));
                            }
                            tb.Insert(startTag);
                        }
                        else if (StringUtil.In(name, "h1", "h2", "h3", "h4", "h5", "h6"))
                        {
                            if (tb.InButtonScope("p"))
                            {
                                tb.Process(new Token.EndTag("p"));
                            }
                            if (StringUtil.In(tb.CurrentElement.NodeName, "h1", "h2", "h3", "h4", "h5", "h6"))
                            {
                                tb.Error(this);
                                tb.Pop();
                            }
                            tb.Insert(startTag);
                        }
                        else if (StringUtil.In(name, "pre", "listing"))
                        {
                            if (tb.InButtonScope("p"))
                            {
                                tb.Process(new Token.EndTag("p"));
                            }
                            tb.Insert(startTag);
                            // todo: ignore LF if next token
                            tb.FramesetOk(false);
                        }
                        else if (name.Equals("form"))
                        {
                            if (tb.FormElement != null)
                            {
                                tb.Error(this);
                                return false;
                            }
                            if (tb.InButtonScope("p"))
                            {
                                tb.Process(new Token.EndTag("p"));
                            }
                            Element form = tb.Insert(startTag);
                            tb.FormElement = form;
                        }
                        else if (name.Equals("li"))
                        {
                            tb.FramesetOk(false);
                            LinkedList<Element> stack = tb.Stack;
                            for (int i = stack.Count - 1; i > 0; i--)
                            {
                                Element el = stack.ElementAt(i);
                                if (el.NodeName.Equals("li"))
                                {
                                    tb.Process(new Token.EndTag("li"));
                                    break;
                                }
                                if (tb.IsSpecial(el) && !StringUtil.In(el.NodeName, "address", "div", "p"))
                                    break;
                            }
                            if (tb.InButtonScope("p"))
                            {
                                tb.Process(new Token.EndTag("p"));
                            }
                            tb.Insert(startTag);
                        }
                        else if (StringUtil.In(name, "dd", "dt"))
                        {
                            tb.FramesetOk(false);
                            LinkedList<Element> stack = tb.Stack;
                            for (int i = stack.Count - 1; i > 0; i--)
                            {
                                Element el = stack.ElementAt(i);
                                if (StringUtil.In(el.NodeName, "dd", "dt"))
                                {
                                    tb.Process(new Token.EndTag(el.NodeName));
                                    break;
                                }

                                if (tb.IsSpecial(el) && !StringUtil.In(el.NodeName, "address", "div", "p"))
                                {
                                    break;
                                }
                            }
                            if (tb.InButtonScope("p"))
                            {
                                tb.Process(new Token.EndTag("p"));
                            }
                            tb.Insert(startTag);
                        }
                        else if (name.Equals("plaintext"))
                        {
                            if (tb.InButtonScope("p"))
                            {
                                tb.Process(new Token.EndTag("p"));
                            }
                            tb.Insert(startTag);
                            tb.Tokeniser.Transition(TokeniserState.PlainText); // once in, never gets out
                        }
                        else if (name.Equals("button"))
                        {
                            if (tb.InButtonScope("button"))
                            {
                                // close and reprocess
                                tb.Error(this);
                                tb.Process(new Token.EndTag("button"));
                                tb.Process(startTag);
                            }
                            else
                            {
                                tb.ReconstructFormattingElements();
                                tb.Insert(startTag);
                                tb.FramesetOk(false);
                            }
                        }
                        else if (name.Equals("a"))
                        {
                            if (tb.GetActiveFormattingElement("a") != null)
                            {
                                tb.Error(this);
                                tb.Process(new Token.EndTag("a"));

                                // still on stack?
                                Element remainingA = tb.GetFromStack("a");
                                if (remainingA != null)
                                {
                                    tb.RemoveFromActiveFormattingElements(remainingA);
                                    tb.RemoveFromStack(remainingA);
                                }
                            }
                            tb.ReconstructFormattingElements();
                            Element a = tb.Insert(startTag);
                            tb.PushActiveFormattingElements(a);
                        }
                        else if (StringUtil.In(name,
                              "b", "big", "code", "em", "font", "i", "s", "small", "strike", "strong", "tt", "u"))
                        {
                            tb.ReconstructFormattingElements();
                            Element el = tb.Insert(startTag);
                            tb.PushActiveFormattingElements(el);
                        }
                        else if (name.Equals("nobr"))
                        {
                            tb.ReconstructFormattingElements();
                            if (tb.InScope("nobr"))
                            {
                                tb.Error(this);
                                tb.Process(new Token.EndTag("nobr"));
                                tb.ReconstructFormattingElements();
                            }
                            Element el = tb.Insert(startTag);
                            tb.PushActiveFormattingElements(el);
                        }
                        else if (StringUtil.In(name, "applet", "marquee", "object"))
                        {
                            tb.ReconstructFormattingElements();
                            tb.Insert(startTag);
                            tb.InsertMarkerToFormattingElements();
                            tb.FramesetOk(false);
                        }
                        else if (name.Equals("table"))
                        {
                            if (tb.Document.QuirksMode() != Document.QuirksModeEnum.Quirks && tb.InButtonScope("p"))
                            {
                                tb.Process(new Token.EndTag("p"));
                            }
                            tb.Insert(startTag);
                            tb.FramesetOk(false);
                            tb.Transition(InTable);
                        }
                        else if (StringUtil.In(name, "area", "br", "embed", "img", "keygen", "wbr"))
                        {
                            tb.ReconstructFormattingElements();
                            tb.InsertEmpty(startTag);
                            tb.FramesetOk(false);
                        }
                        else if (name.Equals("input"))
                        {
                            tb.ReconstructFormattingElements();
                            Element el = tb.InsertEmpty(startTag);

                            if (!el.Attr("type").Equals("hidden", StringComparison.InvariantCultureIgnoreCase))
                            {
                                tb.FramesetOk(false);
                            }
                        }
                        else if (StringUtil.In(name, "param", "source", "track"))
                        {
                            tb.InsertEmpty(startTag);
                        }
                        else if (name.Equals("hr"))
                        {
                            if (tb.InButtonScope("p"))
                            {
                                tb.Process(new Token.EndTag("p"));
                            }
                            tb.InsertEmpty(startTag);
                            tb.FramesetOk(false);
                        }
                        else if (name.Equals("image"))
                        {
                            // we're not supposed to ask.
                            startTag.Name("img");
                            return tb.Process(startTag);
                        }
                        else if (name.Equals("isindex"))
                        {
                            // how much do we care about the early 90s?
                            tb.Error(this);

                            if (tb.FormElement != null)
                            {
                                return false;
                            }

                            tb.Tokeniser.AcknowledgeSelfClosingFlag();
                            tb.Process(new Token.StartTag("form"));
                            if (startTag.Attributes.ContainsKey("action"))
                            {
                                Element form = tb.FormElement;
                                form.Attr("action", startTag.Attributes["action"]);
                            }
                            tb.Process(new Token.StartTag("hr"));
                            tb.Process(new Token.StartTag("label"));
                            // hope you like english.
                            string prompt = startTag.Attributes.ContainsKey("prompt") ?
                                    startTag.Attributes["prompt"] :
                                    "This is a searchable index. Enter search keywords: ";

                            tb.Process(new Token.Character(prompt));

                            // input
                            Attributes inputAttribs = new Attributes();
                            foreach (NSoup.Nodes.Attribute attr in startTag.Attributes)
                            {
                                if (!StringUtil.In(attr.Key, "name", "action", "prompt"))
                                {
                                    inputAttribs.Add(attr);
                                }
                            }
                            inputAttribs["name"] = "isindex";
                            tb.Process(new Token.StartTag("input", inputAttribs));
                            tb.Process(new Token.EndTag("label"));
                            tb.Process(new Token.StartTag("hr"));
                            tb.Process(new Token.EndTag("form"));
                        }
                        else if (name.Equals("textarea"))
                        {
                            tb.Insert(startTag);
                            // todo: If the next token is a U+000A LINE FEED (LF) character token, then ignore that token and move on to the next one. (Newlines at the start of textarea elements are ignored as an authoring convenience.)
                            tb.Tokeniser.Transition(TokeniserState.RcData);
                            tb.MarkInsertionMode();
                            tb.FramesetOk(false);
                            tb.Transition(Text);
                        }
                        else if (name.Equals("xmp"))
                        {
                            if (tb.InButtonScope("p"))
                            {
                                tb.Process(new Token.EndTag("p"));
                            }
                            tb.ReconstructFormattingElements();
                            tb.FramesetOk(false);
                            HandleRawText(startTag, tb);
                        }
                        else if (name.Equals("iframe"))
                        {
                            tb.FramesetOk(false);
                            HandleRawText(startTag, tb);
                        }
                        else if (name.Equals("noembed"))
                        {
                            // also handle noscript if script enabled
                            HandleRawText(startTag, tb);
                        }
                        else if (name.Equals("select"))
                        {
                            tb.ReconstructFormattingElements();
                            tb.Insert(startTag);
                            tb.FramesetOk(false);

                            TreeBuilderState state = tb.State;
                            if (state.Equals(InTable) || state.Equals(InCaption) || state.Equals(InTableBody) || state.Equals(InRow) || state.Equals(InCell))
                            {
                                tb.Transition(InSelectInTable);
                            }
                            else
                            {
                                tb.Transition(InSelect);
                            }
                        }
                        else if (StringUtil.In("optgroup", "option"))
                        {
                            if (tb.CurrentElement.NodeName.Equals("option"))
                            {
                                tb.Process(new Token.EndTag("option"));
                            }
                            tb.ReconstructFormattingElements();
                            tb.Insert(startTag);
                        }
                        else if (StringUtil.In("rp", "rt"))
                        {
                            if (tb.InScope("ruby"))
                            {
                                tb.GenerateImpliedEndTags();
                                if (!tb.CurrentElement.NodeName.Equals("ruby"))
                                {
                                    tb.Error(this);
                                    tb.PopStackToBefore("ruby"); // i.e. close up to but not include name
                                }
                                tb.Insert(startTag);
                            }
                        }
                        else if (name.Equals("math"))
                        {
                            tb.ReconstructFormattingElements();
                            // todo: handle A start tag whose tag name is "math" (i.e. foreign, mathml)
                            tb.Insert(startTag);
                            tb.Tokeniser.AcknowledgeSelfClosingFlag();
                        }
                        else if (name.Equals("svg"))
                        {
                            tb.ReconstructFormattingElements();
                            // todo: handle A start tag whose tag name is "svg" (xlink, svg)
                            tb.Insert(startTag);
                            tb.Tokeniser.AcknowledgeSelfClosingFlag();
                        }
                        else if (StringUtil.In(name,
                              "caption", "col", "colgroup", "frame", "head", "tbody", "td", "tfoot", "th", "thead", "tr"))
                        {
                            tb.Error(this);
                            return false;
                        }
                        else
                        {
                            tb.ReconstructFormattingElements();
                            tb.Insert(startTag);
                        }
                        break;
                    case Token.TokenType.EndTag:
                        Token.EndTag endTag = t.AsEndTag();
                        name = endTag.Name();
                        if (name.Equals("body"))
                        {
                            if (!tb.InScope("body"))
                            {
                                tb.Error(this);
                                return false;
                            }
                            else
                            {
                                // todo: error if stack contains something not dd, dt, li, optgroup, option, p, rp, rt, tbody, td, tfoot, th, thead, tr, body, html
                                tb.Transition(AfterBody);
                            }
                        }
                        else if (name.Equals("html"))
                        {
                            bool notIgnored = tb.Process(new Token.EndTag("body"));
                            if (notIgnored)
                            {
                                return tb.Process(endTag);
                            }
                        }
                        else if (StringUtil.In(name,
                              "address", "article", "aside", "blockquote", "button", "center", "details", "dir", "div",
                              "dl", "fieldset", "figcaption", "figure", "footer", "header", "hgroup", "listing", "menu",
                              "nav", "ol", "pre", "section", "summary", "ul"))
                        {
                            // todo: refactor these lookups
                            if (!tb.InScope(name))
                            {
                                // nothing to close
                                tb.Error(this);
                                return false;
                            }
                            else
                            {
                                tb.GenerateImpliedEndTags();
                                if (!tb.CurrentElement.NodeName.Equals(name))
                                {
                                    tb.Error(this);
                                }
                                tb.PopStackToClose(name);
                            }
                        }
                        else if (name.Equals("form"))
                        {
                            Element currentForm = tb.FormElement;
                            tb.FormElement = null;
                            if (currentForm == null || !tb.InScope(name))
                            {
                                tb.Error(this);
                                return false;
                            }
                            else
                            {
                                tb.GenerateImpliedEndTags();
                                if (!tb.CurrentElement.NodeName.Equals(name))
                                {
                                    tb.Error(this);
                                }
                                // remove currentForm from stack. will shift anything under up.
                                tb.RemoveFromStack(currentForm);
                            }
                        }
                        else if (name.Equals("p"))
                        {
                            if (!tb.InButtonScope(name))
                            {
                                tb.Error(this);
                                tb.Process(new Token.StartTag(name)); // if no p to close, creates an empty <p></p>
                                return tb.Process(endTag);
                            }
                            else
                            {
                                tb.GenerateImpliedEndTags(name);
                                if (!tb.CurrentElement.NodeName.Equals(name))
                                {
                                    tb.Error(this);
                                }
                                tb.PopStackToClose(name);
                            }
                        }
                        else if (name.Equals("li"))
                        {
                            if (!tb.InListItemScope(name))
                            {
                                tb.Error(this);
                                return false;
                            }
                            else
                            {
                                tb.GenerateImpliedEndTags(name);
                                if (!tb.CurrentElement.NodeName.Equals(name))
                                {
                                    tb.Error(this);
                                }
                                tb.PopStackToClose(name);
                            }
                        }
                        else if (StringUtil.In(name, "dd", "dt"))
                        {
                            if (!tb.InScope(name))
                            {
                                tb.Error(this);
                                return false;
                            }
                            else
                            {
                                tb.GenerateImpliedEndTags(name);
                                if (!tb.CurrentElement.NodeName.Equals(name))
                                {
                                    tb.Error(this);
                                }
                                tb.PopStackToClose(name);
                            }
                        }
                        else if (StringUtil.In(name, "h1", "h2", "h3", "h4", "h5", "h6"))
                        {
                            if (!tb.InScope(new string[] { "h1", "h2", "h3", "h4", "h5", "h6" }))
                            {
                                tb.Error(this);
                                return false;
                            }
                            else
                            {
                                tb.GenerateImpliedEndTags(name);
                                if (!tb.CurrentElement.NodeName.Equals(name))
                                {
                                    tb.Error(this);
                                }
                                tb.PopStackToClose("h1", "h2", "h3", "h4", "h5", "h6");
                            }
                        }
                        else if (name.Equals("sarcasm"))
                        {
                            // *sigh*
                            return AnyOtherEndTag(t, tb);
                        }
                        else if (StringUtil.In(name,
                              "a", "b", "big", "code", "em", "font", "i", "nobr", "s", "small", "strike", "strong", "tt", "u"))
                        {
                            // Adoption Agency Algorithm.
                            //OUTER:
                            for (int i = 0; i < 8; i++)
                            {
                                Element formatEl = tb.GetActiveFormattingElement(name);
                                if (formatEl == null)
                                {
                                    return AnyOtherEndTag(t, tb);
                                }
                                else if (!tb.OnStack(formatEl))
                                {
                                    tb.Error(this);
                                    tb.RemoveFromActiveFormattingElements(formatEl);
                                    return true;
                                }
                                else if (!tb.InScope(formatEl.NodeName))
                                {
                                    tb.Error(this);
                                    return false;
                                }
                                else if (tb.CurrentElement != formatEl)
                                {
                                    tb.Error(this);
                                }

                                Element furthestBlock = null;
                                Element commonAncestor = null;
                                bool seenFormattingElement = false;
                                LinkedList<Element> stack = tb.Stack;
                                for (int si = 0; si < stack.Count; si++)
                                {
                                    Element el = stack.ElementAt(si);
                                    if (el == formatEl)
                                    {
                                        commonAncestor = stack.ElementAt(si - 1);
                                        seenFormattingElement = true;
                                    }
                                    else if (seenFormattingElement && tb.IsSpecial(el))
                                    {
                                        furthestBlock = el;
                                        break;
                                    }
                                }

                                if (furthestBlock == null)
                                {
                                    tb.PopStackToClose(formatEl.NodeName);
                                    tb.RemoveFromActiveFormattingElements(formatEl);
                                    return true;
                                }

                                // todo: Let a bookmark note the position of the formatting element in the list of active formatting elements relative to the elements on either side of it in the list.
                                // does that mean: int pos of format el in list?
                                Element node = furthestBlock;
                                Element lastNode = furthestBlock;

                                for (int j = 0; j < 3; j++)
                                {
                                    if (tb.OnStack(node))
                                        node = tb.AboveOnStack(node);
                                    if (!tb.IsInActiveFormattingElements(node))
                                    { // note no bookmark check
                                        tb.RemoveFromStack(node);
                                        continue;
                                    }
                                    else if (node == formatEl)
                                    {
                                        break;
                                    }

                                    Element replacement = new Element(Tag.ValueOf(node.NodeName), tb.BaseUri);
                                    tb.ReplaceActiveFormattingElement(node, replacement);
                                    tb.ReplaceOnStack(node, replacement);
                                    node = replacement;

                                    if (lastNode == furthestBlock)
                                    {
                                        // todo: move the aforementioned bookmark to be immediately after the new node in the list of active formatting elements.
                                        // not getting how this bookmark both straddles the element above, but is inbetween here...
                                    }
                                    if (lastNode.Parent != null)
                                    {
                                        lastNode.Remove();
                                    }

                                    node.AppendChild(lastNode);

                                    lastNode = node;
                                }

                                if (StringUtil.In(commonAncestor.NodeName, "table", "tbody", "tfoot", "thead", "tr"))
                                {
                                    if (lastNode.Parent != null)
                                    {
                                        lastNode.Remove();
                                    }

                                    tb.InsertInFosterParent(lastNode);
                                }
                                else
                                {
                                    if (lastNode.Parent != null)
                                    {
                                        lastNode.Remove();
                                    }

                                    commonAncestor.AppendChild(lastNode);
                                }

                                Element adopter = new Element(Tag.ValueOf(name), tb.BaseUri);
                                Node[] childNodes = furthestBlock.ChildNodes.ToArray();
                                foreach (Node childNode in childNodes)
                                {
                                    adopter.AppendChild(childNode); // append will reparent. thus the clone to avvoid concurrent mod.
                                }

                                furthestBlock.AppendChild(adopter);
                                tb.RemoveFromActiveFormattingElements(formatEl);
                                // todo: insert the new element into the list of active formatting elements at the position of the aforementioned bookmark.
                                tb.RemoveFromStack(formatEl);
                                tb.InsertOnStackAfter(furthestBlock, adopter);
                            }
                        }
                        else if (StringUtil.In(name, "applet", "marquee", "object"))
                        {
                            if (!tb.InScope("name"))
                            {
                                if (!tb.InScope(name))
                                {
                                    tb.Error(this);
                                    return false;
                                }

                                tb.GenerateImpliedEndTags();

                                if (!tb.CurrentElement.NodeName.Equals(name))
                                {
                                    tb.Error(this);
                                }

                                tb.PopStackToClose(name);
                                tb.ClearFormattingElementsToLastMarker();
                            }
                        }
                        else if (name.Equals("br"))
                        {
                            tb.Error(this);
                            tb.Process(new Token.StartTag("br"));
                            return false;
                        }
                        else
                        {
                            return AnyOtherEndTag(t, tb);
                        }
                        break;
                    case Token.TokenType.EOF:
                        // todo: error if stack contains something not dd, dt, li, p, tbody, td, tfoot, th, thead, tr, body, html
                        // stop parsing
                        break;
                    default:
                        break;
                }
                return true;
            }