コード例 #1
0
        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendFormat("{0}", this.isSentItems ? "1" : "0");
            stringBuilder.AppendFormat("{0:X4}", this.internetMessageId.Length);
            stringBuilder.Append(this.internetMessageId);
            if (!string.IsNullOrEmpty(this.conversationTopic))
            {
                stringBuilder.AppendFormat("{0:X4}", this.conversationTopic.Length);
                stringBuilder.Append(this.conversationTopic);
            }
            else
            {
                stringBuilder.AppendFormat("{0:X4}", 0);
            }
            string text = UniqueItemHash.SerializeBodyTagInfoToString(this.bodyTagInfo);

            if (!string.IsNullOrEmpty(text))
            {
                stringBuilder.AppendFormat("{0:X4}", text.Length);
                stringBuilder.Append(text);
            }
            else
            {
                stringBuilder.AppendFormat("{0:X4}", 0);
            }
            return(stringBuilder.ToString());
        }
コード例 #2
0
        public override bool Equals(object obj)
        {
            UniqueItemHash uniqueItemHash = obj as UniqueItemHash;

            if (uniqueItemHash == null)
            {
                return(false);
            }
            if (!this.internetMessageId.Equals(uniqueItemHash.internetMessageId, StringComparison.OrdinalIgnoreCase) || !UniqueItemHash.CompareTopics(this.conversationTopic, uniqueItemHash.conversationTopic))
            {
                return(false);
            }
            if (this.bodyTagInfo != null && uniqueItemHash.bodyTagInfo != null)
            {
                return(this.bodyTagInfo.Equals(uniqueItemHash.bodyTagInfo));
            }
            return((!(this.bodyTagInfo == null) || !(uniqueItemHash.bodyTagInfo == null)) && ((this.bodyTagInfo == null && this.isSentItems) || (uniqueItemHash.bodyTagInfo == null && uniqueItemHash.isSentItems)));
        }
コード例 #3
0
ファイル: ItemId.cs プロジェクト: YHZX2013/exchange_diff
 public virtual void WriteToStream(Stream fs)
 {
     ItemId.WriteString(base.Id, fs, Encoding.ASCII);
     ItemId.WriteString(this.ParentFolder, fs, Encoding.Unicode);
     ItemId.WriteString(this.PrimaryItemId, fs, Encoding.ASCII);
     ItemId.WriteString(this.Subject, fs, Encoding.Unicode);
     ItemId.WriteString(this.Sender, fs, Encoding.Unicode);
     fs.Write(BitConverter.GetBytes(this.SentTime.Ticks), 0, 8);
     fs.Write(BitConverter.GetBytes(this.ReceivedTime.Ticks), 0, 8);
     ItemId.WriteString(this.BodyPreview, fs, Encoding.Unicode);
     ItemId.WriteString(this.Importance, fs, Encoding.Unicode);
     fs.Write(BitConverter.GetBytes(this.IsRead), 0, 1);
     fs.Write(BitConverter.GetBytes(this.HasAttachment), 0, 1);
     ItemId.WriteString(this.ToRecipients, fs, Encoding.Unicode);
     ItemId.WriteString(this.CcRecipients, fs, Encoding.Unicode);
     ItemId.WriteString(this.BccRecipients, fs, Encoding.Unicode);
     ItemId.WriteString(this.ToGroupExpansionRecipients, fs, Encoding.Unicode);
     ItemId.WriteString(this.CcGroupExpansionRecipients, fs, Encoding.Unicode);
     ItemId.WriteString(this.BccGroupExpansionRecipients, fs, Encoding.Unicode);
     ItemId.WriteString((this.DGGroupExpansionError == null) ? null : this.DGGroupExpansionError.ToString(), fs, Encoding.Unicode);
     byte[] bytes = BitConverter.GetBytes(this.Size);
     fs.Write(bytes, 0, 4);
     if (!this.IsDuplicate)
     {
         ItemId.WriteString(this.UniqueHash, fs, Encoding.Unicode);
         string value = string.Empty;
         if (!string.IsNullOrEmpty(this.UniqueHash))
         {
             UniqueItemHash uniqueItemHash = UniqueItemHash.Parse(this.UniqueHash);
             value = uniqueItemHash.InternetMessageId;
         }
         ItemId.WriteString(value, fs, Encoding.Unicode);
     }
     byte[] bytes2 = BitConverter.GetBytes(this.DocumentId);
     fs.Write(bytes2, 0, 4);
     fs.Write(new byte[]
     {
         this.NeedsDGExpansion ? 1 : 0
     }, 0, 1);
     ItemId.WriteString(this.SenderSmtpAddress, fs, Encoding.Unicode);
 }
コード例 #4
0
        public static UniqueItemHash Parse(string serializedUniqueItemHash)
        {
            if (string.IsNullOrEmpty(serializedUniqueItemHash))
            {
                return(null);
            }
            bool sentItems = false;

            if (serializedUniqueItemHash.Substring(0, 1) == "1")
            {
                sentItems = true;
            }
            else if (serializedUniqueItemHash.Substring(0, 1) != "0")
            {
                throw new ArgumentException("Expected sent items serialized value is not either 1 or 0.");
            }
            int num  = 1;
            int num2 = 0;

            if (!int.TryParse(serializedUniqueItemHash.Substring(num, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out num2))
            {
                throw new ArgumentException("Cannot read the length indicator value of internet message id part.");
            }
            if (num2 == 0)
            {
                throw new ArgumentException("Internet message id value read from serialized item is empty.");
            }
            num += 4;
            string internetMsgId = serializedUniqueItemHash.Substring(num, num2);

            num += num2;
            if (!int.TryParse(serializedUniqueItemHash.Substring(num, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out num2))
            {
                throw new ArgumentException("Cannot read the length indicator value of conversation topic part.");
            }
            num += 4;
            string topic = null;

            if (num2 != 0)
            {
                topic = serializedUniqueItemHash.Substring(num, num2);
                num  += num2;
            }
            if (!int.TryParse(serializedUniqueItemHash.Substring(num, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out num2))
            {
                throw new ArgumentException("Cannot read the length indicator value of body tag info part.");
            }
            num += 4;
            BodyTagInfo btInfo = null;

            if (num2 != 0)
            {
                string bodyTagInfoString = serializedUniqueItemHash.Substring(num, num2);
                btInfo = UniqueItemHash.DeserializeBodyTagInfoFromString(bodyTagInfoString);
                num   += num2;
            }
            if (num != serializedUniqueItemHash.Length)
            {
                throw new ArgumentException(string.Format("The serialized unique item hash has not been completely parsed. Start index = {0}, Length = {1}", num, serializedUniqueItemHash.Length));
            }
            return(new UniqueItemHash(internetMsgId, topic, btInfo, sentItems));
        }