FSSHTTPandWOPIInspector.Parsers.CompactUnsigned64bitInteger.TryParse C# (CSharp) Method

TryParse() public method

Parse the CompactUnsigned64bitInteger structure.
public TryParse ( Stream s ) : CompactUnsigned64bitInteger
s Stream An stream containing CompactUnsigned64bitInteger structure.
return CompactUnsigned64bitInteger
        public CompactUnsigned64bitInteger TryParse(Stream s)
        {
            base.Parse(s);
            byte temp = ReadByte();
            s.Position -= 1;
            CompactUnsigned64bitInteger compactUint64 = new CompactUnsigned64bitInteger();
            if (temp == 0x0)
            {
                compactUint64 = new CompactUintZero();
                compactUint64.Parse(s);
            }
            else if ((temp & 0x01) == 0x01)
            {
                compactUint64 = new CompactUint7bitvalues();
                compactUint64.Parse(s);
            }
            else if ((temp & 0x03) == 0x02)
            {
                compactUint64 = new CompactUint14bitvalues();
                compactUint64.Parse(s);
            }
            else if ((temp & 0x07) == 0x04)
            {
                compactUint64 = new CompactUint21bitvalues();
                compactUint64.Parse(s);
            }
            else if ((temp & 0x0F) == 0x08)
            {
                compactUint64 = new CompactUint28bitvalues();
                compactUint64.Parse(s);
            }
            else if ((temp & 0x1F) == 0x10)
            {
                compactUint64 = new CompactUint35bitvalues();
                compactUint64.Parse(s);
            }
            else if ((temp & 0x3F) == 0x20)
            {
                compactUint64 = new CompactUint42bitvalues();
                compactUint64.Parse(s);
            }
            else if ((temp & 0x7F) == 0x40)
            {
                compactUint64 = new CompactUint49bitvalues();
                compactUint64.Parse(s);
            }
            else if (temp == 0x80)
            {
                compactUint64 = new CompactUint64bitvalues();
                compactUint64.Parse(s);
            }
            return compactUint64;
        }

Usage Example

        /// <summary>
        /// Parse the FsshttpbSubResponse structure.
        /// </summary>
        /// <param name="s">An stream containing FsshttpbSubResponse structure.</param>
        public override void Parse(Stream s)
        {
            base.Parse(s);
            this.SubResponseStart = new bit32StreamObjectHeaderStart();
            this.SubResponseStart.Parse(s);
            this.RequestID = new CompactUnsigned64bitInteger();
            this.RequestID = RequestID.TryParse(s);
            this.RequestType = new CompactUnsigned64bitInteger();
            this.RequestType = RequestType.TryParse(s);
            byte tempByte = ReadByte();
            this.Status = GetBits(tempByte, 0, 1);
            this.Reserved = GetBits(tempByte, 1, 7);
            if (this.Status == 0x1)
            {
                this.ResponseError = new ResponseError();
                this.ResponseError.Parse(s);
            }
            else
            {
                if (this.RequestType.GetUint(RequestType) == 0x01)
                {
                    this.SubResponseData = new QueryAccessResponse();
                    ((QueryAccessResponse)this.SubResponseData).Parse(s);
                }
                else if (this.RequestType.GetUint(RequestType) == 0x02)
                {
                    this.SubResponseData = new QueryChangesResponse();
                    ((QueryChangesResponse)this.SubResponseData).Parse(s);
                }
                else if (this.RequestType.GetUint(RequestType) == 0x05)
                {
                    this.SubResponseData = new PutChangesResponse();
                    ((PutChangesResponse)this.SubResponseData).Parse(s);
                }
                else if (this.RequestType.GetUint(RequestType) == 0x0B)
                {
                    this.SubResponseData = new AllocateExtendedGUIDRange();
                    ((AllocateExtendedGUIDRange)this.SubResponseData).Parse(s);
                }

            }
            this.SubResponseEnd = new bit16StreamObjectHeaderEnd();
            this.SubResponseEnd.Parse(s);
        }
CompactUnsigned64bitInteger