/// <summary> /// Check the data in ReadPerUserInformation is valid or not /// </summary> /// <param name="data">Byte array value</param> /// <returns>Return Boolean value</returns> protected bool VerifyDataIsIDSETStructure(byte[] data) { IDSETWithReplGuid idset = new IDSETWithReplGuid(); try { idset.Deserialize(data, 0); } catch (FormatException formatedError) { this.Site.Log.Add(LogEntryKind.Debug, "bad formatted IDSETStructure: {0}.", formatedError.Message); return false; } return true; }
/// <summary> /// Generate a valid IDSETWithReplGuid structure /// </summary> /// <param name="bigData">The default value is false, if the value is true, this function will generate big data which length is greater than 4096</param> /// <returns>Return IDSETWithReplGuid</returns> protected IDSETWithReplGuid GenerateRandomValidIdset(bool bigData = false) { IDSETWithReplGuid idset = new IDSETWithReplGuid { ReplGuid = this.longTermIdFromIdResponse.LongTermId.DatabaseGuid, Globset = new Globset() }; List<GlobCnt> globCntList = new List<GlobCnt>(); GlobCnt globcnt = new GlobCnt(); // According to [MS-OXCFXICS] section 2.2.2.3.2. // In PushCommand, Command (1 byte): A value in the range "0x01" through "0x06". // CommonBytes (variable): Variable length byte array to be pushed onto the common byte stack. // The length of the byte array is equal to the Command value ("0x01" through "0x06"). // Here use 06 only PushCommand push = new PushCommand { Command = 0x06 }; System.Threading.Thread.Sleep(1); push.GenerateRandomCommandBytes(); // The first three byte must be zero push.CommandBytes[0] = 0x00; push.CommandBytes[1] = 0x00; push.CommandBytes[2] = 0x00; globcnt.Command = push; globCntList.Add(globcnt); if (bigData) { for (int i = 0; i < 1400; i++) { globcnt = new GlobCnt(); push = new PushCommand { Command = 0x06 }; System.Threading.Thread.Sleep(1); push.GenerateRandomCommandBytes(); // The first three byte must be zero push.CommandBytes[0] = 0x00; push.CommandBytes[1] = 0x00; push.CommandBytes[2] = 0x00; globcnt.Command = push; globCntList.Add(globcnt); } } GlobCnt globcnt1 = new GlobCnt(); // In EndCommand, the value of command is "0x00". EndCommand end = new EndCommand(); globcnt1.Command = end; globCntList.Add(globcnt1); idset.Globset.GlobCntList = globCntList; return idset; }