void FireContainerInitialized(HttpApplication instance, DefaultMonoRailContainer container) { ExecuteContainerEvent( instance.GetType().GetMethod("MonoRail_ContainerInitialized"), instance, container); }
/// <summary> /// Creates the default service container. /// </summary> /// <param name="userServiceProvider">The user service provider.</param> /// <param name="appInstance">The app instance.</param> /// <returns></returns> protected virtual IMonoRailContainer CreateDefaultMonoRailContainer(IServiceProviderEx userServiceProvider, HttpApplication appInstance) { var container = new DefaultMonoRailContainer(userServiceProvider); container.UseServicesFromParent(); container.InstallPrimordialServices(); container.Configure(Configuration); FireContainerCreated(appInstance, container); // Too dependent on Http and MR surroundings services to be moved to Container class if (!container.HasService <IServerUtility>()) { container.AddService <IServerUtility>(new ServerUtilityAdapter(appInstance.Context.Server)); } if (!container.HasService <IRoutingEngine>()) { container.AddService <IRoutingEngine>(RoutingModuleEx.Engine); } container.InstallMissingServices(); container.StartExtensionManager(); FireContainerInitialized(appInstance, container); return(container); }
private void FireContainerInitialized(HttpApplication instance, DefaultMonoRailContainer container) { var events = instance as IMonoRailContainerEvents; if (events != null) { events.Initialized(container); } }
public void Init() { _defaultMonoRailContainer = new DefaultMonoRailContainer(); _defaultMonoRailContainer.AddService<IUrlTokenizer>(new DefaultUrlTokenizer()); _defaultMonoRailContainer.AddService<IUrlBuilder>(new DefaultUrlBuilder()); _defaultMonoRailContainer.AddService<ICacheProvider>(new DefaultCacheProvider()); _defaultMonoRailContainer.AddService<IEngineContextFactory>(new DefaultEngineContextFactory()); _defaultMonoRailContainer.AddService<IControllerFactory>(new DefaultControllerFactory()); _defaultMonoRailContainer.AddService<IControllerContextFactory>(new DefaultControllerContextFactory()); _defaultMonoRailContainer.AddService<IControllerTree>(new DefaultControllerTree()); _defaultMonoRailContainer.AddService<IViewSourceLoader>(new FileAssemblyViewSourceLoader()); _defaultMonoRailContainer.AddService<IFilterFactory>(new DefaultFilterFactory()); _defaultMonoRailContainer.AddService<IControllerDescriptorProvider>(new DefaultControllerDescriptorProvider()); _defaultMonoRailContainer.AddService<IViewEngineManager>(new DefaultViewEngineManager()); _defaultMonoRailContainer.AddService<IValidatorRegistry>(new CachedValidationRegistry()); _defaultMonoRailContainer.AddService<IActionSelector>(new DefaultActionSelector()); _defaultMonoRailContainer.AddService<IScaffoldingSupport>(new StubScaffoldingSupport()); _defaultMonoRailContainer.AddService<IJSONSerializer>(new NewtonsoftJSONSerializer()); _defaultMonoRailContainer.AddService<IStaticResourceRegistry>(new DefaultStaticResourceRegistry()); _defaultMonoRailContainer.AddService<IEmailTemplateService>(new StubEmailTemplateService(new StubEngineContext())); _defaultMonoRailContainer.AddService<IEmailSender>(new StubSmtpSender(new StubEngineContext())); _defaultMonoRailContainer.AddService<IResourceFactory>(new DefaultResourceFactory()); _defaultMonoRailContainer.AddService<ITransformFilterFactory>(new DefaultTransformFilterFactory()); _defaultMonoRailContainer.AddService<IHelperFactory>(new DefaultHelperFactory()); _defaultMonoRailContainer.AddService<IServiceInitializer>(new DefaultServiceInitializer()); _defaultMonoRailContainer.AddService<IDynamicActionProviderFactory>(new DefaultDynamicActionProviderFactory()); _defaultMonoRailContainer.AddService<IAjaxProxyGenerator>(new PrototypeAjaxProxyGenerator()); _defaultMonoRailContainer.AddService<IDictionaryAdapterFactory>(new DictionaryAdapterFactory()); _serviceTypes.Add(typeof(IUrlTokenizer)); _serviceTypes.Add(typeof(IUrlBuilder)); _serviceTypes.Add(typeof(ICacheProvider)); _serviceTypes.Add(typeof(IEngineContextFactory)); _serviceTypes.Add(typeof(IControllerFactory)); _serviceTypes.Add(typeof(IControllerContextFactory)); _serviceTypes.Add(typeof(IControllerTree)); _serviceTypes.Add(typeof(IViewSourceLoader)); _serviceTypes.Add(typeof(IFilterFactory)); _serviceTypes.Add(typeof(IControllerDescriptorProvider)); _serviceTypes.Add(typeof(IViewEngineManager)); _serviceTypes.Add(typeof(IValidatorRegistry)); _serviceTypes.Add(typeof(IActionSelector)); _serviceTypes.Add(typeof(IScaffoldingSupport)); _serviceTypes.Add(typeof(IJSONSerializer)); _serviceTypes.Add(typeof(IStaticResourceRegistry)); _serviceTypes.Add(typeof(IEmailTemplateService)); _serviceTypes.Add(typeof(IEmailSender)); _serviceTypes.Add(typeof(IResourceFactory)); _serviceTypes.Add(typeof(ITransformFilterFactory)); _serviceTypes.Add(typeof(IHelperFactory)); _serviceTypes.Add(typeof(IServiceInitializer)); _serviceTypes.Add(typeof(IDynamicActionProviderFactory)); _serviceTypes.Add(typeof(IAjaxProxyGenerator)); _serviceTypes.Add(typeof(IDictionaryAdapterFactory)); }
public void Init() { _defaultMonoRailContainer = new DefaultMonoRailContainer(); _defaultMonoRailContainer.AddService <IUrlTokenizer>(new DefaultUrlTokenizer()); _defaultMonoRailContainer.AddService <IUrlBuilder>(new DefaultUrlBuilder()); _defaultMonoRailContainer.AddService <ICacheProvider>(new DefaultCacheProvider()); _defaultMonoRailContainer.AddService <IEngineContextFactory>(new DefaultEngineContextFactory()); _defaultMonoRailContainer.AddService <IControllerFactory>(new DefaultControllerFactory()); _defaultMonoRailContainer.AddService <IControllerContextFactory>(new DefaultControllerContextFactory()); _defaultMonoRailContainer.AddService <IControllerTree>(new DefaultControllerTree()); _defaultMonoRailContainer.AddService <IViewSourceLoader>(new FileAssemblyViewSourceLoader()); _defaultMonoRailContainer.AddService <IFilterFactory>(new DefaultFilterFactory()); _defaultMonoRailContainer.AddService <IControllerDescriptorProvider>(new DefaultControllerDescriptorProvider()); _defaultMonoRailContainer.AddService <IViewEngineManager>(new DefaultViewEngineManager()); _defaultMonoRailContainer.AddService <IValidatorRegistry>(new CachedValidationRegistry()); _defaultMonoRailContainer.AddService <IActionSelector>(new DefaultActionSelector()); _defaultMonoRailContainer.AddService <IScaffoldingSupport>(new StubScaffoldingSupport()); _defaultMonoRailContainer.AddService <IJSONSerializer>(new NewtonsoftJSONSerializer()); _defaultMonoRailContainer.AddService <IStaticResourceRegistry>(new DefaultStaticResourceRegistry()); _defaultMonoRailContainer.AddService <IEmailTemplateService>(new StubEmailTemplateService(new StubEngineContext())); _defaultMonoRailContainer.AddService <IEmailSender>(new StubSmtpSender(new StubEngineContext())); _defaultMonoRailContainer.AddService <IResourceFactory>(new DefaultResourceFactory()); _defaultMonoRailContainer.AddService <ITransformFilterFactory>(new DefaultTransformFilterFactory()); _defaultMonoRailContainer.AddService <IHelperFactory>(new DefaultHelperFactory()); _defaultMonoRailContainer.AddService <IServiceInitializer>(new DefaultServiceInitializer()); _defaultMonoRailContainer.AddService <IDynamicActionProviderFactory>(new DefaultDynamicActionProviderFactory()); _defaultMonoRailContainer.AddService <IAjaxProxyGenerator>(new PrototypeAjaxProxyGenerator()); _defaultMonoRailContainer.AddService <IDictionaryAdapterFactory>(new DictionaryAdapterFactory()); _serviceTypes.Add(typeof(IUrlTokenizer)); _serviceTypes.Add(typeof(IUrlBuilder)); _serviceTypes.Add(typeof(ICacheProvider)); _serviceTypes.Add(typeof(IEngineContextFactory)); _serviceTypes.Add(typeof(IControllerFactory)); _serviceTypes.Add(typeof(IControllerContextFactory)); _serviceTypes.Add(typeof(IControllerTree)); _serviceTypes.Add(typeof(IViewSourceLoader)); _serviceTypes.Add(typeof(IFilterFactory)); _serviceTypes.Add(typeof(IControllerDescriptorProvider)); _serviceTypes.Add(typeof(IViewEngineManager)); _serviceTypes.Add(typeof(IValidatorRegistry)); _serviceTypes.Add(typeof(IActionSelector)); _serviceTypes.Add(typeof(IScaffoldingSupport)); _serviceTypes.Add(typeof(IJSONSerializer)); _serviceTypes.Add(typeof(IStaticResourceRegistry)); _serviceTypes.Add(typeof(IEmailTemplateService)); _serviceTypes.Add(typeof(IEmailSender)); _serviceTypes.Add(typeof(IResourceFactory)); _serviceTypes.Add(typeof(ITransformFilterFactory)); _serviceTypes.Add(typeof(IHelperFactory)); _serviceTypes.Add(typeof(IServiceInitializer)); _serviceTypes.Add(typeof(IDynamicActionProviderFactory)); _serviceTypes.Add(typeof(IAjaxProxyGenerator)); _serviceTypes.Add(typeof(IDictionaryAdapterFactory)); }
public void UseServicesFromParent_WhenParentContainsRoutingEngineService_ServiceAddedToMonoRailContainer() { var engine = MockRepository.GenerateStub <IRoutingEngine>(); var parent = MockRepository.GenerateStub <IServiceProvider>(); parent.Stub(stub => stub.GetService(typeof(IRoutingEngine))).Return(engine); var container = new DefaultMonoRailContainer(parent); container.UseServicesFromParent(); Assert.True(container.HasService <IRoutingEngine>()); }
static void ExecuteContainerEvent(MethodInfo eventMethod, HttpApplication instance, DefaultMonoRailContainer container) { if (eventMethod != null) { if (eventMethod.IsStatic) { eventMethod.Invoke(null, new object[] { container }); } else { eventMethod.Invoke(instance, new object[] { container }); } } }
public void UseServicesFromParent_WhenParentContainsRoutingEngineService_ServiceAddedToMonoRailContainer() { IRoutingEngine engine = MockRepository.GenerateStub<IRoutingEngine>(); IServiceProvider parent = MockRepository.GenerateStub<IServiceProvider>(); parent.Stub(stub => stub.GetService(typeof(IRoutingEngine))).Return(engine); DefaultMonoRailContainer container = new DefaultMonoRailContainer(parent); container.UseServicesFromParent(); Assert.True(container.HasService<IRoutingEngine>()); }