Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / MonoRail / Castle.MonoRail.Framework / JSGeneration / IJSCodeGenerator.cs
blob9a9f5e76a8004172be036cb666ef9d139af835f7
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 System;
18 using System.Collections.Generic;
19 using System.Text;
20 using Services;
22 /// <summary>
23 /// Pendent
24 /// </summary>
25 public interface IJSCodeGenerator
27 /// <summary>
28 /// Gets the main JS generator.
29 /// </summary>
30 /// <value>The JS generator.</value>
31 IJSGenerator JSGenerator { get; set; }
33 /// <summary>
34 /// Gets or sets the URL helper.
35 /// </summary>
36 /// <value>The URL helper.</value>
37 IUrlBuilder UrlBuilder { get; set; }
39 /// <summary>
40 /// Gets or sets the server utility.
41 /// </summary>
42 /// <value>The server utility.</value>
43 IServerUtility ServerUtility { get; set; }
45 /// <summary>
46 /// Gets or sets the engine context.
47 /// </summary>
48 /// <value>The engine context.</value>
49 IEngineContext EngineContext { get; set; }
51 /// <summary>
52 /// Gets the extensions.
53 /// </summary>
54 /// <value>The extensions.</value>
55 IDictionary<string, object> Extensions { get; }
57 /// <summary>
58 /// Calls the specified function with the optional arguments.
59 /// </summary>
60 ///
61 /// <example>
62 /// The following example uses nvelocity syntax:
63 ///
64 /// <code>
65 /// $page.call('myJsFunctionAlreadyDeclared', '10', "'message'", $somethingfrompropertybag, $anothermessage.to_squote)
66 /// </code>
67 ///
68 /// <para>
69 /// Which outputs:
70 /// </para>
71 ///
72 /// <code>
73 /// myJsFunctionAlreadyDeclared(10, 'message', 1001, 'who let the dogs out?')
74 /// </code>
75 ///
76 /// </example>
77 ///
78 /// <param name="function">The function name.</param>
79 /// <param name="args">The arguments.</param>
80 void Call(object function, params object[] args);
82 /// <summary>
83 /// Writes the content specified to the generator instance
84 /// </summary>
85 ///
86 /// <remarks>
87 /// This is for advanced scenarios and for the infrastructure. Usually not useful.
88 /// </remarks>
89 ///
90 /// <param name="content">The content.</param>
91 void Write(String content);
93 /// <summary>
94 /// Outputs the content using the renderOptions approach.
95 /// <para>
96 /// If the renderOptions is a string, the content is escaped and quoted.
97 /// </para>
98 /// <para>
99 /// If the renderOptions is a dictionary, we extract the key <c>partial</c>
100 /// and evaluate the template it points to. The content is escaped and quoted.
101 /// </para>
102 /// </summary>
103 /// <param name="renderOptions">The render options.</param>
104 /// <returns></returns>
105 /// <example>
106 /// The following example uses nvelocity syntax:
107 /// <code>
108 /// $page.Call('myJsFunction', $page.render("%{partial='shared/newmessage.vm'}") )
109 /// </code>
110 /// <para>
111 /// Which outputs:
112 /// </para>
113 /// <code>
114 /// myJsFunction('the content from the newmessage partial view template')
115 /// </code>
116 /// </example>
117 object Render(object renderOptions);
119 /// <summary>
120 /// Writes the content specified to the generator instance
121 /// </summary>
122 ///
123 /// <remarks>
124 /// This is for advanced scenarios and for the infrastructure. Usually not useful.
125 /// </remarks>
126 /// <param name="content">The content.</param>
127 void AppendLine(String content);
129 /// <summary>
130 /// Records the specified line.
131 /// </summary>
132 /// <param name="line">The line.</param>
133 void Record(string line);
135 /// <summary>
136 /// Builds the JS arguments.
137 /// </summary>
138 /// <param name="args">The args.</param>
139 /// <returns></returns>
140 string BuildJSArguments(object[] args);
142 /// <summary>
143 /// Replaces the tail from the current line (usually a ';') by period.
144 /// </summary>
145 void ReplaceTailByPeriod();
147 /// <summary>
148 /// Removes the tail from the current line (usually a ';')
149 /// </summary>
150 void RemoveTail();
152 /// <summary>
153 /// Gets the js lines.
154 /// </summary>
155 /// <value>The js lines.</value>
156 StringBuilder Lines { get; }
158 /// <summary>
159 /// Dump the operations recorded so far as javascript code.
160 /// </summary>
161 ///
162 /// <returns></returns>
163 string ToString();