/// <summary> /// Deserialize the NotificationData. /// </summary> /// <param name="ropBytes">ROPs bytes in response.</param> /// <param name="startIndex">The start index of this ROP.</param> /// <returns>The size of NotificationData struct.</returns> public int Deserialize(byte[] ropBytes, int startIndex) { int index = startIndex; this.AvailableFields = new AvailableFieldsType(); this.NotificationFlags = (ushort)BitConverter.ToUInt16(ropBytes, index); index += 2; if ((this.NotificationFlags & 0x0100) == 0x0100) { this.TableEventType = (ushort)BitConverter.ToUInt16(ropBytes, index); index += 2; } if (this.HasTableRowFolderId()) { this.TableRowFolderID = (ulong)BitConverter.ToUInt64(ropBytes, index); this.AvailableFields.IsTableRowFolderIDAvailable = true; index += 8; if ((this.NotificationFlags & 0x8000) == 0x8000) { this.TableRowMessageID = (ulong)BitConverter.ToUInt64(ropBytes, index); this.AvailableFields.IsTableRowMessageIDAvailable = true; index += 8; this.TableRowInstance = (uint)BitConverter.ToUInt32(ropBytes, index); this.AvailableFields.IsTableRowPreviousInstanceAvailable = true; index += 4; } if (this.TableEventType == 0x03 || this.TableEventType == 0x05) { this.InsertAfterTableRowFolderID = (ulong)BitConverter.ToUInt64(ropBytes, index); this.AvailableFields.IsTableRowOldFolderIDAvailable = true; index += 8; if ((this.NotificationFlags & 0x8000) == 0x8000) { this.InsertAfterTableRowID = (ulong)BitConverter.ToUInt64(ropBytes, index); this.AvailableFields.IsTableRowOldMessageIDAvailable = true; index += 8; this.InsertAfterTableRowInstance = (uint)BitConverter.ToUInt32(ropBytes, index); index += 4; } this.TableRowDataSize = (ushort)BitConverter.ToUInt16(ropBytes, index); this.AvailableFields.IsTableRowDataSizeAvailable = true; index += 2; this.TableRowData = new byte[this.TableRowDataSize.Value]; Array.Copy(ropBytes, index, this.TableRowData, 0, this.TableRowDataSize.Value); index += this.TableRowDataSize.Value; } } if ((this.NotificationFlags & 0x0200) == 0x0200) { this.HierarchyChanged = ropBytes[index++]; this.FolderIDNumber = (uint)BitConverter.ToUInt32(ropBytes, index); this.AvailableFields.IsFolderIDNumberAvailable = true; index += 4; this.FolderIDs = new GlobalIdentifier[this.FolderIDNumber.Value]; this.ICSChangeNumbers = new uint[this.FolderIDNumber.Value]; for (int i = 0; i < this.FolderIDNumber; i++) { index += this.FolderIDs[i].Deserialize(ropBytes, index); } for (int i = 0; i < this.FolderIDNumber; i++) { this.ICSChangeNumbers[i] = (uint)BitConverter.ToUInt32(ropBytes, index); index += 4; } } else { // when the field HierarchyChanged is not available,set value 0xFF to it. this.HierarchyChanged = 0xFF; } if (this.HasFolderId()) { this.FolderId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; if ((this.NotificationFlags & 0x8000) == 0x8000) { this.MessageId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; } } if (this.HasParentFolderId()) { this.ParentFolderId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; } if ((this.NotificationFlags & 0x0020) == 0x0020 || (this.NotificationFlags & 0x0040) == 0x0040) { this.OldFolderId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; if ((this.NotificationFlags & 0x8000) == 0x8000) { this.OldMessageId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; } else { this.OldParentFolderId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; } } if ((this.NotificationFlags & 0x0004) == 0x0004 || (this.NotificationFlags & 0x0010) == 0x0010) { this.TagCount = (ushort)BitConverter.ToUInt16(ropBytes, index); index += 2; } if (this.TagCount > 0 && this.TagCount != 0xFFFF) { this.Tags = new uint[this.TagCount.Value]; for (int i = 0; i < this.TagCount; i++) { this.Tags[i] = (uint)BitConverter.ToUInt32(ropBytes, index); index += 4; } } if ((this.NotificationFlags & 0x1000) == 0x1000) { this.TotalMessageCount = (uint)BitConverter.ToUInt32(ropBytes, index); this.AvailableFields.IsTotalMessageCountAvailable = true; index += 4; } if ((this.NotificationFlags & 0x2000) == 0x2000) { this.UnreadMessageCount = (uint)BitConverter.ToUInt32(ropBytes, index); this.AvailableFields.IsUnreadMessageCountAvailable = true; index += 4; } if ((this.NotificationFlags & 0x0fff) == 0x0002) { this.MessageFlags = (uint)BitConverter.ToUInt32(ropBytes, index); index += 4; this.UnicodeFlag = ropBytes[index++]; this.ParseString(ref index, ref ropBytes); } return(index - startIndex); }
/// <summary> /// Deserialize the NotificationData. /// </summary> /// <param name="ropBytes">ROPs bytes in response.</param> /// <param name="startIndex">The start index of this ROP.</param> /// <returns>The size of NotificationData struct.</returns> public int Deserialize(byte[] ropBytes, int startIndex) { int index = startIndex; this.AvailableFields = new AvailableFieldsType(); this.NotificationFlags = (ushort)BitConverter.ToUInt16(ropBytes, index); index += 2; if ((this.NotificationFlags & 0x0100) == 0x0100) { this.TableEventType = (ushort)BitConverter.ToUInt16(ropBytes, index); index += 2; } if (this.HasTableRowFolderId()) { this.TableRowFolderID = (ulong)BitConverter.ToUInt64(ropBytes, index); this.AvailableFields.IsTableRowFolderIDAvailable = true; index += 8; if ((this.NotificationFlags & 0x8000) == 0x8000) { this.TableRowMessageID = (ulong)BitConverter.ToUInt64(ropBytes, index); this.AvailableFields.IsTableRowMessageIDAvailable = true; index += 8; this.TableRowInstance = (uint)BitConverter.ToUInt32(ropBytes, index); this.AvailableFields.IsTableRowPreviousInstanceAvailable = true; index += 4; } if (this.TableEventType == 0x03 || this.TableEventType == 0x05) { this.InsertAfterTableRowFolderID = (ulong)BitConverter.ToUInt64(ropBytes, index); this.AvailableFields.IsTableRowOldFolderIDAvailable = true; index += 8; if ((this.NotificationFlags & 0x8000) == 0x8000) { this.InsertAfterTableRowID = (ulong)BitConverter.ToUInt64(ropBytes, index); this.AvailableFields.IsTableRowOldMessageIDAvailable = true; index += 8; this.InsertAfterTableRowInstance = (uint)BitConverter.ToUInt32(ropBytes, index); index += 4; } this.TableRowDataSize = (ushort)BitConverter.ToUInt16(ropBytes, index); this.AvailableFields.IsTableRowDataSizeAvailable = true; index += 2; this.TableRowData = new byte[this.TableRowDataSize.Value]; Array.Copy(ropBytes, index, this.TableRowData, 0, this.TableRowDataSize.Value); index += this.TableRowDataSize.Value; } } if ((this.NotificationFlags & 0x0200) == 0x0200) { this.HierarchyChanged = ropBytes[index++]; this.FolderIDNumber = (uint)BitConverter.ToUInt32(ropBytes, index); this.AvailableFields.IsFolderIDNumberAvailable = true; index += 4; this.FolderIDs = new GlobalIdentifier[this.FolderIDNumber.Value]; this.ICSChangeNumbers = new uint[this.FolderIDNumber.Value]; for (int i = 0; i < this.FolderIDNumber; i++) { index += this.FolderIDs[i].Deserialize(ropBytes, index); } for (int i = 0; i < this.FolderIDNumber; i++) { this.ICSChangeNumbers[i] = (uint)BitConverter.ToUInt32(ropBytes, index); index += 4; } } else { // when the field HierarchyChanged is not available,set value 0xFF to it. this.HierarchyChanged = 0xFF; } if (this.HasFolderId()) { this.FolderId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; if ((this.NotificationFlags & 0x8000) == 0x8000) { this.MessageId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; } } if (this.HasParentFolderId()) { this.ParentFolderId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; } if ((this.NotificationFlags & 0x0020) == 0x0020 || (this.NotificationFlags & 0x0040) == 0x0040) { this.OldFolderId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; if ((this.NotificationFlags & 0x8000) == 0x8000) { this.OldMessageId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; } else { this.OldParentFolderId = (ulong)BitConverter.ToUInt64(ropBytes, index); index += 8; } } if ((this.NotificationFlags & 0x0004) == 0x0004 || (this.NotificationFlags & 0x0010) == 0x0010) { this.TagCount = (ushort)BitConverter.ToUInt16(ropBytes, index); index += 2; } if (this.TagCount > 0 && this.TagCount != 0xFFFF) { this.Tags = new uint[this.TagCount.Value]; for (int i = 0; i < this.TagCount; i++) { this.Tags[i] = (uint)BitConverter.ToUInt32(ropBytes, index); index += 4; } } if ((this.NotificationFlags & 0x1000) == 0x1000) { this.TotalMessageCount = (uint)BitConverter.ToUInt32(ropBytes, index); this.AvailableFields.IsTotalMessageCountAvailable = true; index += 4; } if ((this.NotificationFlags & 0x2000) == 0x2000) { this.UnreadMessageCount = (uint)BitConverter.ToUInt32(ropBytes, index); this.AvailableFields.IsUnreadMessageCountAvailable = true; index += 4; } if ((this.NotificationFlags & 0x0fff) == 0x0002) { this.MessageFlags = (uint)BitConverter.ToUInt32(ropBytes, index); index += 4; this.UnicodeFlag = ropBytes[index++]; this.ParseString(ref index, ref ropBytes); } return index - startIndex; }