Esempio n. 1
0
        public static string EncodeIdentifier(string identifier, ScriptDom.QuoteType quoteType)
        {
            StringBuilder stringBuilder = new StringBuilder();

            switch (quoteType)
            {
            case ScriptDom.QuoteType.NotQuoted:
                return(identifier);

            case ScriptDom.QuoteType.SquareBracket:
                stringBuilder.Append("[");
                stringBuilder.Append(identifier.Replace("]", "]]"));
                stringBuilder.Append("]");
                break;

            case ScriptDom.QuoteType.DoubleQuote:
                stringBuilder.Append("\"");
                stringBuilder.Append(identifier.Replace("\"", "\"\""));
                stringBuilder.Append("\"");
                break;

            default:
                throw new ArgumentOutOfRangeException("quoteType");
            }
            return(stringBuilder.ToString());
        }
Esempio n. 2
0
 /// <summary>
 /// Decode
 /// </summary>
 /// <param name="identifier">the identifier</param>
 /// <param name="quote">output quote</param>
 /// <returns>the unquoted text</returns>
 public static string DecodeIdentifier(string identifier, out ScriptDom.QuoteType quote)
 {
     if (identifier != null && identifier.Length > 2)
     {
         if (identifier.Length != 0 && (identifier[0] == '[' || identifier[0] == '"'))
         {
             string text = identifier.Substring(1, identifier.Length - 2);
             if (identifier[0] == '[')
             {
                 quote = ScriptDom.QuoteType.SquareBracket;
                 return(text.Replace("]]", "]"));
             }
             quote = ScriptDom.QuoteType.DoubleQuote;
             return(text.Replace("\"\"", "\""));
         }
         quote = ScriptDom.QuoteType.NotQuoted;
         return(identifier);
     }
     quote = ScriptDom.QuoteType.NotQuoted;
     return(identifier);
 }
Esempio n. 3
0
 internal void SetUnquotedIdentifier(string text)
 {
     this.Value     = text;
     this.QuoteType = ScriptDom.QuoteType.NotQuoted;
 }
Esempio n. 4
0
 public IdentifierLiteral(ScriptDom.IdentifierLiteral src) : base(src)
 {
     this._quoteType = src.QuoteType;
 }