Castle.MonoRail.Framework.ViewComponent.Init C# (CSharp) Method

Init() public method

Invoked by the framework.
public Init ( IRailsEngineContext engineContext, IViewComponentContext componentContext ) : void
engineContext IRailsEngineContext Request context
componentContext IViewComponentContext ViewComponent context
return void
		public void Init(IRailsEngineContext engineContext, IViewComponentContext componentContext)
		{
			railsContext = engineContext;
			context = componentContext;

			BindComponentParameters();

			Initialize();
		}

Usage Example

		/// <summary>
		/// Initialize the view component with mock services it needs to 
		/// be functional.
		/// </summary>
		/// <param name="component">The component instance.</param>
		protected void PrepareViewComponent(ViewComponent component)
		{
			if (Context == null)
			{
				BuildEngineContext("", "Controller", "Action");
			}

			viewEngine = BuildViewEngine();

			componentContext = BuildViewComponentContext(component.GetType().Name);

			component.Init(Context, componentContext);
		}