Castle.MonoRail.Framework.ControllerLifecycleExecutor.CreateAndInitializeHelpers C# (CSharp) Method

CreateAndInitializeHelpers() protected method

Creates the and initialize helpers associated with a controller.
protected CreateAndInitializeHelpers ( ) : void
return void
		protected void CreateAndInitializeHelpers()
		{
			HybridDictionary helpers = new HybridDictionary();

			// Custom helpers

			foreach(HelperDescriptor helper in metaDescriptor.Helpers)
			{
				object helperInstance = Activator.CreateInstance(helper.HelperType);

				IControllerAware aware = helperInstance as IControllerAware;

				if (aware != null)
				{
					aware.SetController(controller);
				}

				PerformAdditionalHelperInitialization(helperInstance);

				if (helpers.Contains(helper.Name))
				{
					throw new ControllerException(String.Format("Found a duplicate helper " +
					                                            "attribute named '{0}' on controller '{1}'", helper.Name,
					                                            controller.Name));
				}

				helpers.Add(helper.Name, helperInstance);
			}

			CreateStandardHelpers(helpers);

			controller.helpers = helpers;
		}