Exemple #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();
 }
        public RequestBenchmark()
        {
            _ninjectSettings = new NinjectSettings
            {
                // Disable to reduce memory pressure
                ActivationCacheDisabled = true,
                LoadExtensions          = false
            };
            _kernelConfiguration = new KernelConfiguration(_ninjectSettings);
            _kernel             = _kernelConfiguration.BuildReadOnlyKernel();
            _service            = typeof(MyInstrumentedService);
            _target             = CreatePropertyTarget(_service);
            _constraint         = null;
            _scopeCallback      = null;
            _cachePruner        = new GarbageCollectionCachePruner(_ninjectSettings);
            _pipeline           = new Pipeline(Enumerable.Empty <IActivationStrategy>(), new ActivationCache(_cachePruner));
            _cache              = new Cache(_pipeline, _cachePruner);
            _planner            = new Planner(Enumerable.Empty <IPlanningStrategy>());
            _exceptionFormatter = new ExceptionFormatter();

            _emptyParameters = Array.Empty <IParameter>();
            _requestParameterWithMixOfShouldInheritSetToTrueAndFalse = new List <IParameter>
            {
                new ConstructorArgument("foo1", 1, true),
                new ConstructorArgument("foo3", 3, true),
                new ConstructorArgument("foo3", 3, false),
                new ConstructorArgument("foo5", 5, false)
            };
            _bindingParameterWithMixOfShouldInheritSetToTrueAndFalse = new List <IParameter>
            {
                new ConstructorArgument("foo1", 1, true),
                new ConstructorArgument("foo2", 2, true),
                new ConstructorArgument("foo3", 3, false),
                new ConstructorArgument("foo4", 4, false),
            };

            _rootRequestWithoutParameters = CreateRootRequest(_emptyParameters);
            _rootRequestWithMixOfShouldInheritSetToTrueAndFalse = CreateRootRequest(_requestParameterWithMixOfShouldInheritSetToTrueAndFalse);

            _bindingWithoutParameters = CreateBinding(Array.Empty <IParameter>());
            _contextWithoutRequestAndBindingParameters = CreateContext(_rootRequestWithoutParameters, _bindingWithoutParameters);
            _bindingWithParameters = CreateBinding(_bindingParameterWithMixOfShouldInheritSetToTrueAndFalse);
            _contextWithRequestAndBindingParameters = CreateContext(_rootRequestWithMixOfShouldInheritSetToTrueAndFalse, _bindingWithParameters);

            _childRequestWithoutParameters = CreateChildRequest(_contextWithoutRequestAndBindingParameters, _target);
            _childRequestWithRequestAndBindingParameters = CreateChildRequest(_contextWithRequestAndBindingParameters, _target);
        }
        public PipelineBenchmark()
        {
            var cachePruner     = new GarbageCollectionCachePruner(new NinjectSettings());
            var activationCache = new ActivationCache(cachePruner);

            for (var i = 0; i < 1000; i++)
            {
                activationCache.AddActivatedInstance("" + i);
                activationCache.AddDeactivatedInstance("" + i);
            }

            var noStrategies = new List <IActivationStrategy>();

            _pipelineWithoutStrategies = new Pipeline(noStrategies, activationCache);

            var strategies = new List <IActivationStrategy> {
                new NoOpStrategy(),
                new NoOpStrategy(),
                new NoOpStrategy(),
                new NoOpStrategy(),
                new NoOpStrategy(),
                new NoOpStrategy()
            };

            _pipelineWithStrategies = new Pipeline(strategies, activationCache);

            _activatedReference = new InstanceReference {
                Instance = "ACTIVATED"
            };
            activationCache.AddActivatedInstance(_activatedReference.Instance);

            _deactivatedReference = new InstanceReference {
                Instance = "DEACTIVATED"
            };
            activationCache.AddDeactivatedInstance(_deactivatedReference.Instance);

            _context = new Mock <IContext>(MockBehavior.Strict).Object;
        }