1
// Copyright 2004-2008 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
.Services
17 using System
.Collections
;
19 using System
.Web
.SessionState
;
20 using Castle
.MonoRail
.Framework
.Adapters
;
21 using Castle
.MonoRail
.Framework
.Container
;
27 public class DefaultEngineContextFactory
: IEngineContextFactory
32 /// <param name="container"></param>
33 /// <param name="urlInfo"></param>
34 /// <param name="context"></param>
35 /// <param name="routeMatch"></param>
36 /// <returns></returns>
37 public IEngineContext
Create(IMonoRailContainer container
, UrlInfo urlInfo
, HttpContext context
, RouteMatch routeMatch
)
39 IDictionary session
= ResolveRequestSession(container
, urlInfo
, context
);
41 IUrlBuilder urlBuilder
= container
.UrlBuilder
;
43 ServerUtilityAdapter serverUtility
= new ServerUtilityAdapter(context
.Server
);
45 string referrer
= context
.Request
.Headers
["Referer"];
47 return new DefaultEngineContext(container
, urlInfo
, context
,
49 new RequestAdapter(context
.Request
),
50 new ResponseAdapter(context
.Response
, urlInfo
, urlBuilder
, serverUtility
, routeMatch
, referrer
),
51 new TraceAdapter(context
.Trace
), session
);
55 /// Resolves the request session.
57 protected virtual IDictionary
ResolveRequestSession(IMonoRailContainer container
, UrlInfo urlInfo
, HttpContext context
)