The hierarchySync element contains the result of the hierarchy synchronization download operation. hierarchySync = *folderChange [deletions] state IncrSyncEnd
Inheritance: SyntacticalBase
        /// <summary>
        /// Generate fast transfer stream data.
        /// </summary>
        /// <param name="serverId">server id.</param>
        /// <param name="buffer">Input buffer data.</param>
        /// <returns>AbstractFastTransferStream object.</returns>
        private AbstractFastTransferStream GenerateAbstractFastTransferStream(
            int serverId,
            byte[] buffer)
        {
            using (FastTransferStream fs = new FastTransferStream(buffer, false))
            {
                AbstractFastTransferStream afts;

                // Record all property list generated while deserializing.
                SyntacticalBase.AllPropList = new List<PropList>();
                int icsStateIndex = -1;
                switch (this.streamType)
                {
                    case FastTransferStreamType.state:
                        State s = new State(fs);
                        this.VerifyMarkers(s);

                        // Insert state to the ICSStateContainer
                        icsStateIndex = this.InsertStateDict(s);
                        afts = new AbstractFastTransferStream();

                        // Get the AbstractState corresponding to the state from the fast transfer stream.
                        AbstractState astate = this.GetAbstractState(serverId, icsStateIndex, s);

                        // Set the AbstractState of the AbstractFastTransferStream.
                        afts.AbstractState = new AbstractState
                        {
                            AbstractICSStateIndex = icsStateIndex,
                            IdSetGiven = astate.IdSetGiven
                        };

                        //// Other fields of the AbstractState of the AbstractFastTransferStream do not need.

                        afts.StreamType = FastTransferStreamType.state;
                        return afts;
                    case FastTransferStreamType.attachmentContent:
                        AttachmentContent att = new AttachmentContent(fs);
                        this.VerifyMarkers(att);
                        return att.GetAbstractFastTransferStream();
                    case FastTransferStreamType.contentsSync:
                        ContentsSync cs = new ContentsSync(fs);
                        this.VerifyMarkers(cs);

                        // Insert the state of the contentsSync to the ICSStateContainer
                        icsStateIndex = this.InsertStateDict(cs.State);
                        afts = this.GetAbstractContentSync(
                            serverId, icsStateIndex, cs);
                        return afts;
                    case FastTransferStreamType.folderContent:
                        FolderContent fc = new FolderContent(fs);
                        this.VerifyMarkers(fc);
                        this.VerifyFolderReplicaInfoStructure(fc);

                        afts = fc.GetAbstractFastTransferStream();

                        if (!this.existNoPermissionFolder)
                        {
                            afts.AbstractFolderContent.IsNoPermissionObjNotOut = false;
                        }

                        this.VerifyMetaProperty(afts);
                        return afts;
                    case FastTransferStreamType.hierarchySync:
                        HierarchySync hs = new HierarchySync(fs);
                        this.VerifyMarkers(hs);
                        if (hs.FolderChangeList.Count > 0)
                        {
                            PropValue property = hs.FolderChangeList[hs.FolderChangeList.Count - 1].PropList.PropValues.Find(p => p.PropInfo.PropID == 0x65e3);
                            if (property != null)
                            {
                                this.lastConflictInfo.PCLXFromServer = ((VarPropTypePropValue)property).ValueArray;
                                this.VerifyPidTagPredecessorChangeList();
                            }
                        }

                        // Insert state to the ICSStateContainer
                        icsStateIndex = this.InsertStateDict(hs.State);
                        afts = this.GetAbstractHierachySync(serverId, hs, icsStateIndex);
                        return afts;
                    case FastTransferStreamType.MessageContent:
                        MessageContent mc = new MessageContent(fs);
                        for (int i = 0; i < mc.PropList.PropValues.Count; i++)
                        {
                            PropValue propValue = mc.PropList.PropValues[i];

                            if (propValue.PropType == 0x84b0)
                            {
                                CodePage codePage = new CodePage();
                                codePage.Deserialize(propValue.PropType);

                                this.VerifyCodePageProperty(codePage);
                            }
                        }

                        this.VerifyMarkers(mc);
                        afts = mc.GetAbstractFastTransferStream();
                        this.VerifyMetaProperty(afts);
                        return afts;
                    case FastTransferStreamType.MessageList:
                        MessageList ml = new MessageList(fs);
                        afts = ml.GetAbstractFastTransferStream();
                        this.VerifyMetaProperty(afts);
                        this.VerifyMarkers(ml);
                        return afts;
                    case FastTransferStreamType.TopFolder:
                        TopFolder tf = new TopFolder(fs);
                        this.VerifyMarkers(tf);
                        afts = tf.GetAbstractFastTransferStream();
                        this.VerifyMetaProperty(afts);
                        return afts;
                    default:
                        AdapterHelper.Site.Assert.Fail("The stream type is invalid, its value is:{0}.", this.streamType);
                        return new AbstractFastTransferStream();
                }
            }
        }
        /// <summary>
        /// Get HierachySync data.
        /// </summary>
        /// <param name="serverId">server id.</param>
        /// <param name="hsync">Content sync object</param>
        /// <param name="stateIndex">Start index.</param>
        /// <returns>The AbstractFastTransferStream</returns>
        private AbstractFastTransferStream GetAbstractHierachySync(
            int serverId,
            HierarchySync hsync,
            int stateIndex)
        {
            AbstractFastTransferStream afts = new AbstractFastTransferStream();
            AbstractHierarchySync ahsync = new AbstractHierarchySync();
            afts.StreamType = FastTransferStreamType.hierarchySync;

            ahsync.FinalICSState = this.GetAbstractState(serverId, stateIndex, hsync.State);
            ahsync.AbstractDeletion = this.GetAbstractDeletion(hsync.Deletions);
            AbstractFolderChange fc = new AbstractFolderChange();

            // Get the FolderchangeInfo, FolderCount and IsParentFolderBeforeChild
            // of the AbstractHierarchySync.
            if (hsync.FolderChangeList != null && hsync.FolderChangeList.Count > 0)
            {
                AbstractFolderChange tmp = new AbstractFolderChange();

                // fields:IsPidTagFolderIdExist,IsPidTagParentFolderIdExist
                // IsPidTagParentSourceKeyValueZero,IsPidTagSourceKeyValueZero
                // need all folderChange's corresponding flag is true.
                fc = hsync.FolderChangeList[0].GetAbstractFolderChange();
                for (int i = 1; i < hsync.FolderChangeList.Count; i++)
                {
                    tmp = hsync.FolderChangeList[i].GetAbstractFolderChange();
                    fc.IsPidTagFolderIdExist =
                        fc.IsPidTagFolderIdExist && tmp.IsPidTagFolderIdExist;
                    fc.IsPidTagParentFolderIdExist =
                        fc.IsPidTagParentFolderIdExist && tmp.IsPidTagParentFolderIdExist;
                    fc.IsPidTagParentSourceKeyValueZero =
                        fc.IsPidTagParentSourceKeyValueZero && tmp.IsPidTagParentSourceKeyValueZero;
                    fc.IsPidTagSourceKeyValueZero =
                        fc.IsPidTagSourceKeyValueZero && tmp.IsPidTagSourceKeyValueZero;
                }

                ahsync.FolderchangeInfo = fc;

                // The count of folderChange.
                ahsync.FolderCount = hsync.FolderChangeList.Count;

                // If parents are before their children,
                // for a specific folder change, its ParentSourceKey
                // must be zero if its parent is the sync folder
                // or can be found before the position of the folder change.
                ahsync.IsParentFolderBeforeChild = hsync.IsParentBeforeChildren;
            }

            afts.AbstractHierarchySync = ahsync;
            return afts;
        }