1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
18 /// Operations related to an element
20 public abstract class JSElementGeneratorDispatcherBase
: DynamicDispatcher
22 private readonly IJSCodeGenerator codeGen
;
25 /// Initializes a new instance of the <see cref="JSElementGeneratorDispatcherBase"/> class.
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
;
37 /// Generates a get statement
39 /// <param name="propName">Name of the prop.</param>
40 protected void InternalGet(string propName
)
42 codeGen
.ReplaceTailByPeriod();
43 codeGen
.Record(propName
);
47 /// Dispatches the invocation (late bound)
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
)
57 codeGen
.Record(" = " + args
[0]);
62 codeGen
.ReplaceTailByPeriod();
64 if (HasMethod(method
))
66 Dispatch(method
, args
);
70 codeGen
.Call(method
, args
);