示例#1
0
        public virtual void WriteAttributeTo(TextWriter writer, string name, PositionTagged <string> prefix, PositionTagged <string> suffix, params AttributeValue[] values)
        {
            if (values.Length == 0)
            {
                WriteLiteralTo(writer, prefix.Value);
                WriteLiteralTo(writer, suffix.Value);
                return;
            }

            bool first          = true;
            bool wroteSomething = false;

            foreach (AttributeValue value in values)
            {
                PositionTagged <object> positionTagged = value.Value;

                if (positionTagged.Value == null)
                {
                    continue;
                }

                string stringValue = positionTagged.Value.Equals(true) ? name : (positionTagged.Value as string ?? positionTagged.Value.ToString());

                if (first)
                {
                    WriteLiteralTo(writer, prefix.Value);
                    first = false;
                }
                else
                {
                    WriteLiteralTo(writer, value.Prefix.Value);
                }
                if (value.Literal)
                {
                    WriteLiteralTo(writer, stringValue);
                }
                else
                {
                    WriteTo(writer, stringValue);
                }
                wroteSomething = true;
            }

            if (wroteSomething)
            {
                WriteLiteralTo(writer, suffix.Value);
            }
        }
示例#2
0
 public virtual void WriteAttribute(string name, PositionTagged <string> prefix, PositionTagged <string> suffix, params AttributeValue[] values)
 {
     WriteAttributeTo(_context.CurrentWriter, name, prefix, suffix, values);
 }
示例#3
0
 public AttributeValue(PositionTagged <string> prefix, PositionTagged <object> value, bool literal)
 {
     _prefix  = prefix;
     _value   = value;
     _literal = literal;
 }
示例#4
0
 protected bool Equals(PositionTagged <T> other)
 {
     return(Position == other.Position && EqualityComparer <T> .Default.Equals(Value, other.Value));
 }