More working tests.
[castle.git] / MonoRail / Castle.MonoRail.Framework.Views.NVelocity / JSGeneration / JSGeneratorDuck.cs
blobe8863d7c8cb5391c06e0f206ee709964a22ae6cd
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 using NVelocity;
17 namespace Castle.MonoRail.Framework.Views.NVelocity.JSGeneration
19 using System;
20 using Castle.MonoRail.Framework.JSGeneration;
21 using Castle.MonoRail.Framework.JSGeneration.DynamicDispatching;
23 /// <summary>
24 ///
25 /// </summary>
26 public class JSGeneratorDuck : JSGeneratorDispatcherBase, IDuck
28 /// <summary>
29 /// Initializes a new instance of the <see cref="JSGeneratorDuck"/> class.
30 /// </summary>
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)
40 #region IDuck
42 /// <summary>
43 /// Defines the behavior when a property is read
44 /// </summary>
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]);
52 /// <summary>
53 /// Defines the behavior when a property is written
54 /// </summary>
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();
62 /// <summary>
63 /// Invokes the specified method.
64 /// </summary>
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);
73 #endregion
75 protected override object CreateNullGenerator()
77 return null;
80 /// <summary>
81 /// Creates a JS element generator.
82 /// </summary>
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();