private bool TryCalculateConversationCreatorSid(IMailboxSession session, MiniRecipient mailboxOwner, ConversationAggregationResult aggregationResult, ICorePropertyBag deliveredMessage, out byte[] conversationCreatorSid)
        {
            conversationCreatorSid = null;
            bool flag = false;
            ConversationCreatorSidCalculatorFactory conversationCreatorSidCalculatorFactory = new ConversationCreatorSidCalculatorFactory(XSOFactory.Default);
            IConversationCreatorSidCalculator       conversationCreatorSidCalculator;

            if (conversationCreatorSidCalculatorFactory.TryCreate(session, mailboxOwner, out conversationCreatorSidCalculator) && conversationCreatorSidCalculator.TryCalculateOnDelivery(deliveredMessage, aggregationResult.Stage, aggregationResult.ConversationIndex, out conversationCreatorSid, out flag))
            {
                if (flag)
                {
                    conversationCreatorSidCalculator.UpdateConversationMessages(aggregationResult.ConversationIndex, conversationCreatorSid);
                }
                return(true);
            }
            return(false);
        }
        protected virtual void UpdateNewItemProperties()
        {
            IExchangePrincipal exchangePrincipal = (this.newItem.Session == null) ? null : this.newItem.Session.MailboxOwner;
            MailboxSession     mailboxSession    = this.newItem.Session as MailboxSession;

            if (mailboxSession != null && exchangePrincipal != null)
            {
                PostItem postItem = this.newItem as PostItem;
                if (postItem != null)
                {
                    postItem.Sender = new Participant(exchangePrincipal);
                }
                else
                {
                    ((MessageItem)this.newItem).Sender = new Participant(exchangePrincipal);
                }
            }
            string text           = null;
            string valueOrDefault = this.originalItem.GetValueOrDefault <string>(InternalSchema.InternetMessageId);

            if (!string.IsNullOrEmpty(valueOrDefault))
            {
                text = valueOrDefault;
            }
            string text2 = null;

            valueOrDefault = this.originalItem.GetValueOrDefault <string>(InternalSchema.InReplyTo);
            if (!string.IsNullOrEmpty(valueOrDefault))
            {
                text2 = valueOrDefault;
            }
            this.newItem.SafeSetProperty(InternalSchema.InReplyTo, text);
            StringBuilder stringBuilder = new StringBuilder(128);

            valueOrDefault = this.originalItem.GetValueOrDefault <string>(InternalSchema.InternetReferences);
            if (!string.IsNullOrEmpty(valueOrDefault))
            {
                stringBuilder.Append(valueOrDefault);
            }
            else if (text2 != null)
            {
                stringBuilder.Append(text2);
            }
            if (text != null)
            {
                if (stringBuilder.Length + 1 + text.Length > 32768 || stringBuilder.Length == 0)
                {
                    stringBuilder.Clear();
                    stringBuilder.Append(text);
                }
                else
                {
                    stringBuilder.Append(',');
                    stringBuilder.Append(text);
                }
            }
            this.newItem.SafeSetProperty(InternalSchema.InternetReferences, stringBuilder.ToString());
            this.newItem.SafeSetProperty(InternalSchema.Categories, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.Categories), typeof(string[]), null));
            byte[]            parentBytes       = this.originalItem.TryGetProperty(InternalSchema.ConversationIndex) as byte[];
            ConversationIndex conversationIndex = ConversationIndex.CreateFromParent(parentBytes);

            this.newItem.SafeSetProperty(InternalSchema.ConversationIndex, conversationIndex.ToByteArray());
            ConversationId valueOrDefault2 = this.originalItem.GetValueOrDefault <ConversationId>(InternalSchema.ConversationFamilyId);

            this.newItem.SafeSetProperty(InternalSchema.ConversationFamilyId, valueOrDefault2);
            object propValue = this.originalItem.TryGetProperty(InternalSchema.SupportsSideConversation);

            this.newItem.SafeSetProperty(InternalSchema.SupportsSideConversation, propValue);
            ConversationCreatorSidCalculatorFactory conversationCreatorSidCalculatorFactory = new ConversationCreatorSidCalculatorFactory(XSOFactory.Default);
            IConversationCreatorSidCalculator       conversationCreatorSidCalculator;

            byte[] propValue2;
            if (conversationCreatorSidCalculatorFactory.TryCreate(mailboxSession, exchangePrincipal, out conversationCreatorSidCalculator) && conversationCreatorSidCalculator.TryCalculateOnReply(conversationIndex, out propValue2))
            {
                this.newItem.SafeSetProperty(ItemSchema.ConversationCreatorSID, propValue2);
            }
            bool?valueAsNullable = this.originalItem.GetValueAsNullable <bool>(InternalSchema.ConversationIndexTracking);

            if (valueAsNullable != null && valueAsNullable.Value)
            {
                this.newItem.SafeSetProperty(InternalSchema.ConversationIndexTracking, true);
            }
            this.newItem.SafeSetProperty(InternalSchema.ConversationTopic, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.ConversationTopic), typeof(string), StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.NormalizedSubjectInternal), typeof(string), null)));
            this.newItem.SafeSetProperty(InternalSchema.Sensitivity, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.Sensitivity), typeof(Sensitivity), Sensitivity.Normal));
            this.newItem.SafeSetProperty(InternalSchema.OriginalSensitivity, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.OriginalSensitivity), typeof(Sensitivity), Sensitivity.Normal));
            this.newItem.SafeSetProperty(InternalSchema.IsReadReceiptRequested, false);
            this.newItem.SafeSetProperty(InternalSchema.IsDeliveryReceiptRequested, false);
            this.newItem.SafeSetProperty(InternalSchema.IsReplyRequested, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.IsReplyRequested), typeof(bool), null));
            this.newItem.SafeSetProperty(InternalSchema.IsResponseRequested, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.IsResponseRequested), typeof(bool), null));
            this.newItem.SafeSetProperty(InternalSchema.NativeBlockStatus, StoreObject.SafePropertyValue(this.originalItem.TryGetProperty(InternalSchema.NativeBlockStatus), typeof(int), null));
            object obj = this.originalItem.TryGetProperty(InternalSchema.IconIndex);

            if (!PropertyError.IsPropertyError(obj))
            {
                IconIndex iconIndex = (IconIndex)obj;
                if (iconIndex != IconIndex.Default)
                {
                    iconIndex = ReplyForwardCommon.GetIconIndexForNewItem(iconIndex);
                    this.newItem.SafeSetProperty(InternalSchema.IconIndex, iconIndex);
                }
            }
            ReplyForwardCommon.UpdateXLoop(this.originalItem, this.newItem, this.parameters.XLoop);
        }