public static MessageConstants ReadFromFile(string xmlConfigurationFile, TrackManiaRPCClient rpcClient) { if (rpcClient == null) { throw new ArgumentNullException("rpcClient"); } MessageConstants result = new MessageConstants(); result["servername"] = rpcClient.Methods.GetServerName().Value; if (!File.Exists(xmlConfigurationFile)) { return(result); } XDocument configDocument = XDocument.Load(xmlConfigurationFile); if (configDocument.Root == null) { throw new ConfigurationErrorsException("Could not find root node in file: " + xmlConfigurationFile); } foreach (XNode node in configDocument.Root.Nodes()) { if (node is XElement) { result[((XElement)node).Name.ToString().ToLower()] = ((XElement)node).Value; } } return(result); }
public PluginHostContext(TrackManiaRPCClient client, ServerInfo serverInfo, Credentials credentials, MessageStyles messageStyles, MessageConstants messageConstants, List <ITMSPSPlugin> plugins) { if (client == null) { throw new ArgumentNullException("client"); } if (serverInfo == null) { throw new ArgumentNullException("serverInfo"); } if (messageStyles == null) { throw new ArgumentNullException("messageStyles"); } if (messageConstants == null) { throw new ArgumentNullException("messageConstants"); } if (plugins == null) { throw new ArgumentNullException("plugins"); } RPCClient = client; ServerInfo = serverInfo; Credentials = credentials; ValueStore = new ValueStore(); Culture = new CultureInfo("en-us"); MessagStyles = messageStyles; MessageConstants = messageConstants; CorePlugin = (TMSPSCorePlugin)plugins[0]; LastPluginID = 0; Plugins = plugins.AsReadOnly(); }