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


C# ConsoleOptions.Help方法代码示例

本文整理汇总了C#中ConsoleOptions.Help方法的典型用法代码示例。如果您正苦于以下问题:C# ConsoleOptions.Help方法的具体用法?C# ConsoleOptions.Help怎么用?C# ConsoleOptions.Help使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConsoleOptions的用法示例。


在下文中一共展示了ConsoleOptions.Help方法的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" );
			}

		}
开发者ID:Buildstarted,项目名称:ContinuousTests,代码行数:87,代码来源:Runner.cs

示例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" );
			}

		}
开发者ID:Phaiax,项目名称:dotnetautoupdate,代码行数:73,代码来源:Runner.cs

示例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();
                }
            }
        }
开发者ID:fotisp,项目名称:conqat,代码行数:67,代码来源:ConsoleUi.cs


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