Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Samples / PestControl / Castle.Applications.PestControl.Web / PestControlApplication.cs
blobdc6f6e11e21f7df236a14d729f111f431e86c5e1
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.Applications.PestControl.Web
17 using System;
18 using System.Web.Security;
19 using System.Web;
21 using Castle.Applications.PestControl.Web.Controllers.Filters;
22 using Castle.Core.Resource;
23 using Castle.Windsor;
24 using Castle.Windsor.Configuration.Interpreters;
26 using Castle.MonoRail.WindsorExtension;
28 using Castle.Applications.PestControl.Model;
29 using Castle.Applications.PestControl.Web.Controllers;
31 /// <summary>
32 /// Summary description for PestControlApplication.
33 /// </summary>
34 public class PestControlApplication : HttpApplication, IContainerAccessor
36 private static WindsorContainer container;
38 public void Application_OnStart()
40 container = new PestControlContainer( new XmlInterpreter(new ConfigResource()) );
42 container.AddFacility( "rails", new RailsFacility() );
44 AddFiltersAndControllers(container);
47 private void AddFiltersAndControllers(WindsorContainer container)
49 container.AddComponent( "auth.filter", typeof(CheckAuthenticationFilter) );
50 container.AddComponent( "home", typeof(HomeController) );
51 container.AddComponent( "dashboard", typeof(DashboardController) );
52 container.AddComponent( "registration", typeof(RegistrationController) );
53 container.AddComponent( "project", typeof(ProjectController) );
56 public void Application_OnEnd()
58 container.Dispose();
61 public void FormsAuthentication_OnAuthenticate(Object sender, FormsAuthenticationEventArgs e)
63 HttpCookie cookie = e.Context.Request.Cookies[ FormsAuthentication.FormsCookieName ];
65 if (cookie == null) return;
67 FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value);
69 PestControlModel model = (PestControlModel) container[ typeof(PestControlModel) ];
71 e.User = model.Users.FindByEmail( ticket.Name );
74 #region IContainerAccessor implementation
76 public IWindsorContainer Container
78 get { return container; }
81 #endregion