本文整理汇总了C#中ConsoleOptions.Validate方法的典型用法代码示例。如果您正苦于以下问题:C# ConsoleOptions.Validate方法的具体用法?C# ConsoleOptions.Validate怎么用?C# ConsoleOptions.Validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConsoleOptions
的用法示例。
在下文中一共展示了ConsoleOptions.Validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static int Main(string[] args)
{
ConsoleOptions options = new ConsoleOptions(args);
// Create SettingsService early so we know the trace level right at the start
SettingsService settingsService = new SettingsService();
InternalTraceLevel level = (InternalTraceLevel)settingsService.GetSetting("Options.InternalTraceLevel", InternalTraceLevel.Default);
if (options.trace != InternalTraceLevel.Default)
level = options.trace;
InternalTrace.Initialize("nunit-console_%p.log", level);
log.Info("NUnit-console.exe starting");
if(!options.nologo)
WriteCopyright();
if(options.help)
{
options.Help();
return ConsoleUi.OK;
}
if(options.NoArgs)
{
Console.Error.WriteLine("fatal error: no inputs specified");
options.Help();
return ConsoleUi.OK;
}
if(!options.Validate())
{
foreach( string arg in options.InvalidArguments )
Console.Error.WriteLine("fatal error: invalid argument: {0}", arg );
options.Help();
return ConsoleUi.INVALID_ARG;
}
// Add Standard Services to ServiceManager
ServiceManager.Services.AddService( settingsService );
ServiceManager.Services.AddService( new DomainManager() );
//ServiceManager.Services.AddService( new RecentFilesService() );
ServiceManager.Services.AddService( new ProjectService() );
//ServiceManager.Services.AddService( new TestLoader() );
ServiceManager.Services.AddService( new AddinRegistry() );
ServiceManager.Services.AddService( new AddinManager() );
ServiceManager.Services.AddService( new TestAgency() );
// Initialize Services
ServiceManager.Services.InitializeServices();
foreach (string parm in options.Parameters)
{
if (!Services.ProjectService.CanLoadProject(parm) && !PathUtils.IsAssemblyFileType(parm))
{
Console.WriteLine("File type not known: {0}", parm);
return ConsoleUi.INVALID_ARG;
}
}
try
{
ConsoleUi consoleUi = new ConsoleUi();
return consoleUi.Execute( options );
}
catch( FileNotFoundException ex )
{
Console.WriteLine( ex.Message );
return ConsoleUi.FILE_NOT_FOUND;
}
catch( Exception ex )
{
Console.WriteLine( "Unhandled Exception:\n{0}", ex.ToString() );
return ConsoleUi.UNEXPECTED_ERROR;
}
finally
{
if(options.wait)
{
Console.Out.WriteLine("\nHit <enter> key to continue");
Console.ReadLine();
}
log.Info( "NUnit-console.exe terminating" );
}
}
示例2: Main
public static int Main(string[] args)
{
log.Info( "NUnit-console.exe starting" );
ConsoleOptions options = new ConsoleOptions(args);
if(!options.nologo)
WriteCopyright();
if(options.help)
{
options.Help();
return ConsoleUi.OK;
}
if(options.NoArgs)
{
Console.Error.WriteLine("fatal error: no inputs specified");
options.Help();
return ConsoleUi.OK;
}
if(!options.Validate())
{
foreach( string arg in options.InvalidArguments )
Console.Error.WriteLine("fatal error: invalid argument: {0}", arg );
options.Help();
return ConsoleUi.INVALID_ARG;
}
// Add Standard Services to ServiceManager
ServiceManager.Services.AddService( new SettingsService() );
ServiceManager.Services.AddService( new DomainManager() );
//ServiceManager.Services.AddService( new RecentFilesService() );
ServiceManager.Services.AddService( new ProjectService() );
//ServiceManager.Services.AddService( new TestLoader() );
ServiceManager.Services.AddService( new AddinRegistry() );
ServiceManager.Services.AddService( new AddinManager() );
// Hack: Resolves conflict with gui testagency when running
// console tests under the gui.
if ( !AppDomain.CurrentDomain.FriendlyName.StartsWith("test-domain-") )
ServiceManager.Services.AddService( new TestAgency() );
// Initialize Services
ServiceManager.Services.InitializeServices();
try
{
ConsoleUi consoleUi = new ConsoleUi();
return consoleUi.Execute( options );
}
catch( FileNotFoundException ex )
{
Console.WriteLine( ex.Message );
return ConsoleUi.FILE_NOT_FOUND;
}
catch( Exception ex )
{
Console.WriteLine( "Unhandled Exception:\n{0}", ex.ToString() );
return ConsoleUi.UNEXPECTED_ERROR;
}
finally
{
if(options.wait)
{
Console.Out.WriteLine("\nHit <enter> key to continue");
Console.ReadLine();
}
log.Info( "NUnit-console.exe terminating" );
}
}
示例3: Main
public static int Main(string[] args)
{
ConsoleOptions options = new ConsoleOptions(args);
if(!options.nologo)
WriteCopyright();
if(options.help)
{
options.Help();
return 0;
}
if(options.NoArgs)
{
Console.Error.WriteLine("fatal error: no inputs specified");
options.Help();
return 0;
}
if(!options.Validate())
{
Console.Error.WriteLine("fatal error: invalid arguments");
options.Help();
return 2;
}
// Add Standard Services to ServiceManager
ServiceManager.Services.AddService( new SettingsService() );
ServiceManager.Services.AddService( new DomainManager() );
//ServiceManager.Services.AddService( new RecentFilesService() );
//ServiceManager.Services.AddService( new TestLoader() );
ServiceManager.Services.AddService( new AddinRegistry() );
ServiceManager.Services.AddService( new AddinManager() );
// Initialize Services
ServiceManager.Services.InitializeServices();
try
{
ConsoleUi consoleUi = new ConsoleUi();
return consoleUi.Execute( options );
}
catch( FileNotFoundException ex )
{
Console.WriteLine( ex.Message );
return 2;
}
catch( BadImageFormatException ex )
{
Console.WriteLine( ex.Message );
return 2;
}
catch( Exception ex )
{
Console.WriteLine( "Unhandled Exception:\n{0}", ex.ToString() );
return 2;
}
finally
{
if(options.wait)
{
Console.Out.WriteLine("\nHit <enter> key to continue");
Console.ReadLine();
}
}
}