1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-17 01:51:14 -05:00
OpenDiablo2/OpenDiablo2.ServiceBus/AutofacModule.cs

33 lines
1.0 KiB
C#
Raw Normal View History

using System;
using Autofac;
using OpenDiablo2.Common.Enums;
using OpenDiablo2.Common.Interfaces;
namespace OpenDiablo2.ServiceBus
{
public sealed class AutofacModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<LocalSessionManager>().AsSelf().InstancePerLifetimeScope();
builder.Register<Func<eSessionType, ISessionManager>>(c =>
{
var componentContext = c.Resolve<IComponentContext>();
return (sessionType) =>
{
switch (sessionType)
{
case eSessionType.Local:
return componentContext.Resolve<LocalSessionManager>();
case eSessionType.Server:
case eSessionType.Remote:
default:
throw new ApplicationException("Unsupported session type.");
}
};
});
}
}
}