Monobjc.Tools.Generator.Parsers.Sgml.Node.AddAttribute C# (CSharp) Method

AddAttribute() public method

public AddAttribute ( string name, string value, char quotechar, bool caseInsensitive ) : Attribute
name string
value string
quotechar char
caseInsensitive bool
return Attribute
        public Attribute AddAttribute(string name, string value, char quotechar, bool caseInsensitive)
        {
            Attribute a;
            // check for duplicates!
            for (int i = 0, n = this.attributes.Count; i < n; i++)
            {
                a = (Attribute) this.attributes[i];
                if (string.Equals(a.Name, name, caseInsensitive ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal))
                {
                    return null;
                }
            }
            // This code makes use of the high water mark for attribute objects,
            // and reuses exisint Attribute objects to avoid memory allocation.
            a = (Attribute) this.attributes.Push();
            if (a == null)
            {
                a = new Attribute();
                this.attributes[this.attributes.Count - 1] = a;
            }
            a.Reset(name, value, quotechar);
            return a;
        }