Ejemplo n.º 1
0
 private void WriteHelpForAllCommand(ICommandTypeProvider commandProvider)
 {
     WriteGeneralInformation();
     var commands = commandProvider.GetAllCommandTypes();
     foreach (var command in commands)
     {
         Console.WriteLine(string.Format(CultureInfo.CurrentUICulture, Strings.HelpCommand_CommandTitleFormat, command.Metadata.Name));
         WriteHelpForCommand(command);
     }
 }
Ejemplo n.º 2
0
        private void WriteHelpForAllCommand(ICommandTypeProvider commandProvider)
        {
            WriteGeneralInformation();
            var commands = commandProvider.GetAllCommandTypes();

            foreach (var command in commands)
            {
                Console.WriteLine(string.Format(CultureInfo.CurrentUICulture, Strings.HelpCommand_CommandTitleFormat, command.Metadata.Name));
                WriteHelpForCommand(command);
            }
        }
Ejemplo n.º 3
0
        private void WriteGeneralHelp(ICommandTypeProvider commandProvider)
        {
            WriteGeneralInformation();

            var commandTypes  = commandProvider.GetAllCommandTypes().ToList();
            var maxNameLength = commandTypes.Max(m => m.Metadata.Name.Length);

            foreach (var commandType in commandTypes)
            {
                Console.Write(" {0, -" + maxNameLength + "}   ", commandType.Metadata.Name);
                // Starting index of the description
                var descriptionPadding = maxNameLength + 4;
                Console.PrintJustified(descriptionPadding, commandType.Metadata.Description);
                Console.WriteLine();
            }
        }
Ejemplo n.º 4
0
        private void SaveDependencies <T>([NotNull] Func <Func <IDependencyResolverScope, IEnumerable <T> > > servicesFactory) where T : class
        {
            var serviceType = typeof(T);

            if (_multiplyRegistredDependencies.ContainsKey(serviceType))
            {
                _multiplyRegistredDependencies[serviceType] = servicesFactory;
            }
            else
            {
                _multiplyRegistredDependencies.Add(serviceType, servicesFactory);
            }
            // This code is here to avoid the CC0052 issue with _commandTypeProvider (https://github.com/code-cracker/code-cracker/issues/544)
            if (_commandTypeProvider == null)
            {
                _commandTypeProvider = null;
            }
        }
Ejemplo n.º 5
0
 private DefaultDependencyResolver()
 {
     SaveDependencies <IConverter>(() => _ => _converters);
     SaveDependency <IConsole>(() => _ => DefaultConsole.Instance);
     SaveDependency <ICommandActivator>(() => _ => BasicCommandActivator.Instance);
     SaveDependency <IAssemblyProvider>(() => _ => CurrentDirectoryAssemblyProvider.Instance);
     SaveDependency <ICommandTypeProvider>(() => _ => _commandTypeProvider ?? (_commandTypeProvider = new AssemblyBrowsingCommandTypeProvider(_.ResolveDependency <IAssemblyProvider>(), _.ResolveDependencies <IConverter>())));
 }
Ejemplo n.º 6
0
        private void WriteGeneralHelp(ICommandTypeProvider commandProvider)
        {
            WriteGeneralInformation();

            var commandTypes = commandProvider.GetAllCommandTypes().ToList();
            var maxNameLength = commandTypes.Max(m => m.Metadata.Name.Length);
            foreach (var commandType in commandTypes)
            {
                Console.Write(" {0, -" + maxNameLength + "}   ", commandType.Metadata.Name);
                // Starting index of the description
                var descriptionPadding = maxNameLength + 4;
                Console.PrintJustified(descriptionPadding, commandType.Metadata.Description);
                Console.WriteLine();
            }
        }