コード例 #1
0
        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();
            }
        }
コード例 #2
0
 /// <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();
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        /// <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();
        }
コード例 #5
0
        public override void Service(IServiceProvider provider)
        {
            base.Service(provider);

            monoRailConfiguration = (IMonoRailConfiguration)provider.GetService(typeof(IMonoRailConfiguration));

            Initialize();
        }
コード例 #6
0
 /// <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;
 }
コード例 #7
0
 public void ResetState()
 {
     _Configuration            = null;
     _MonoRailContainer        = null;
     _UrlTokenizer             = null;
     _EngineContextFactory     = null;
     _ServiceProviderLocator   = null;
     _ControllerFactory        = null;
     _ControllerContextFactory = null;
     _StaticResourceRegistry   = null;
 }
コード例 #8
0
        /*----------------------------------------------------------------------------------------*/
        #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);
                }
            }
        }
コード例 #9
0
        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();
        }
コード例 #10
0
		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;
		}
コード例 #11
0
        /// <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));
            }
        }
コード例 #12
0
        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();
                    }
                }
            }
        }
コード例 #13
0
        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);
        }
コード例 #14
0
		/// <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);
			}
		}
コード例 #15
0
        /// <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);
            }
        }
コード例 #16
0
 public void Configure(IMonoRailConfiguration configuration)
 {
     configuration.ViewEngineConfig.ViewPathRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views");
     configuration.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(NVelocityViewEngine), false));
 }
コード例 #17
0
		/// <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 ) );
			}
		}
コード例 #18
0
		public override void Service(IServiceProvider provider)
		{
			base.Service(provider);

			monoRailConfiguration = (IMonoRailConfiguration)provider.GetService(typeof(IMonoRailConfiguration));
		}
コード例 #19
0
        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();
        }
コード例 #20
0
		/// <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;
		}
コード例 #21
0
 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();
 }
コード例 #22
0
		/// <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();
		}
コード例 #23
0
		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();
					}
				}
			}
		}
コード例 #24
0
 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));
 }
コード例 #25
0
 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));
 }
コード例 #26
0
ファイル: Global.asax.cs プロジェクト: sclaughl/NhDynamicCrud
 public void Configure(IMonoRailConfiguration configuration)
 {
     configuration.ViewEngineConfig.ViewPathRoot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Views");
     configuration.ViewEngineConfig.ViewEngines.Add(new ViewEngineInfo(typeof(NVelocityViewEngine), false));
 }
コード例 #27
0
 public void Configure(IMonoRailConfiguration configuration)
 {
     
 }
コード例 #28
0
		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();
			}
		}
コード例 #29
0
 public void Configure(IMonoRailConfiguration configuration)
 {
     SetupBrailViewEngine(configuration);
 }
コード例 #30
0
		public void ResetState()
		{
			_Configuration = null;
			_MonoRailContainer = null;
			_UrlTokenizer = null;
			_EngineContextFactory = null;
			_ServiceProviderLocator = null;
			_ControllerFactory = null;
			_ControllerContextFactory = null;
			_StaticResourceRegistry = null;
		}