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.
17 namespace Castle
.MonoRail
.Framework
.Views
.NVelocity
.JSGeneration
20 using Castle
.MonoRail
.Framework
.JSGeneration
;
21 using Castle
.MonoRail
.Framework
.JSGeneration
.DynamicDispatching
;
26 public class JSGeneratorDuck
: JSGeneratorDispatcherBase
, IDuck
29 /// Initializes a new instance of the <see cref="JSGeneratorDuck"/> class.
31 /// <param name="codeGen">The code gen.</param>
32 /// <param name="generator">The generator.</param>
33 /// <param name="extensions">The extensions.</param>
34 /// <param name="elementExtensions">The element extensions.</param>
35 public JSGeneratorDuck(IJSCodeGenerator codeGen
, IJSGenerator generator
, object[] extensions
, object[] elementExtensions
) :
36 base(codeGen
, generator
, extensions
, elementExtensions
)
43 /// Defines the behavior when a property is read
45 /// <param name="propName">Property name.</param>
46 /// <returns>value back to the template</returns>
47 public object GetInvoke(string propName
)
49 return Invoke(propName
, new object[0]);
53 /// Defines the behavior when a property is written
55 /// <param name="propName">Property name.</param>
56 /// <param name="value">The value to assign.</param>
57 public void SetInvoke(string propName
, object value)
59 throw new NotImplementedException();
63 /// Invokes the specified method.
65 /// <param name="method">The method name.</param>
66 /// <param name="args">The method arguments.</param>
67 /// <returns>value back to the template</returns>
68 public object Invoke(string method
, params object[] args
)
70 return InternalInvoke(method
, args
);
75 protected override object CreateNullGenerator()
81 /// Creates a JS element generator.
83 /// <param name="codeGen">The code gen.</param>
84 /// <param name="elementGenerator">The element generator.</param>
85 /// <param name="elementExtensions">The element extensions.</param>
86 /// <returns></returns>
87 protected override object CreateJSElementGeneratorProxy(IJSCodeGenerator codeGen
, IJSElementGenerator elementGenerator
, object[] elementExtensions
)
89 return new JSElementGeneratorDuck(codeGen
, elementGenerator
, elementExtensions
);
92 public override string ToString()
94 return CodeGen
.ToString();