本文整理汇总了C#中IExecutionContext.Out方法的典型用法代码示例。如果您正苦于以下问题:C# IExecutionContext.Out方法的具体用法?C# IExecutionContext.Out怎么用?C# IExecutionContext.Out使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExecutionContext
的用法示例。
在下文中一共展示了IExecutionContext.Out方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public void Execute(string[] args, IExecutionContext context)
{
if (!args.Any())
{
context.Out(this.GetCommandsList());
return;
}
if (args[0].Length > 3 && args[0].StartsWith(CommandPrefix, StringComparison.OrdinalIgnoreCase))
{
var command = string.Concat(args[0].Skip(3));
var usage = new CommandFactory().Create(command).GetUsage();
context.Out(usage);
return;
}
throw new ToolException(Resources.InvalidArgsErrorMessage, this.GetCommandsList(), ExitCode.InvalidArguments);
}
示例2: Execute
public void Execute(string[] args, IExecutionContext context)
{
var configuration = this.ParseArguments(args, context);
try
{
IEnumerable<TypeSchema> schemas =
configuration.JsonSchemas.SelectMany(CodeGenerator.ResolveCodeGeneratingSchemas)
.GroupBy(t => t.ToString())
.Select(g => g.First())
.ToList();
if (schemas.Any())
{
foreach (var schema in schemas)
{
var filePath = Path.Combine(configuration.OutputDirectory, ((NamedSchema)schema).Name + ".cs");
using (var memoryStream = new MemoryStream())
{
CodeGenerator.Generate(schema, configuration.Namespace, configuration.ForceNamespace, memoryStream);
context.WriteFile(filePath, memoryStream);
}
context.Out(string.Format(CultureInfo.InvariantCulture, Resources.GenerationInfoMessage, filePath));
}
context.Out(Resources.GenerationFinishedMessage);
}
else
{
context.Out(Resources.NoSchemataForGeneration);
}
}
catch (Exception exception)
{
throw new ToolException(
string.Format(CultureInfo.InvariantCulture, Resources.GenerationError, exception.Message),
string.Empty,
ExitCode.InvalidOperation);
}
}
示例3: Run
internal static ExitCode Run(string[] args, IExecutionContext context)
{
try
{
var factory = new CommandFactory();
factory.Create(args[0]).Execute(args.Skip(1).ToArray(), context);
return ExitCode.Success;
}
catch (ToolException exception)
{
context.Error(exception.Message);
if (!string.IsNullOrEmpty(exception.Out))
{
context.Out(exception.Out);
}
return exception.ExitCode;
}
catch (Exception)
{
context.Error(Properties.Resources.InvalidArgsErrorMessage);
context.Out(new HelpCommand().GetCommandsList());
return ExitCode.InvalidArguments;
}
}