Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Framework / JSGeneration / DynamicDispatching / JSElementGeneratorDispatcherBase.cs
blobf64c9b046ce3e5d759db0d8c38ce6dae409dfb45
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.MonoRail.Framework.JSGeneration.DynamicDispatching
17 /// <summary>
18 /// Operations related to an element
19 /// </summary>
20 public abstract class JSElementGeneratorDispatcherBase : DynamicDispatcher
22 private readonly IJSCodeGenerator codeGen;
24 /// <summary>
25 /// Initializes a new instance of the <see cref="JSElementGeneratorDispatcherBase"/> class.
26 /// </summary>
27 /// <param name="codeGen">The code gen.</param>
28 /// <param name="elementGenerator">The element generator.</param>
29 /// <param name="extensions">The extensions.</param>
30 protected JSElementGeneratorDispatcherBase(IJSCodeGenerator codeGen, IJSElementGenerator elementGenerator, params object[] extensions)
31 : base(elementGenerator, extensions)
33 this.codeGen = codeGen;
36 /// <summary>
37 /// Generates a get statement
38 /// </summary>
39 /// <param name="propName">Name of the prop.</param>
40 protected void InternalGet(string propName)
42 codeGen.ReplaceTailByPeriod();
43 codeGen.Record(propName);
46 /// <summary>
47 /// Dispatches the invocation (late bound)
48 /// </summary>
49 /// <param name="method">The method.</param>
50 /// <param name="args">The args.</param>
51 /// <returns></returns>
52 protected object InternalInvoke(string method, object[] args)
54 if (method == "set")
56 codeGen.RemoveTail();
57 codeGen.Record(" = " + args[0]);
58 return null;
60 else
62 codeGen.ReplaceTailByPeriod();
64 if (HasMethod(method))
66 Dispatch(method, args);
68 else
70 codeGen.Call(method, args);
73 return this;