Verify() public static method

Verify that a stream's current position contains a serialized messageChange.
public static Verify ( FastTransferStream stream ) : bool
stream FastTransferStream A FastTransferStream.
return bool
Beispiel #1
0
 /// <summary>
 /// Verify that a stream's current position contains a serialized contentsSync.
 /// </summary>
 /// <param name="stream">A FastTransferStream.</param>
 /// <returns>If the stream's current position contains
 /// a serialized contentsSync, return true, else false.</returns>
 public static bool Verify(FastTransferStream stream)
 {
     return((ProgressTotal.Verify(stream) ||
             ProgressPerMessage.Verify(stream) ||
             MessageChange.Verify(stream) ||
             Deletions.Verify(stream) ||
             ReadStateChanges.Verify(stream) ||
             State.Verify(stream)) &&
            stream.VerifyMarker(
                EndMarker,
                (int)stream.Length - MarkersHelper.PidTagLength - (int)stream.Position));
 }
Beispiel #2
0
        /// <summary>
        /// Deserialize fields from a FastTransferStream.
        /// </summary>
        /// <param name="stream">A FastTransferStream.</param>
        public override void Deserialize(FastTransferStream stream)
        {
            this.messageChangeTuples = new List <Tuple <ProgressPerMessage, MessageChange> >();
            if (ProgressTotal.Verify(stream))
            {
                this.progressTotal = new ProgressTotal(stream);
            }

            while (ProgressPerMessage.Verify(stream) ||
                   MessageChange.Verify(stream))
            {
                ProgressPerMessage tmp1 = null;
                MessageChange      tmp2 = null;
                if (ProgressPerMessage.Verify(stream))
                {
                    tmp1 = new ProgressPerMessage(stream);
                }

                tmp2 = MessageChange.DeserializeFrom(stream) as MessageChange;
                this.messageChangeTuples.Add(
                    new Tuple <ProgressPerMessage, MessageChange>(
                        tmp1, tmp2));
            }

            if (Deletions.Verify(stream))
            {
                this.deletions = new Deletions(stream);
            }

            if (ReadStateChanges.Verify(stream))
            {
                this.readStateChanges = new ReadStateChanges(stream);
            }

            this.state = new State(stream);
            if (!stream.ReadMarker(Markers.PidTagIncrSyncEnd))
            {
                AdapterHelper.Site.Assert.Fail("The stream cannot be deserialized successfully.");
            }
        }