public WurmCharacters([NotNull] IWurmCharacterDirectories characterDirectories, [NotNull] IWurmConfigs wurmConfigs, [NotNull] IWurmServers wurmServers, [NotNull] IWurmServerHistory wurmServerHistory, [NotNull] ILogger logger, [NotNull] TaskManager taskManager) { this.characterDirectories = characterDirectories; this.wurmConfigs = wurmConfigs; this.wurmServers = wurmServers; this.wurmServerHistory = wurmServerHistory; this.logger = logger; this.taskManager = taskManager; if (characterDirectories == null) throw new ArgumentNullException("characterDirectories"); if (wurmConfigs == null) throw new ArgumentNullException("wurmConfigs"); if (wurmServers == null) throw new ArgumentNullException("wurmServers"); if (wurmServerHistory == null) throw new ArgumentNullException("wurmServerHistory"); if (logger == null) throw new ArgumentNullException("logger"); if (taskManager == null) throw new ArgumentNullException("taskManager"); var allChars = characterDirectories.GetAllCharacters(); foreach (var characterName in allChars) { try { Create(characterName); } catch (Exception exception) { logger.Log(LogLevel.Error, "Could not initialize character for name {0}", this, exception); } } }
public WurmCharacterLogs( [NotNull] IWurmCharacter character, [NotNull] IWurmServerGroups serverGroups, [NotNull] IWurmLogsHistory logsHistory, [NotNull] IWurmServers wurmServers, [NotNull] IWurmApiLogger logger) { if (character == null) { throw new ArgumentNullException(nameof(character)); } if (serverGroups == null) { throw new ArgumentNullException(nameof(serverGroups)); } if (logsHistory == null) { throw new ArgumentNullException(nameof(logsHistory)); } if (wurmServers == null) { throw new ArgumentNullException(nameof(wurmServers)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } this.character = character; this.logsHistory = logsHistory; this.logger = logger; }
public WurmCharacter([NotNull] CharacterName name, [NotNull] string playerDirectoryFullPath, [NotNull] IWurmConfigs wurmConfigs, [NotNull] IWurmServers wurmServers, [NotNull] IWurmServerHistory wurmServerHistory, [NotNull] ILogger logger, [NotNull] TaskManager taskManager) { if (name == null) throw new ArgumentNullException("name"); if (playerDirectoryFullPath == null) throw new ArgumentNullException("playerDirectoryFullPath"); if (wurmConfigs == null) throw new ArgumentNullException("wurmConfigs"); if (wurmServers == null) throw new ArgumentNullException("wurmServers"); if (wurmServerHistory == null) throw new ArgumentNullException("wurmServerHistory"); if (logger == null) throw new ArgumentNullException("logger"); if (taskManager == null) throw new ArgumentNullException("taskManager"); this.wurmConfigs = wurmConfigs; this.wurmServers = wurmServers; this.wurmServerHistory = wurmServerHistory; this.logger = logger; this.taskManager = taskManager; Name = name; configDefiningFileFullPath = Path.Combine(playerDirectoryFullPath, ConfigDefinerFileName); RefreshCurrentConfig(); configUpdateTask = new TaskHandle(RefreshCurrentConfig, "Current config update for player " + Name); taskManager.Add(configUpdateTask); configFileWatcher = new FileSystemWatcher(playerDirectoryFullPath) { Filter = ConfigDefinerFileName }; configFileWatcher.Changed += ConfigFileWatcherOnChanged; configFileWatcher.Created += ConfigFileWatcherOnChanged; configFileWatcher.Deleted += ConfigFileWatcherOnChanged; configFileWatcher.Renamed += ConfigFileWatcherOnChanged; configFileWatcher.EnableRaisingEvents = true; configUpdateTask.Trigger(); }
public WurmCharacter([NotNull] CharacterName name, [NotNull] string playerDirectoryFullPath, [NotNull] IWurmConfigs wurmConfigs, [NotNull] IWurmServers wurmServers, [NotNull] IWurmServerHistory wurmServerHistory, [NotNull] IWurmApiLogger logger, [NotNull] TaskManager taskManager, [NotNull] IWurmLogsMonitorInternal logsMonitor, [NotNull] IPublicEventInvoker publicEventInvoker, [NotNull] InternalEventAggregator internalEventAggregator, [NotNull] IWurmLogsHistory logsHistory, [NotNull] IWurmPaths wurmPaths, [NotNull] IWurmServerGroups wurmServerGroups) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (playerDirectoryFullPath == null) { throw new ArgumentNullException(nameof(playerDirectoryFullPath)); } if (wurmConfigs == null) { throw new ArgumentNullException(nameof(wurmConfigs)); } if (wurmServers == null) { throw new ArgumentNullException(nameof(wurmServers)); } if (wurmServerHistory == null) { throw new ArgumentNullException(nameof(wurmServerHistory)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (taskManager == null) { throw new ArgumentNullException(nameof(taskManager)); } if (logsMonitor == null) { throw new ArgumentNullException(nameof(logsMonitor)); } if (publicEventInvoker == null) { throw new ArgumentNullException(nameof(publicEventInvoker)); } if (internalEventAggregator == null) { throw new ArgumentNullException(nameof(internalEventAggregator)); } if (logsHistory == null) { throw new ArgumentNullException(nameof(logsHistory)); } if (wurmPaths == null) { throw new ArgumentNullException(nameof(wurmPaths)); } if (wurmServerGroups == null) { throw new ArgumentNullException(nameof(wurmServerGroups)); } this.wurmConfigs = wurmConfigs; this.wurmServers = wurmServers; this.wurmServerHistory = wurmServerHistory; this.logger = logger; this.taskManager = taskManager; this.logsMonitor = logsMonitor; this.publicEventInvoker = publicEventInvoker; this.internalEventAggregator = internalEventAggregator; this.logsHistory = logsHistory; this.wurmServerGroups = wurmServerGroups; internalEventAggregator.Subscribe(this); Name = name; configDefiningFileFullPath = Path.Combine(playerDirectoryFullPath, ConfigDefinerFileName); RefreshCurrentConfig(); configUpdateTask = new TaskHandle(RefreshCurrentConfig, "Current config update for player " + Name); taskManager.Add(configUpdateTask); configFileWatcher = new FileSystemWatcher(playerDirectoryFullPath) { Filter = ConfigDefinerFileName }; configFileWatcher.Changed += ConfigFileWatcherOnChanged; configFileWatcher.Created += ConfigFileWatcherOnChanged; configFileWatcher.Deleted += ConfigFileWatcherOnChanged; configFileWatcher.Renamed += ConfigFileWatcherOnChanged; configFileWatcher.EnableRaisingEvents = true; configUpdateTask.Trigger(); try { wurmServerHistory.BeginTracking(Name); } catch (Exception exception) { logger.Log(LogLevel.Error, string.Format("Failed to initiate tracking of server history for character {0}", name), this, exception); } skills = new WurmCharacterSkills(this, publicEventInvoker, logsMonitor, logsHistory, logger, wurmPaths, internalEventAggregator); Logs = new WurmCharacterLogs(this, wurmServerGroups, logsHistory, wurmServers, logger); }
public WurmCharacters([NotNull] IWurmCharacterDirectories characterDirectories, [NotNull] IWurmConfigs wurmConfigs, [NotNull] IWurmServers wurmServers, [NotNull] IWurmServerHistory wurmServerHistory, [NotNull] IWurmApiLogger logger, [NotNull] TaskManager taskManager, [NotNull] IWurmLogsMonitorInternal wurmLogsMonitor, [NotNull] IPublicEventInvoker publicEventInvoker, [NotNull] InternalEventAggregator internalEventAggregator, [NotNull] IWurmPaths wurmPaths, [NotNull] IWurmLogsHistory wurmLogsHistory, [NotNull] IWurmServerGroups serverGroups) { this.characterDirectories = characterDirectories; this.wurmConfigs = wurmConfigs; this.wurmServers = wurmServers; this.wurmServerHistory = wurmServerHistory; this.logger = logger; this.taskManager = taskManager; this.wurmLogsMonitor = wurmLogsMonitor; this.publicEventInvoker = publicEventInvoker; this.internalEventAggregator = internalEventAggregator; this.wurmPaths = wurmPaths; this.wurmLogsHistory = wurmLogsHistory; this.serverGroups = serverGroups; if (characterDirectories == null) { throw new ArgumentNullException(nameof(characterDirectories)); } if (wurmConfigs == null) { throw new ArgumentNullException(nameof(wurmConfigs)); } if (wurmServers == null) { throw new ArgumentNullException(nameof(wurmServers)); } if (wurmServerHistory == null) { throw new ArgumentNullException(nameof(wurmServerHistory)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } if (taskManager == null) { throw new ArgumentNullException(nameof(taskManager)); } if (wurmLogsMonitor == null) { throw new ArgumentNullException(nameof(wurmLogsMonitor)); } if (publicEventInvoker == null) { throw new ArgumentNullException(nameof(publicEventInvoker)); } if (internalEventAggregator == null) { throw new ArgumentNullException(nameof(internalEventAggregator)); } if (wurmPaths == null) { throw new ArgumentNullException(nameof(wurmPaths)); } if (wurmLogsHistory == null) { throw new ArgumentNullException(nameof(wurmLogsHistory)); } if (serverGroups == null) { throw new ArgumentNullException(nameof(serverGroups)); } var allChars = characterDirectories.GetAllCharacters(); foreach (var characterName in allChars) { try { Create(characterName); } catch (Exception exception) { logger.Log(LogLevel.Error, string.Format("Could not initialize character for name {0}", characterName), this, exception); } } }