Ejemplo n.º 1
0
 private void DisplayStartup(ISendFireService iSendFireService, BaseCommandArgumentSelected status)
 {
     // Display help if asked to console.
     if (status == BaseCommandArgumentSelected.DisplayHelp)
     {
         var maxLineLength    = Console.WindowWidth - 10;
         var executionOptions = iSendFireService.GetCommandLineCollections().CommandCollectionsAsExecutionOptions();
         foreach (var info in iSendFireService.GetHelpDescription().SplitAtLines(maxLineLength))
         {
             Console.WriteLine(info);
         }
         Console.WriteLine();
         Console.WriteLine($"{iSendFireService.ApplicationName} ({iSendFireService.ApplicationVersion}) ");
         Console.WriteLine($"Usage: {iSendFireService.ApplicationName} [general-options]");
         Console.WriteLine($"Usage: {iSendFireService.ApplicationName} --{BaseCommandArguments.RegisterService}{executionOptions}");
         Console.WriteLine($"Usage: {iSendFireService.ApplicationName} --{BaseCommandArguments.UninstallService}{executionOptions}");
         Console.WriteLine($"Usage: {iSendFireService.ApplicationName} --{BaseCommandArguments.ConsoleMode}{executionOptions}");
         Console.WriteLine();
         foreach (var line in BasicCommandLineOptions.CommandCollectionsAsArgumentDescriptions(maxLineLength))
         {
             Console.WriteLine(line);
         }
         foreach (var line in iSendFireService.GetCommandLineCollections().CommandCollectionsAsArgumentDescriptions(maxLineLength))
         {
             Console.WriteLine(line);
         }
     }
     // Otherwise log execution to logger.
     //else
     //{
     //    //if (model.ParameterInfo.Count > 0)
     //    //{
     //    //    Logger.PushHeaderInfo($"{CommandLineModel.AppBinaryName} Execution Parameters");
     //    //    foreach (var info in model.ParameterInfo)
     //    //    {
     //    //        Logger.PushInfo(info);
     //    //    }
     //    //}
     //    if (Configuration["console"].IsTrue())
     //    {
     //        Logger.LogInformation($"{iSendFireService.ServiceName} Started on {DateTime.Now} in Console Mode.");
     //    }
     //    else
     //    {
     //        Logger.LogInformation($"{iSendFireService.ServiceName} Started on {DateTime.Now} in Service Mode.");
     //    }
     //}
 }
Ejemplo n.º 2
0
        public override void ValidateConfigurationForBaseCommand(BaseCommandArgumentSelected baseCommand)
        {
            if (!Configuration["qn"].IsNullOrEmpty())
            {
                QueueName = Configuration["qn"].ToLower();
            }
            else
            {
                QueueName = ServiceProvider.GetService <IEnvironmentManager>().GetMachineName().ToLower().Replace("-", "_");
            }

            if (!Regex.IsMatch(QueueName, @"^[a-z0-9_]+$"))
            {
                throw new ArgumentException($"The queue name must consist of lowercase letters, digits and underscore characters only. Given: '{QueueName}'.");
            }
            ServiceName  = $"{ApplicationName} ({QueueName})";
            _displayName = $"{_baseDisplayName} ({QueueName})";
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Anyone deriving from this method should throw when configuration is not valid for the given Base command option.
 /// </summary>
 public abstract void ValidateConfigurationForBaseCommand(BaseCommandArgumentSelected baseCommand);