Beispiel #1
0
        public static WindsorContainer ConfigureWindsor(IConfiguration Configuration)
        {
            var container = new WindsorContainer();

            container.Register(Component.For <ISessionSource>().ImplementedBy <AspNetCoreNHibernateSessionSource>().LifeStyle.Scoped());

            WindsorIoC.Initialize(container);
            container.RegisterComponents();

            var configurationSection = Configuration.GetSection("AppSettings");
            var collection           = new NameValueCollection();

            foreach (var appSetting in configurationSection.GetChildren())
            {
                collection.Add(appSetting.Key, appSetting.Value);
            }

            container.Register(Component.For <ApplicationSettingsProvider>().ImplementedBy <ApplicationSettingsProvider>()
                               .DynamicParameters((k, d) => d.Add("collection", collection))
                               .LifeStyle.Singleton);

            container.Install(new LoggerWindsorInstaller());
            container.Install(new EdugameCloud.Core.Logging.LoggerWindsorInstaller());

            RegisterLtiComponents(container);

            return(container);
        }
        private static IServiceLocator BuildLocator()
        {
            var container = new WindsorContainer();

            container.RegisterComponents(typeof(IFoo).Assembly);

            return new WindsorServiceLocator(container);
        }
Beispiel #3
0
        public static void Init()
        {
            var container = new WindsorContainer();

            IoC.Initialize(container);
            container.RegisterComponents(console: true);
            RegisterLtiComponents(container);

            container.Register(Component.For <ILog>().ImplementedBy <ConsoleLog>());
        }
Beispiel #4
0
        public static void Init()
        {
            var container = new WindsorContainer();

            IoC.Initialize(container);
            container.RegisterComponents(console: true);
            container.Install(new LoggerWindsorInstaller());
            container.Install(new EdugameCloud.Core.Logging.LoggerWindsorInstaller());
            RegisterLtiComponents(container);

            container.Register(Component.For <ILog>().ImplementedBy <ConsoleLog>());
        }
Beispiel #5
0
        protected void Application_Start()
        {
            var container = new WindsorContainer();

            WindsorIoC.Initialize(container);

            container.RegisterComponents();
            RegisterComponentsWeb(container);
            container.Install(new Esynctraining.CastleLog4Net.LoggerWindsorInstaller());
            container.Install(new EdugameCloud.Core.Logging.LoggerWindsorInstaller());
            RegisterLtiComponents(container);
            RegisterLocalComponents(container);

            GlobalConfiguration.Configure(WebApiConfig.Register);
            GlobalConfiguration.Configuration.Services.Replace(
                typeof(IHttpControllerActivator),
                new ServiceLocatorControllerActivator(new WindsorServiceLocator(container)));
        }
Beispiel #6
0
        protected void Application_Start()
        {
            var webformVE = ViewEngines.Engines.OfType <WebFormViewEngine>().FirstOrDefault();

            ViewEngines.Engines.Remove(webformVE);

            var container = new WindsorContainer();

            WindsorIoC.Initialize(container);

            container.RegisterComponents();
            RegisterLtiComponents(container);
            RegisterComponentsWeb(container);
            container.Install(new LoggerWindsorInstaller());
            container.Install(new EdugameCloud.Core.Logging.LoggerWindsorInstaller());
            RegisterLocalComponents(container);
            RegisterHttpClient(container);
            SetControllerFactory(container);
            AreaRegistration.RegisterAllAreas();
            var modelBinders = container.ResolveAll(typeof(BaseModelBinder));

            foreach (var binder in modelBinders)
            {
                var modelBinder = (BaseModelBinder)binder;
                if (modelBinder.BinderTypes != null)
                {
                    foreach (var binderType in modelBinder.BinderTypes)
                    {
                        ModelBinders.Binders.Add(binderType, modelBinder);
                    }
                }
            }

            DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
            ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new WindsorValidatorFactory(new WindsorServiceLocator(container), IoC.Resolve <ILogger>())));
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            DefaultModelBinder.ResourceClassKey = "Errors";
            MvcHandler.DisableMvcResponseHeader = true;

            string pathPropertiesPath = this.GetPathPropertiesPath();

            container.Register(Component.For <FlexSettingsProvider>().ImplementedBy <FlexSettingsProvider>().DynamicParameters((k, d) => d.Add("collection", FlexSettingsProvider.ReadSettings(pathPropertiesPath))).LifeStyle.Singleton);
        }
Beispiel #7
0
        /// <summary>
        /// The application_ start.
        /// </summary>
        protected void Application_Start()
        {
            var webformVE = ViewEngines.Engines.OfType <WebFormViewEngine>().FirstOrDefault();

            ViewEngines.Engines.Remove(webformVE);

            var container = new WindsorContainer();

            WindsorIoC.Initialize(container);

            container.RegisterComponents();
            RegisterComponentsWeb(container);
            container.Install(new LoggerWindsorInstaller());
            container.Install(new Esynctraining.Core.Logging.CastleLogger.LoggerWindsorInstaller());
            RegisterLocalComponents(container);

            SetControllerFactory(container);
            AreaRegistration.RegisterAllAreas();
            //var modelBinders = container.ResolveAll(typeof(BaseModelBinder));
            //foreach (var binder in modelBinders)
            //{
            //    var modelBinder = (BaseModelBinder)binder;
            //    if (modelBinder.BinderTypes != null)
            //    {
            //        foreach (var binderType in modelBinder.BinderTypes)
            //        {
            //            ModelBinders.Binders.Add(binderType, modelBinder);
            //        }
            //    }
            //}

            DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
            ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new WindsorValidatorFactory(new WindsorServiceLocator(container), IoC.Resolve <ILogger>())));
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            DefaultModelBinder.ResourceClassKey = "Errors";
            MvcHandler.DisableMvcResponseHeader = true;

            AuthConfig.RegisterAuth(container.Resolve <ApplicationSettingsProvider>());
        }
Beispiel #8
0
        protected void Application_Start()
        {
            var webformVE = ViewEngines.Engines.OfType <WebFormViewEngine>().FirstOrDefault();

            ViewEngines.Engines.Remove(webformVE);

            var container = new WindsorContainer();

            WindsorIoC.Initialize(container);

            container.RegisterComponents();
            RegisterComponentsWeb(container);
            container.Install(new LoggerWindsorInstaller());
            container.Install(new EdugameCloud.Core.Logging.LoggerWindsorInstaller());
            RegisterLtiComponents(container);
            //RegisterLocalComponents(container);

            SetControllerFactory(container);
            AreaRegistration.RegisterAllAreas();

            //var modelBinders = container.ResolveAll(typeof(BaseModelBinder));
            //foreach (var binder in modelBinders)
            //{
            //    var modelBinder = (BaseModelBinder)binder;
            //    if (modelBinder.BinderTypes != null)
            //    {
            //        foreach (var binderType in modelBinder.BinderTypes)
            //        {
            //            ModelBinders.Binders.Add(binderType, modelBinder);
            //        }
            //    }
            //}

            DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;
            //ModelValidatorProviders.Providers.Add(new FluentValidationModelValidatorProvider(new WindsorValidatorFactory(new WindsorServiceLocator(container), IoC.Resolve<ILogger>())));
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            DefaultModelBinder.ResourceClassKey = "Errors";
            MvcHandler.DisableMvcResponseHeader = true;

            AuthConfig.RegisterAuth(container.Resolve <ApplicationSettingsProvider>(), container.Resolve <IHttpClientFactory>());


            GlobalConfiguration.Configure(WebApiConfig.Register);
            GlobalConfiguration.Configuration.Services.Replace(
                typeof(IHttpControllerActivator),
                new ServiceLocatorControllerActivator(new WindsorServiceLocator(container)));

            // TRICK: remove all files on start
            CachePolicies.InvalidateCache();

            ServicePointManager.DefaultConnectionLimit = int.Parse(ConfigurationManager.AppSettings["DefaultConnectionLimit"]);
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            ServicePointManager.SecurityProtocol =
                SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;

            //hack - to use parameterized Resolve in LmsFactory. Must be removed when corresponding methods are added to IoC and IServiceLocator
            if (!container.Kernel.HasComponent(typeof(IWindsorContainer)))
            {
                container.Register((IRegistration)Component.For <IWindsorContainer>().Instance(container).LifestyleSingleton());
            }
        }