1 // Copyright 2004-2007 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.
15 namespace Castle
.MonoRail
.Framework
18 using System
.ComponentModel
.Design
;
20 using System
.Security
.Principal
;
21 using System
.Collections
;
22 using System
.Collections
.Specialized
;
25 /// Represents an abstraction between the MonoRail API
26 /// and the ASP.Net API.
28 public interface IRailsEngineContext
: IServiceContainer
31 /// Gets the request type (GET, POST, etc)
33 String RequestType { get; }
36 /// Gets the request URL.
41 /// Gets the referring URL.
43 String UrlReferrer { get; }
46 /// Gets the underlying context of the API being used.
48 HttpContext UnderlyingContext { get; }
51 /// Access the params (Query, Post, headers and Cookies)
53 NameValueCollection Params { get; }
56 /// Access the session objects.
58 IDictionary Session { get; }
61 /// Gets the request object.
63 IRequest Request { get; }
66 /// Gets the response object.
68 IResponse Response { get; }
71 /// Gets the trace object.
76 /// Access the Cache associated with this
77 /// web execution context.
79 ICacheProvider Cache { get; }
82 /// Access a dictionary of volative items.
87 /// Transfer the execution to another resource.
89 /// <param name="path"></param>
90 /// <param name="preserveForm"></param>
91 void Transfer( String path
, bool preserveForm
);
94 /// Gets or sets the current user.
96 IPrincipal CurrentUser { get; set; }
99 /// Gets the last exception raised during
100 /// the execution of an action.
102 Exception LastException { get; set; }
105 /// Returns the application path.
107 String ApplicationPath { get; }
110 /// Returns the physical application path.
112 String ApplicationPhysicalPath { get; }
115 /// Returns the <see cref="UrlInfo"/> of the the current request.
117 UrlInfo UrlInfo { get; }
120 /// Returns an <see cref="IServerUtility"/>.
122 IServerUtility Server { get; }
125 /// Returns the Items collection from the current HttpContext.
127 IDictionary Items { get; }
130 /// Gets or sets the current controller.
132 /// <value>The current controller.</value>
133 IController CurrentController { get; set; }
136 /// If a container is available for the app, this
137 /// property exposes its instance.
139 IServiceProvider Container { get; }
142 /// Request a service from the engine context.
144 /// <typeparam name="T">Service type</typeparam>
145 /// <returns>Service instance</returns>