Пример #1
0
        public CommandResponse(SendReceiveResult response)
        {
            if (response == null) throw new ArgumentNullException("response");
            if (!response.Success)
            {
                throw new ProtocolException(response.Error);
            }
            if (response.Lines.Count != 1)
            {
                throw new ProtocolException("Response to command wasn't 1 lines long.");
            }

            var successLine = new KeyAndValue(response.Lines[0]);
            if (successLine.Key != "Success") throw new ProtocolException("Key of Success line isn't right.");
            this.Success = bool.Parse(successLine.Value);
        }
        public RuntimeVersionIdResponse(SendReceiveResult response)
        {
            if (response == null) throw new ArgumentNullException("response");
            if (!response.Success)
            {
                throw new ProtocolException(response.Error);
            }
            if (response.Lines.Count != 1)
            {
                throw new ProtocolException("Response to \"version-id\" command wasn't 1 lines long.");
            }

            var runningLine = new KeyAndValue(response.Lines[0]);
            if (runningLine.Key != "RuntimeVersionId") throw new ProtocolException("Key of RuntimeVersionId line isn't right.");
            this.RuntimeVersionId = Guid.Parse(runningLine.Value);
        }
        public DownloadOrPatchResponse(SendReceiveResult response)
        {
            if (response == null) throw new ArgumentNullException("response");
            if (!response.Success)
            {
                throw new ProtocolException(response.Error);
            }
            if (response.Lines.Count != 2)
            {
                throw new ProtocolException("Response to \"download\" or \"patch\" command wasn't 2 lines long.");
            }

            var successLine = new KeyAndValue(response.Lines[0]);
            if (successLine.Key != "Success") throw new ProtocolException("Key of Success line isn't right.");
            this.Success = bool.Parse(successLine.Value);

            var bytesLine = new KeyAndValue(response.Lines[1]);
            if (bytesLine.Key != "Bytes") throw new ProtocolException("Key of Bytes line isn't right.");
            this.Bytes = Int32.Parse(bytesLine.Value);
        }
Пример #4
0
        public InformationResponse(SendReceiveResult response)
        {
            if (response == null) throw new ArgumentNullException("response");
            if (!response.Success)
            {
                throw new ProtocolException(response.Error);
            }
            if (response.Lines.Count != 7)
            {
                throw new ProtocolException("Response to \"information\" command wasn't 7 lines long.");
            }
            this.RuntimeName = response.Lines[0];

            var protocolVersionLine = new KeyAndValue(response.Lines[1]);
            if (protocolVersionLine.Key != "Protocol Version") throw new ProtocolException("Key of Protocol Version line isn't right.");
            this.ProtocolVersion = protocolVersionLine.Value;

            var booleansLine = new KeyAndValue(response.Lines[2]);
            if (booleansLine.Key != "Booleans") throw new ProtocolException("Key of Booleans line isn't right.");
            this.Booleans = Int32.Parse(booleansLine.Value);

            var numericsLine = new KeyAndValue(response.Lines[3]);
            if (numericsLine.Key != "Numerics") throw new ProtocolException("Key of Numerics line isn't right.");
            this.Numerics = Int32.Parse(numericsLine.Value);

            var stringsLine = new KeyAndValue(response.Lines[4]);
            if (stringsLine.Key != "Strings") throw new ProtocolException("Key of Strings line isn't right.");
            this.Strings = Int32.Parse(stringsLine.Value);

            var maxProgramSizeLine = new KeyAndValue(response.Lines[5]);
            if (maxProgramSizeLine.Key != "Max Program Size") throw new ProtocolException("Key of Max Program Size line isn't right.");
            this.MaxProgramSize = Int32.Parse(maxProgramSizeLine.Value);

            var currentProgramSizeLine = new KeyAndValue(response.Lines[6]);
            if (currentProgramSizeLine.Key != "Current Program Size") throw new ProtocolException("Key of Current Program Size line isn't right.");
            this.CurrentProgramSize = Int32.Parse(currentProgramSizeLine.Value);
        }