コード例 #1
0
        public virtual void WriteLiteral(object value)
        {
            var expr = LuaConvert.ToString(value);

            DelimitLastValue(Token.Literal);
            Writer.Write(expr);
        }
コード例 #2
0
 /// <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;
     }
 }
コード例 #3
0
        /// <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;
        }
コード例 #4
0
 public virtual void WriteLiteral(Uri value)
 {
     DelimitLastValue(Token.Literal);
     Writer.Write(LuaConvert.ToString(value));
 }
コード例 #5
0
 public virtual void WriteLiteral(string value)
 {
     DelimitLastValue(Token.Literal);
     LuaConvert.WriteEscapedString(value, StringDelimiterInfo.DoubleQuote, Writer);
 }