ReadUInt32() public method

Reads a 4-byte unsigned integer from the current position and advances the current position of the buffer by 4 bytes.
public ReadUInt32 ( ) : uint
return uint
        /// <summary>
        /// Deserialized byte array to a ReplyActionData instance
        /// </summary>
        /// <param name="buffer">Byte array contains data of an ActionData instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public uint Deserialize(byte[] buffer)
        {
            BufferReader bufferReader = new BufferReader(buffer);
            this.messageEIDSize = bufferReader.ReadUInt32();
            this.replyTemplateMessageEID = bufferReader.ReadBytes(this.messageEIDSize);
            uint guidLength = (uint)Guid.NewGuid().ToByteArray().Length;
            this.ReplyTemplateGUID = bufferReader.ReadBytes((uint)guidLength);

            return bufferReader.Position;
        }
        /// <summary>
        /// Deserialized byte array to a Restriction instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of a Restriction instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public override uint Deserialize(byte[] buffer)
        {
            BufferReader bufferReader = new BufferReader(buffer);
            this.RestrictType = (RestrictionType)bufferReader.ReadByte();
            this.restrictCount = (this.CountType == CountByte.TwoBytesCount) ? bufferReader.ReadUInt16() : bufferReader.ReadUInt32();
            int count = (this.CountType == CountByte.TwoBytesCount) ? (int)(ushort)this.RestrictCount : (int)(uint)this.RestrictCount;
            this.Restricts = new IRestriction[count];

            uint size = bufferReader.Position;
            byte[] tmpArray = bufferReader.ReadToEnd();
            for (int i = 0; i < count; i++)
            {
                RestrictionType restrictionType = (RestrictionType)tmpArray[0];
                switch (restrictionType)
                {
                    case RestrictionType.AndRestriction:
                        this.Restricts[i] = new AndRestriction(this.CountType);
                        break;
                    case RestrictionType.BitMaskRestriction:
                        this.Restricts[i] = new BitMaskRestriction();
                        break;
                    case RestrictionType.CommentRestriction:
                        this.Restricts[i] = new CommentRestriction(this.CountType);
                        break;
                    case RestrictionType.ComparePropertiesRestriction:
                        this.Restricts[i] = new ComparePropertiesRestriction();
                        break;
                    case RestrictionType.ContentRestriction:
                        this.Restricts[i] = new ContentRestriction();
                        break;
                    case RestrictionType.CountRestriction:
                        this.Restricts[i] = new CountRestriction(this.CountType);
                        break;
                    case RestrictionType.ExistRestriction:
                        this.Restricts[i] = new ExistRestriction();
                        break;
                    case RestrictionType.NotRestriction:
                        this.Restricts[i] = new NotRestriction(this.CountType);
                        break;
                    case RestrictionType.OrRestriction:
                        this.Restricts[i] = new OrRestriction(this.CountType);
                        break;
                    case RestrictionType.PropertyRestriction:
                        this.Restricts[i] = new PropertyRestriction();
                        break;
                    case RestrictionType.SizeRestriction:
                        this.Restricts[i] = new SizeRestriction();
                        break;
                    case RestrictionType.SubObjectRestriction:
                        this.Restricts[i] = new SubObjectRestriction(this.CountType);
                        break;
                }

                uint tmpLength = this.Restricts[i].Deserialize(tmpArray);
                size += tmpLength;
                bufferReader = new BufferReader(tmpArray);
                tmpArray = bufferReader.ReadBytes(tmpLength, (uint)(tmpArray.Length - tmpLength));
            }

            return size;
        }
        /// <summary>
        /// Deserialized byte array to an ActionBlock instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of an ActionBlock instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public uint Deserialize(byte[] buffer)
        {
            BufferReader reader = new BufferReader(buffer);
            uint flags = reader.ReadUInt32();
            if (this.Flags != flags)
            {
                string errorMessage = "Flags MUST be 0x00000000, the actual value is " + flags.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte[] providerUID = reader.ReadBytes(16);
            if (!Common.CompareByteArray(this.ProviderUID, providerUID))
            {
                string errorMessage = "ProviderUID MUST be %x38.A1.BB.10.05.E5.10.1A.A1.BB.08.00.2B.2A.56.C2., the actual value is " + providerUID.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte version = reader.ReadByte();
            if (this.Version != version)
            {
                string errorMessage = "Version MUST be zero., the actual value is " + version.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte flag = reader.ReadByte();
            if (this.Flag != flag)
            {
                string errorMessage = "Flag MUST be zero, the actual value is " + flag.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte[] dllFileName = reader.ReadBytes(14);
            if (!Common.CompareByteArray(this.DLLFileName, dllFileName))
            {
                string errorMessage = "DLLFileName MUST be set to the following value which represents \"emsmdb.dll\": %x45.4D.53.4D.44.42.2E.44.4C.4C.00.00.00.00., the actual value is " + dllFileName.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            uint wrappedFlags = reader.ReadUInt32();
            if (this.WrappedFlags != wrappedFlags)
            {
                string errorMessage = "WrappedFlags MUST be 0x00000000, the actual value is " + wrappedFlags.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            byte[] wrappedProviderUID = reader.ReadBytes(16);
            if (Common.CompareByteArray(this.mailboxWrappedProviderUID, wrappedProviderUID))
            {
                this.objectType = StoreObjectType.Mailbox;
            }
            else if (Common.CompareByteArray(this.publicFolderWrappedProviderUID, wrappedProviderUID))
            {
                this.objectType = StoreObjectType.PublicFolder;
            }
            else
            {
                string errorMessage = "WrappedProviderUID is not mailbox or public folder, the actual wrappedProviderUID value is " + wrappedProviderUID.ToString() + "!";
                throw new ArgumentException(errorMessage);
            }

            uint wrappedType = reader.ReadUInt32();
            if (this.WrappedType != wrappedType)
            {
                if (this.ObjectType == StoreObjectType.Mailbox)
                {
                    string errorMessage = "For Mailbox Store object, WrappedType MUST be %x0C.00.00.00, the actual value is " + StoreObjectType.Mailbox.ToString() + "!";
                    throw new ArgumentException(errorMessage);
                }
                else
                {
                    string errorMessage = "For Public folder Store object, WrappedType MUST be %x06.00.00.00, the actual value is " + wrappedType.ToString() + "!";
                    throw new ArgumentException(errorMessage);
                }
            }

            this.ServerShortname = reader.ReadASCIIString();
            this.MailBoxDN = reader.ReadASCIIString();
            return reader.Position;
        }
        /// <summary>
        /// Deserialized byte array to a Restriction instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of a Restriction instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public override uint Deserialize(byte[] buffer)
        {
            BufferReader reader = new BufferReader(buffer);
            this.RestrictType = (RestrictionType)reader.ReadByte();
            this.RelOp = (RelationalOperator)reader.ReadByte();
            this.propTag.PropertyId = reader.ReadUInt16();
            this.propTag.PropertyType = reader.ReadUInt16();
            this.SizeValue = reader.ReadUInt32();

            return reader.Position;
        }
        /// <summary>
        /// Parse method to obtain current structure from byte array
        /// </summary>
        /// <param name="buffer">Byte array data.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public uint Deserialize(byte[] buffer)
        {
            BufferReader bufferReader = new BufferReader(buffer);
            uint count = 0;
            if (this.CountType == CountByte.TwoBytesCount)
            {
                this.NoOfActions = bufferReader.ReadUInt16();
                this.Actions = new ActionBlock[(ushort)this.NoOfActions];
                count = (uint)(ushort)this.NoOfActions;
            }
            else if (this.CountType == CountByte.FourBytesCount)
            {
                this.NoOfActions = bufferReader.ReadUInt32();
                this.Actions = new ActionBlock[(uint)this.NoOfActions];
                count = (uint)this.NoOfActions;
            }

            uint totalBytes = bufferReader.Position;
            byte[] tmpArray = bufferReader.ReadToEnd();
            uint bytesCount = 0;
            for (uint i = 0; i < count; i++)
            {
                bufferReader = new BufferReader(tmpArray);
                tmpArray = bufferReader.ReadBytes(bytesCount, (uint)(tmpArray.Length - bytesCount));
                this.Actions[i] = new ActionBlock(this.CountType);
                bytesCount = this.Actions[i].Deserialize(tmpArray);
                totalBytes += bytesCount;
            }

            return totalBytes;
        }
        /// <summary>
        /// Deserialized byte array to a ForwardActionData instance
        /// </summary>
        /// <param name="buffer">Byte array contains data of an ActionData instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public uint Deserialize(byte[] buffer)
        {
            BufferReader bufferReader = new BufferReader(buffer);
            uint totalBytes = 0;
            uint count = 0;
            if (this.CountType == CountByte.TwoBytesCount)
            {
                this.RecipientCount = bufferReader.ReadUInt16();
                this.RecipientsData = new RecipientBlock[(ushort)this.RecipientCount];
                count = (uint)(ushort)this.RecipientCount;
            }
            else if (this.CountType == CountByte.FourBytesCount)
            {
                this.RecipientCount = bufferReader.ReadUInt32();
                this.RecipientsData = new RecipientBlock[(uint)this.RecipientCount];
                count = (uint)this.RecipientCount;
            }

            totalBytes += bufferReader.Position;
            byte[] tempArray = bufferReader.ReadToEnd();
            uint bytesCount = 0;
            for (uint i = 0; i < count; i++)
            {
                bufferReader = new BufferReader(tempArray);
                tempArray = bufferReader.ReadBytes(bytesCount, (uint)(tempArray.Length - bytesCount));
                this.RecipientsData[i] = new RecipientBlock(this.CountType);
                bytesCount = this.RecipientsData[i].Deserialize(tempArray);
            }

            totalBytes += bufferReader.Position;
            return totalBytes;
        }
        /// <summary>
        /// Deserialized byte array to a Restriction instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of a Restriction instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public override uint Deserialize(byte[] buffer)
        {
            BufferReader reader = new BufferReader(buffer);
            this.RestrictType = (RestrictionType)reader.ReadByte();
            this.SubObject = (SubObjectValue)reader.ReadUInt32();

            uint size = reader.Position;
            byte[] tmpArray = reader.ReadToEnd();

            RestrictionType restrictionType = (RestrictionType)tmpArray[0];
            switch (restrictionType)
            {
                case RestrictionType.AndRestriction:
                    this.Restriction = new AndRestriction(CountType);
                    break;
                case RestrictionType.BitMaskRestriction:
                    this.Restriction = new BitMaskRestriction();
                    break;
                case RestrictionType.CommentRestriction:
                    this.Restriction = new CommentRestriction(CountType);
                    break;
                case RestrictionType.ComparePropertiesRestriction:
                    this.Restriction = new ComparePropertiesRestriction();
                    break;
                case RestrictionType.ContentRestriction:
                    this.Restriction = new ContentRestriction();
                    break;
                case RestrictionType.CountRestriction:
                    this.Restriction = new CountRestriction(CountType);
                    break;
                case RestrictionType.ExistRestriction:
                    this.Restriction = new ExistRestriction();
                    break;
                case RestrictionType.NotRestriction:
                    this.Restriction = new NotRestriction(CountType);
                    break;
                case RestrictionType.OrRestriction:
                    this.Restriction = new OrRestriction(CountType);
                    break;
                case RestrictionType.PropertyRestriction:
                    this.Restriction = new PropertyRestriction();
                    break;
                case RestrictionType.SizeRestriction:
                    this.Restriction = new SizeRestriction();
                    break;
                case RestrictionType.SubObjectRestriction:
                    this.Restriction = new SubObjectRestriction(CountType);
                    break;
            }

            size += this.Restriction.Deserialize(tmpArray);

            return size;
        }
        /// <summary>
        /// Deserialized byte array to a ForwardActionData instance
        /// </summary>
        /// <param name="buffer">Byte array contains data of an ActionData instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public uint Deserialize(byte[] buffer)
        {
            BufferReader bufferReader = new BufferReader(buffer);
            this.Reserved = bufferReader.ReadByte();

            uint count = 0;
            if (this.CountType == CountByte.TwoBytesCount)
            {
                this.NoOfProperties = bufferReader.ReadUInt16();
                this.PropertiesData = new TaggedPropertyValue[(ushort)this.NoOfProperties];
                count = (uint)(ushort)this.NoOfProperties;
            }
            else if (this.CountType == CountByte.FourBytesCount)
            {
                this.NoOfProperties = bufferReader.ReadUInt32();
                this.PropertiesData = new TaggedPropertyValue[(uint)this.NoOfProperties];
                count = (uint)this.NoOfProperties;
            }

            uint size = bufferReader.Position;
            byte[] tmpArray = bufferReader.ReadToEnd();
            for (uint i = 0; i < count; i++)
            {
                TaggedPropertyValue tagValue = AdapterHelper.ReadTaggedProperty(tmpArray);
                this.PropertiesData[i] = tagValue;
                uint tagSize = (uint)tagValue.Size();
                size += tagSize;

                bufferReader = new BufferReader(tmpArray);
                tmpArray = bufferReader.ReadBytes(tagSize, (uint)(tmpArray.Length - tagSize));
            }

            return size;
        }
 /// <summary>
 /// Deserialized byte array to an ActionData instance
 /// </summary>
 /// <param name="buffer">Byte array contain data of an ActionData instance.</param>
 /// <returns>Bytes count that deserialized in buffer.</returns>
 public uint Deserialize(byte[] buffer)
 {
     BufferReader bufferReader = new BufferReader(buffer);
     this.NamedPropertyInformation = new NamedPropertyInfo();
     uint namedPropertyInfoLength = this.NamedPropertyInformation.Deserialize(buffer);
     bufferReader = new BufferReader(bufferReader.ReadBytes(namedPropertyInfoLength, (uint)(buffer.Length - namedPropertyInfoLength)));
     this.RuleVersion = bufferReader.ReadUInt32();
     this.RuleActionBuffer = new RuleAction(CountByte.FourBytesCount);
     uint actionLength = this.RuleActionBuffer.Deserialize(bufferReader.ReadToEnd());
     uint length = namedPropertyInfoLength + sizeof(uint) + actionLength;
     return length;
 }
 /// <summary>
 /// Deserialized byte array to a BounceActionData instance
 /// </summary>
 /// <param name="buffer">Byte array contains data of an ActionData instance.</param>
 /// <returns>Bytes count that deserialized in buffer.</returns>
 public uint Deserialize(byte[] buffer)
 {
     BufferReader bufferReader = new BufferReader(buffer);
     this.Bounce = (BounceCode)bufferReader.ReadUInt32();
     return bufferReader.Position;
 }
        /// <summary>
        /// Deserialized byte array to an ActionBlock instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of an ActionBlock instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public uint Deserialize(byte[] buffer)
        {
            BufferReader reader = new BufferReader(buffer);
            uint flags = reader.ReadUInt32();
            if (this.Flags != flags)
            {
                throw new ParseException("Flags MUST be 0x00000000.");
            }

            byte[] providerUID = reader.ReadBytes(16);
            if (!Common.CompareByteArray(this.ProviderUID, providerUID))
            {
                throw new ParseException("ProviderUID MUST be %xDC.A7.40.C8.C0.42.10.1A.B4.B9.08.00.2B.2F.E1.82.");
            }

            uint version = reader.ReadUInt32();
            if (this.Version != version)
            {
                throw new ParseException("Version MUST be 0x00000001.");
            }

            this.Type = (ObjectTypes)reader.ReadUInt32();
            this.valueOfX500DN = reader.ReadASCIIString();

            return reader.Position;
        }
        /// <summary>
        /// Deserialized byte array to an ActionData instance
        /// </summary>
        /// <param name="buffer">Byte array contain data of an ActionData instance.</param>
        /// <returns>Bytes count that deserialized in buffer.</returns>
        public uint Deserialize(byte[] buffer)
        {
            BufferReader bufferReader = new BufferReader(buffer);
            this.NoOfNamedProps = bufferReader.ReadUInt16();
            if (this.NoOfNamedProps == 0x0000)
            {
                return bufferReader.Position;
            }

            this.PropId = new uint[this.NoOfNamedProps];
            for (int i = 0; i < this.NoOfNamedProps; i++)
            {
                this.PropId[i] = bufferReader.ReadUInt32();
            }

            this.NamedPropertiesSize = bufferReader.ReadUInt32();
            this.NamedProperty = new PropertyName[this.NoOfNamedProps];

            uint length = bufferReader.Position;
            byte[] tmpArray = bufferReader.ReadToEnd();
            int startIndex = 0;
            for (int j = 0; j < this.NoOfNamedProps; j++)
            {
                this.NamedProperty[j] = new PropertyName();
                startIndex += this.NamedProperty[j].Deserialize(tmpArray, startIndex);
            }

            length += (uint)startIndex;
            return length;
        }