Skip to content

Instantly share code, notes, and snippets.

View jglozano's full-sized avatar

Javier Lozano jglozano

View GitHub Profile
public override void Init() {
// Inject properties into the handler before execution
PreRequestHandlerExecute += (sender, e) =>
{
var app = sender as HttpApplication;
if (app == null) return;
var handler = app.Context.CurrentHandler;
if (handler == null) return;
public override void Init() {
// Inject properties into the handler before execution
PreRequestHandlerExecute += (sender, e) =>
{
var app = sender as HttpApplication;
if (app == null) return;
var handler = app.Context.CurrentHandler;
if (handler == null) return;
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using Spark.Web.Mvc;
namespace Dimecasts.Web
{
using MvcTurbine.ComponentModel;
using MvcTurbine.Web;
public class CommonServiceRegistration : IServiceRegistration
{
public void Register(IServiceLocator locator)
{
// use the GetUnderlyingContainer to get the 'internal' container the
// application is using
var container = locator.GetUnderlyingContainer<IWindsorContainer>();
// now you can leverage your container to it's needs
// yes, I know it smells of hack
@jglozano
jglozano / MVC2 Area Registration
Created April 14, 2010 18:27
shows how the system can handle registration of MVC2 Areas out of the box.
/// <summary>
/// Provides the auto-registration of MVC related components (controllers, view engines, filters, etc).
/// </summary>
/// <param name="registrationList"></param>
public virtual void AddRegistrations(AutoRegistrationList registrationList) {
registrationList
.Add(MvcRegistration.RegisterController())
.Add(MvcRegistration.RegisterViewEngine())
.Add(MvcRegistration.RegisterFilter<IActionFilter>())
.Add(MvcRegistration.RegisterFilter<IResultFilter>())
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>
Product Details</h2>
<p>
<%= Html.LabelFor(x => x.Id) %>:
<%= Html.InputFor(x => x.Id) %>
<%= Html.DisplayFor(x => x.Id) %></p>
<p>
<%= Html.LabelFor(x => x.Name) %>:
<%= Html.InputFor(x => x.Name) %>
public class MvcApplication : HttpApplication {
protected void Application_Start() {
var container = new WindsorContainer();
LocalHtmlConventionRegistry.AddRegistrationsToContainer(container); // must be before HtmlTagsRegistry.
HtmlTagsRegistry.AddRegistrationsToContainer(container);
ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));
container.Register(Component.For<IServiceLocator>().Instance(ServiceLocator.Current).LifeStyle.Singleton);
}
}
namespace FubuMvc.Blades.UI {
using FubuMVC.UI;
using FubuMVC.UI.Tags;
using MvcTurbine;
using MvcTurbine.Blades;
using MvcTurbine.ComponentModel;
public class HtmlConventionBlade : Blade, ISupportAutoRegistration {
public void AddRegistrations(AutoRegistrationList registrationList) {
// Tell the system to scan and auto-register all the HtmlConventionRegistry types
namespace FubuMvc.Blades.UI {
using FubuMVC.UI;
using FubuMVC.UI.Configuration;
using FubuMVC.UI.Tags;
using MvcTurbine.ComponentModel;
public class SupportingServiceRegistration : IServiceRegistration {
public void Register(IServiceLocator locator) {
// Register the common Fubu UI pieces
locator.Register<IElementNamingConvention, DefaultElementNamingConvention>();
namespace HtmlConventions {
using System;
using FubuMVC.UI;
using FubuMVC.UI.Configuration;
using FubuMVC.UI.Tags;
using HtmlTags;
public class CommonConventions : HtmlConventionRegistry {
public CommonConventions() {
Editors.Always.Attr("class", "test");