public static DedimaniaSettings ReadFromFile(string xmlConfigurationFile) { DedimaniaSettings result = new DedimaniaSettings(); XDocument configDocument = XDocument.Load(xmlConfigurationFile); if (configDocument.Root == null) { throw new ConfigurationErrorsException("Could not find root node in file: " + xmlConfigurationFile); } result.AuthUrl = ReadConfigString(configDocument.Root, "AuthUrl", AUTH_URL, xmlConfigurationFile); result.ReportUrl = ReadConfigString(configDocument.Root, "ReportUrl", REPORT_URL, xmlConfigurationFile); result.Plugins = PluginConfigEntryCollection.ReadFromDirectory(Path.GetDirectoryName(xmlConfigurationFile)); return(result); }
public static List <ITMSPSPlugin> GetPlugins(string mainDirectory, ILogger logger) { string pluginDirectory = Path.Combine(mainDirectory, "Plugins"); List <ITMSPSPlugin> result = new List <ITMSPSPlugin>(); PluginConfigEntryCollection pluginConfigEntries = PluginConfigEntryCollection.ReadFromDirectory(pluginDirectory, logger).GetEnabledPlugins(); foreach (PluginConfigEntry pluginConfigEntry in pluginConfigEntries) { logger.Debug(string.Format("Instantiating ITMSPSPlugin {0}", pluginConfigEntry.PluginClass)); result.Add(Instancer.GetInstanceOfInterface <ITMSPSPlugin>(pluginConfigEntry.AssemblyName, pluginConfigEntry.PluginClass, pluginConfigEntry.PluginDirectory)); } return(result); }
public static LocalRecordsSettings ReadFromFile(string xmlConfigurationFile) { LocalRecordsSettings result = new LocalRecordsSettings(); XDocument configDocument = XDocument.Load(xmlConfigurationFile); if (configDocument.Root == null) { throw new ConfigurationErrorsException("Could not find root node in file: " + xmlConfigurationFile); } XElement providerSettingsElement = configDocument.Root.Element("ProviderSettings"); if (providerSettingsElement == null) { throw new ConfigurationErrorsException("Could not find ProviderSettings node in file: " + xmlConfigurationFile); } XElement assemblyElement = providerSettingsElement.Element("Assembly"); if (assemblyElement == null) { throw new ConfigurationErrorsException("Could not find Assembly node in file: " + xmlConfigurationFile); } if (assemblyElement.Value.IsNullOrTimmedEmpty()) { throw new ConfigurationErrorsException("Assembly node is empty in file: " + xmlConfigurationFile); } result.ProviderAssemblyLocation = assemblyElement.Value.Trim(); XElement providerElement = providerSettingsElement.Element("Provider"); if (providerElement == null) { throw new ConfigurationErrorsException("Could not find Provider node in file: " + xmlConfigurationFile); } if (providerElement.Value.IsNullOrTimmedEmpty()) { throw new ConfigurationErrorsException("Provider node is empty in file: " + xmlConfigurationFile); } result.ProviderClass = providerElement.Value.Trim(); XElement parameterElement = providerSettingsElement.Element("Parameter"); if (parameterElement == null) { throw new ConfigurationErrorsException("Could not find Parameter node in file: " + xmlConfigurationFile); } result.ProviderParameter = parameterElement.Value.Trim(); result.MaxRecordsToReport = ReadConfigUInt(configDocument.Root, "MaxRecordsToReport", MAX_RECORDS_TO_REPORT, xmlConfigurationFile); result.CheaterDeletedMessage = ReadConfigString(configDocument.Root, "CheaterDeletedMessage", CHEATER_DELETED_MSG, xmlConfigurationFile); result.CheaterDeletionFailedMessage = ReadConfigString(configDocument.Root, "CheaterDeletionFailedMessage", CHEATER_DELETION_FAILED_MSG, xmlConfigurationFile); result.CheaterBannedMessage = ReadConfigString(configDocument.Root, "CheaterBannedMessage", CHEATER_BANNED_MSG, xmlConfigurationFile); result.Plugins = PluginConfigEntryCollection.ReadFromDirectory(Path.GetDirectoryName(xmlConfigurationFile)); return(result); }