コード例 #1
0
ファイル: BodyTagInfo.cs プロジェクト: YHZX2013/exchange_diff
 public byte[] ToByteArray()
 {
     byte[] array = new byte[12];
     BodyTagInfo.WriteInt(array, 0, this.wordCount);
     BodyTagInfo.WriteInt(array, 4, this.wordCrc);
     BodyTagInfo.WriteInt(array, 8, this.formatCrc);
     return(array);
 }
コード例 #2
0
ファイル: BodyTagInfo.cs プロジェクト: YHZX2013/exchange_diff
        public static BodyTagInfo FromByteArray(byte[] byteArray)
        {
            int num  = BodyTagInfo.ReadInt(byteArray, 0);
            int num2 = BodyTagInfo.ReadInt(byteArray, 4);
            int num3 = BodyTagInfo.ReadInt(byteArray, 8);

            return(new BodyTagInfo(num, num2, num3));
        }
コード例 #3
0
 private static string SerializeBodyTagInfoToString(BodyTagInfo bodyTagInfo)
 {
     if (bodyTagInfo == null)
     {
         return(null);
     }
     byte[] bytes = bodyTagInfo.ToByteArray();
     return(UniqueItemHash.asciiEncoding.GetString(bytes));
 }
コード例 #4
0
 public UniqueItemHash(string internetMsgId, string topic, BodyTagInfo btInfo, bool sentItems)
 {
     if (string.IsNullOrEmpty(internetMsgId))
     {
         throw new ArgumentNullException("internetMsgId");
     }
     this.internetMessageId = internetMsgId;
     this.conversationTopic = topic;
     this.bodyTagInfo       = btInfo;
     this.isSentItems       = sentItems;
 }
コード例 #5
0
ファイル: BodyTagInfo.cs プロジェクト: YHZX2013/exchange_diff
        public override bool Equals(object obj)
        {
            BodyTagInfo bodyTagInfo = obj as BodyTagInfo;

            return(bodyTagInfo != null && bodyTagInfo.WordCount == this.WordCount && bodyTagInfo.WordCrc == this.WordCrc && bodyTagInfo.FormatCrc == this.FormatCrc);
        }
コード例 #6
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));
        }