Castle.MonoRail.Framework.Internal.JSGeneratorBase.InternalInvoke C# (CSharp) Method

InternalInvoke() protected method

Executes an operation (totally late bound)
protected InternalInvoke ( string method ) : object
method string The method.
return object
		protected object InternalInvoke(string method, params object[] args)
		{
			if (method == "el")
			{
				if (args == null || args.Length != 1)
				{
					throw new ArgumentException("el() method must be invoked with the element name as an argument");
				}
				if (args[0] == null)
				{
					throw new ArgumentNullException("el() method invoked with a null argument");
				}

				return CreateJSElementGenerator(
					generator.CreateElementGenerator(args[0].ToString()));
			}
			else if (method == "select")
			{
				if (args == null || args.Length != 1)
				{
					throw new ArgumentException(
						"select() method must be invoked with the element/css selection rule name as an argument");
				}
				if (args[0] == null)
				{
					throw new ArgumentNullException("select() method invoked with a null argument");
				}

				return CreateJSCollectionGenerator(
					generator.CreateCollectionGenerator(args[0].ToString()));
			}

			DynamicDispatchSupport dispInterface = generator as DynamicDispatchSupport;
			if (dispInterface == null)
			{
				throw new MonoRail.Framework.RailsException("JS Generators must inherit DynamicDispatchSupport");
			}

			if (dispInterface.IsGeneratorMethod(method))
			{
				return dispInterface.Dispatch(method, args);
			}

			return CreateNullGenerator();
		}