/// <summary>
        /// Deserialize from a stream.
        /// </summary>
        /// <param name="stream">A stream contains serialize.</param>
        /// <param name="size">Must be -1.</param>
        /// <returns>The number of bytes read from the stream.</returns>
        public int Deserialize(System.IO.Stream stream, int size)
        {
            AdapterHelper.Site.Assert.AreEqual(-1, size, "The size value should be -1, but the actual value is {0}.", size);

            int bytesRead = 0;

            this.Flags = StreamHelper.ReadUInt32(stream);
            bytesRead += 4;

            this.Depth = StreamHelper.ReadUInt32(stream);
            bytesRead += 4;

            this.FolderLongTermId = StreamHelper.ReadLongTermId(stream);
            bytesRead            += 0x10 + 6 + 2;

            this.ServerDNCount = StreamHelper.ReadUInt32(stream);
            bytesRead         += 4;

            this.CheapServerDNCount = StreamHelper.ReadUInt32(stream);
            bytesRead += 4;

            this.ServerDNArray = new string[this.ServerDNCount];
            for (int i = 0; i < this.ServerDNCount; i++)
            {
                this.ServerDNArray[i] = StreamHelper.ReadString8(stream);
            }

            AdapterHelper.Site.Assert.AreEqual(this.ServerDNArray.Length, (int)this.ServerDNCount, "The deserialized serverDN count is not equal to the original server DN count. The expected value of the deserialized server DN is {0}, but the actual value is {1}.", this.ServerDNCount, this.ServerDNArray.Length);

            bytesRead += Common.GetBytesFromMutiUnicodeString(this.ServerDNArray).Length;
            return(bytesRead);
        }
Exemple #2
0
        /// <summary>
        /// Read a LongTermId from a stream
        /// and advances the position within the stream by 24.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <returns>The number of bytes read from the stream.</returns>
        public static LongTermId ReadLongTermId(Stream stream)
        {
            LongTermId id = new LongTermId();

            id.DatabaseGuid = StreamHelper.ReadGuid(stream).ToByteArray();

            id.GlobalCounter = new byte[6];
            stream.Read(id.GlobalCounter, 0, 6);
            stream.Read(new byte[2], 0, 2);
            return(id);
        }
Exemple #3
0
        /// <summary>
        /// Write  a LongTermId value to a stream
        /// and advances the position within the stream by 24.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="id">A LongTermId value.</param>
        /// <returns>The number of bytes written to the stream.</returns>
        public static int WriteLongTermId(Stream stream, LongTermId id)
        {
            int size = 0;

            size += StreamHelper.WriteGuid(stream, new Guid(id.DatabaseGuid));
            size += StreamHelper.WriteBuffer(stream, id.GlobalCounter);
            size += StreamHelper.WriteBuffer(stream, new byte[2] {
                0x00, 0x00
            });
            return(size);
        }
Exemple #4
0
        /// <summary>
        /// Gets LongTermIds.
        /// </summary>
        /// <returns>A list of LongTermIds.</returns>
        public List <LongTermId> GetLongTermIds()
        {
            List <LongTermId> idlist = new List <LongTermId>();

            if (this.globset != null && this.globset.GLOBCNTList != null)
            {
                List <GLOBCNT> cntList = this.globset.GLOBCNTList;
                for (int i = 0; i < cntList.Count; i++)
                {
                    LongTermId lid = new LongTermId
                    {
                        DatabaseGuid  = this.replguid.ToByteArray(),
                        GlobalCounter = StructureSerializer.Serialize(cntList[i])
                    };
                    idlist.Add(lid);
                }
            }

            return(idlist);
        }
        /// <summary>
        /// Initializes a new instance of the FolderReplicaInfo structure.
        /// </summary>
        /// <param name="stream">A FastTransferStream.</param>
        public FolderReplicaInfo(FastTransferStream stream)
        {
            this.Flags            = stream.ReadUInt32();
            this.Depth            = stream.ReadUInt32();
            this.FolderLongTermId = new LongTermId
            {
                DatabaseGuid  = stream.ReadGuid().ToByteArray(),
                GlobalCounter = new byte[6]
            };
            stream.Read(
                this.FolderLongTermId.GlobalCounter,
                0,
                this.FolderLongTermId.GlobalCounter.Length);
            stream.Read(new byte[2], 0, 2);
            this.ServerDNCount      = stream.ReadUInt32();
            this.CheapServerDNCount = stream.ReadUInt32();
            this.ServerDNArray      = new string[this.ServerDNCount];

            for (int i = 0; i < this.ServerDNCount; i++)
            {
                this.ServerDNArray[i] = stream.ReadString8();
            }
        }