public ExpressionInjectorFactoryBenchmark()
        {
            _injectorFactory = new ExpressionInjectorFactory();

            _constructorWarriorAndWeapon = typeof(NinjaBarracks).GetConstructor(new[] { typeof(IWarrior), typeof(IWeapon) });
            _argumentsWarriorAndWeapon   = new object[] { new FootSoldier(), new Sword() };
            _injector = _injectorFactory.Create(_constructorWarriorAndWeapon);
        }
示例#2
0
        public ConstructorInjectionDirectiveBenchmark()
        {
            _zeroArgumentConstructor = typeof(NinjaBarracks).GetConstructor(new Type[0]);
            _twoArgumentConstructor  = typeof(NinjaBarracks).GetConstructor(new[] { typeof(IWarrior), typeof(IWeapon) });

            var injectorFactory = new ExpressionInjectorFactory();

            _zeroArgumentIinjector = injectorFactory.Create(_zeroArgumentConstructor);
            _twoArgumentIinjector  = injectorFactory.Create(_twoArgumentConstructor);
        }
示例#3
0
        public MethodInjectionStrategyBenchmark()
        {
            var injectorFactory = new ExpressionInjectorFactory();

            var ninjectSettings = new NinjectSettings {
                LoadExtensions = false
            };
            var kernelConfiguration = new KernelConfiguration(ninjectSettings);

            kernelConfiguration.Bind <MyService>().ToSelf();
            kernelConfiguration.Bind <IWarrior>().To <Monk>();
            kernelConfiguration.Bind <IWeapon>().To <Sword>();

            _context = CreateContext(kernelConfiguration,
                                     kernelConfiguration.BuildReadOnlyKernel(),
                                     Array.Empty <IParameter>(),
                                     typeof(MyService),
                                     ninjectSettings);
            _reference = new InstanceReference {
                Instance = _context.Resolve()
            };

            _methodInjectionStrategy = new MethodInjectionStrategy();
        }
 public ExpressionInjectorFactoryContext()
 {
     this.injectorFactory = new ExpressionInjectorFactory();
 }