• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CommandLineArguments类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CommandLineArguments的典型用法代码示例。如果您正苦于以下问题:C# CommandLineArguments类的具体用法?C# CommandLineArguments怎么用?C# CommandLineArguments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CommandLineArguments类属于命名空间,在下文中一共展示了CommandLineArguments类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CommandLineArgumentsConstructor_NullParameter_EmptyDictionary

        public void CommandLineArgumentsConstructor_NullParameter_EmptyDictionary()
        {
            IEnumerable<string> args = null;
            CommandLineArguments target = new CommandLineArguments(args);

            Assert.AreEqual(0, target.Count);
        }
开发者ID:mtazva,项目名称:Snippets,代码行数:7,代码来源:CommandLineArgumentsTest.cs


示例2: CommandLineArgumentsConstructor_AllValuesWithNoArgumentName_ValuesIncludedInOneKey

        public void CommandLineArgumentsConstructor_AllValuesWithNoArgumentName_ValuesIncludedInOneKey()
        {
            IEnumerable<string> args = @"0 1 2 3".Split(' ');
            CommandLineArguments target = new CommandLineArguments(args);

            Assert.AreEqual(1, target.Count);
        }
开发者ID:mtazva,项目名称:Snippets,代码行数:7,代码来源:CommandLineArgumentsTest.cs


示例3: Empty

        public void Empty()
        {
            CommandLineArguments args = new CommandLineArguments();
            string[] cmdLine = new string[]
            {
                //@"/path:c:\windows"
            };

            if (!CommandLineParser.ParseArgumentsWithUsage(cmdLine, args))
            {
                Assert.Fail();
            }

            Assert.AreEqual(false, args.AddHost);
            Assert.AreEqual(null, args.ApplicationPath);
            Assert.AreEqual(null, args.HostName);
            Assert.AreEqual(null, args.IPAddress);
            Assert.AreEqual(IPMode.Loopback, args.IPMode);
            Assert.AreEqual(false, args.IPv6);
            Assert.AreEqual(false, args.Nodirlist);
            Assert.AreEqual(false, args.Ntlm);
            Assert.AreEqual(0, args.Port);
            Assert.AreEqual(PortMode.FirstAvailable, args.PortMode);
            Assert.AreEqual(65535, args.PortRangeEnd);
            Assert.AreEqual(32768, args.PortRangeStart);
            Assert.AreEqual(RunMode.Server, args.RunMode);
            Assert.AreEqual(false, args.Silent);
            Assert.AreEqual(0, args.TimeOut);
            Assert.AreEqual("/", args.VirtualPath);
            Assert.AreEqual(0, args.WaitForPort);

            Assert.AreEqual("/v:\"/\"", args.ToString());
        }
开发者ID:kissstudio,项目名称:cassinidev,代码行数:33,代码来源:CommandLineFixture.cs


示例4: ProcessArguments

        private static CommandLineArguments ProcessArguments(string[] arguments)
        {
            var commandLineArguments = new CommandLineArguments();
            int current = 0;

            for (; current < arguments.Length; current++)
            {
                string argument = arguments[current];

                if (argument.Length > 0 && (argument[0] == '/' || argument[0] == '-'))
                {
                    string argumentFlag = argument.Substring(1);

                    if (argumentFlag == "debug")
                    {
                        commandLineArguments.Debug = true;
                    }
                    else if (argumentFlag == "profile")
                    {
                        commandLineArguments.Profile = true;
                    }
                    else
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }

            commandLineArguments.ArgumentsStart = current;
            return commandLineArguments;
        }
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:35,代码来源:Program.cs


示例5: Main

        private static void Main(string[] args)
        {
            CommandLineArguments commandLineArgs = new CommandLineArguments(args);

            string hostFormatString = "http://{0}:{1}";
            string owinAddress = String.Format(hostFormatString, commandLineArgs.AllowRemote ? "+" : "localhost", commandLineArgs.Port);
            string visibleHost = (commandLineArgs.AllowRemote) ? Environment.MachineName : "localhost";
            string visibleAddress = String.Format(hostFormatString, visibleHost, commandLineArgs.Port);

            PortManager.OpenPortInFirewall(commandLineArgs.Port);

            OwinSelfhostStartup.Startup(owinAddress);

            Console.WriteLine("The Bridge is listening at {0} with remote access {1}", visibleAddress, commandLineArgs.AllowRemote ? "enabled" : "disabled");

            Test(visibleHost, commandLineArgs.Port);

            while (true)
            {
                Console.WriteLine("Type \"exit\" to stop the Bridge.");
                string answer = Console.ReadLine();
                if (String.Equals(answer, "exit", StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }
            }

            Environment.Exit(0);
        }
开发者ID:huoxudong125,项目名称:wcf,代码行数:29,代码来源:Program.cs


示例6: Main

        private static void Main(string[] args)
        {
            CommandLineArguments commandLineArgs = new CommandLineArguments(args);

            string hostFormatString = "http://{0}:{1}";
            string owinAddress = String.Format(hostFormatString, commandLineArgs.AllowRemote ? "+" : "localhost", commandLineArgs.Port);
            string visibleHost = (commandLineArgs.AllowRemote) ? Environment.MachineName : "localhost";
            string visibleAddress = String.Format(hostFormatString, visibleHost, commandLineArgs.Port);

            // Configure the remote addresses the firewall rules will accept.
            // If remote access is not allowed, specifically disallow remote addresses
            PortManager.RemoteAddresses = commandLineArgs.AllowRemote ? commandLineArgs.RemoteAddresses : String.Empty;

            // Initialize the BridgeConfiguration from command line.
            // The first POST to the ConfigController will supply the rest.
            ConfigController.BridgeConfiguration.BridgeHost = visibleHost;
            ConfigController.BridgeConfiguration.BridgePort = commandLineArgs.Port;

            // Remove any pre-existing firewall rules the Bridge may have added
            // in past runs.  We normally cleanup on exit but could have been
            // aborted.
            PortManager.RemoveAllBridgeFirewallRules();

            // Open the port used to communicate with the Bridge itself
            PortManager.OpenPortInFirewall(commandLineArgs.Port);

            Console.WriteLine("Starting the Bridge at {0}", visibleAddress);
            OwinSelfhostStartup.Startup(owinAddress);

            Test(visibleHost, commandLineArgs.Port);

            while (true)
            {
                Console.WriteLine("The Bridge is listening at {0}", visibleAddress);
                if (commandLineArgs.AllowRemote)
                {
                    Console.WriteLine("Remote access is allowed from '{0}'", commandLineArgs.RemoteAddresses);
                }
                else
                {
                    Console.WriteLine("Remote access is disabled.");
                }

                Console.WriteLine("Current configuration is:{0}{1}", Environment.NewLine, ConfigController.BridgeConfiguration.ToString());

                Console.WriteLine("Type \"exit\" to stop the Bridge.");
                string answer = Console.ReadLine();
                if (String.Equals(answer, "exit", StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }
            }

            Environment.Exit(0);
        }
开发者ID:cashcat,项目名称:wcf,代码行数:55,代码来源:Program.cs


示例7: Process

        /// <summary>
        /// Parses the command line arguments for valid options and returns them.
        /// </summary>
        /// <param name="CommandLineArgs">Array of strings containing the command line arguments</param>
        /// <returns>CommandLineArguments structure holding the options from the command line</returns>
        /// <history>
        /// [Curtis_Beard]		07/26/2006	Created
        /// [Curtis_Beard]		05/08/2007	ADD: 1590157, support project file
        /// </history>
        public static CommandLineArguments Process(string[] CommandLineArgs)
        {
            // create the args structure and initialize it
             CommandLineArguments args = new CommandLineArguments();
             InitializeArgs(ref args);

             // process the command line
             Arguments myArgs = new Arguments(CommandLineArgs);

             // check for just a single directory / project file
             if (CommandLineArgs.Length == 2)
             {
            args.AnyArguments = true;

            // Check command line for a path to start at
            string arg1 = CommandLineArgs[1];

            // remove an extra quote if (a drive letter
            if (arg1.EndsWith("\""))
               arg1 = arg1.Substring(0, arg1.Length - 1);

            // check for a project file
            if (arg1.EndsWith(".agproj"))
            {
               args.ProjectFile = arg1;
               args.IsProjectFile = true;
            }

            // check for a directory
            if (!args.IsProjectFile && System.IO.Directory.Exists(arg1))
            {
               args.StartPath = arg1;
               args.IsValidStartPath = true;
            }

            // do this before setting defaults to prevent loading wrong config file.
            if (!args.IsValidStartPath && !args.IsProjectFile)
            {
               // check for some other single setting, such as /local
               ProcessFlags(myArgs, ref args);
            }
             }
             else if (CommandLineArgs.Length > 1)
             {
            args.AnyArguments = true;

            ProcessFlags(myArgs, ref args);
             }

             return args;
        }
开发者ID:NikolayIT,项目名称:NStudio,代码行数:60,代码来源:CommandLineProcessing.cs


示例8: App

        public App()
        {
            // Add Ctrl+Shift+Z as a redo command. Don't know why it isn't enabled by default.
            ApplicationCommands.Redo.InputGestures.Add(new KeyGesture(Key.Z, ModifierKeys.Control | ModifierKeys.Shift));

            var cmdArgs = Environment.GetCommandLineArgs().Skip(1);
            App.CommandLineArguments = new CommandLineArguments(cmdArgs);
            if (App.CommandLineArguments.SingleInstance ?? true) {
                cmdArgs = cmdArgs.Select(FullyQualifyPath);
                string message = string.Join(Environment.NewLine, cmdArgs);
                if (SendToPreviousInstance("dnSpy:\r\n" + message, !App.CommandLineArguments.NoActivate)) {
                    Environment.Exit(0);
                }
            }
            InitializeComponent();

            var catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new AssemblyCatalog(typeof(App).Assembly));
            // Don't use DirectoryCatalog, that causes problems if the plugins are from the Internet zone
            // see http://stackoverflow.com/questions/8063841/mef-loading-plugins-from-a-network-shared-folder
            string appPath = Path.GetDirectoryName(typeof(App).Module.FullyQualifiedName);
            foreach (string plugin in Directory.GetFiles(appPath, "*.Plugin.dll")) {
                string shortName = Path.GetFileNameWithoutExtension(plugin);
                try {
                    var asm = Assembly.Load(shortName);
                    asm.GetTypes();
                    catalog.Catalogs.Add(new AssemblyCatalog(asm));
                } catch (Exception ex) {
                    // Cannot show MessageBox here, because WPF would crash with a XamlParseException
                    // Remember and show exceptions in text output, once MainWindow is properly initialized
                    StartupExceptions.Add(new ExceptionData { Exception = ex, PluginName = shortName });
                }
            }

            compositionContainer = new CompositionContainer(catalog);

            Languages.Initialize(compositionContainer);

            if (!System.Diagnostics.Debugger.IsAttached) {
                AppDomain.CurrentDomain.UnhandledException += ShowErrorBox;
                Dispatcher.CurrentDispatcher.UnhandledException += Dispatcher_UnhandledException;
            }
            TaskScheduler.UnobservedTaskException += DotNet40_UnobservedTaskException;

            EventManager.RegisterClassHandler(typeof(Window),
                                              Hyperlink.RequestNavigateEvent,
                                              new RequestNavigateEventHandler(Window_RequestNavigate));

            FixEditorContextMenuStyle();
        }
开发者ID:kenwilcox,项目名称:dnSpy,代码行数:50,代码来源:App.xaml.cs


示例9: Main

        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException +=
                new UnhandledExceptionEventHandler(BridgeUnhandledExceptionHandler);
            CommandLineArguments commandLineArgs = new CommandLineArguments(args);

            Console.WriteLine("Bridge.exe was launched with:{0}{1}", 
                              Environment.NewLine, commandLineArgs.ToString());

            // If asked to ping (not the default), just ping and return an exit code indicating its state
            if (commandLineArgs.Ping)
            {
                string errorMessage = null;
                if (PingBridge(commandLineArgs.BridgeConfiguration.BridgeHost,
                               commandLineArgs.BridgeConfiguration.BridgePort,
                               out errorMessage))
                {
                    Console.WriteLine("The Bridge is running.");
                    Environment.Exit(0);
                }
                else
                {
                    Console.WriteLine("The Bridge is not running: {0}", errorMessage);
                    Environment.Exit(1);
                }
            }
            if (commandLineArgs.StopIfLocal)
            {
                StopBridgeIfLocal(commandLineArgs);
                Environment.Exit(0);
            }
            if (commandLineArgs.Stop)
            {
                StopBridge(commandLineArgs);
                Environment.Exit(0);
            }
            if (commandLineArgs.Reset)
            {
                ResetBridge(commandLineArgs);
                Environment.Exit(0);
            }
            if (commandLineArgs.RequireBridgeTimeoutSeconds.HasValue)
            {
                RequireBridge(commandLineArgs);
            }

            // Default action is starting the Bridge
            StartBridge(commandLineArgs);
        }
开发者ID:mehtavipul,项目名称:wcf,代码行数:49,代码来源:Program.cs


示例10: QuotedValuesInToString

        public void QuotedValuesInToString()
        {
            CommandLineArguments args = new CommandLineArguments();
            string[] cmdLine = new string[]
            {
                @"/port:32768",
                @"/path:c:\temp foo",
                @"/vpath:/myapp with spaces",
                @"/ntlm",
                @"/silent",
                @"/nodirlist"
            };

            if (!CommandLineParser.ParseArgumentsWithUsage(cmdLine, args))
            {
                Assert.Fail();
            }

            Assert.AreEqual(false, args.AddHost);
            Assert.AreEqual(@"c:\temp foo", args.ApplicationPath);
            Assert.AreEqual(null, args.HostName);
            Assert.AreEqual(null, args.IPAddress);
            Assert.AreEqual(IPMode.Loopback, args.IPMode);
            Assert.AreEqual(false, args.IPv6);
            Assert.AreEqual(true, args.Nodirlist);
            Assert.AreEqual(true, args.Ntlm);
            Assert.AreEqual(32768, args.Port);
            Assert.AreEqual(PortMode.FirstAvailable, args.PortMode);
            Assert.AreEqual(65535, args.PortRangeEnd);
            Assert.AreEqual(32768, args.PortRangeStart);
            Assert.AreEqual(RunMode.Server, args.RunMode);
            Assert.AreEqual(true, args.Silent);
            Assert.AreEqual(0, args.TimeOut);
            Assert.AreEqual("/myapp with spaces", args.VirtualPath);
            Assert.AreEqual(0, args.WaitForPort);

            Assert.AreEqual("/a:\"c:\\temp foo\" /v:\"/myapp with spaces\" /p:32768 /ntlm /silent /nodirlist", args.ToString());
        }
开发者ID:kissstudio,项目名称:cassinidev,代码行数:38,代码来源:CommandLineFixture.cs


示例11: Main

        private static void Main(string[] args)
        {
            CommandLineArguments commandLineArgs = new CommandLineArguments(args);

            Console.WriteLine("Specified BridgeConfiguration is:{0}{1}",
                                Environment.NewLine, commandLineArgs.BridgeConfiguration.ToString());

            // If asked to ping (not the default), just ping and return an exit code indicating its state
            if (commandLineArgs.Ping)
            {
                string errorMessage = null;
                if (PingBridge(commandLineArgs.BridgeConfiguration.BridgeHost,
                               commandLineArgs.BridgeConfiguration.BridgePort,
                               out errorMessage))
                {
                    Console.WriteLine("The Bridge is running.");
                    Environment.Exit(0);
                }
                else
                {
                    Console.WriteLine("The Bridge is not running: {0}", errorMessage);
                    Environment.Exit(1);
                }
            }
            else if (commandLineArgs.StopIfLocal)
            {
                StopBridgeIfLocal(commandLineArgs);
            }
            else if (commandLineArgs.Stop)
            {
                StopBridge(commandLineArgs);
            }
            else
            {
                // Default action is starting the Bridge
                StartBridge(commandLineArgs);
            }
        }
开发者ID:dmetzgar,项目名称:wcf,代码行数:38,代码来源:Program.cs


示例12: GetImports

 // TODO (https://github.com/dotnet/roslyn/issues/5854): remove 
 public static ImmutableArray<string> GetImports(CommandLineArguments args)
 {
     return args.CompilationOptions.GetImports();
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:5,代码来源:CommandLineHelpers.cs


示例13: GetScriptOptions

        private static ScriptOptions GetScriptOptions(CommandLineArguments arguments, string scriptPathOpt, CommonMessageProvider messageProvider, List<DiagnosticInfo> diagnostics)
        {
            var touchedFilesLoggerOpt = (arguments.TouchedFilesPath != null) ? new TouchedFileLogger() : null;

            var metadataResolver = GetMetadataReferenceResolver(arguments, touchedFilesLoggerOpt);
            var sourceResolver = GetSourceReferenceResolver(arguments, touchedFilesLoggerOpt);

            var resolvedReferences = new List<MetadataReference>();
            if (!arguments.ResolveMetadataReferences(metadataResolver, diagnostics, messageProvider, resolvedReferences))
            {
                // can't resolve some references
                return null;
            }

            return new ScriptOptions(
                filePath: scriptPathOpt ?? "", 
                references: ImmutableArray.CreateRange(resolvedReferences),
                namespaces: CommandLineHelpers.GetImports(arguments),
                metadataResolver: metadataResolver,
                sourceResolver: sourceResolver);
        }
开发者ID:Ryujose,项目名称:roslyn,代码行数:21,代码来源:CommandLineRunner.cs


示例14: ResetBridge

        // Asks the Bridge to release all its resources but continue running
        private static void ResetBridge(CommandLineArguments commandLineArgs)
        {
            string errorMessage = null;

            if (!PingBridge(commandLineArgs.BridgeConfiguration.BridgeHost,
                                           commandLineArgs.BridgeConfiguration.BridgePort,
                                           out errorMessage))
            {
                Console.WriteLine("The Bridge is not running: {0}", errorMessage);
                Environment.Exit(0);
            }

            string bridgeUrl = String.Format("http://{0}:{1}/Resource", commandLineArgs.BridgeConfiguration.BridgeHost, commandLineArgs.BridgeConfiguration.BridgePort);
            string problem = null;

            Console.WriteLine("Resetting the Bridge by sending DELETE request to {0}", bridgeUrl);

            // We reset the Bridge using a DELETE request to the /resource endpoint.
            using (HttpClient httpClient = new HttpClient())
            {
                try
                {
                    var response = httpClient.DeleteAsync(bridgeUrl).GetAwaiter().GetResult();
                    if (!response.IsSuccessStatusCode)
                    {
                        problem = String.Format("{0}Bridge returned unexpected status code='{1}', reason='{2}'",
                                                    Environment.NewLine, response.StatusCode, response.ReasonPhrase);
                        if (response.Content != null)
                        {
                            string contentAsString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
                            if (contentAsString.Length > 1000)
                            {
                                contentAsString = contentAsString.Substring(0, 999) + "...";
                            }
                            problem = String.Format("{0}, content:{1}{2}",
                                                    problem, Environment.NewLine, contentAsString);
                        }
                    }
                }
                catch (Exception ex)
                {
                    problem = ex.ToString();
                }
            }

            if (problem != null)
            {
                Console.WriteLine("A problem was encountered resetting the Bridge:{0}{1}",
                                    Environment.NewLine, problem);
                Console.WriteLine("Forcing local resource cleanup...");
            }

            // A successfull DELETE will have cleaned up all firewall rules,
            // certificates, etc.  So when using localhost, this cleanup will
            // be redundant and harmless.  When the Bridge is running remotely,
            // this cleanup will remove all firewall rules and certificates we
            // installed on the current machine to talk with that Bridge.
            BridgeController.ReleaseAllResources(force: false);
        }
开发者ID:noodlese,项目名称:wcf,代码行数:60,代码来源:Program.cs


示例15: StartBridge

        // Starts the Bridge locally if it is not already running.
        private static void StartBridge(CommandLineArguments commandLineArgs)
        {
            string errorMessage = null;

            if (PingBridge(commandLineArgs.BridgeConfiguration.BridgeHost,
                                           commandLineArgs.BridgeConfiguration.BridgePort,
                                           out errorMessage))
            {
                Console.WriteLine("The Bridge is already running.");
                Environment.Exit(0);
            }

            // The host is not local so we cannot start the Bridge
            if (!IsBridgeHostLocal(commandLineArgs.BridgeConfiguration))
            {
                Console.WriteLine("The Bridge cannot be started from this machine on {0}",
                                  commandLineArgs.BridgeConfiguration.BridgeHost);
                Environment.Exit(1);
            }

            string resourceFolder = commandLineArgs.BridgeConfiguration.BridgeResourceFolder;
            if (String.IsNullOrWhiteSpace(resourceFolder))
            {
                Console.WriteLine("Starting the Bridge requires the BridgeResourceFolder to be specified.");
                Console.WriteLine("Use either -BridgeResourceFolder:folderName or set it as an environment variable.");
                Environment.Exit(1);
            }

            resourceFolder = Path.GetFullPath(resourceFolder);
            if (!Directory.Exists(resourceFolder))
            {
                Console.WriteLine("The specified BridgeResourceFolder '{0}' does not exist.");
                Environment.Exit(1);
            }
            commandLineArgs.BridgeConfiguration.BridgeResourceFolder = resourceFolder;

            int port = commandLineArgs.BridgeConfiguration.BridgePort;

            string hostFormatString = "http://{0}:{1}";
            string owinAddress = String.Format(hostFormatString, commandLineArgs.AllowRemote ? "+" : "localhost", port);
            string visibleHost = (commandLineArgs.AllowRemote) ? Environment.MachineName : "localhost";
            string visibleAddress = String.Format(hostFormatString, visibleHost, port);

            // Configure the remote addresses the firewall rules will accept.
            // If remote access is not allowed, specifically disallow remote addresses
            PortManager.RemoteAddresses = commandLineArgs.AllowRemote ? commandLineArgs.RemoteAddresses : String.Empty;

            // Initialize the BridgeConfiguration from command line.
            ConfigController.BridgeConfiguration = commandLineArgs.BridgeConfiguration;
            ConfigController.BridgeConfiguration.BridgeHost = visibleHost;

            // Remove any pre-existing firewall rules or certificates the Bridge
            // may have added in past runs.  We normally clean them up on exit but
            // it is possible a prior Bridge process was terminated prematurely.
            BridgeController.ReleaseAllResources(force: false);

            Console.WriteLine("Starting the Bridge at {0}", visibleAddress);
            OwinSelfhostStartup.Startup(owinAddress);

            // Now test whether the Bridge is running.  Failure cleans up
            // all resources and terminates the process.
            if (!PingBridge(visibleHost, port, out errorMessage))
            {
                Console.WriteLine("The Bridge failed to start or is not responding: {0}", errorMessage);
                BridgeController.StopBridgeProcess(1);
            }

            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("The Bridge is running");
                Console.WriteLine("    Listening at {0}/{1}", 
                                    visibleAddress, BridgeControllerEndpoint);

                if (commandLineArgs.AllowRemote)
                {
                    Console.WriteLine("    Remote access is allowed from '{0}'", commandLineArgs.RemoteAddresses);
                }
                else
                {
                    Console.WriteLine("    Remote access is disabled.");
                }

                Console.WriteLine("    Commands:");
                Console.WriteLine("    \"cls\" to clear the screen");
                Console.WriteLine("    \"exit\" to stop the Bridge");
                Console.WriteLine(); 
                Console.Write("Bridge> ");

                string answer = Console.ReadLine();
                if (string.Equals(answer, "exit", StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }
                else if (string.Equals(answer, "cls", StringComparison.OrdinalIgnoreCase))
                {
                    Console.Clear(); 
                }
            }
//.........这里部分代码省略.........
开发者ID:noodlese,项目名称:wcf,代码行数:101,代码来源:Program.cs


示例16: Initialize

        /// <summary>
        /// Parses the command line arguments and initializes the object.
        /// </summary>
        /// <param name="args">
        /// Command line arguments.
        /// </param>
        /// <returns>
        /// Parsed command line arguments.
        /// </returns>
        private static CommandLineArguments Initialize(string[] args)
        {
            const string ErrorMessage = "Incorrect arguments..\nUsage: DelineationSample /Input=<Input file> " +
                "/ColorMap=<Color Map File> /ColorMapOrientation <Horizontal or Vertical> " +
                "/ShapeFilePath=<Shape file path> /RegionHvMapPath=<Region map path> /ShapeKey=<string key used to access shape file> " +
                "/MaxLevel=<Number of levels of tiles to be built.> [/OutputDir=<Output Directory>]";

            if (args == null || args.Length < 6)
            {
                Trace.TraceError("{0}: " + ErrorMessage, DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"));
                return null;
            }

            CommandLineArguments cmdLine = new CommandLineArguments();
            CommandLineParser.ParseArguments(cmdLine, args);
            if (string.IsNullOrWhiteSpace(cmdLine.Input) || string.IsNullOrWhiteSpace(cmdLine.ColorMap))
            {
                Trace.TraceError("{0}: " + ErrorMessage, DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"));
                return null;
            }

            if (string.IsNullOrWhiteSpace(cmdLine.OutputDir))
            {
                string outputFolderName = string.Format("{0}_{1}", Path.GetFileNameWithoutExtension(cmdLine.Input), DateTime.Now.ToString("yyyyddMM-HHmmss"));
                cmdLine.OutputDir = Path.Combine(TileHelper.GetDefaultOutputDirectory(), outputFolderName);
                Trace.TraceInformation("{0}: Output directory {1}", DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"), cmdLine.OutputDir);
            }

            if (!Path.IsPathRooted(cmdLine.Input))
            {
                cmdLine.Input = Path.GetFullPath(cmdLine.Input);
            }

            if (!Path.IsPathRooted(cmdLine.OutputDir))
            {
                cmdLine.OutputDir = Path.GetFullPath(cmdLine.OutputDir);
            }

            if (!Path.IsPathRooted(cmdLine.ColorMap))
            {
                cmdLine.ColorMap = Path.GetFullPath(cmdLine.ColorMap);
            }

            if (!string.IsNullOrEmpty(cmdLine.ColorMapOrientation))
            {
                ColorMapOrientation orientation;
                if (!Enum.TryParse(cmdLine.ColorMapOrientation, true, out orientation))
                {
                    Trace.TraceError("{0}: " + ErrorMessage, DateTime.Now.TimeOfDay.ToString(@"hh\:mm\:ss"));
                    return null;
                }
            }

            return cmdLine;
        }
开发者ID:hxhlb,项目名称:wwt-tile-sdk,代码行数:64,代码来源:Program.cs


示例17: StopBridgeIfLocal

 private static void StopBridgeIfLocal(CommandLineArguments commandLineArgs)
 {
     if (IsBridgeHostLocal(commandLineArgs.BridgeConfiguration))
     {
         StopBridge(commandLineArgs);
     }
     else
     {
         Console.WriteLine("The Bridge on host {0} is not running locally and will not be stopped.",
                             commandLineArgs.BridgeConfiguration.BridgeHost);
         Console.WriteLine("Use 'Bridge.exe /stop' to stop a Bridge on another machine.");
     }
 }
开发者ID:noodlese,项目名称:wcf,代码行数:13,代码来源:Program.cs


示例18: Start

 public bool Start(CommandLineArguments arguments = null)
 {
     var filename = Settings.Default.UseCustomPuttyPath ? Settings.Default.CustomPuttyPath : App.Info.GeneralAppInfo.PuttyPath;
     return Start(filename, arguments);
 }
开发者ID:mRemoteNG,项目名称:mRemoteNG,代码行数:5,代码来源:PuttyProcessController.cs


示例19: SetLocale

        public static string SetLocale(CommandLineArguments cmdLineArgs)
        {
            var supportedLocale = new HashSet<string>(new[]
                        {
                            "cs-CZ", "de-DE", "en-US", "es-ES", "fr-FR", "it-IT",
                            "ja-JP", "ko-KR", "pl-PL", "pt-BR", "ru-RU", "zh-CN", "zh-TW"
                        });
            string libgLocale = string.Empty;

            if (!string.IsNullOrEmpty(cmdLineArgs.Locale))
            {
                // Change the application locale, if a locale information is supplied.
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(cmdLineArgs.Locale);
                Thread.CurrentThread.CurrentCulture = new CultureInfo(cmdLineArgs.Locale);
                libgLocale = cmdLineArgs.Locale;
            }
            else
            {
                // In case no language is specified, libG's locale should be that of the OS.
                // There is no need to set Dynamo's locale in this case.
                libgLocale = CultureInfo.InstalledUICulture.ToString();
            }

            // If locale is not supported by Dynamo, default to en-US.
            if (!supportedLocale.Any(s => s.Equals(libgLocale, StringComparison.InvariantCultureIgnoreCase)))
            {
                libgLocale = "en-US";
            }
            // Change the locale that LibG depends on.
            StringBuilder sb = new StringBuilder("LANGUAGE=");
            sb.Append(libgLocale.Replace("-", "_"));
            return sb.ToString();
        }
开发者ID:ksobon,项目名称:Dynamo,代码行数:33,代码来源:StartupUtils.cs


示例20: InitializeArgs

        /// <summary>
        /// Initializes values of the given CommandLineArguments structure.
        /// </summary>
        /// <param name="args">CommandLineArguments to initialize</param>
        /// <history>
        /// [Curtis_Beard]		07/26/2006	Created
        /// </history>
        private static void InitializeArgs(ref CommandLineArguments args)
        {
            args.AnyArguments = false;

             args.StartPath = string.Empty;
             args.IsValidStartPath = false;

             args.FileTypes = string.Empty;
             args.IsValidFileTypes = false;

             args.SearchText = string.Empty;
             args.IsValidSearchText = false;

             args.StartSearch = false;

             // default to all turned off, user must specify each one, or use /d for defaults
             args.UseRegularExpressions = false;
             args.IsCaseSensitive = false;
             args.IsWholeWord = false;
             args.UseRecursion = false;
             args.IsNegation = false;
             args.UseLineNumbers = false;
             args.IsFileNamesOnly = false;
        }
开发者ID:joshball,项目名称:astrogrep,代码行数:31,代码来源:CommandLineProcessing.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CommandLineParser类代码示例发布时间:2022-05-24
下一篇:
C# CommandLineArgumentParser类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap