Esempio n. 1
0
        private static IContainer CompositionRoot(ApplicationOptions options)
        {
            var builder = new ContainerBuilder();

            builder.RegisterType <PlayerStatisticStorage>().AsImplementedInterfaces().SingleInstance();
            builder.RegisterType <ServerStatisticStorage>().AsImplementedInterfaces().SingleInstance();
            builder.RegisterType <ReportStorage>().AsImplementedInterfaces().SingleInstance();
            builder.RegisterType <GlobalServerStatisticStorage>().AsImplementedInterfaces().SingleInstance();

            builder.RegisterInstance(new RavenDbStorage(RavenDbStore.GetStore(options)))
            .As <IDataRepository>()
            .SingleInstance();

            builder.RegisterType <DataStatisticStorage>().As <IDataStatisticStorage>().SingleInstance();

            builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(BaseModule)))
            .Where(t => t.IsAssignableTo <IServerModule>())
            .AsImplementedInterfaces();
            builder.RegisterType <HttpServer>().AsImplementedInterfaces();
            builder.RegisterInstance(new HttpServerOptions {
                Prefix = options.Prefix
            }).AsSelf();

            return(builder.Build());
        }
Esempio n. 2
0
 public virtual void Setup()
 {
     GlobalStatisticStorage = new GlobalServerStatisticStorage();
     ServerStatisticStorage = new ServerStatisticStorage(GlobalStatisticStorage);
     PlayerStatisticStorage = new PlayerStatisticStorage();
     ReportStorage          = new ReportStorage(ServerStatisticStorage, PlayerStatisticStorage);
     DocumentStore          = RavenDbStore.GetStore(new ApplicationOptions
     {
         InMemory    = true,
         UnitTesting = true
     });
     DataRepository   = new RavenDbStorage(DocumentStore);
     StatisticStorage = new DataStatisticStorage(
         DataRepository,
         GlobalStatisticStorage,
         ServerStatisticStorage,
         PlayerStatisticStorage,
         ReportStorage);
 }