2018-11-22 22:53:05 -05:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Autofac;
|
2018-11-22 00:18:42 -05:00
|
|
|
|
using OpenDiablo2.Common.Attributes;
|
|
|
|
|
using OpenDiablo2.Common.Interfaces;
|
|
|
|
|
|
|
|
|
|
namespace OpenDiablo2.Scenes
|
|
|
|
|
{
|
|
|
|
|
public sealed class AutofacModule : Module
|
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
|
|
|
|
protected override void Load(ContainerBuilder builder)
|
|
|
|
|
{
|
|
|
|
|
log.Info("Configuring OpenDiablo2.Scenes service implementations.");
|
|
|
|
|
|
|
|
|
|
var types = ThisAssembly.GetTypes().Where(x => typeof(IScene).IsAssignableFrom(x) && x.IsClass);
|
|
|
|
|
foreach (var type in types)
|
|
|
|
|
{
|
2018-12-08 13:31:50 -05:00
|
|
|
|
var att = type.GetCustomAttributes(true).First(x => (x is SceneAttribute)) as SceneAttribute;
|
2018-11-22 00:18:42 -05:00
|
|
|
|
builder
|
|
|
|
|
.RegisterType(type)
|
2018-12-08 09:12:40 -05:00
|
|
|
|
.Keyed<IScene>(att.SceneType)
|
2018-12-09 14:55:01 -05:00
|
|
|
|
.InstancePerDependency();
|
2018-11-22 00:18:42 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|