コード例 #1
0
ファイル: RecordLoad.cs プロジェクト: yojimbo87/Eastern
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            DtoRecord record = new DtoRecord();

            if (response == null)
            {
                return record;
            }

            // operation specific fields
            PayloadStatus payloadStatus = (PayloadStatus)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
            offset += 1;

            if (payloadStatus != PayloadStatus.NoRemainingRecords)
            {
                int contentLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                offset += 4;
                record.Content = response.Data.Skip(offset).Take(contentLength).ToArray();
                offset += contentLength;

                record.Version = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                offset += 4;

                record.Type = (ORecordType)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
                offset += 1;
            }

            return record;
        }
コード例 #2
0
ファイル: RecordCreate.cs プロジェクト: yojimbo87/Eastern
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            DtoRecord record = new DtoRecord();
            record.ORID.ClusterID = ClusterID;

            if (response == null)
            {
                return record;
            }

            // operation specific fields
            record.ORID.ClusterPosition = BinaryParser.ToLong(response.Data.Skip(offset).Take(8).ToArray());
            offset += 8;

            record.Version = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
            offset += 4;

            return record;
        }
コード例 #3
0
ファイル: Command.cs プロジェクト: yojimbo87/Eastern
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            DtoCommand command = new DtoCommand();

            if (response == null)
            {
                return command;
            }

            // operation specific fields
            command.PayloadStatus = (PayloadStatus)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
            offset += 1;

            if (OperationMode == OperationMode.Asynchronous)
            {
                command.Content = new List<DtoRecord>();

                while (command.PayloadStatus != PayloadStatus.NoRemainingRecords)
                {
                    switch (command.PayloadStatus)
                    {
                        case PayloadStatus.ResultSet:
                            DtoRecord record = new DtoRecord();

                            int contentLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                            offset += 4;
                            record.Content = response.Data.Skip(offset).Take(contentLength).ToArray();
                            offset += contentLength;

                            record.Version = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                            offset += 4;

                            record.Type = (ORecordType)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
                            offset += 1;

                            ((List<DtoRecord>)command.Content).Add(record);
                            break;
                        case PayloadStatus.PreFetched:
                            // TODO:
                            break;
                        default:
                            break;
                    }

                    command.PayloadStatus = (PayloadStatus)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
                    offset += 1;
                }
            }
            else
            {
                DtoRecord record;
                int contentLength;

                switch (command.PayloadStatus)
                {
                    case PayloadStatus.NullResult:
                        command.Content = null;
                        break;
                    case PayloadStatus.SingleRecord:
                        record = new DtoRecord();

                        contentLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                        offset += 4;
                        record.Content = response.Data.Skip(offset).Take(contentLength).ToArray();
                        offset += contentLength;

                        record.Version = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                        offset += 4;

                        record.Type = (ORecordType)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
                        offset += 1;

                        command.Content = record;
                        break;
                    case PayloadStatus.SerializedResult:
                        contentLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                        offset += 4;
                        command.Content = response.Data.Skip(offset).Take(contentLength).ToArray();
                        offset += contentLength;
                        break;
                    case PayloadStatus.RecordCollection:
                        command.Content = new List<DtoRecord>();
                        int recordsCount = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                        offset += 4;

                        for (int i = 0; i < recordsCount; i++)
                        {
                            record = new DtoRecord();

                            contentLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                            offset += 4;
                            record.Content = response.Data.Skip(offset).Take(contentLength).ToArray();
                            offset += contentLength;

                            record.Version = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                            offset += 4;

                            record.Type = (ORecordType)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
                            offset += 1;

                            ((List<DtoRecord>)command.Content).Add(record);
                        }
                        break;
                    default:
                        break;
                }
            }

            return command;
        }