﻿using StructureMap.Graph;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using StructureMap;
using StructureMap.Graph.Scanning;
using System.Web.Mvc;
using StructureMap.Pipeline;
using StructureMap.TypeRules;

namespace CenterQ.Web.Infrastructure
{
    public class ControllerConvention : IRegistrationConvention
    {
        public void ScanTypes(TypeSet types, Registry registry)
        {
            foreach (var type in types.AllTypes())
            {
                if (type.CanBeCastTo<Controller>() && !type.IsAbstract)
                    registry.For(type).LifecycleIs(new UniquePerRequestLifecycle());
            }
        }
    }
}