Esempio n. 1
0
 private static void RegisterRequiredServices(IContainer container)
 {
     container.Register <IActiveViewLocator, ActiveViewLocator>(Reuse.Singleton);
     container.Register <IScopedViewLocator, ScopedViewLocator>(Reuse.Scoped);
     container.Register <INavigationService, NavigationService>(Reuse.Scoped);
     container.Register <IViewConfiguration, DefaultViewConfigurations>(Reuse.Singleton, serviceKey: "defaultConfiguration");
     container.Register <ILogger, NullLogger>();
 }
Esempio n. 2
0
 protected override void RegisterTypeWithContainer <T>(IocLifetime lifeTime)
 {
     if (lifeTime == IocLifetime.Transient)
     {
         _dryIocContainer.Register <T>(Reuse.Transient, Made.Default, Setup.With(allowDisposableTransient: true));
     }
     else
     {
         _dryIocContainer.Register <T>(Reuse.Singleton);
     }
 }
Esempio n. 3
0
        public DryIocBenchmark()
        {
            _container = new DryIoc.Container();
            foreach (var map in TransientMap)
            {
                _container.Register(map.Item1, map.Item2);
            }

            foreach (var map in SingletonMap)
            {
                _container.Register(map.Item1, map.Item2, Reuse.Singleton);
            }
        }
Esempio n. 4
0
        public void SetUp()
        {
            _harmony = new DependencyContainer();
            _harmony.Register(new Singleton());
            _harmony.Resolve <Singleton>();

            var builder = new ContainerBuilder();

            builder.RegisterInstance(new Singleton());
            _autofac = builder.Build();
            _autofac.Resolve <Singleton>();

            _ninject = new StandardKernel();
            _ninject.Load(Assembly.GetExecutingAssembly());
            _ninject.Bind <Singleton>().ToConstant(new Singleton());
            _ninject.Get <Singleton>();

            _dry = new Container();
            _dry.Register <Singleton>(Reuse.Singleton);
            _dry.Resolve <Singleton>();

            var services = new ServiceCollection();

            services.AddSingleton(new Singleton());
            _dotnet = services.BuildServiceProvider();
            _dotnet.GetService <Singleton>();

            _native = new Singleton();
        }
Esempio n. 5
0
 public void RegisterType <TFrom, TTo>()
     where TTo : TFrom
 => _container.Register <TFrom, TTo>();
 public void Decorator <TImplementation, TService>()
     where TImplementation : TService
 {
     _dryContainer.Register <TService, TImplementation>(setup: Setup.Decorator);
 }
 private void RegisterTools()
 {
     _container.Register <AppCore.IObjectSerializer, Tools.ObjectSerializer>();
     _container.Register <Core.IEventLogger, Tools.Logger>();
 }