예제 #1
0
 /// <summary>
 /// Register an ICommand with the builder with a name
 /// </summary>
 /// <param name="builder">The builder</param>
 /// <param name="command">The command type</param>
 /// <param name="name">The name to register the command as</param>
 private void AddICommandToContext(ContainerBuilder builder, Type command, string name) =>
 builder
 .RegisterType(command)
 .Named <ICommand>(name)
 .WithParameter(
     new ResolvedParameter(
         (pi, ctx) => pi.ParameterType == typeof(ICommand) && pi.Name == "commandToHelpWith",
         (pi, ctx) => CommandLocator.GetOptionalNamedCommand(ctx, HelpCommand)))
 .SingleInstance();
예제 #2
0
 protected override void Load(ContainerBuilder builder)
 {
     builder.RegisterType <Program>()
     .WithParameter(
         new ResolvedParameter(
             (pi, ctx) => pi.ParameterType == typeof(ICommand),
             (pi, ctx) => CommandLocator.GetOptionalNamedCommand(ctx, CalamariCommandsModule.RunCommand)))
     .SingleInstance();
     builder.RegisterType <CombinedScriptEngine>().AsSelf();
     builder.RegisterType <HelpCommand>().AsSelf();
 }
예제 #3
0
        protected override void Load(ContainerBuilder builder)
        {
            builder.RegisterType <Program>()
            .WithParameter(
                new ResolvedParameter(
                    (pi, ctx) => pi.ParameterType == typeof(ICommand),
                    (pi, ctx) => CommandLocator.GetOptionalNamedCommand(ctx, CalamariCommandsModule.RunCommand)))
            .SingleInstance();
            builder.RegisterType <DeploymentJournalWriter>().As <IDeploymentJournalWriter>();
            builder.Register((_) => CalamariPhysicalFileSystem.GetPhysicalFileSystem()).As <ICalamariFileSystem>();
            builder.RegisterType <CombinedScriptEngine>().AsSelf();
            builder.RegisterType <HelpCommand>().AsSelf();

            builder
            .RegisterAssemblyTypes(this.GetType().Assembly)
            .AssignableTo <IScriptWrapper>()
            .As <IScriptWrapper>()
            .SingleInstance();
        }