Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 46 lines (39 sloc) 1.677 kB
8027e1f @mausch CRLF
authored
1 #region license
2 // Copyright (c) 2007-2010 Mauricio Scheffer
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 #endregion
16
17 using System;
18 using System.Web;
19 using System.Web.Mvc;
8b77c18 @mausch upgraded sample app to VS2010 / ASP.NET MVC 2
authored
20 using System.Web.Routing;
8027e1f @mausch CRLF
authored
21
22 namespace SampleSolrApp {
23 public class ServiceProviderControllerFactory : DefaultControllerFactory {
24 private readonly IServiceProvider container;
25
26 public ServiceProviderControllerFactory(IServiceProvider container) {
27 this.container = container;
28 }
29
8b77c18 @mausch upgraded sample app to VS2010 / ASP.NET MVC 2
authored
30 protected override IController GetControllerInstance(RequestContext context, Type controllerType) {
8027e1f @mausch CRLF
authored
31 if (controllerType == null) {
8b77c18 @mausch upgraded sample app to VS2010 / ASP.NET MVC 2
authored
32 throw new HttpException(404, string.Format("The controller for path '{0}' could not be found or it does not implement IController.", context.HttpContext.Request.Path));
8027e1f @mausch CRLF
authored
33 }
34
35 return (IController) container.GetService(controllerType);
36 }
37
38 public override void ReleaseController(IController controller) {
39 var disposable = controller as IDisposable;
40
41 if (disposable != null) {
42 disposable.Dispose();
43 }
44 }
45 }
3ed4cef @mausch pagination
authored
46 }
Something went wrong with that request. Please try again.