ContainsKey() 공개 메소드

public ContainsKey ( string parameterName ) : bool
parameterName string
리턴 bool
예제 #1
0
        internal static void Main(string[] args)
        {
            Console.WriteLine(@"KonfDBRC : KonfDB Remote Console");
            Console.WriteLine(@"KonfDBRC : Initializing..");
            var arguments = new CommandArgs(args);

            if (arguments.ContainsKey("configFile"))
            {
                var configFile = arguments.GetValue("configFile", "konfdbc.json");
                var instance = ConnectionFactory.GetInstance(new FileInfo(configFile));

                RunFromConfig(instance);
            }
            else if (File.Exists("konfdbc.json"))
            {
                var configFile = arguments.GetValue("configFile", "konfdbc.json");
                var instance = ConnectionFactory.GetInstance(new FileInfo(configFile));

                RunFromConfig(instance);
            }
            else
            {
                Console.WriteLine(@" ");
            }

            Console.WriteLine(@"Thanks for using KonfDBRC. Press any key to exit.");
            Console.ReadKey();
            Console.WriteLine();
        }
예제 #2
0
        internal static void Main(string[] args)
        {
            IArguments argsDictionary = new CommandArgs(args);
            var backgroundService = new KonfDBH(argsDictionary);
            var services = new ServiceBase[] {backgroundService};

            if (argsDictionary.ContainsKey("install"))
            {
                ManagedInstallerClass.InstallHelper(new[]
                {
                    Assembly.GetExecutingAssembly().Location
                });
            }
            else if (argsDictionary.ContainsKey("uninstall"))
            {
                ManagedInstallerClass.InstallHelper(new[]
                {
                    "/u",
                    Assembly.GetExecutingAssembly().Location
                });
            }
            else if (argsDictionary.ContainsKey("console")) // console mode
            {
                #region Console

                var contextSettings = new ContextSettings
                {
                    CommandFactory = new CommandFactory()
                };
                HostContext.CreateFrom(argsDictionary.GetValue("configPath", "konfdb.json"), contextSettings);
                CurrentHostContext.Default.Log.Debug("Running in Console Mode");
                Console.SetWindowPosition(0, 0);
                Console.BackgroundColor = ConsoleColor.DarkGray;
                Console.ForegroundColor = ConsoleColor.White;
                Console.Clear();

                services.RunService();

                var shutdown = new ManualResetEvent(false);
                var thread = new Thread(() =>
                {
                    while (!shutdown.WaitOne(0))
                    {
                        Thread.Sleep(1000);
                    }
                });
                thread.Start();

                bool exitLoop = false;
                var commandService = backgroundService.ServiceFacade;
                string internalSessionId = Guid.NewGuid().ToString();
                while (!exitLoop)
                {
                    Console.Write(">");
                    string line = Console.ReadLine();

                    if (string.IsNullOrEmpty(line)) continue;

                    var commandOutput = commandService.ExecuteCommand(new ServiceRequestContext
                    {
                        Command = line,
                        Token = backgroundService.AuthenticationToken,
                        SessionId = internalSessionId
                    });
                    if (commandOutput == null) continue;

                    if (commandOutput.MessageType == CommandOutput.DisplayMessageType.Message)
                        Console.WriteLine(commandOutput.Data != null
                            ? commandOutput.Data.ToJson()
                            : commandOutput.DisplayMessage);
                    else if (commandOutput.MessageType == CommandOutput.DisplayMessageType.Error)
                        Console.WriteLine(commandOutput.DisplayMessage);

                    if (commandOutput.PostAction == CommandOutput.PostCommandAction.ExitApplication)
                    {
                        shutdown.Set();
                        thread.Join();

                        services.StopService();

                        CurrentHostContext.Default.Log.Info("Exiting...");

                        Thread.Sleep(500);

                        exitLoop = true;
                    }
                }

                #endregion
            }
            else
            {
                ServiceBase.Run(services);
            }
        }