コード例 #1
0
 public WurmPaths(IWurmClientInstallDirectory wurmInstallDirectory, [NotNull] IWurmApiConfig wurmApiConfig)
 {
     if (wurmApiConfig == null)
     {
         throw new ArgumentNullException(nameof(wurmApiConfig));
     }
     this.wurmApiConfig = wurmApiConfig;
     ConfigsDirFullPath = Path.Combine(wurmInstallDirectory.FullPath, "configs");
     playersDirPath     = Path.Combine(wurmInstallDirectory.FullPath, "players");
 }
コード例 #2
0
 /// <summary>
 /// Constructor for integration testing.
 /// </summary>
 internal WurmApiManager(
     string dataDir,
     IWurmClientInstallDirectory installDirectory,
     IHttpWebRequests httpWebRequests,
     IWurmApiLogger logger,
     WurmApiConfig wurmApiConfig)
 {
     ConstructSystems(dataDir,
                      installDirectory,
                      httpWebRequests,
                      logger,
                      new SimpleMarshaller(),
                      new SimpleMarshaller(),
                      wurmApiConfig);
 }
コード例 #3
0
        /// <summary>
        /// Public factory constructor.
        /// </summary>
        internal WurmApiManager(
            WurmApiDataDirectory dataDirectory,
            IWurmClientInstallDirectory installDirectory,
            IWurmApiLogger wurmApiLogger,
            IWurmApiEventMarshaller publicEventMarshaller,
            WurmApiConfig wurmApiConfig)
        {
            var threadPoolMarshaller = new ThreadPoolMarshaller(wurmApiLogger);

            if (publicEventMarshaller == null)
            {
                publicEventMarshaller = threadPoolMarshaller;
            }
            IHttpWebRequests httpRequests = new HttpWebRequests();

            ConstructSystems(dataDirectory.FullPath,
                             installDirectory,
                             httpRequests,
                             wurmApiLogger,
                             publicEventMarshaller,
                             threadPoolMarshaller,
                             wurmApiConfig);
        }
コード例 #4
0
        void ConstructSystems(string wurmApiDataDirectoryFullPath, IWurmClientInstallDirectory installDirectory,
                              IHttpWebRequests httpWebRequests, IWurmApiLogger logger, IWurmApiEventMarshaller publicEventMarshaller,
                              IWurmApiEventMarshaller internalEventMarshaller, WurmApiConfig wurmApiConfig)
        {
            IWurmApiConfig internalWurmApiConfig = wurmApiConfig.CreateCopy();

            LogFileStreamReaderFactory logFileStreamReaderFactory = Wire(new LogFileStreamReaderFactory(internalWurmApiConfig));

            Wire(installDirectory);
            Wire(httpWebRequests);

            if (logger == null)
            {
                logger = new WurmApiLoggerStub();
            }

            PublicEventInvoker publicEventInvoker = Wire(new PublicEventInvoker(publicEventMarshaller, logger));

            TaskManager taskManager = Wire(new TaskManager(logger));

            InternalEventAggregator internalEventAggregator = Wire(new InternalEventAggregator());

            InternalEventInvoker internalEventInvoker =
                Wire(new InternalEventInvoker(internalEventAggregator, logger, internalEventMarshaller));

            WurmPaths        paths        = Wire(new WurmPaths(installDirectory, wurmApiConfig));
            WurmServerGroups serverGroups = Wire(new WurmServerGroups(internalWurmApiConfig.ServerInfoMap));

            WurmServerList serverList = Wire(new WurmServerList(internalWurmApiConfig.ServerInfoMap));

            WurmLogDefinitions logDefinitions = Wire(new WurmLogDefinitions());

            WurmConfigDirectories configDirectories =
                Wire(new WurmConfigDirectories(paths, internalEventAggregator, taskManager, logger));
            WurmCharacterDirectories characterDirectories =
                Wire(new WurmCharacterDirectories(paths, internalEventAggregator, taskManager, logger));
            WurmLogFiles logFiles =
                Wire(new WurmLogFiles(characterDirectories,
                                      logger,
                                      logDefinitions,
                                      internalEventAggregator,
                                      internalEventInvoker,
                                      taskManager,
                                      paths));

            WurmLogsMonitor logsMonitor =
                Wire(new WurmLogsMonitor(logFiles,
                                         logger,
                                         publicEventInvoker,
                                         internalEventAggregator,
                                         characterDirectories,
                                         internalEventInvoker,
                                         taskManager,
                                         logFileStreamReaderFactory));
            var heuristicsDataDirectory = Path.Combine(wurmApiDataDirectoryFullPath, "WurmLogsHistory");

            if (internalWurmApiConfig.ClearAllCaches)
            {
                ClearDir(heuristicsDataDirectory, logger);
            }

            WurmLogsHistory logsHistory =
                Wire(new WurmLogsHistory(logFiles,
                                         logger,
                                         heuristicsDataDirectory,
                                         logFileStreamReaderFactory,
                                         wurmApiConfig));

            WurmConfigs wurmConfigs =
                Wire(new WurmConfigs(configDirectories,
                                     logger,
                                     publicEventInvoker,
                                     internalEventAggregator,
                                     taskManager));
            WurmAutoruns autoruns = Wire(new WurmAutoruns(wurmConfigs, characterDirectories, logger));

            var wurmServerHistoryDataDirectory = Path.Combine(wurmApiDataDirectoryFullPath, "WurmServerHistory");

            if (internalWurmApiConfig.ClearAllCaches)
            {
                ClearDir(wurmServerHistoryDataDirectory, logger);
            }
            WurmServerHistory wurmServerHistory =
                Wire(new WurmServerHistory(wurmServerHistoryDataDirectory,
                                           logsHistory,
                                           serverList,
                                           logger,
                                           logsMonitor,
                                           logFiles,
                                           internalEventAggregator,
                                           serverGroups,
                                           wurmApiConfig));

            var wurmServersDataDirectory = Path.Combine(wurmApiDataDirectoryFullPath, "WurmServers");

            if (internalWurmApiConfig.ClearAllCaches)
            {
                ClearDir(wurmServersDataDirectory, logger);
            }
            WurmServers wurmServers =
                Wire(new WurmServers(logsHistory,
                                     logsMonitor,
                                     serverList,
                                     httpWebRequests,
                                     wurmServersDataDirectory,
                                     characterDirectories,
                                     wurmServerHistory,
                                     logger,
                                     serverGroups,
                                     wurmApiConfig));

            WurmCharacters characters =
                Wire(new WurmCharacters(characterDirectories,
                                        wurmConfigs,
                                        wurmServers,
                                        wurmServerHistory,
                                        logger,
                                        taskManager,
                                        logsMonitor,
                                        publicEventInvoker,
                                        internalEventAggregator,
                                        paths,
                                        logsHistory,
                                        serverGroups));

            HttpWebRequests          = httpWebRequests;
            Autoruns                 = autoruns;
            Characters               = characters;
            Configs                  = wurmConfigs;
            LogDefinitions           = logDefinitions;
            LogsHistory              = logsHistory;
            LogsMonitor              = logsMonitor;
            Servers                  = wurmServers;
            WurmLogFiles             = logFiles;
            WurmServerHistory        = wurmServerHistory;
            WurmCharacterDirectories = characterDirectories;
            WurmConfigDirectories    = configDirectories;
            InternalEventAggregator  = internalEventAggregator;
            Paths        = paths;
            ServerGroups = serverGroups;
            Logger       = logger;
            ServersList  = serverList;
        }