当前位置: 首页>>代码示例>>C#>>正文


C# IWorker.WriteLine方法代码示例

本文整理汇总了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.");
        }
开发者ID:Confirmit,项目名称:Students,代码行数:16,代码来源:Application.cs

示例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"));
        }
开发者ID:Confirmit,项目名称:Students,代码行数:37,代码来源:Application.cs

示例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!");
 }
开发者ID:Confirmit,项目名称:Students,代码行数:19,代码来源:Application.cs

示例4: ShowPlan

 private void ShowPlan(Command command, IWorker worker)
 {
     worker.WriteLine(command.Accept(new GetFilePathVisitor()));
     worker.WriteLine(command.Accept(new DifferenceVisitor()));
 }
开发者ID:Confirmit,项目名称:Students,代码行数:5,代码来源:Application.cs


注:本文中的IWorker.WriteLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。