Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 public void Ninject()
 {
     var ninjectLoader     = new ModuleLoader(null);
     var resolver          = new StandardBindingResolver();
     var bindingResolver   = new OpenGenericBindingResolver();
     var cache             = new Cache(null, null);
     var pipeline          = new Pipeline(null, null);
     var activationCache   = new ActivationCache(null);
     var gccp              = new GarbageCollectionCachePruner();
     var acs               = new ActivationCacheStrategy(null);
     var pis               = new PropertyInjectionStrategy(null);
     var rif               = new ReflectionInjectorFactory();
     var mis               = new MethodInjectionStrategy();
     var initStrategy      = new InitializableStrategy();
     var startableStrategy = new StartableStrategy();
     var bas               = new BindingActionStrategy();
     var ds                        = new DisposableStrategy();
     var planner                   = new Planner(null);
     var crs                       = new ConstructorReflectionStrategy(null, null);
     var selector                  = new Selector(null, null);
     var scs                       = new StandardConstructorScorer();
     var sih                       = new StandardInjectionHeuristic();
     var prs                       = new PropertyReflectionStrategy(null, null);
     var mrs                       = new MethodReflectionStrategy(null, null);
     var dvbr                      = new DefaultValueBindingResolver();
     var selfBindingResolver       = new SelfBindingResolver(null);
     var bindingPrecedenceComparer = new BindingPrecedenceComparer();
 }
Ejemplo n.º 2
0
 public PropertyInjectionDirectiveContext()
 {
     strategy = new PropertyInjectionStrategy(null)
     {
         Settings = new NinjectSettings()
     };
 }
Ejemplo n.º 3
0
        public PropertyInjectionDirectiveContext()
        {
            this.injectorFactoryMock    = new Mock <IInjectorFactory>(MockBehavior.Strict);
            this.exceptionFormatterMock = new Mock <IExceptionFormatter>(MockBehavior.Strict);
            this.contextMock            = new Mock <IContext>(MockBehavior.Strict);
            this.planMock          = new Mock <IPlan>(MockBehavior.Strict);
            this.targetFactoryMock = new Mock <ITargetFactory>(MockBehavior.Strict);

            this.random = new Random();

            this.strategy = new PropertyInjectionStrategy(injectorFactoryMock.Object,
                                                          new NinjectSettings(),
                                                          this.exceptionFormatterMock.Object);
        }
Ejemplo n.º 4
0
 public PropertyInjectionDirectiveContext()
 {
     this.strategy = new PropertyInjectionStrategy(null, new NinjectSettings());
 }
        public PropertyInjectionStrategyBenchmark()
        {
            var ninjectSettings = new NinjectSettings
            {
                // Disable to reduce memory pressure
                ActivationCacheDisabled = true,
                LoadExtensions          = false
            };
            var kernelConfiguration = new KernelConfiguration(ninjectSettings);

            kernelConfiguration.Bind <MyInstrumentedService>().ToSelf();
            kernelConfiguration.Bind <MyBareService>().ToSelf();
            kernelConfiguration.Bind <IWarrior>().To <Monk>();
            kernelConfiguration.Bind <IWeapon>().To <Sword>();
            kernelConfiguration.Bind <ICleric>().To <Monk>();

            var propertyValuesFullMatch = new List <IPropertyValue>
            {
                new PropertyValue(nameof(MyInstrumentedService.Warrior), new FootSoldier()),
                new PropertyValue(nameof(MyInstrumentedService.Weapon), new Dagger()),
                new PropertyValue(nameof(MyInstrumentedService.Cleric), new Monk())
            };
            var propertyValuesPartialMatch = new List <IPropertyValue>
            {
                new PropertyValue(nameof(MyInstrumentedService.Weapon), new Dagger()),
                new PropertyValue(nameof(MyInstrumentedService.Cleric), new Monk())
            };

            _instrumentedContextWithPropertyValuesFullMatch = CreateContext(kernelConfiguration,
                                                                            kernelConfiguration.BuildReadOnlyKernel(),
                                                                            propertyValuesFullMatch,
                                                                            typeof(MyInstrumentedService),
                                                                            ninjectSettings);
            _instrumentedContextWithPropertyValuesPartialMatch = CreateContext(kernelConfiguration,
                                                                               kernelConfiguration.BuildReadOnlyKernel(),
                                                                               propertyValuesPartialMatch,
                                                                               typeof(MyInstrumentedService),
                                                                               ninjectSettings);
            _instrumentedContextWithoutPropertyValues = CreateContext(kernelConfiguration,
                                                                      kernelConfiguration.BuildReadOnlyKernel(),
                                                                      Enumerable.Empty <IParameter>(),
                                                                      typeof(MyInstrumentedService),
                                                                      ninjectSettings);
            _bareContextWithPropertyValuesFullMatch = CreateContext(kernelConfiguration,
                                                                    kernelConfiguration.BuildReadOnlyKernel(),
                                                                    propertyValuesFullMatch,
                                                                    typeof(MyBareService),
                                                                    ninjectSettings);
            _bareContextWithPropertyValuesPartialMatch = CreateContext(kernelConfiguration,
                                                                       kernelConfiguration.BuildReadOnlyKernel(),
                                                                       propertyValuesPartialMatch,
                                                                       typeof(MyBareService),
                                                                       ninjectSettings);
            _bareContextWithoutPropertyValues = CreateContext(kernelConfiguration,
                                                              kernelConfiguration.BuildReadOnlyKernel(),
                                                              Enumerable.Empty <IParameter>(),
                                                              typeof(MyBareService),
                                                              ninjectSettings);

            _bareReferenceWithPropertyValuesFullMatch = new InstanceReference {
                Instance = _bareContextWithPropertyValuesFullMatch.Resolve()
            };
            _bareReferenceWithPropertyValuesPartialMatch = new InstanceReference {
                Instance = _bareContextWithPropertyValuesPartialMatch.Resolve()
            };
            _bareReferenceWithoutPropertyValues = new InstanceReference {
                Instance = _bareContextWithoutPropertyValues.Resolve()
            };
            _instrumentedReferenceWithPropertyValuesFullMatch = new InstanceReference {
                Instance = _instrumentedContextWithPropertyValuesFullMatch.Resolve()
            };
            _instrumentedReferenceWithPropertyValuesPartialMatch = new InstanceReference {
                Instance = _instrumentedContextWithPropertyValuesPartialMatch.Resolve()
            };
            _instrumentedReferenceWithoutPropertyValues = new InstanceReference {
                Instance = _instrumentedContextWithoutPropertyValues.Resolve()
            };

            _propertyInjectionStrategy = new PropertyInjectionStrategy(new ExpressionInjectorFactory(), ninjectSettings, new ExceptionFormatter());
        }