Пример #1
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            // configure required providers using out-of-the-box implementations
            var localizationFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "localization.xml");
            var valueProvider = new XmlValueProvider(localizationFilePath, true);
            var notifier = new ExceptionNotifier();
            var localeProvider = new MvcLocaleProvider("en", "nl");
            var partProvider = new MvcPartProvider(new Part("General"));
            var logger = new VoidLogger();

            kernel.Bind<String>().ToConstant("flar");

            // bind all required providers as singletons
            kernel.Bind<ILocalizedValueProvider>().ToConstant(valueProvider).InSingletonScope();
            kernel.Bind<INotifier>().ToConstant(notifier).InSingletonScope();
            kernel.Bind<ILocaleProvider>().ToConstant(localeProvider).InSingletonScope();
            kernel.Bind<IPartProvider>().ToConstant(partProvider).InSingletonScope();
            kernel.Bind<ILocalizationLogger>().ToConstant(logger).InSingletonScope();

            // set up the repository and context, this is actually our goal here!
            kernel.Bind<LocalizationRepository>().ToSelf().InRequestScope();
            kernel.Bind<ILocalizationContext>().To<AlwaysDebuggingContext>().InRequestScope();
        }
Пример #2
0
        /// <summary>
        /// Load your modules or register your services here!
        /// </summary>
        /// <param name="kernel">The kernel.</param>
        private static void RegisterServices(IKernel kernel)
        {
            // configure required providers using out-of-the-box implementations
            var localizationFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "localization.xml");
            var valueProvider        = new XmlValueProvider(localizationFilePath, true);
            var notifier             = new ExceptionNotifier();
            var localeProvider       = new MvcLocaleProvider("en", "nl");
            var partProvider         = new MvcPartProvider(new Part("General"));
            var logger = new VoidLogger();

            kernel.Bind <String>().ToConstant("flar");

            // bind all required providers as singletons
            kernel.Bind <ILocalizedValueProvider>().ToConstant(valueProvider).InSingletonScope();
            kernel.Bind <INotifier>().ToConstant(notifier).InSingletonScope();
            kernel.Bind <ILocaleProvider>().ToConstant(localeProvider).InSingletonScope();
            kernel.Bind <IPartProvider>().ToConstant(partProvider).InSingletonScope();
            kernel.Bind <ILocalizationLogger>().ToConstant(logger).InSingletonScope();

            // set up the repository and context, this is actually our goal here!
            kernel.Bind <LocalizationRepository>().ToSelf().InRequestScope();
            kernel.Bind <ILocalizationContext>().To <AlwaysDebuggingContext>().InRequestScope();
        }