ToLiteral() публичный статический Метод

文字列をC#のリテラル文字列に変換します
public static ToLiteral ( string text ) : string
text string
Результат string
Пример #1
0
        static string MakeGetArgs(bool useText, int[] indices, string[] texts)
        {
            var getArgs = new StringBuilder();

            if (useText)
            {
                foreach (var element in texts)
                {
                    if (0 < getArgs.Length)
                    {
                        getArgs.Append(", ");
                    }
                    getArgs.Append(GenerateUtility.ToLiteral(element));
                }
            }
            else
            {
                foreach (var element in indices)
                {
                    if (0 < getArgs.Length)
                    {
                        getArgs.Append(", ");
                    }
                    getArgs.Append(element);
                }
            }
            return(getArgs.ToString());
        }
 void TextChanged(object sender, TextChangedEventArgs e)
 {
     if (_control.IsFocused)
     {
         var literal = GenerateUtility.ToLiteral(_control.Text);
         AddSentence(new TokenName(),
                     ".EmulateChangeText(",
                     literal,
                     new TokenAsync(CommaType.Before),
                     ");");
     }
 }
 void PasswordChanged(object sender, System.Windows.RoutedEventArgs e)
 {
     if (_control.IsFocused)
     {
         var literal = GenerateUtility.ToLiteral(_control.Password);
         AddSentence(new TokenName(),
                     ".EmulateChangePassword(",
                     literal,
                     new TokenAsync(CommaType.Before),
                     ");");
     }
 }
        static string MakeGetArgs(string[] texts)
        {
            StringBuilder getArgs = new StringBuilder();

            foreach (var element in texts)
            {
                if (0 < getArgs.Length)
                {
                    getArgs.Append(", ");
                }
                getArgs.Append(GenerateUtility.ToLiteral(element));
            }
            return(getArgs.ToString());
        }
        void Click(MenuItem item, string[] texts)
        {
            if (!string.IsNullOrEmpty(item.Name) || 0 < item.Items.Count)
            {
                return;
            }
            StringBuilder getArgs = new StringBuilder();

            foreach (var element in texts)
            {
                if (0 < getArgs.Length)
                {
                    getArgs.Append(", ");
                }
                getArgs.Append(GenerateUtility.ToLiteral(element));
            }

            AddSentence(new TokenName(), ".GetItem(" + getArgs.ToString() + ").EmulateClick(", new TokenAsync(CommaType.Non), ");");
        }
Пример #6
0
 void TextChanged(object sender, TextChangedEventArgs e)
 {
     if (_control.IsFocused)
     {
         var text = RichTextBoxUtility.GetText(_control);
         if (text.IndexOf(_lastText) != 0)
         {
             AddSentence(new TokenName(),
                         ".EmulateClearText(",
                         new TokenAsync(CommaType.Non),
                         ");");
         }
         AddSentence(new TokenName(),
                     ".EmulateAppendText(",
                     GenerateUtility.ToLiteral(text),
                     new TokenAsync(CommaType.Before),
                     ");");
     }
     _lastText = RichTextBoxUtility.GetText(_control);
 }
Пример #7
0
        void CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            int col = -1;

            for (int i = 0; i < _control.Columns.Count; i++)
            {
                if (ReferenceEquals(_control.Columns[i], e.Column))
                {
                    col = i;
                    break;
                }
            }

            if (e.EditingElement is TextBox)
            {
                AddSentence(new TokenName(),
                            ".EmulateChangeCellText(", _control.SelectedIndex, ", ", col, ", ",
                            GenerateUtility.ToLiteral(((TextBox)e.EditingElement).Text),
                            new TokenAsync(CommaType.Before), ");");
            }
            else if (e.EditingElement is ComboBox)
            {
                AddSentence(new TokenName(),
                            ".EmulateChangeCellComboSelect(", _control.SelectedIndex, ", ", col + ", ",
                            ((ComboBox)e.EditingElement).SelectedIndex,
                            new TokenAsync(CommaType.Before), ");");
            }
            else if (e.EditingElement is CheckBox)
            {
                bool?  val    = ((CheckBox)e.EditingElement).IsChecked;
                string valStr = val.HasValue && val.Value ? "true" : "false";
                AddSentence(new TokenName(),
                            ".EmulateCellCheck(", _control.SelectedIndex, ", ", col, ", ",
                            valStr,
                            new TokenAsync(CommaType.Before), ");");
            }
        }