public virtual void WriteLiteral(object value) { var expr = LuaConvert.ToString(value); DelimitLastValue(Token.Literal); Writer.Write(expr); }
/// <summary> /// Writes a Lua table field key. /// </summary> /// <param name="key">The key content to write.</param> public virtual void WriteKey(string key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (key.Length <= MaxUnquotedNameLength && LuaConvert.IsValidIdentifier(key)) { DelimitLastValue(Token.KeyStart); GotoNextState(Token.Literal); Writer.Write(key); if ((_Formatting & Formatting.Prettified) == Formatting.Prettified) { Writer.Write(" = "); } else { Writer.Write("="); } GotoNextState(Token.KeyEnd); } else { WriteStartKey(); WriteLiteral(key); WriteEndKey(); currentContext.Key = key; currentContext.KeyIsExpression = false; } }
/// <summary> /// Writes a Lua table field key. /// </summary> public virtual void WriteKey(object key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (key is string s) { WriteKey(s); return; } var expr = LuaConvert.ToString(key); WriteStartKey(); GotoNextState(Token.Literal); Writer.Write(expr); WriteEndKey(); currentContext.Key = expr; currentContext.KeyIsExpression = true; }
public virtual void WriteLiteral(Uri value) { DelimitLastValue(Token.Literal); Writer.Write(LuaConvert.ToString(value)); }
public virtual void WriteLiteral(string value) { DelimitLastValue(Token.Literal); LuaConvert.WriteEscapedString(value, StringDelimiterInfo.DoubleQuote, Writer); }