Fixing an issue with output parameters that are of type IntPtr
[castle.git] / MonoRail / Castle.MonoRail.Framework / JSGeneration / AbstractJSGenerator.cs
blobc4443ea6067037edf8da1a8dfa2766c60efeeda6
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
17 using DynamicDispatching;
18 using Helpers;
20 /// <summary>
21 /// Pendent
22 /// </summary>
23 public abstract class AbstractJSGenerator : IJSGenerator
25 private readonly IJSCodeGenerator codeGenerator;
27 /// <summary>
28 /// Initializes a new instance of the <see cref="AbstractJSGenerator"/> class.
29 /// </summary>
30 /// <param name="codeGenerator">The code generator.</param>
31 protected AbstractJSGenerator(IJSCodeGenerator codeGenerator)
33 this.codeGenerator = codeGenerator;
36 /// <summary>
37 /// Pendent
38 /// </summary>
39 [DynamicOperation]
40 public abstract void InsertHtml(string position, string id, object renderOptions);
42 /// <summary>
43 /// Pendent
44 /// </summary>
45 [DynamicOperation]
46 public abstract void ReplaceHtml(string id, object renderOptions);
48 /// <summary>
49 /// Pendent
50 /// </summary>
51 [DynamicOperation]
52 public abstract void Replace(string id, object renderOptions);
54 /// <summary>
55 /// Pendent
56 /// </summary>
57 [DynamicOperation]
58 public abstract void Show(params string[] ids);
60 /// <summary>
61 /// Pendent
62 /// </summary>
63 [DynamicOperation]
64 public abstract void Hide(params string[] ids);
66 /// <summary>
67 /// Pendent
68 /// </summary>
69 [DynamicOperation]
70 public abstract void Toggle(params string[] ids);
72 /// <summary>
73 /// Pendent
74 /// </summary>
75 [DynamicOperation]
76 public abstract void Remove(params string[] ids);
78 /// <summary>
79 /// Outputs the content using the renderOptions approach.
80 /// <para>
81 /// If the renderOptions is a string, the content is escaped and quoted.
82 /// </para>
83 /// <para>
84 /// If the renderOptions is a dictionary, we extract the key <c>partial</c>
85 /// and evaluate the template it points to. The content is escaped and quoted.
86 /// </para>
87 /// </summary>
88 /// <param name="renderOptions">The render options.</param>
89 /// <returns></returns>
90 /// <example>
91 /// The following example uses nvelocity syntax:
92 /// <code>
93 /// $page.Call('myJsFunction', $page.render("%{partial='shared/newmessage.vm'}") )
94 /// </code>
95 /// <para>
96 /// Which outputs:
97 /// </para>
98 /// <code>
99 /// myJsFunction('the content from the newmessage partial view template')
100 /// </code>
101 /// </example>
102 [DynamicOperation]
103 public virtual object Render(object renderOptions)
105 return CodeGenerator.Render(renderOptions);
108 /// <summary>
109 /// Creates a generator for an element.
110 /// </summary>
111 /// <param name="root">The root expression.</param>
112 /// <returns></returns>
113 public abstract IJSElementGenerator CreateElementGenerator(string root);
115 /// <summary>
116 /// Gets the code generator instance.
117 /// </summary>
118 /// <value>The code generator.</value>
119 public IJSCodeGenerator CodeGenerator
121 get { return codeGenerator; }
124 /// <summary>
125 /// Quotes the specified content.
126 /// </summary>
127 /// <param name="content">The content.</param>
128 /// <returns></returns>
129 protected string Quote(string content)
131 return AbstractHelper.Quote(content);
134 /// <summary>
135 /// Quotes the specified content array.
136 /// </summary>
137 /// <param name="content">The content array.</param>
138 /// <returns></returns>
139 protected string[] Quote(object[] content)
141 return AbstractHelper.Quote(content);