コード例 #1
0
ファイル: TestManager.cs プロジェクト: mgestal/MAD-MiniPortal
        /// <summary>
        /// Configures and populates the Ninject kernel
        /// </summary>
        /// <returns>The NInject kernel</returns>
        public static IKernel ConfigureNInjectKernel()
        {
            NinjectSettings settings = new NinjectSettings()
            {
                LoadExtensions = true
            };

            IKernel kernel = new StandardKernel(settings);

            kernel.Bind <IUserProfileDao>().
            To <UserProfileDaoEntityFramework>();

            kernel.Bind <IUserService>().
            To <UserService>();

            string connectionString =
                ConfigurationManager.ConnectionStrings["MiniPortalEntities"].ConnectionString;

            kernel.Bind <DbContext>().
            ToSelf().
            InSingletonScope().
            WithConstructorArgument("nameOrConnectionString", connectionString);

            return(kernel);
        }
コード例 #2
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            NinjectSettings settings = new NinjectSettings()
            {
                InjectNonPublic = true
            };
            var kernel = new StandardKernel(settings);

            try
            {
                kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => Bootstrapper.Kernel);
                kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>();



                RegisterServices(kernel);



                return(kernel);
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
コード例 #3
0
        public void GlobalSetup()
        {
            var ninjectSettingsWithConstructorAndPropertyInjection = new NinjectSettings
            {
                // Disable to reduce memory pressure
                ActivationCacheDisabled = true,
                LoadExtensions          = false,
                PropertyInjection       = true,
                MethodInjection         = false
            };
            var ninjectSettingsWithOnlyConstructorInjection = new NinjectSettings
            {
                // Disable to reduce memory pressure
                ActivationCacheDisabled = true,
                LoadExtensions          = false,
                PropertyInjection       = false,
                MethodInjection         = false
            };

            _kernelWithConstructorAndPropertyInjection = BuildKernel(ninjectSettingsWithConstructorAndPropertyInjection);
            _kernelWithOnlyConstructorInjection        = BuildKernel(ninjectSettingsWithOnlyConstructorInjection);

            _weaponRequest   = _kernelWithConstructorAndPropertyInjection.CreateRequest(typeof(IWeapon), null, Array.Empty <IParameter>(), false, true);
            _clericRequest   = _kernelWithConstructorAndPropertyInjection.CreateRequest(typeof(ICleric), null, Array.Empty <IParameter>(), false, true);
            _reflectRequest  = _kernelWithConstructorAndPropertyInjection.CreateRequest(typeof(IReflect), null, Array.Empty <IParameter>(), false, true);
            _barracksRequest = _kernelWithConstructorAndPropertyInjection.CreateRequest(typeof(NinjaBarracks), null, Array.Empty <IParameter>(), false, true);
            _leasureRequest  = _kernelWithConstructorAndPropertyInjection.CreateRequest(typeof(ILeasure), null, new IParameter[] { new ConstructorArgument("immediately", true, true) }, false, true);
        }
コード例 #4
0
ファイル: CacheBenchmark.cs プロジェクト: xsysfan/Ninject
        public CacheBenchmark()
        {
            var ninjectSettings = new NinjectSettings
            {
                // Disable to reduce memory pressure
                ActivationCacheDisabled = true,
                LoadExtensions          = false,
            };

            _cache = new Cache(new Pipeline(Enumerable.Empty <IActivationStrategy>(), new ActivationCache(new NoOpCachePruner())), new NoOpCachePruner());

            _kernelConfiguration                      = new KernelConfiguration();
            _readOnlyKernel                           = _kernelConfiguration.BuildReadOnlyKernel();
            _instanceForScopeWithZeroEntries          = new object();
            _instanceReferenceForScopeWithZeroEntries = new InstanceReference {
                Instance = _instanceForScopeWithZeroEntries
            };

            _scopeWithNoCache = new object();
            _scopeWithOneEntryForBindingConfiguration         = new object();
            _scopeWithZeroEntriesForBindingConfiguration      = new object();
            _scopeWithMoreThanOneEntryForBindingConfiguration = new object();

            _contextWithNoCache = CreateContext(_kernelConfiguration, _readOnlyKernel, typeof(string), _scopeWithNoCache, ninjectSettings);
            _contextWithZeroEntriesForBindingConfiguration      = CreateContext(_kernelConfiguration, _readOnlyKernel, typeof(string), _scopeWithZeroEntriesForBindingConfiguration, ninjectSettings);
            _contextWithOneEntryForBindingConfiguration         = CreateContext(_kernelConfiguration, _readOnlyKernel, typeof(string), _scopeWithOneEntryForBindingConfiguration, ninjectSettings);
            _contextWithMoreThanOneEntryForBindingConfiguration = CreateContext(_kernelConfiguration, _readOnlyKernel, typeof(string), _scopeWithMoreThanOneEntryForBindingConfiguration, ninjectSettings);
        }
コード例 #5
0
ファイル: ConnectInfoForm.cs プロジェクト: jpann/SSRSMigrate
        public ConnectInfoForm()
        {
            XmlConfigurator.Configure();

            var settings = new NinjectSettings()
            {
                LoadExtensions = false
            };

            this.mKernel = new StandardKernel(
                settings,
                new Log4NetModule(),
                new ReportServerRepositoryModule());

            //this.mKernel.Load<FuncModule>();

            this.mLoggerFactory = this.mKernel.Get<ILoggerFactory>();
            this.mFileSystem = this.mKernel.Get<IFileSystem>();
            this.mLogger = this.mLoggerFactory.GetCurrentClassLogger();

            InitializeComponent();

            this.LoadSettings();

            // Create the DebugForm and hide it if debug is False
            this.mDebugForm = new DebugForm();
            this.mDebugForm.Show();
            if (!this.mDebug)
                this.mDebugForm.Hide();
        }
コード例 #6
0
ファイル: AppConfig.cs プロジェクト: rubenlr/Utilities
        public AppConfig()
        {
            var settings = new NinjectSettings { LoadExtensions = false };
            var kernel = new StandardKernel(settings, new INinjectModule[] { new Log4NetModule() });

            _log = kernel.Get<ILoggerFactory>().GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
        }
コード例 #7
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            log4net.Config.XmlConfigurator.Configure();
            var settings = new NinjectSettings { LoadExtensions = false };
            var kernel = new StandardKernel(settings, new INinjectModule[] { new Log4NetModule() });

            try
            {
                kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);
                // ControllerBuilder.Current.SetControllerFactory(new ControllerFactory(kernel)); <-- used that until WebApi entered the solution\

                System.Web.Http.GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel); // webApi controller
                System.Web.Mvc.DependencyResolver.SetResolver(new NinjectMvcDependencyResolver(kernel)); // mvc controller

                return kernel;
            }
            catch(Exception ex)
            {
                var foo = ex.Message;
                kernel.Dispose();
                throw;
            }
        }
コード例 #8
0
        private static INinjectSettings CreateSettings()
        {
            var settings = new NinjectSettings();

            settings.LoadExtensions = false;
            return(settings);
        }
コード例 #9
0
        public void InstancesAreDisposedWhenRequestEndsAndCacheIsPruned()
        {
            var settings = new NinjectSettings {
                CachePruningInterval = TimeSpan.MaxValue
            };
            var kernel = new StandardKernel(settings);

            kernel.Bind <ITool>().To <Hammer>().InRequestScope();
            var cache = kernel.Components.Get <ICache>();

            StartNewHttpRequest();

            var instance = kernel.Get <ITool>();

            instance.ShouldNotBeNull();
            instance.ShouldBeInstanceOf <Hammer>();

            StartNewHttpRequest();

            GC.Collect();
            GC.WaitForPendingFinalizers();

            cache.Prune();

            instance.IsDisposed.ShouldBeTrue();
        }
コード例 #10
0
        public void RequestScopeReturnsTheSameInstanceForAHttpRequest()
        {
            StartNewHttpRequest();

            var settings = new NinjectSettings {
                CachePruningInterval = TimeSpan.MaxValue
            };
            var kernel = new StandardKernel(settings);

            kernel.Bind <ITool>().To <Hammer>().InRequestScope();

            var tool1 = kernel.Get <ITool>();
            var tool2 = kernel.Get <ITool>();

            tool1.ShouldBe(tool2);


            StartNewHttpRequest();

            GC.Collect();
            GC.WaitForPendingFinalizers();

            var tool3 = kernel.Get <ITool>();

            tool1.ShouldNotBe(tool3);
        }
コード例 #11
0
 /// <summary>
 /// Creates the kernel that will manage your application.
 /// </summary>
 /// <returns>The created kernel.</returns>
 private static IKernel CreateKernel()
 {
     var settings = new NinjectSettings {LoadExtensions = false};
     var kernel = new StandardKernel(settings);
     RegisterServices(kernel);
     return kernel;
 }
コード例 #12
0
        public NinjectHttpResolver(params NinjectModule[] modules)
        {
            var settings = new NinjectSettings();

            settings.LoadExtensions = false;
            Kernel = new StandardKernel(settings, modules);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: toorani/Neutrino
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            var settings = new NinjectSettings
            {
                LoadExtensions     = false,
                AllowNullInjection = true
            };
            IKernel kernel = new StandardKernel(settings);

            NinjectContainer.RegisterModules(kernel, NinjectModules.Modules);

            if (ConfigurationManager.AppSettings["AppMode"].ToLower() == "debug")
            {
                Application.Run(new ServiceRunner(new DataSyncService()));
            }
            else
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new DataSyncService()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
コード例 #14
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var settings = new NinjectSettings();
            settings.LoadExtensions = true;
            settings.ExtensionSearchPatterns = settings.ExtensionSearchPatterns
                .Union(new string[] { "EvidencijaClanova.*.dll" }).ToArray();
            var kernel = new StandardKernel(settings);

            try
            {
                kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);

                GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);

                return kernel;
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
コード例 #15
0
        private static IKernel CreateKernel()
        {
            var settings = new NinjectSettings {
                LoadExtensions = true
            };

            var kernel = new StandardKernel(settings);

            try
            {
                kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);

                GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);

                return(kernel);
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
コード例 #16
0
        public void GlobalSetup()
        {
            var ninjectSettings = new NinjectSettings {
                LoadExtensions = false
            };

            var kernelConfiguration = new KernelConfiguration(ninjectSettings);

            kernelConfiguration.Bind <IWarrior>().To <SpecialNinja>().WhenInjectedExactlyInto <NinjaBarracks>();
            kernelConfiguration.Bind <IWarrior>().To <Samurai>().WhenInjectedExactlyInto <Barracks>();
            kernelConfiguration.Bind <IWarrior>().To <FootSoldier>().WhenInjectedExactlyInto <Barracks>();
            kernelConfiguration.Bind <IWeapon>().To <Shuriken>().WhenInjectedExactlyInto <Barracks>();
            kernelConfiguration.Bind <IWeapon>().To <ShortSword>().WhenInjectedExactlyInto <Spartan>();

            _injectorFactory = new ExpressionInjectorFactory();

            _contextWithParams = CreateContext(kernelConfiguration,
                                               kernelConfiguration.BuildReadOnlyKernel(),
                                               new List <IParameter>
            {
                new ConstructorArgument("height", 34),
                new PropertyValue("name", "cutter"),
                new ConstructorArgument("width", 17),
                new ConstructorArgument("location", "Biutiful")
            },
                                               typeof(StandardConstructorScorerBenchmark),
                                               ninjectSettings);

            _contextWithoutParams = CreateContext(kernelConfiguration,
                                                  kernelConfiguration.BuildReadOnlyKernel(),
                                                  Enumerable.Empty <IParameter>(),
                                                  typeof(StandardConstructorScorerBenchmark),
                                                  ninjectSettings);

            _injectCtor          = typeof(NinjaBarracks).GetConstructor(new[] { typeof(IWarrior), typeof(IWeapon) });
            _injectCtorDirective = new ConstructorInjectionDirective(_injectCtor, _injectorFactory.Create(_injectCtor));

            _defaultCtor          = typeof(NinjaBarracks).GetConstructor(new Type[0]);
            _defaultCtorDirective = new ConstructorInjectionDirective(_defaultCtor, _injectorFactory.Create(_defaultCtor));

            _knifeCtor          = typeof(Knife).GetConstructor(new[] { typeof(int), typeof(int) });
            _knifeCtorDirective = new ConstructorInjectionDirective(_knifeCtor, _injectorFactory.Create(_knifeCtor));

            _knifeDefaultsCtor          = typeof(Knife).GetConstructor(new[] { typeof(bool), typeof(string) });
            _knifeDefaultsCtorDirective = new ConstructorInjectionDirective(_knifeDefaultsCtor, _injectorFactory.Create(_knifeDefaultsCtor));

            _spartanNameAndAgeCtor          = typeof(Spartan).GetConstructor(new[] { typeof(string), typeof(int) });
            _spartanNameAndAgeCtorDirective = new ConstructorInjectionDirective(_spartanNameAndAgeCtor, _injectorFactory.Create(_spartanNameAndAgeCtor));

            _spartanHeightAndWeaponCtor          = typeof(Spartan).GetConstructor(new[] { typeof(string), typeof(int) });
            _spartanHeightAndWeaponCtorDirective = new ConstructorInjectionDirective(_spartanHeightAndWeaponCtor, _injectorFactory.Create(_spartanHeightAndWeaponCtor));

            _barracksCtor          = typeof(Barracks).GetConstructor(new[] { typeof(IWarrior), typeof(IWeapon) });
            _barracksCtorDirective = new ConstructorInjectionDirective(_barracksCtor, _injectorFactory.Create(_barracksCtor));

            _monasteryCtor          = typeof(Monastery).GetConstructor(new[] { typeof(IWarrior), typeof(IWeapon) });
            _monasteryCtorDirective = new ConstructorInjectionDirective(_monasteryCtor, _injectorFactory.Create(_monasteryCtor));

            _standardConstructorScorer = new StandardConstructorScorer(ninjectSettings);
        }
コード例 #17
0
        public void GlobalSetup()
        {
            _settingsInjectNonPublicIsTrueAndInjectParentPrivatePropertiesIsTrue = new NinjectSettings
            {
                InjectNonPublic = true,
                InjectParentPrivateProperties = true
            };
            _selectorInjectNonPublicIsTrueAndInjectParentPrivatePropertiesIsTrue = new Selector(new[] { new StandardInjectionHeuristic(_settingsInjectNonPublicIsTrueAndInjectParentPrivatePropertiesIsTrue) },
                                                                                                _settingsInjectNonPublicIsTrueAndInjectParentPrivatePropertiesIsTrue);

            _settingsInjectNonPublicIsTrueAndInjectParentPrivatePropertiesIsFalse = new NinjectSettings
            {
                InjectNonPublic = true,
                InjectParentPrivateProperties = false
            };
            _selectorInjectNonPublicIsTrueAndInjectParentPrivatePropertiesIsFalse = new Selector(new[] { new StandardInjectionHeuristic(_settingsInjectNonPublicIsTrueAndInjectParentPrivatePropertiesIsFalse) },
                                                                                                 _settingsInjectNonPublicIsTrueAndInjectParentPrivatePropertiesIsFalse);

            _settingsInjectNonPublicIsFalseAndInjectParentPrivatePropertiesIsTrue = new NinjectSettings
            {
                InjectNonPublic = false,
                InjectParentPrivateProperties = true
            };
            _selectorInjectNonPublicIsFalseAndInjectParentPrivatePropertiesIsTrue = new Selector(new[] { new StandardInjectionHeuristic(_settingsInjectNonPublicIsFalseAndInjectParentPrivatePropertiesIsTrue) },
                                                                                                 _settingsInjectNonPublicIsFalseAndInjectParentPrivatePropertiesIsTrue);

            _settingsInjectNonPublicIsFalseAndInjectParentPrivatePropertiesIsFalse = new NinjectSettings
            {
                InjectNonPublic = false,
                InjectParentPrivateProperties = false
            };
            _selectorInjectNonPublicIsFalseAndInjectParentPrivatePropertiesIsFalse = new Selector(new[] { new StandardInjectionHeuristic(_settingsInjectNonPublicIsFalseAndInjectParentPrivatePropertiesIsFalse) },
                                                                                                  _settingsInjectNonPublicIsFalseAndInjectParentPrivatePropertiesIsFalse);
        }
コード例 #18
0
        public ConnectInfoForm()
        {
            XmlConfigurator.Configure();

            var settings = new NinjectSettings()
            {
                LoadExtensions = false
            };

            this.mKernel = new StandardKernel(
                settings,
                new Log4NetModule(),
                new ReportServerRepositoryModule());

            //this.mKernel.Load<FuncModule>();

            this.mLoggerFactory = this.mKernel.Get <ILoggerFactory>();
            this.mFileSystem    = this.mKernel.Get <IFileSystem>();
            this.mLogger        = this.mLoggerFactory.GetCurrentClassLogger();

            InitializeComponent();

            this.LoadSettings();

            // Create the DebugForm and hide it if debug is False
            this.mDebugForm = new DebugForm();
            this.mDebugForm.Show();
            if (!this.mDebug)
            {
                this.mDebugForm.Hide();
            }
        }
コード例 #19
0
        public static IKernel Setup()
        {
            var setting = new NinjectSettings
            {
                ExtensionSearchPatterns = new[]
                {
                    //"Ninject.Extensions.*.dll",
                    //"Ninject.Web*.dll",
                    //@"..\Configs\NinjectModule.xml"
                    "*.dll"
                },
                LoadExtensions = true
            };
            var kernel = new StandardKernel(setting);

            try
            {
                //kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
                //kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
                RegisterServices(kernel);
                //kernel.Bind<WebPluginManager>().ToConstant(_webPluginManager);
                return(kernel);
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
コード例 #20
0
ファイル: Kernel.cs プロジェクト: pebblecode/pc-common
        /// <summary>
        /// Initialise the kernel, load any assemblies which define bindings
        /// </summary>
        static Kernel()
        {
            NinjectSettings settings = new NinjectSettings();

            settings.InjectAttribute = typeof(InjectAttribute);

            _kernel = new StandardKernel(settings);

            // Load additionally configured assemblies
            if (IoCKernelConfiguration.Instance != null)
            {
                foreach (BindingAssembly bindingAssembly in IoCKernelConfiguration.Instance.BindingAssemblys)
                {
                    try
                    {
                        var assembly = Assembly.Load(bindingAssembly.Assembly);
                        _kernel.Load(assembly);
                    }
                    catch (FileNotFoundException)
                    {
                        System.Diagnostics.Debug.WriteLine("Failed to load IoC assembly " + bindingAssembly.Assembly);
                    }
                }
            }
        }
コード例 #21
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var settings = new NinjectSettings();

            settings.LoadExtensions          = true;
            settings.ExtensionSearchPatterns = settings.ExtensionSearchPatterns.Union(new string[] { "Cart.*.dll" }).ToArray();
            var kernel = new StandardKernel(settings);

            try
            {
                kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);

                // Install Ninject-based IDependencyResolver into the Web API configuration to set Web API Resolver
                GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);
                return(kernel);
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
コード例 #22
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var settings = new NinjectSettings()
            {
                LoadExtensions = false
            };
            var kernel = new StandardKernel(settings);

            try
            {
                kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>();

                kernel.Bind <ICustomersRepository>().To <CustomersRepository>();
                kernel.Bind <IPeopleRepository>().To <PeopleRepository>();
                kernel.Bind <IStoreRepository>().To <StoreRepository>();
                kernel.Bind <IGenericUoW>().To <GenericUoW>();
                kernel.Bind <ICustomersGetterService>().To <CustomersGetterService>();
                kernel.Bind <ICustomersAdderService>().To <CustomersAdderService>();
                kernel.Bind <IPeopleAdderService>().To <PeopleAdderService>();
                kernel.Bind <IRequestValidationService>().To <RequestValidationService>();

                GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyCoreResolver(kernel);

                return(kernel);
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
コード例 #23
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            NinjectSettings settings = new NinjectSettings();

            settings.LoadExtensions          = true;
            settings.InjectNonPublic         = true;
            settings.ExtensionSearchPatterns = new List <string>(settings.ExtensionSearchPatterns)
            {
                "PM.*.dll"
            }.ToArray();

            var kernel = new StandardKernel(settings);

            try
            {
                kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);

                GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);
                return(kernel);
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
コード例 #24
0
        public void GlobalSetup()
        {
            var ninjectSettings = new NinjectSettings
            {
                // Disable to reduce memory pressure
                ActivationCacheDisabled = true,
                LoadExtensions          = false
            };

            _kernelConfiguration = new KernelConfiguration(ninjectSettings);
            _kernelConfiguration.Bind <IWarrior>().To <SpecialNinja>().WhenInjectedExactlyInto <NinjaBarracks>();
            _kernelConfiguration.Bind <IWarrior>().To <Samurai>().WhenInjectedExactlyInto <Barracks>();
            _kernelConfiguration.Bind <IWarrior>().To <FootSoldier>().WhenInjectedExactlyInto <Barracks>();
            _kernelConfiguration.Bind <IWarrior>().To <FootSoldier>();
            _kernelConfiguration.Bind <IWeapon>().To <Shuriken>().WhenInjectedExactlyInto <Barracks>();
            _kernelConfiguration.Bind <IWeapon>().To <Sword>();
            _kernelConfiguration.Bind <ICleric>().To <Monk>();
            _kernelConfiguration.Bind(typeof(ICollection <>)).To(typeof(List <>));
            _kernelConfiguration.Bind(typeof(IList <>)).To(typeof(List <>));
            _kernelConfiguration.Bind <ISingleton>().To <Singleton>().InSingletonScope();
            _kernelConfiguration.Bind <IRouteProvider>().To <RouteProvider>();
            _kernelConfiguration.Bind <IRouteRepository>().To <RouteRepository>();
            _kernelConfiguration.Bind <ITrainPlanner>().To <TrainPlanner>();
            _kernelConfiguration.Bind <IRealtimeEventSource>().To <RealtimeEventSource>();

            _readOnlyKernel = _kernelConfiguration.BuildReadOnlyKernel();
            ClearCache(_readOnlyKernel);
        }
コード例 #25
0
ファイル: App.xaml.cs プロジェクト: stellasstar/PlugEVMe_old
        public App(params INinjectModule[] platformModules)
        {
            InitializeComponent();
            ThemeManager.LoadTheme();
            var mainPage = new NavigationPage(new MainPage());
            var modules  = new INinjectModule[]
            {
                new PlugEVMeCoreModule(),
                new PlugEVMeNavModule(mainPage.Navigation),
            };
            var settings = new NinjectSettings();

            settings.LoadExtensions = false;

            // Register core services
            Kernel = new StandardKernel(settings, modules);

            // Register platform specific services
            Kernel.Load(platformModules);

            // Get the MainViewModel from the IoC
            mainPage.BindingContext = Kernel.Get <MainViewModel>();

            MainPage = mainPage;
        }
コード例 #26
0
        public void Configure()
        {
            settings = new NinjectSettings()
            {
                LoadExtensions = true
            };
            kernel = new StandardKernel(settings);

            /* UserProfileDao */
            kernel.Bind <IUserProfileDao>().
            To <UserProfileDaoEntityFramework>();

            /* UserService */
            kernel.Bind <IUserService>().
            To <UserService>();

            /* DbContext */
            string connectionString =
                ConfigurationManager.ConnectionStrings["MiniPortalEntities"].ConnectionString;

            kernel.Bind <DbContext>().
            ToSelf().
            InSingletonScope().
            WithConstructorArgument("nameOrConnectionString", connectionString);
        }
コード例 #27
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var settings = new NinjectSettings {
                LoadExtensions = false
            };
            var kernel = new StandardKernel(settings, new INinjectModule[] {  });

            try
            {
                kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);
                // ControllerBuilder.Current.SetControllerFactory(new ControllerFactory(kernel)); <-- used that until WebApi entered the solution\

                System.Web.Http.GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel); // webApi controller
                System.Web.Mvc.DependencyResolver.SetResolver(new NinjectMvcDependencyResolver(kernel));                      // mvc controller

                return(kernel);
            }
            catch (Exception ex)
            {
                var foo = ex.Message;
                kernel.Dispose();
                throw;
            }
        }
コード例 #28
0
        public void Configure()
        {
            settigns = new NinjectSettings()
            {
                LoadExtensions = true
            };
            kernel = new StandardKernel(settigns);

            /* UserProfileDao */
            kernel.Bind <IUserProfileDao>().
            To <UserProfileDaoEntityFramework>();

            /* CategoryDao */
            kernel.Bind <ICategoryDao>().
            To <CategoryDaoEntityFramework>();
            /* SportEventDao */
            kernel.Bind <ISportEventDao>().
            To <SportEventDaoEntityFramework>();

            /* CommentDao */
            kernel.Bind <ICommentDao>().
            To <CommentDaoEntityFramework>();

            /* RecommendationDao */
            kernel.Bind <IRecommendationDao>().
            To <RecomendationDaoEntityFramework>();

            /* GroupUsersDao */
            kernel.Bind <IGroupUsersDao>().
            To <GroupUsersDaoEntityFramework>();

            /* SportEventService */
            kernel.Bind <ISportEventService>().
            To <SportEventService>();

            /* UserService*/
            kernel.Bind <IUserService>().
            To <UserService>();

            /* RecommendationGroupService */
            kernel.Bind <IRecommendationGroupService>().
            To <RecommendationGroupService>();

            /*TagDao*/
            kernel.Bind <ITagDao>().
            To <TagDaoEntityFramework>();

            /*FavoritesDao*/
            kernel.Bind <IFavoritesDao>().
            To <FavoritesDaoEntityFramework>();

            /* DbContext */
            string connectionString =
                ConfigurationManager.ConnectionStrings["practica_dbEntities"].ConnectionString;

            kernel.Bind <DbContext>().
            ToSelf().
            InSingletonScope().
            WithConstructorArgument("nameOrConnectionString", connectionString);
        }
コード例 #29
0
        public static void Main()
        {
            // Simulate heavy load, collect frequently
            var task = new Task(() =>
            {
                while (true)
                {
                    Thread.Sleep(500);

                    Console.WriteLine("test");
                    GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                    GC.WaitForPendingFinalizers();
                }
            });

            task.Start();

            var settings = new NinjectSettings {CachePruningInterval = new TimeSpan(0, 0, 5)};
            IKernel kernel = new StandardKernel(settings, new NinjectBindingsModule());

            PrintLoadedModules(kernel);

            var processor = kernel.Get<IMainProcessor>();
            processor.ProcessOnce();
            processor.ProcessOnce(); // second time is successful just as much
            Thread.Sleep(5000);

            var processor2 = kernel.Get<IMainProcessor>();
            processor2.ProcessOnce(); // ScopeDisposedException
        }
コード例 #30
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var settings = new NinjectSettings();

            settings.LoadExtensions          = true;                                                      //zbog toga mi radi ovo ispod
            settings.ExtensionSearchPatterns = settings.ExtensionSearchPatterns                           //kazem sto trazim
                                               .Union(new string[] { "OnlineCookbook.*.dll" }).ToArray(); //trazi mi sve ciji NS pocinje s OnlineCookBook
            var kernel = new StandardKernel(settings);                                                    //standardni kernel

            try
            {
                //pitati
                kernel.Bind <Func <IKernel> >().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind <IHttpModule>().To <HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);


                GlobalConfiguration.Configuration.DependencyResolver = new NinjectDependencyResolver(kernel);

                return(kernel);
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
コード例 #31
0
        public void TestFixtureSetUp()
        {
            EnvironmentSetup();

            var settings = new NinjectSettings()
            {
                LoadExtensions = false
            };

            kernel = new StandardKernel(
                settings,
                new Log4NetModule(),
                new DependencyModule());

            exporter = kernel.Get <ReportItemExporter>();

            reportItem_CompanySales = new ReportItem()
            {
                Name        = "Company Sales",
                Path        = "/SSRSMigrate_AW_Tests/Reports/Company Sales",
                Description = "Adventure Works sales by quarter and product category. This report illustrates the use of a tablix data region with nested row groups and column groups. You can drilldown from summary data into detail data by showing and hiding rows. This report also illustrates the use of a logo image and a background image.",
                ID          = "16d599e6-9c87-4ebc-b45b-5a47e3c73746",
                Definition  = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[0])))
            };

            reportItem_StoreContacts = new ReportItem()
            {
                Name        = "Store Contacts",
                Path        = "/SSRSMigrate_AW_Tests/Reports/Store Contacts",
                Description = "AdventureWorks store contacts. This report is a subreport used in Sales Order Detail to show all contacts for a store. Borderstyle is None so lines do not display in main report.",
                ID          = "18fc782e-dd5f-4c65-95ff-957e1bdc98de",
                VirtualPath = null,
                Definition  = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[2]))),
            };

            reportItem_SalesOrderDetail = new ReportItem()
            {
                Name        = "Sales Order Detail",
                Path        = "/SSRSMigrate_AW_Tests/Reports/Sales Order Detail",
                Description = "Detail of an individual Adventure Works order. This report can be accessed as a drillthrough report from the Employee Sales Summary and Territory Sales drilldown report. This report illustrates the use of a free form layout, a table, parameters, a subreport that shows multiple store contacts, and expressions.",
                ID          = "70650568-7dd4-4ef4-aeaa-67502de11b4f",
                VirtualPath = null,
                Definition  = TesterUtility.StringToByteArray(TesterUtility.LoadRDLFile(Path.Combine(TestContext.CurrentContext.TestDirectory, testReportFiles[1]))),
                SubReports  = new List <ReportItem>()
                {
                    reportItem_StoreContacts
                }
            };

            // Setup GetReports - Expected ReportItems
            reportItems = new List <ReportItem>()
            {
                reportItem_CompanySales,
                reportItem_SalesOrderDetail,
                reportItem_StoreContacts
            };

            outputPath = GetOutPutPath();
        }
コード例 #32
0
 public void Initialize(NinjectSettings settings, params INinjectModule[] modules)
 {
     if (IsInitialized)
     {
         throw new InvalidOperationException("The DI Container is already initialized.");
     }
     kernel = new StandardKernel(settings, modules);
 }
コード例 #33
0
        public void SetUp()
        {
            var settings = new NinjectSettings {
                CachePruningInterval = TimeSpan.MaxValue
            };

            this.kernel = new StandardKernel(settings);
        }
コード例 #34
0
        public XmlModuleContext()
        {
            var settings = new NinjectSettings {
                LoadExtensions = false
            };

            this.Kernel = new StandardKernel(settings, new XmlExtensionModule());
        }
コード例 #35
0
        public ThreadScopeContext()
        {
            var settings = new NinjectSettings {
                CachePruningInterval = TimeSpan.MaxValue
            };

            this.kernel = new StandardKernel(settings);
        }
コード例 #36
0
        public NinjectHttpResolver(Assembly assembly)
        {
            var settings = new NinjectSettings();

            settings.LoadExtensions = false;
            Kernel = new StandardKernel(settings);
            Kernel.Load(assembly);
        }
コード例 #37
0
 public virtual void SetUp()
 {
     NinjectSettings settings = new NinjectSettings()
                                    {
                                        InjectNonPublic = true
                                    };
     IKernel kernel = new StandardKernel(settings, new CoreBindingModule(), new DataAccessBindingModule());
     kernel.Inject(this);
 }
コード例 #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationService"/> class.
 /// </summary>
 public ConfigurationService()
 {
     var settings = new NinjectSettings
                        {
                            LoadExtensions = false
                        };
     this.kernel = new StandardKernel(settings, new CoreModule());
     this.context = new CoreXamlSchemaContext(this.kernel);
 }
コード例 #39
0
        protected override void Given()
        {
            base.Given();
            var settings = new NinjectSettings {InjectNonPublic = true};

            IKernel kernel = new StandardKernel(settings);
            kernel.Bind<IClock>().To<DateTimeBasedClock>();
            _creationStrategy = new NinjectAggregateRootCreationStrategy(kernel);
        }
コード例 #40
0
        public void CreatesMocksWithTheConfiguredMockBehavior()
        {
            var settings = new NinjectSettings();
            settings.SetMockBehavior(MockBehavior.Strict);
            var testee = new DefaultMockRepositoryProvider { Settings = settings };

            var mock = testee.Instance.Create<IDummyService>();
            mock.Behavior.Should().Be(MockBehavior.Strict);
        }
コード例 #41
0
ファイル: Program.cs プロジェクト: gridmaster/DCMapper
        // This initializes the IOC Container and implements
        // the singleton pattern.
        private static void InitializeDiContainer()
        {
            NinjectSettings settings = new NinjectSettings
            {
                LoadExtensions = false
            };

            // change DesignTimeModule to run other implementation ProductionModule || DebugModule
            IOCContainer.Instance.Initialize(settings, new DebugModule());
        }
コード例 #42
0
ファイル: TestBase.cs プロジェクト: robrich/NAntTasks
 public void SetupMockRepository()
 {
     // MockBehavior.Strict says "I have to impliment every use"
     // DefaultValue.Mock means "recursive fakes"
     NinjectSettings settings = new NinjectSettings();
     settings.SetMockBehavior( MockBehavior.Strict );
     this.kernel = new MoqMockingKernel( settings );
     this.mockRepository = this.kernel.MockRepository;
     this.mockRepository.DefaultValue = DefaultValue.Mock;
     this.MockServiceLocator = new MockServiceLocator( this.kernel );
 }
コード例 #43
0
ファイル: Program.cs プロジェクト: axle-h/Axh.PageTracker
 private static int Main(string[] args)
 {
     // Running this from directory with WebApi extension. Need to ensure we don't try to load it as we don't have a dependency on System.Web.
     var settings = new NinjectSettings { LoadExtensions = false };
     using (var kernel = new StandardKernel(settings, new SubProcessApplicationModule()))
     {
         var subProcess = kernel.Get<ISubProcessService>();
         var returnCode = subProcess.Initialize(args);
         return returnCode;
     }
 }
コード例 #44
0
        public void MocksAreStrictIfConfigured()
        {
            var settings = new NinjectSettings();
            settings.SetMockBehavior(MockBehavior.Strict);

            using (var kernel = new MoqMockingKernel(settings))
            {
                var mock = kernel.Get<IDummyService>();

                Assert.Throws<MockException>(() => mock.Do());
            }
        }
コード例 #45
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="configFilename"></param>
        public static void Initialize(string configFilename)
        {
            var _setting = new NinjectSettings();
            _setting.LoadExtensions = false;

            var _module = new XmlExtensionModule();
            _kernel = new StandardKernel(_setting, _module);

            if (_kernel != null)
            {
                _kernel.Load(configFilename);
            }
        }
コード例 #46
0
        protected override IKernel CreateKernel()
        {
            NinjectSettings settings = new NinjectSettings() { InjectNonPublic = true };

            Kernel = new StandardKernel(settings, new CoreBindingModule(), new DataAccessBindingModule());

            Kernel.Bind<HttpContext>().ToMethod(ctx => HttpContext.Current).InTransientScope();
            Kernel.Bind<HttpContextBase>().ToMethod(ctx => new HttpContextWrapper(HttpContext.Current)).InTransientScope();

            _controllerFactory = new NinjectControllerFactory(Kernel);

            return Kernel;
        }
コード例 #47
0
        private void Bind()
        {
            var settings = new NinjectSettings { LoadExtensions = true };

            _kernel = new StandardKernel(settings);

            _kernel.Bind<IInterceptor>().To<LoggingInterceptor>();

            _kernel.Load(new DataModule(), new LoggerModule(), new BlackstoneDbModule(), new InventoryModule());
            _kernel.Load(new ServiceModule(GetLoggingInterceptor()));

            //_kernel.Get<OrdersController>();
        }
コード例 #48
0
        public void CanChangeTheInjectAttribute()
        {
            var settings = new NinjectSettings();

            settings.InjectAttribute.ShouldBe(typeof(InjectAttribute));

            settings.InjectAttribute = typeof (Weaponize);
            var kernel = new StandardKernel(settings);

            var murphy = kernel.Get<RoboCop>();

            murphy.LeftHand.ShouldBeNull();
            murphy.RightHand.ShouldNotBeNull();
        }
コード例 #49
0
        public void CanChangeTheInjectAttribute()
        {
            var settings = new NinjectSettings();

            Assert.That(settings.InjectAttribute.Name, Is.EqualTo("InjectAttribute"));

            settings.InjectAttribute = typeof (Weaponize);
            var kernel = new StandardKernel(settings);

            var murphy = kernel.Get<RoboCop>();

            Assert.That(murphy.LeftHand, Is.Null);
            Assert.That(murphy.RightHand, Is.Not.Null);
        }
コード例 #50
0
ファイル: Test.cs プロジェクト: iringtools/sp_3d
        public SP3DDataLayerTest()
        {
            _settings = new NameValueCollection();

            _settings["XmlPath"] = @".\12345_000\";
            _settings["ProjectName"] = "12345_000";
            _settings["ApplicationName"] = "SP3D";

            _baseDirectory = Directory.GetCurrentDirectory();
            _baseDirectory = _baseDirectory.Substring(0, _baseDirectory.LastIndexOf("\\bin"));
            _settings["BaseDirectoryPath"] = _baseDirectory;
            Directory.SetCurrentDirectory(_baseDirectory);

            _adapterSettings = new AdapterSettings();
            _adapterSettings.AppendSettings(_settings);

            string appSettingsPath = String.Format("{0}12345_000.SP3D.config",
                _adapterSettings["XmlPath"]
            );

            if (File.Exists(appSettingsPath))
            {
                AppSettingsReader appSettings = new AppSettingsReader(appSettingsPath);
                _adapterSettings.AppendSettings(appSettings);
            }

            var ninjectSettings = new NinjectSettings { LoadExtensions = false };
            _kernel = new StandardKernel(ninjectSettings);

            _kernel.Load(new XmlExtensionModule());

            string relativePath = String.Format(@"{0}BindingConfiguration.{1}.{2}.xml",
            _settings["XmlPath"],
            _settings["ProjectName"],
            _settings["ApplicationName"]
              );

            //Ninject Extension requires fully qualified path.
            string bindingConfigurationPath = Path.Combine(
              _settings["BaseDirectoryPath"],
              relativePath
            );

            _kernel.Load(bindingConfigurationPath);

               // _sp3dDataLayer = _kernel.Get<SP3DDataLayer>(); This will reset the new updated adaptersettings with default values.

            _sp3dDataLayer = new SP3DDataLayer(_adapterSettings);
        }
コード例 #51
0
ファイル: TestBase.cs プロジェクト: robrich/BetaSigmaPhi
        public void SetupMockRepository()
        {
            // MockBehavior.Strict says "I have to impliment every use"
            // DefaultValue.Mock means "recursive fakes"
            MockBehavior mockBehavior = MockBehavior.Strict;
            DefaultValue defaultValue = DefaultValue.Mock;

            // Ninject, why you gotta make this so hard?
            NinjectSettings settings = new NinjectSettings();
            settings.SetMockBehavior( mockBehavior );
            MoqMockingKernel kernel = new MoqMockingKernel( settings );
            kernel.MockRepository.DefaultValue = defaultValue;

            // Initialize the mock service locator
            this.MockServiceLocator = new MockServiceLocator( kernel, mockBehavior );
        }
コード例 #52
0
 /// <summary>
 /// Creates the kernel that will manage your application.
 /// </summary>
 /// <returns>The created kernel.</returns>
 private static IKernel CreateKernel()
 {
     INinjectSettings settings = new NinjectSettings
     {
         UseReflectionBasedInjection = true,
         InjectNonPublic = false,
         InjectParentPrivateProperties = false,
         //LoadExtensions = false
     };
     var kernel = new StandardKernel(settings);
     kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
     kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
     RegisterServices(kernel);
     GlobalConfiguration.Configuration.DependencyResolver = new TheFlow.IoC.LocalNinjectDependencyResolver(kernel);
     return kernel;
 }
コード例 #53
0
ファイル: NinjectWebCommon.cs プロジェクト: TDevs/2014_TBS
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            INinjectSettings settings = new NinjectSettings
            {
                UseReflectionBasedInjection = true,    // disable code generation for partial trust
                InjectNonPublic = false,               // disable private reflection for partial trust
                InjectParentPrivateProperties = false, // reduce magic
                LoadExtensions = false                 // reduce magic
            };

            var kernel = new StandardKernel(settings);
            kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
            kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

            RegisterServices(kernel);
            DependencyResolver.SetResolver(new NinjectDependencyResolver(kernel));
            return kernel;
        }
コード例 #54
0
        public void InstancesAreDisposedViaOnePerRequestModule()
        {
            var settings = new NinjectSettings { CachePruningInterval = TimeSpan.MaxValue };
            var kernel = new StandardKernel(settings);
            kernel.Bind<ITool>().To<Hammer>().InRequestScope();

            StartNewHttpRequest();

            var instance = kernel.Get<ITool>();

            instance.ShouldNotBeNull();
            instance.ShouldBeInstanceOf<Hammer>();

            var opr = new OnePerRequestModule();
            opr.DeactivateInstancesForCurrentHttpRequest();

            instance.IsDisposed.ShouldBeTrue();
        }
コード例 #55
0
 /// <summary>
 /// Creates the kernel that will manage your application.
 /// </summary>
 /// <returns>The created kernel.</returns>
 private static IKernel CreateKernel()
 {
     //var kernel = new StandardKernel();
     var settings = new NinjectSettings { LoadExtensions = false };
     var kernel = new StandardKernel(settings, new XmlExtensionModule());
     try
     {
         kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
         kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();
         RegisterServices(kernel);
         GlobalConfiguration.Configuration.DependencyResolver =
             new NinjectDependencyResolver(kernel);
         return kernel;
     }
     catch (Exception ex)
     {
         kernel.Dispose();
         throw;
     }
 }
コード例 #56
0
        /// <summary>
        /// Creates the kernel that will manage your application.
        /// </summary>
        /// <returns>The created kernel.</returns>
        private static IKernel CreateKernel()
        {
            var settings = new NinjectSettings();
            settings.LoadExtensions = true; //enable automatic extension load
            settings.ExtensionSearchPatterns = settings.ExtensionSearchPatterns.Union(new string[] { "StartUpMentor.*.dll" }).ToArray(); //search path for extension loading
            var kernel = new StandardKernel(settings);
            try
            {
                kernel.Bind<Func<IKernel>>().ToMethod(ctx => () => new Bootstrapper().Kernel);
                kernel.Bind<IHttpModule>().To<HttpApplicationInitializationHttpModule>();

                RegisterServices(kernel);
                return kernel;
            }
            catch
            {
                kernel.Dispose();
                throw;
            }
        }
コード例 #57
0
        public void RequestScopeReturnsTheSameInstanceForAHttpRequest()
        {
            StartNewHttpRequest();

            var settings = new NinjectSettings { CachePruningInterval = TimeSpan.MaxValue };
            var kernel = new StandardKernel(settings);
            kernel.Bind<ITool>().To<Hammer>().InRequestScope();

            var tool1 = kernel.Get<ITool>();
            var tool2 = kernel.Get<ITool>();

            tool1.ShouldBe(tool2);

            StartNewHttpRequest();

            GC.Collect();
            GC.WaitForPendingFinalizers();

            var tool3 = kernel.Get<ITool>();

            tool1.ShouldNotBe(tool3);
        }
コード例 #58
0
        public void InstancesAreDisposedWhenRequestEndsAndCacheIsPruned()
        {
            var settings = new NinjectSettings { CachePruningInterval = TimeSpan.MaxValue };
            var kernel = new StandardKernel(settings);

            kernel.Bind<ITool>().To<Hammer>().InRequestScope();
            var cache = kernel.Components.Get<ICache>();

            StartNewHttpRequest();

            var instance = kernel.Get<ITool>();

            instance.ShouldNotBeNull();
            instance.ShouldBeInstanceOf<Hammer>();

            StartNewHttpRequest();

            GC.Collect();
            GC.WaitForPendingFinalizers();

            cache.Prune();

            instance.IsDisposed.ShouldBeTrue();
        }
コード例 #59
0
        public void TestFixtureSetUp()
        {
            EnvironmentSetup();

            var settings = new NinjectSettings()
            {
                LoadExtensions = false
            };

            kernel = new StandardKernel(
                settings,
                new Log4NetModule(),
                new DependencyModule());

            exporter = kernel.Get<FolderItemExporter>();

            folderItems = new List<FolderItem>()
            {
                new FolderItem()
                {
                    Name = "Reports",
                    Path = "/SSRSMigrate_AW_Tests/Reports",
                },
                new FolderItem()
                {
                    Name = "Sub Folder",
                    Path = "/SSRSMigrate_AW_Tests/Reports/Sub Folder",
                },
                new FolderItem()
                {
                    Name = "Data Sources",
                    Path = "/SSRSMigrate_AW_Tests/Data Sources",
                }
            };

            outputPath = GetOutPutPath();
        }
コード例 #60
0
ファイル: RequestScopeTests.cs プロジェクト: ALyman/ninject
 public RequestScopeContext()
 {
     var settings = new NinjectSettings { CachePruningInterval = TimeSpan.MaxValue };
     kernel = new StandardKernel(settings);
 }