public void RealTestForSecurityRule() { IDependencyContainer container = new LightInjectContainer(); container.RegisterCommandHandler <TestAuthenticatedCommand, TestAuthenticatedCommandHandler>(); container.RegisterSecurityRule <TestAuthenticatedCommand, TestSecurityRule <TestAuthenticatedCommand> >(); var bus = new SimpleCommandBus(container); var command = new TestAuthenticatedCommand(new FrameworkClaimsIdentity(Guid.Empty)); bus.Send(command); }
public static IRegister CreateRegister(string name) { switch (name.ToLower()) { case LightInject: return(LightInjectContainer.Create()); case Castle: return(CastleWindsorContainer.Create()); case MsDi: return(MsDiRegister.Create()); default: throw new ArgumentOutOfRangeException(nameof(name)); } }
static void Main(string[] args) { try { var container = new LightInjectContainer(); container.Register <IUnitOfWork, SampleAppUnitOfWork>(); container.Register <IGetOrdersQuery, GetOrdersQuery>(); container.Register <IMainPresenter, MainPresenter>(); container.Register <IConnectionStringProvider, AppSettingsConnectionStringProvider>(); var mainPresenter = container.Resolve <IMainPresenter>(); mainPresenter.Run(); } catch (Exception e) { System.Console.WriteLine(e); throw; } }
public static IContainer Create() { var containterImpl = new ServiceContainer(); var assembliesLoader = new AssembliesLoader.AssembliesLoader(); foreach (var assembly in assembliesLoader.LoadAssemblies()) { containterImpl.RegisterAssembly(assembly, () => new PerContainerLifetime()); } containterImpl.Register <IServiceContainer>(factory => containterImpl, new PerContainerLifetime());; containterImpl.Register <IAssembliesLoader>(factory => assembliesLoader, new PerContainerLifetime());; var result = new LightInjectContainer(containterImpl); containterImpl.Register <IContainer>(factory => result, new PerContainerLifetime()); return(result); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // TODO Switch to another container that provides signed assemblies IIocContainer container = new LightInjectContainer(); // UI classes IApplicationController controller = new ApplicationController(container) .RegisterView<IMainView, MainForm>() .RegisterView<IThumbnailView, ThumbnailView>() .RegisterView<IThumbnailDescriptionView, ThumbnailDescriptionView>() .RegisterInstance(new ApplicationContext()); // Application services controller.RegisterService<IThumbnailManager, ThumbnailManager>() .RegisterService<IThumbnailViewFactory, ThumbnailViewFactory>() .RegisterService<IThumbnailDescriptionViewFactory, ThumbnailDescriptionViewFactory>() .RegisterService<IConfigurationStorage, ConfigurationStorage>() .RegisterInstance<IApplicationConfiguration>(new ApplicationConfiguration()); controller.Run<MainPresenter>(); }
public ISingleton1 LightInject() { return(LightInjectContainer.GetInstance <ISingleton1>()); }