/
Обычные макросы => C# макросы

Обычные макросы => C# макросы

Работа с текстом

Допустим переменная yourText хранит ваш текст.

Обычный макрос

C# макрос

Обычный макрос

C# макрос

String.SubString

yourText.Substring(…)

var yourText = "For the second time in three years..."; return yourText.Substring(3,10);

String.Replace

yourText.Replace(…)

var yourText = "For the second time in three years..."; return yourText.Replace("For","*");

String.Insert

yourText.Insert(…)

var yourText = "For the second time in three years..."; return yourText.Insert(0, "Hi there.");

String.ToUpper

yourText.ToUpper()

String.ToLower

yourText.ToLower()

String.Split

Macros.TextProcessing.Split(…)

var yourText = "email:password"; return Macros.TextProcessing.Split(yourText,":","0").First();

String.SplitCount

yourText.Split(…).Length

var yourText = "email:password"; return Macros.TextProcessing.Split(yourText,":","all").Count();

String.RemoveDuplicates

Macros.TextProcessing.RemoveDuplicates(…)

var yourText = "email:password:email"; return Macros.TextProcessing.RemoveDuplicates(yourText,":");

String.Enter

System.Environment.NewLine

var yourText = "email"+System.Environment.NewLine +"password"; return yourText;

String.Spintax

Macros.TextProcessing.Spintax(…)

var yourText = "{Hi|Hey}"; return Macros.TextProcessing.Spintax(yourText);

Профиль и личные данные

Обычный макрос

C# макрос

Обычный макрос

C# макрос

Profile.Age

project.Profile.Age

Profile.Login

project.Profile.Login

Profile.ZipCode

project.Profile.ZipCode

Случайные величины

Обычный макрос

C# макрос

Обычный макрос

C# макрос

Random.Int

Random.Next(…)

var r = new Random(); return r.Next(1,100);

Random.Double

Random.NextDouble()

var r = new Random(); return r.NextDouble();

Файлы и директории

Обычный макрос

C# макрос

Обычный макрос

C# макрос

File.GetString

Macros.FileSystem.FileGetLine()

var path = @"D:\file.txt"; return Macros.FileSystem.FileGetLine(path,"2",false);

File.GetBlock

Macros.FileSystem.FileGetBlock()

var path = @"D:\file.txt"; return Macros.FileSystem.FileGetBlock(path,System.Environment.NewLine,"all",false);

File.AppendString

Macros.FileSystem.FileAppendString()

var path = @"D:\file.txt"; return Macros.FileSystem.FileAppendString(path,"new line", true);

File.CountOfStrings

Macros.FileSystem.FileCountOfLines()

var path = @"D:\file.txt"; return Macros.FileSystem.FileCountOfLines(path);

File.Copy

Macros.FileSystem.FileCopy()

var path = @"D:\file.txt"; Macros.FileSystem.FileCopy(path,"D:\newfile.txt");

Directory.CountOfFiles

Macros.FileSystem.DirectoryCountOfFiles()

var path = @"D:\"; return Macros.FileSystem.DirectoryCountOfFiles(path);

Directory.RandomFile

Macros.FileSystem.DirectoryRandomFile()

var path = @"D:\"; return Macros.FileSystem.DirectoryRandomFile(path);

Directory.DeleteFileByMask

Macros.FileSystem.DirectoryDeleteFileByMask()

var path = @"D:\"; Macros.FileSystem.DirectoryDeleteFileByMask(path,"*.txt");

Directory.DeleteFile

Macros.FileSystem.DirectoryDeleteFile()

var path = @"D:\file.txt"; Macros.FileSystem.DirectoryDeleteFile(path);

Directory.SelfFile

Macros.FileSystem.DirectoryDeleteDirectory()

var path = @"D:\"; Macros.FileSystem.DirectoryDeleteDirectory(path,true,true);

Регулярные выражения

string regex = project.Variables["myRegEx"].Value; string text = project.Variables["textToParse"].Value; var reg = new System.Text.RegularExpressions.Regex(regex, System.Text.RegularExpressions.RegexOptions.None); return reg.Matches(text)[0];

Счетчики

Обычный макрос

C# макрос

Обычный макрос

C# макрос

Counter.Set

var counter = 0;

Counter.Add

counter++;

Counter.Multiple

counter = counter*2;

Counter.Get

return counter;

Для того, чтобы работать в коде с переменными проекта необходимо воспользоваться следующей конструкцией:

var tmp = project.Variables["variable"].Value; var counter = System.Convert.ToInt32(tmp);

Глобальные переменные

Для работы с глобальными переменными в коде, её значение берётся с помощью следующей конструкции:

var tmp = project.GlobalVariables["license@email.com","globVar"].Value; var counter = System.Convert.ToInt32(tmp);

Операции с глобальными переменными аналогичны операциям со счётчиками.