Skip to content

Instantly share code, notes, and snippets.

@reharik
Created October 11, 2012 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reharik/3872486 to your computer and use it in GitHub Desktop.
Save reharik/3872486 to your computer and use it in GitHub Desktop.
Windsor IOC config
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using CommonServiceLocator.WindsorAdapter;
using HSTM.Common.Web.SessionState;
using HSTM.HLC.BusinessLogic;
using HSTM.HLC.Common;
using HSTM.HLC.DataAccess;
using HSTM.HLC.Web.UI.Controllers;
using Microsoft.Practices.ServiceLocation;
namespace HSTM.HLC.Web.UI.Config
{
public class WindsorContainerBootStrapper
{
public static void Bootstrap()
{
new WindsorContainerBootStrapper().Start();
}
private void Start()
{
var container = new WindsorContainer();
ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));
container.Register(Component.For<ICategoryDataService>().ImplementedBy<CategoryDataService>().LifeStyle.Transient);
container.Register(Component.For<IStatementDataService>().ImplementedBy<StatementDataService>().LifeStyle.Transient);
container.Register(Component.For<IDocumentDataService>().ImplementedBy<DocumentDataService>().LifeStyle.Transient);
container.Register(Component.For<IRatingScaleDataService>().ImplementedBy<RatingScaleDataService>().LifeStyle.Transient);
container.Register(Component.For<IRatingLevelDataService>().ImplementedBy<RatingLevelDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormTemplateDataService>().ImplementedBy<FormTemplateDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormTemplatePublisherDataService>().ImplementedBy<FormTemplatePublisherDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormTemplateOrgNodeLmsDataService>().ImplementedBy<FormTemplateOrgNodeLmsDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormTemplateSectionDataService>().ImplementedBy<FormTemplateSectionDataService>().LifeStyle.Transient);
container.Register(Component.For<ISectionContentStatementDataService>().ImplementedBy<SectionContentStatementDataService>().LifeStyle.Transient);
container.Register(Component.For<IRiskOutcomeDataService>().ImplementedBy<RiskOutcomeDataService>().LifeStyle.Transient);
container.Register(Component.For<IMethodOfValidationDataService>().ImplementedBy<MethodOfValidationDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormActorDataService>().ImplementedBy<FormActorDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormDataService>().ImplementedBy<FormDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormSectionDataService>().ImplementedBy<FormSectionDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormStatementDataService>().ImplementedBy<FormStatementDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormStatementRatingDataService>().ImplementedBy<FormStatementRatingDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormStatementRatingRiskOutcomeDataService>().ImplementedBy<FormStatementRatingRiskOutcomeDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormStatementRatingMethodOfValidationDataService>().ImplementedBy<FormStatementRatingMethodOfValidationDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormReflectivePlanDataService>().ImplementedBy<FormReflectivePlanDataService>().LifeStyle.Transient);
container.Register(Component.For<IGoalDataService>().ImplementedBy<GoalDataService>().LifeStyle.Transient);
container.Register(Component.For<IGoalStudentDataService>().ImplementedBy<GoalStudentDataService>().LifeStyle.Transient);
container.Register(Component.For<IGoalStudentGroupDataService>().ImplementedBy<GoalStudentGroupDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormGoalDataService>().ImplementedBy<FormGoalDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormGoalRatingDataService>().ImplementedBy<FormGoalRatingDataService>().LifeStyle.Transient);
container.Register(Component.For<INoteDataService>().ImplementedBy<NoteDataService>().LifeStyle.Transient);
container.Register(Component.For<ILibraryDataService>().ImplementedBy<LibraryDataService>().LifeStyle.Transient);
container.Register(Component.For<ILibraryItemDataService>().ImplementedBy<LibraryItemDataService>().LifeStyle.Transient);
container.Register(Component.For<ILibrarySubscriberDataService>().ImplementedBy<LibrarySubscriberDataService>().LifeStyle.Transient);
container.Register(Component.For<ICustomReportDataService>().ImplementedBy<CustomReportDataService>().LifeStyle.Transient);
container.Register(Component.For<IOrganizationSettingDataService>().ImplementedBy<OrganizationSettingDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormTemplateFieldOverrideDataService>().ImplementedBy<FormTemplateFieldOverrideDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormTemplateSectionFieldOverrideDataService>().ImplementedBy<FormTemplateSectionFieldOverrideDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormTemplateReflectivePlanRatingLevelDataService>().ImplementedBy<FormTemplateReflectivePlanRatingLevelDataService>().LifeStyle.Transient);
container.Register(Component.For<ImportStatementDataService>().ImplementedBy<ImportStatementDataService>().LifeStyle.Transient);
container.Register(Component.For<IJobDescriptionDataService>().ImplementedBy<JobDescriptionDataService>().LifeStyle.Transient);
container.Register(Component.For<IFormJobDescriptionRatingDataService>().ImplementedBy<FormJobDescriptionRatingDataService>().LifeStyle.Transient);
container.Register(Component.For<IJobDescriptionStudentGroupDataService>().ImplementedBy<JobDescriptionStudentGroupDataService>().LifeStyle.Transient);
container.Register(Component.For<IHstmScormExternalRegistrationId>().ImplementedBy<HstmScormExternalRegistrationIdCompressed>().LifeStyle.Transient);
container.Register(Component.For<IImportStudent>().ImplementedBy<ImportUserStudent>().LifeStyle.Transient);
container.Register(Component.For(typeof(ILibraryRepository<>)).ImplementedBy(typeof(LibraryRepository<>)).LifeStyle.Transient);
container.Register(AllTypes.FromAssemblyContaining<ThreadUserSessionManagement>().Where(type => type.IsPublic).WithService.FirstInterface().Configure(req => req.LifeStyle.Transient));
container.Register(AllTypes.FromAssemblyContaining<JobDescriptionDataService>().Where(type => type.IsPublic).WithService.FirstInterface().Configure(req => req.LifeStyle.Transient));
container.Register(AllTypes.FromAssemblyContaining<OrthogonalController>().BasedOn<System.Web.Mvc.IController>().Configure(req => req.LifeStyle.Transient));
container.Register(AllTypes.FromAssemblyContaining<WebUIInstaller>().Where(type => type.IsPublic).WithService.FirstInterface().Configure(req => req.LifeStyle.Transient));
container.Register(Component.For<IWebStateProvider>().ImplementedBy<WebState>().LifeStyle.Singleton);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment