Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / MonoRail / Castle.MonoRail.Framework / IViewEngine.cs
blob25f1e4b252d0fff6958ea21dcc7bcb8952f48f75
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
17 using System;
18 using System.Collections.Generic;
19 using System.IO;
21 /// <summary>
22 /// Depicts the contract used by the engine
23 /// to process views, in an independent manner.
24 /// </summary>
25 public interface IViewEngine
27 /// <summary>
28 /// Gets a value indicating whether the view engine
29 /// support the generation of JS.
30 /// </summary>
31 /// <value>
32 /// <c>true</c> if JS generation is supported; otherwise, <c>false</c>.
33 /// </value>
34 bool SupportsJSGeneration { get; }
36 /// <summary>
37 /// Evaluates whether the specified template can be used to generate js.
38 /// </summary>
39 /// <returns><c>true</c> if it exists</returns>
40 bool IsTemplateForJSGeneration(String templateName);
42 /// <summary>
43 /// Gets the JS generator view template file extension.
44 /// </summary>
45 /// <value>The JS generator file extension.</value>
46 string JSGeneratorFileExtension { get; }
48 /// <summary>
49 /// Implementors should return a generator instance if
50 /// the view engine supports JS generation.
51 /// </summary>
52 /// <param name="generatorInfo">The generator info.</param>
53 /// <param name="context">The request context.</param>
54 /// <param name="controller">The controller.</param>
55 /// <param name="controllerContext">The controller context.</param>
56 /// <returns>A JS generator instance</returns>
57 object CreateJSGenerator(JSCodeGeneratorInfo generatorInfo, IEngineContext context, IController controller, IControllerContext controllerContext);
59 /// <summary>
60 /// Processes the js generation view template - using the templateName
61 /// to obtain the correct template, and using the specified <see cref="TextWriter"/>
62 /// to output the result.
63 /// </summary>
64 /// <param name="templateName">Name of the template.</param>
65 /// <param name="output">The output.</param>
66 /// <param name="generatorInfo">The generator info.</param>
67 /// <param name="context">The request context.</param>
68 /// <param name="controller">The controller.</param>
69 /// <param name="controllerContext">The controller context.</param>
70 void GenerateJS(string templateName, TextWriter output, JSCodeGeneratorInfo generatorInfo,
71 IEngineContext context, IController controller, IControllerContext controllerContext);
73 /// <summary>
74 /// Gets or sets a value indicating whether the view engine should set the
75 /// content type to xhtml.
76 /// </summary>
77 /// <value><c>true</c> if the content type should be set to xhtml; otherwise, <c>false</c>.</value>
78 bool XHtmlRendering { get; set; }
80 /// <summary>
81 /// Gets the view template file extension.
82 /// </summary>
83 /// <value>The view file extension.</value>
84 string ViewFileExtension { get; }
86 /// <summary>
87 /// Evaluates whether the specified template exists.
88 /// </summary>
89 /// <returns><c>true</c> if it exists</returns>
90 bool HasTemplate(string templateName);
92 ///<summary>
93 /// Processes the view - using the templateName
94 /// to obtain the correct template
95 /// and writes the results to the <see cref="TextWriter"/>.
96 /// No layout is applied!
97 /// </summary>
98 void Process(string templateName, TextWriter output, IEngineContext context, IController controller,
99 IControllerContext controllerContext);
101 /// <summary>
102 /// Processes the view - using the templateName
103 /// to obtain the correct template
104 /// and writes the results to the <see cref="TextWriter"/>.
105 /// No layout is applied!
106 /// </summary>
107 void Process(string templateName, string layoutName, TextWriter output, IDictionary<string,object> parameters);
109 /// <summary>
110 /// Wraps the specified content in the layout using
111 /// the context to output the result.
112 /// </summary>
113 /// <param name="context">The request context.</param>
114 /// <param name="controller">The controller.</param>
115 /// <param name="controllerContext">The controller context.</param>
116 /// <param name="contents">Static content to output within the layout</param>
117 void RenderStaticWithinLayout(string contents, IEngineContext context, IController controller,
118 IControllerContext controllerContext);
120 /// <summary>
121 /// Should process the specified partial. The partial name must contains
122 /// the path relative to the views folder.
123 /// </summary>
124 /// <param name="partialName">The partial name.</param>
125 /// <param name="output">The output.</param>
126 /// <param name="context">The request context.</param>
127 /// <param name="controller">The controller.</param>
128 /// <param name="controllerContext">The controller context.</param>
129 void ProcessPartial(string partialName, TextWriter output, IEngineContext context, IController controller,
130 IControllerContext controllerContext);
132 // Holding it a little more as it would be a breaking change (meaning all partials view would break)
134 // /// <summary>
135 // /// Should process the specified partial. The partial name must contains
136 // /// the path relative to the views folder.
137 // /// </summary>
138 // /// <param name="partialName">The partial name.</param>
139 // /// <param name="output">The output.</param>
140 // /// <param name="context">The request context.</param>
141 // /// <param name="parameters">The parameters.</param>
142 // void ProcessPartial(String partialName, TextWriter output, IEngineContext context, IDictionary<string, object> parameters);