示例#1
0
        private PluginHostContext GetHostContext()
        {
            GenericResponse <string> packMaskResponse = _client.Methods.GetServerPackMask();

            if (packMaskResponse.Erroneous)
            {
                Log.ErrorToUI("Error retrieving ServerPackMask: " + packMaskResponse.Fault.FaultMessage);
                return(null);
            }

            GenericResponse <Version> versionResponse = _client.Methods.GetVersion();

            if (versionResponse.Erroneous)
            {
                Log.ErrorToUI("Error retrieving VersionInfo: " + packMaskResponse.Fault.FaultMessage);
                return(null);
            }

            GenericResponse <string> directoryResponse = _client.Methods.GetTracksDirectory();

            if (directoryResponse.Erroneous)
            {
                Log.ErrorToUI("Error retrieving TracksDirectory: " + directoryResponse.Fault.FaultMessage);
                return(null);
            }

            GenericResponse <DetailedPlayerInfo> serverPlayerInfo = _client.Methods.GetDetailedPlayerInfo(ConfigSettings.ServerLogin);

            if (serverPlayerInfo.Erroneous)
            {
                Log.ErrorToUI("Error retrieving server player details: " + serverPlayerInfo.Fault.FaultMessage);
                return(null);
            }


            ServerInfo       serverInfo       = new ServerInfo(ConfigSettings, packMaskResponse.Value, versionResponse.Value, directoryResponse.Value, serverPlayerInfo.Value);
            MessageStyles    messageStyles    = MessageStyles.ReadFromFileOrGetDefault(Path.Combine(ApplicationDirectory, "MessageStyles.xml"));
            MessageConstants messageConstants = MessageConstants.ReadFromFile(Path.Combine(ApplicationDirectory, "MessageConstants.xml"), _client);

            return(new PluginHostContext(_client, serverInfo, new Credentials(GetFullFilePath("Credentials.xml")), messageStyles, messageConstants, Plugins));
        }