private void PerformOneTimeInitializationIfNecessary(HttpContext context) { locker.AcquireReaderLock(Timeout.Infinite); if (mrContainer != null) { locker.ReleaseReaderLock(); return; } locker.UpgradeToWriterLock(Timeout.Infinite); if (mrContainer != null) // remember remember the race condition { locker.ReleaseWriterLock(); return; } try { if (configuration == null) { configuration = ObtainConfiguration(context.ApplicationInstance); } var userServiceProvider = serviceProviderLocator.LocateProvider(); mrContainer = CreateDefaultMonoRailContainer(userServiceProvider, context.ApplicationInstance); } finally { locker.ReleaseWriterLock(); } }
/// <summary> /// Implementors can take a chance to change MonoRail's configuration. /// </summary> /// <param name="configuration">The configuration.</param> public void Configure(IMonoRailConfiguration configuration) { configuration.JSGeneratorConfiguration.AddLibrary("jquery-1.6", typeof(JQueryGenerator)) .AddExtension(typeof(CommonJSExtension)) .BrowserValidatorIs(typeof(JQueryValidator)) .SetAsDefault(); }
IMonoRailConfiguration ObtainConfiguration(HttpApplication appInstance) { IMonoRailConfiguration config = MonoRailConfiguration.GetConfig(); MethodInfo method = appInstance.GetType().GetMethod("MonoRail_Configure"); if (method != null) { config = config ?? new MonoRailConfiguration(); if (method.IsStatic) { method.Invoke(null, new object[] { config }); } else { method.Invoke(appInstance, new object[] { config }); } } if (config == null) { throw new ApplicationException("You have to provide a small configuration to use MonoRail. This can be done using the web.config or your global asax (your class that extends HttpApplication) through the method MonoRail_Configure(IMonoRailConfiguration config). Check the samples or the documentation."); } return(config); }
/// <summary> /// Services the specified service provider. /// </summary> /// <param name="serviceProvider">The service provider.</param> public void Service(IServiceProvider serviceProvider) { provider = serviceProvider; config = (IMonoRailConfiguration)provider.GetService(typeof(IMonoRailConfiguration)); Initialize(); }
public override void Service(IServiceProvider provider) { base.Service(provider); monoRailConfiguration = (IMonoRailConfiguration)provider.GetService(typeof(IMonoRailConfiguration)); Initialize(); }
/// <summary> /// Resets the state (only used from test cases) /// </summary> public void ResetState() { configuration = null; mrContainer = null; urlTokenizer = null; engineContextFactory = null; serviceProviderLocator = null; controllerFactory = null; controllerContextFactory = null; staticResourceRegistry = null; }
public void ResetState() { _Configuration = null; _MonoRailContainer = null; _UrlTokenizer = null; _EngineContextFactory = null; _ServiceProviderLocator = null; _ControllerFactory = null; _ControllerContextFactory = null; _StaticResourceRegistry = null; }
/*----------------------------------------------------------------------------------------*/ #region Public Methods /// <summary> /// Initializes the controller factory by searching the configured assemblies for defined controllers. /// </summary> public void Initialize() { IMonoRailConfiguration config = MonoRailConfiguration.GetConfig(); if (config != null) { foreach (string assembly in config.ControllersConfig.Assemblies) { Inspect(assembly); } } }
public void Configure(IMonoRailConfiguration configuration) { configuration.ControllersConfig.AddAssembly(Assembly.GetExecutingAssembly()); configuration.ViewEngineConfig.ViewPathRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views"); configuration.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(AspViewEngine), false)); configuration.JSGeneratorConfiguration .AddLibrary("jquery-1.3.1", typeof(JQueryGenerator)) .AddExtension(typeof(CommonJSExtension)).ElementGenerator .AddExtension(typeof(JQueryElementGenerator)) .Done .BrowserValidatorIs(typeof(JQueryValidator)) .SetAsDefault(); }
public void Configure(IMonoRailConfiguration config) { config.ControllersConfig.AddAssembly(typeof(Global).Assembly); config.ViewEngineConfig.ViewPathRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views"); config.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(NVelocityViewEngine), false)); config.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(WebFormsViewEngine), false)); config.ExtensionEntries.Add(new ExtensionEntry(typeof(ExceptionChainingExtension), null)); MutableConfiguration configSection = new MutableConfiguration("monorail"); IConfiguration exceptionNode = configSection.Children.Add(new MutableConfiguration("exception")); exceptionNode.Children.Add(new MutableConfiguration("handler")).Attributes["type"] = typeof(LocalExceptionFilterHandler).FullName; config.ConfigurationSection = configSection; }
/// <summary> /// Configures the specified config. /// </summary> /// <param name="config">The config.</param> public void Configure(IMonoRailConfiguration config) { if (config == null) { throw new ArgumentNullException("config"); } AddService <IMonoRailConfiguration>(config); if (config.ServicesConfig != null) { foreach (var serviceConfig in config.ServicesConfig.Children) { RegisterServiceOverrideFromConfigurationNode(serviceConfig); } } if (!HasService <IScaffoldingSupport>() && config.ScaffoldConfig.ScaffoldImplType != null) { AddService <IScaffoldingSupport>(Activator.CreateInstance(config.ScaffoldConfig.ScaffoldImplType)); } }
void PerformOneTimeInitializationIfNecessary(HttpContext context) { _Locker.AcquireReaderLock(-1); if (_MonoRailContainer != null) { _Locker.ReleaseReaderLock(); } else { _Locker.UpgradeToWriterLock(-1); if (_MonoRailContainer != null) { _Locker.ReleaseWriterLock(); } else { try { if (_Configuration == null) { _Configuration = ObtainConfiguration(context.ApplicationInstance); } IServiceProviderEx userServiceProvider = _ServiceProviderLocator.LocateProvider(); _MonoRailContainer = CreateDefaultMonoRailContainer( userServiceProvider, context.ApplicationInstance); } finally { _Locker.ReleaseWriterLock(); } } } }
private IMonoRailConfiguration ObtainConfiguration(HttpApplication appInstance) { IMonoRailConfiguration config = MonoRailConfiguration.GetConfig(); var events = appInstance as IMonoRailConfigurationEvents; if (events != null) { config = config ?? new MonoRailConfiguration(); events.Configure(config); } if (config == null) { throw new ApplicationException("You have to provide a small configuration to use " + "MonoRail. This can be done using the web.config or " + "your global asax (your class that extends HttpApplication) " + "through the method MonoRail_Configure(IMonoRailConfiguration config). " + "Check the samples or the documentation."); } return(config); }
/// <summary> /// Reads the attribute <c>customSession</c> /// from <see cref="MonoRailConfiguration"/> and /// instantiate it based on the type name provided. /// </summary> /// <exception cref="ConfigurationException"> /// If the typename was not provided or the type /// could not be instantiated/found /// </exception> /// <param name="manager">The Extension Manager</param> /// <param name="configuration">The configuration</param> private void Init(ExtensionManager manager, IMonoRailConfiguration configuration) { manager.AcquireSessionState += OnAdquireSessionState; manager.ReleaseSessionState += OnReleaseSessionState; var customSessionAtt = configuration.ConfigurationSection.Attributes["customSession"]; if (customSessionAtt == null) { var message = "The CustomSessionExtension requires that " + "the type that implements ICustomSessionFactory be specified through the " + "'customSession' attribute on 'monorail' configuration node"; throw new ConfigurationErrorsException(message); } var customSessType = TypeLoadUtil.GetType(customSessionAtt); if (customSessType == null) { var message = "The Type for the custom session could not be loaded. " + customSessionAtt; throw new ConfigurationErrorsException(message); } try { customSession = (ICustomSessionFactory) Activator.CreateInstance(customSessType); } catch(InvalidCastException) { var message = "The Type for the custom session must " + "implement ICustomSessionFactory. " + customSessionAtt; throw new ConfigurationErrorsException(message); } }
/// <summary> /// Reads the attribute <c>customSession</c> /// from <see cref="MonoRailConfiguration"/> and /// instantiate it based on the type name provided. /// </summary> /// <exception cref="ConfigurationException"> /// If the typename was not provided or the type /// could not be instantiated/found /// </exception> /// <param name="manager">The Extension Manager</param> /// <param name="configuration">The configuration</param> private void Init(ExtensionManager manager, IMonoRailConfiguration configuration) { manager.AcquireSessionState += OnAdquireSessionState; manager.ReleaseSessionState += OnReleaseSessionState; var customSessionAtt = configuration.ConfigurationSection.Attributes["customSession"]; if (customSessionAtt == null) { var message = "The CustomSessionExtension requires that " + "the type that implements ICustomSessionFactory be specified through the " + "'customSession' attribute on 'monorail' configuration node"; throw new ConfigurationErrorsException(message); } var customSessType = TypeLoadUtil.GetType(customSessionAtt); if (customSessType == null) { var message = "The Type for the custom session could not be loaded. " + customSessionAtt; throw new ConfigurationErrorsException(message); } try { customSession = (ICustomSessionFactory)Activator.CreateInstance(customSessType); } catch (InvalidCastException) { var message = "The Type for the custom session must " + "implement ICustomSessionFactory. " + customSessionAtt; throw new ConfigurationErrorsException(message); } }
public void Configure(IMonoRailConfiguration configuration) { configuration.ViewEngineConfig.ViewPathRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views"); configuration.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(NVelocityViewEngine), false)); }
/// <summary> /// Configures the specified config. /// </summary> /// <param name="config">The config.</param> public void Configure( IMonoRailConfiguration config ) { if( config == null ) throw new ArgumentNullException( "config" ); AddService<IMonoRailConfiguration>( config ); if( config.ServicesConfig != null ) { foreach( var serviceConfig in config.ServicesConfig.Children ) { RegisterServiceOverrideFromConfigurationNode( serviceConfig ); } } if( !HasService<IScaffoldingSupport>() && config.ScaffoldConfig.ScaffoldImplType != null ) { AddService<IScaffoldingSupport>( Activator.CreateInstance( config.ScaffoldConfig.ScaffoldImplType ) ); } }
public override void Service(IServiceProvider provider) { base.Service(provider); monoRailConfiguration = (IMonoRailConfiguration)provider.GetService(typeof(IMonoRailConfiguration)); }
public void Configure(IMonoRailConfiguration configuration) { foreach (var pluginAssembly in pluginAssemblies) { var assemblyName = pluginAssembly.GetName().Name; try { configuration.ViewEngineConfig.AssemblySources.Add(new AssemblySourceInfo(assemblyName, assemblyName + ".Views")); } catch(Exception) { } } // Get MonoRail to use jQuery configuration.JSGeneratorConfiguration.AddLibrary("jquery-1.2.6", typeof(JQueryGenerator)) .AddExtension(typeof(CommonJSExtension)) .BrowserValidatorIs(typeof(JQueryValidator)) .SetAsDefault(); }
public void Configure(IMonoRailConfiguration configuration) { configuration.JSGeneratorConfiguration.AddLibrary("jquery-1.8.2", typeof(JQueryGenerator)).AddExtension( typeof(CommonJSExtension)).ElementGenerator.AddExtension(typeof(JQueryElementGenerator)).Done. BrowserValidatorIs(typeof(JQueryValidator)).SetAsDefault(); }
/// <summary> /// Services the specified service provider. /// </summary> /// <param name="serviceProvider">The service provider.</param> public void Service(IServiceProvider serviceProvider) { provider = serviceProvider; config = (IMonoRailConfiguration) provider.GetService(typeof(IMonoRailConfiguration)); Initialize(); }
void PerformOneTimeInitializationIfNecessary( HttpContext context ) { _Locker.AcquireReaderLock( -1 ); if ( _MonoRailContainer != null ) { _Locker.ReleaseReaderLock(); } else { _Locker.UpgradeToWriterLock( -1 ); if ( _MonoRailContainer != null ) { _Locker.ReleaseWriterLock(); } else { try { if ( _Configuration == null ) { _Configuration = ObtainConfiguration( context.ApplicationInstance ); } IServiceProviderEx userServiceProvider = _ServiceProviderLocator.LocateProvider(); _MonoRailContainer = CreateDefaultMonoRailContainer( userServiceProvider, context.ApplicationInstance ); } finally { _Locker.ReleaseWriterLock(); } } } }
private static void SetupBrailViewEngine(IMonoRailConfiguration configuration) { var viewEngineConfig = configuration.ViewEngineConfig; viewEngineConfig.ViewPathRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views"); viewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(BooViewEngine), false)); }
public void Configure(IMonoRailConfiguration configuration) { configuration.ControllersConfig.AddAssembly(Assembly.GetExecutingAssembly()); configuration.ViewEngineConfig.ViewPathRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views"); configuration.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(BooViewEngine), false)); }
public void Configure(IMonoRailConfiguration configuration) { }
public void Configure(IMonoRailConfiguration configuration) { SetupBrailViewEngine(configuration); }