public static IHttpWebRequests SetupUrl(this IHttpWebRequests req, string url, Func <HttpWebResponse> response)
        {
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
            // intended to be async for testing purposes
            req.Arrange(requests => requests.GetResponseAsync(url)).Returns(async() => response());
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
            return(req);
        }
Пример #2
0
 public WebFeedExtractor(IHttpWebRequests httpWebRequests)
 {
     if (httpWebRequests == null)
     {
         throw new ArgumentNullException(nameof(httpWebRequests));
     }
     this.httpWebRequests = httpWebRequests;
 }
Пример #3
0
 public WebFeedExtractor(IHttpWebRequests httpWebRequests)
 {
     if (httpWebRequests == null)
     {
         throw new ArgumentNullException("httpWebRequests");
     }
     this.httpWebRequests = httpWebRequests;
 }
Пример #4
0
        public WebFeeds(IHttpWebRequests httpWebRequests, IWurmServerList wurmServerList, ILogger logger)
        {
            if (httpWebRequests == null) throw new ArgumentNullException("httpWebRequests");
            if (wurmServerList == null) throw new ArgumentNullException("wurmServerList");
            if (logger == null) throw new ArgumentNullException("logger");
            this.httpWebRequests = httpWebRequests;
            this.wurmServerList = wurmServerList;
            this.logger = logger;

            extractor = new WebFeedExtractor(httpWebRequests);
        }
Пример #5
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);
 }
 public HttpWebRequestWebCache(HttpWebRequestWebReader webReader, IHttpWebRequests httpWebRequests, IRetryManager retryManager)
 {
     if (webReader == null)
     {
         throw new ArgumentNullException("webReader");
     }
     if (null == httpWebRequests)
     {
         throw new ArgumentNullException("httpWebRequests");
     }
     if (null == retryManager)
     {
         throw new ArgumentNullException("retryManager");
     }
     this._webReader       = webReader;
     this._httpWebRequests = httpWebRequests;
     this._retryManager    = retryManager;
 }
Пример #7
0
        public WebFeeds(IHttpWebRequests httpWebRequests, IWurmServerList wurmServerList, IWurmApiLogger logger)
        {
            if (httpWebRequests == null)
            {
                throw new ArgumentNullException(nameof(httpWebRequests));
            }
            if (wurmServerList == null)
            {
                throw new ArgumentNullException(nameof(wurmServerList));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            this.wurmServerList = wurmServerList;
            this.logger         = logger;

            extractor = new WebFeedExtractor(httpWebRequests);
        }
Пример #8
0
        public WurmServers(
            IWurmLogsHistory wurmLogsHistory,
            IWurmLogsMonitorInternal wurmLogsMonitor,
            IWurmServerList wurmServerList,
            IHttpWebRequests httpWebRequests,
            string dataDirectory,
            IWurmCharacterDirectories wurmCharacterDirectories,
            IWurmServerHistory wurmServerHistory,
            ILogger logger)
        {
            if (wurmLogsHistory == null) throw new ArgumentNullException("wurmLogsHistory");
            if (wurmLogsMonitor == null) throw new ArgumentNullException("wurmLogsMonitor");
            if (wurmServerList == null) throw new ArgumentNullException("wurmServerList");
            if (httpWebRequests == null) throw new ArgumentNullException("httpWebRequests");
            if (dataDirectory == null) throw new ArgumentNullException("dataDirectory");
            if (wurmCharacterDirectories == null) throw new ArgumentNullException("wurmCharacterDirectories");
            if (wurmServerHistory == null) throw new ArgumentNullException("wurmServerHistory");
            if (logger == null) throw new ArgumentNullException("logger");

            liveLogsDataQueue = new LiveLogsDataQueue(wurmLogsMonitor);
            LiveLogs liveLogs = new LiveLogs(liveLogsDataQueue, wurmServerHistory);

            persistentCollectionsLibrary =
                new PersistentCollectionsLibrary(new FlatFilesPersistenceStrategy(dataDirectory),
                    new PersObjErrorHandlingStrategy(logger));
            var persistent = persistentCollectionsLibrary.DefaultCollection.GetObject<ServersData>("WurmServers");
            LogHistorySaved logHistorySaved = new LogHistorySaved(persistent);
            LogHistory logHistory = new LogHistory(wurmLogsHistory, wurmCharacterDirectories, wurmServerHistory, logHistorySaved, new LogEntriesParser());

            WebFeeds webFeeds = new WebFeeds(httpWebRequests, wurmServerList, logger);

            runner = new QueuedJobsSyncRunner<Job, JobResult>(new JobRunner(liveLogs, logHistory, webFeeds, persistentCollectionsLibrary), logger);

            wurmServerFactory = new WurmServerFactory(runner);

            var descriptions = wurmServerList.All;
            foreach (var serverDescription in descriptions)
            {
                RegisterServer(serverDescription);
            }
        }
 public HttpWebRequestWebReaderManager(IHttpWebRequests httpWebRequests, IWebReaderManagerParameters webReaderManagerParameters, IContentTypeDetector contentTypeDetector, IRetryManager retryManager)
 {
     if (null == httpWebRequests)
     {
         throw new ArgumentNullException("httpWebRequests");
     }
     if (null == webReaderManagerParameters)
     {
         throw new ArgumentNullException("webReaderManagerParameters");
     }
     if (null == contentTypeDetector)
     {
         throw new ArgumentNullException("contentTypeDetector");
     }
     if (null == retryManager)
     {
         throw new ArgumentNullException("retryManager");
     }
     this._httpWebRequests            = httpWebRequests;
     this._webReaderManagerParameters = webReaderManagerParameters;
     this._contentTypeDetector        = contentTypeDetector;
     this._retryManager = retryManager;
 }
Пример #10
0
        public WurmServers(
            [NotNull] IWurmLogsHistory wurmLogsHistory,
            [NotNull] IWurmLogsMonitorInternal wurmLogsMonitor,
            [NotNull] IWurmServerList wurmServerList,
            [NotNull] IHttpWebRequests httpWebRequests,
            [NotNull] string dataDirectory,
            [NotNull] IWurmCharacterDirectories wurmCharacterDirectories,
            [NotNull] IWurmServerHistory wurmServerHistory,
            [NotNull] IWurmApiLogger logger,
            [NotNull] IWurmServerGroups wurmServerGroups,
            [NotNull] IWurmApiConfig wurmApiConfig)
        {
            if (wurmLogsHistory == null)
            {
                throw new ArgumentNullException(nameof(wurmLogsHistory));
            }
            if (wurmLogsMonitor == null)
            {
                throw new ArgumentNullException(nameof(wurmLogsMonitor));
            }
            if (wurmServerList == null)
            {
                throw new ArgumentNullException(nameof(wurmServerList));
            }
            if (httpWebRequests == null)
            {
                throw new ArgumentNullException(nameof(httpWebRequests));
            }
            if (dataDirectory == null)
            {
                throw new ArgumentNullException(nameof(dataDirectory));
            }
            if (wurmCharacterDirectories == null)
            {
                throw new ArgumentNullException(nameof(wurmCharacterDirectories));
            }
            if (wurmServerHistory == null)
            {
                throw new ArgumentNullException(nameof(wurmServerHistory));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (wurmServerGroups == null)
            {
                throw new ArgumentNullException(nameof(wurmServerGroups));
            }
            if (wurmApiConfig == null)
            {
                throw new ArgumentNullException(nameof(wurmApiConfig));
            }

            this.wurmServerGroups = wurmServerGroups;
            this.wurmApiConfig    = wurmApiConfig;

            liveLogsDataQueue = new LiveLogsDataQueue(wurmLogsMonitor);
            LiveLogs liveLogs = new LiveLogs(liveLogsDataQueue, wurmServerHistory);

            IPersistenceStrategy persistenceStrategy = new FlatFilesPersistenceStrategy(dataDirectory);

            persistentCollectionsLibrary =
                new PersistentCollectionsLibrary(persistenceStrategy,
                                                 new PersObjErrorHandlingStrategy(logger));
            var             persistent      = persistentCollectionsLibrary.DefaultCollection.GetObject <ServersData>("WurmServers");
            LogHistorySaved logHistorySaved = new LogHistorySaved(persistent);
            LogHistory      logHistory      = new LogHistory(wurmLogsHistory,
                                                             wurmCharacterDirectories,
                                                             wurmServerHistory,
                                                             logHistorySaved,
                                                             new LogEntriesParser(),
                                                             logger);

            WebFeeds webFeeds = new WebFeeds(httpWebRequests, wurmServerList, logger);

            runner = new QueuedJobsSyncRunner <Job, JobResult>(new JobRunner(liveLogs, logHistory, webFeeds, persistentCollectionsLibrary), logger);

            wurmServerFactory = new WurmServerFactory(runner);

            var descriptions = wurmServerList.All;

            foreach (var serverDescription in descriptions)
            {
                RegisterServer(serverDescription);
            }
        }
Пример #11
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;
        }