本文整理汇总了C#中IWorker.WriteLine方法的典型用法代码示例。如果您正苦于以下问题:C# IWorker.WriteLine方法的具体用法?C# IWorker.WriteLine怎么用?C# IWorker.WriteLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorker
的用法示例。
在下文中一共展示了IWorker.WriteLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveChanges
private void SaveChanges(IEnumerable<IMp3File> files, IWorker worker, bool enableBackup)
{
worker.WriteLine("Save changes? y/n");
if (worker.ReadLine() != "y")
{
worker.WriteLine("Command cancelled.");
return;
}
foreach (var mp3File in files)
{
SaveMp3File(mp3File, enableBackup);
}
worker.WriteLine("Command succesfully executed.");
}
示例2: Execute
public void Execute(string[] args, IWorker worker)
{
var parser = new ArgumentParser(args);
parser.CheckIfCanBeExecuted();
if (args[0] == CommandNames.Help)
{
ShowHelp(args, worker);
return;
}
var files = new FileSource().GetFiles(args[1]);
var commandPool = files.Select(file => new CommandFactory().ChooseCommand(args[0], file, worker, args[2])).ToList();
if (!commandPool.Any(command => command.IsPlanningCommand()))
{
commandPool.ForEach(command => command.Execute());
return;
}
foreach (var command in commandPool)
{
try
{
command.Execute();
ShowPlan(command, worker);
}
catch (Exception e)
{
worker.WriteLine("Command " + command.Accept(new GetCommandNameVisitor())
+ "cannot be executed for file" + command.Accept(new GetFilePathVisitor())
+ "because of exception:\n" + e.Message);
}
}
SaveChanges(files, worker, args.Contains("--backup-ignore"));
}
示例3: ShowHelp
private void ShowHelp(string[] args, IWorker worker)
{
var helpMessages = new Dictionary<string, string>
{
{CommandNames.Help, ""},
{CommandNames.Rename, @"<path> <pattern>"},
{CommandNames.ChangeTags, @"<path> <mask>"},
{CommandNames.Analyse, @"<path> <mask>"},
{CommandNames.Sync, @"<path> <mask>"},
};
var commandForHelp = args.Length == 2 ? args[1] : null;
if (commandForHelp == null)
foreach (var message in helpMessages)
worker.WriteLine(message.Key + ": " + message.Value);
else
worker.WriteLine(helpMessages.ContainsKey(commandForHelp)
? helpMessages[commandForHelp]
: "There is no such command!");
}
示例4: ShowPlan
private void ShowPlan(Command command, IWorker worker)
{
worker.WriteLine(command.Accept(new GetFilePathVisitor()));
worker.WriteLine(command.Accept(new DifferenceVisitor()));
}