예제 #1
0
        internal static StoreObjectType ReadStoreObjectTypeFromPropertyBag(ICorePropertyBag propertyBag)
        {
            object propertyValue = propertyBag.TryGetProperty(CoreItemSchema.ItemClass);
            string text;

            if (PropertyError.IsPropertyValueTooBig(propertyValue) || PropertyError.IsPropertyNotFound(propertyValue))
            {
                text = string.Empty;
            }
            else
            {
                text = PropertyBag.CheckPropertyValue <string>(CoreItemSchema.ItemClass, propertyValue);
            }
            StoreObjectType objectType = ObjectClass.GetObjectType(text);

            for (int i = 0; i < ItemBuilder.storeObjectTypeDetectionChain.Length; i++)
            {
                StoreObjectType?storeObjectType = ItemBuilder.storeObjectTypeDetectionChain[i](propertyBag, text, objectType);
                if (storeObjectType != null)
                {
                    return(storeObjectType.Value);
                }
            }
            return(objectType);
        }
예제 #2
0
        internal override void Normalize(PropertyBag participantPropertyBag)
        {
            string valueOrDefault  = participantPropertyBag.GetValueOrDefault <string>(ParticipantSchema.DisplayName);
            string valueOrDefault2 = participantPropertyBag.GetValueOrDefault <string>(ParticipantSchema.EmailAddress);
            string valueOrDefault3 = participantPropertyBag.GetValueOrDefault <string>(ParticipantSchema.SmtpAddress);

            if (valueOrDefault == null)
            {
                if (valueOrDefault3 != null)
                {
                    participantPropertyBag[ParticipantSchema.DisplayName] = valueOrDefault3;
                }
                else if (valueOrDefault2 != null && ExRoutingTypeDriver.IsValidExAddress(valueOrDefault2))
                {
                    participantPropertyBag.SetOrDeleteProperty(ParticipantSchema.DisplayName, Util.SubstringBetween(valueOrDefault2, "=", null, SubstringOptions.Backward));
                }
            }
            if (PropertyError.IsPropertyNotFound(participantPropertyBag.TryGetProperty(ParticipantSchema.EmailAddressForDisplay)))
            {
                participantPropertyBag.SetOrDeleteProperty(ParticipantSchema.EmailAddressForDisplay, valueOrDefault3);
            }
            participantPropertyBag.SetOrDeleteProperty(ParticipantSchema.LegacyExchangeDN, valueOrDefault2);
            participantPropertyBag.SetOrDeleteProperty(ParticipantSchema.SendRichInfo, true);
            base.Normalize(participantPropertyBag);
        }
        private bool GetStoredFolderId(out StoreObjectId folderId)
        {
            folderId = null;
            byte[] valueOrDefault = base.CoreItem.PropertyBag.GetValueOrDefault <byte[]>(ConversationActionItemSchema.ConversationActionMoveStoreId);
            if (valueOrDefault != null && valueOrDefault.Length > 0)
            {
                return(false);
            }
            object obj = base.CoreItem.PropertyBag.TryGetProperty(ConversationActionItemSchema.ConversationActionMoveFolderId);

            if (PropertyError.IsPropertyNotFound(obj))
            {
                return(false);
            }
            byte[] array = (byte[])obj;
            if (array != null && array.Length != 0)
            {
                try
                {
                    folderId = StoreObjectId.FromProviderSpecificId(array, StoreObjectType.Unknown);
                }
                catch (CorruptDataException)
                {
                    return(false);
                }
                return(true);
            }
            folderId = null;
            return(true);
        }
예제 #4
0
        protected override bool WriteEnforceRule(ICorePropertyBag propertyBag)
        {
            bool   flag = false;
            object obj  = null;

            foreach (PropertyDefinition propertyDefinition in base.ReadProperties)
            {
                if (propertyBag.IsPropertyDirty(propertyDefinition))
                {
                    flag = true;
                    obj  = propertyBag.TryGetProperty(propertyDefinition);
                    if (!PropertyError.IsPropertyNotFound(obj))
                    {
                        break;
                    }
                }
            }
            if (flag)
            {
                foreach (PropertyDefinition property in base.WriteProperties)
                {
                    propertyBag.SetOrDeleteProperty(property, obj);
                }
            }
            return(flag);
        }
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            Participant.Builder builder = new Participant.Builder();
            bool flag = base.Get(propertyBag, builder);

            if (this.emailAddressForDisplayPropDef != null)
            {
                string valueOrDefault = propertyBag.GetValueOrDefault <string>(this.emailAddressForDisplayPropDef);
                if (!string.IsNullOrEmpty(valueOrDefault))
                {
                    builder[ParticipantSchema.EmailAddressForDisplay] = valueOrDefault;
                    if (Participant.RoutingTypeEquals(builder.RoutingType, "EX") && PropertyError.IsPropertyNotFound(builder.TryGetProperty(ParticipantSchema.SmtpAddress)) && SmtpAddress.IsValidSmtpAddress(valueOrDefault))
                    {
                        builder[ParticipantSchema.SmtpAddress] = valueOrDefault;
                    }
                }
            }
            if (!flag && PropertyError.IsPropertyNotFound(builder.TryGetProperty(ParticipantSchema.EmailAddressForDisplay)))
            {
                return(new PropertyError(this, PropertyErrorCode.NotFound));
            }
            byte[] valueOrDefault2 = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.EntryId);
            if (valueOrDefault2 != null)
            {
                builder.Origin = new StoreParticipantOrigin(StoreObjectId.FromProviderSpecificId(valueOrDefault2), this.emailAddressIndex);
            }
            return(builder.ToParticipant());
        }
예제 #6
0
 private static void WriteAttributeForProperty(XmlWriter xmlWriter, string localName, object value)
 {
     if (!PropertyError.IsPropertyNotFound(value))
     {
         xmlWriter.WriteAttributeString(localName, MasterCategoryListSerializer.ConvertToXmlString(value));
     }
 }
예제 #7
0
 public void SetOrDeleteProperty(StorePropertyDefinition propertyDefinition, object propertyValue)
 {
     if (propertyValue == null || PropertyError.IsPropertyNotFound(propertyValue))
     {
         this.Delete(propertyDefinition);
         return;
     }
     this.SetProperty(propertyDefinition, propertyValue);
 }
예제 #8
0
 public void Update(AtomicStorePropertyDefinition propertyDefinition, object propertyValue)
 {
     if (propertyValue == null || PropertyError.IsPropertyNotFound(propertyValue))
     {
         this.parent.DeleteStoreProperty(propertyDefinition);
         return;
     }
     this.parent.SetProperty(propertyDefinition, propertyValue);
 }
예제 #9
0
 internal override ParticipantValidationStatus Validate(Participant participant)
 {
     if (participant.EmailAddress != null)
     {
         return(ParticipantValidationStatus.AddressAndRoutingTypeMismatch);
     }
     if (PropertyError.IsPropertyNotFound(participant.TryGetProperty(ParticipantSchema.OriginItemId)))
     {
         return(ParticipantValidationStatus.AddressAndOriginMismatch);
     }
     return(ParticipantValidationStatus.NoError);
 }
예제 #10
0
        protected sealed override bool WriteEnforceRule(ICorePropertyBag propertyBag)
        {
            bool   result        = false;
            object propertyValue = propertyBag.TryGetProperty(this.propertyToSet);

            if (PropertyError.IsPropertyNotFound(propertyValue))
            {
                propertyBag.SetOrDeleteProperty(this.propertyToSet, this.defaultValue);
                result = true;
            }
            return(result);
        }
예제 #11
0
 private void EnsureRequiredPropertiesArePresent()
 {
     if (PropertyError.IsPropertyNotFound(this.Item.TryGetProperty(InternalSchema.ReminderIsSetInternal)))
     {
         this.Item.LocationIdentifierHelperInstance.SetLocationIdentifier(57205U);
         this.Item[InternalSchema.ReminderIsSetInternal] = false;
     }
     if (PropertyError.IsPropertyNotFound(this.Item.TryGetProperty(InternalSchema.ReminderMinutesBeforeStartInternal)))
     {
         this.Item.LocationIdentifierHelperInstance.SetLocationIdentifier(44917U);
         this.Item[InternalSchema.ReminderMinutesBeforeStartInternal] = 0;
     }
 }
예제 #12
0
 internal static void SetOrDeleteProperty(this ICorePropertyBag propertyBag, PropertyDefinition property, object newValue)
 {
     if (property == null)
     {
         throw new ArgumentNullException("property");
     }
     if (newValue == null || PropertyError.IsPropertyNotFound(newValue))
     {
         propertyBag.Delete(property);
         return;
     }
     propertyBag.SetProperty(property, newValue);
 }
        internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
        {
            object obj  = validatablePropertyBag.TryGetProperty(this.leftPropertyDefinition);
            object obj2 = validatablePropertyBag.TryGetProperty(this.rightPropertyDefinition);

            if (PropertyError.IsPropertyNotFound(obj) && PropertyError.IsPropertyNotFound(obj2) && (this.comparisonOperator == ComparisonOperator.Equal || this.comparisonOperator == ComparisonOperator.LessThanOrEqual || this.comparisonOperator == ComparisonOperator.GreaterThanOrEqual))
            {
                return(null);
            }
            if (PropertyError.IsPropertyError(obj))
            {
                return(new StoreObjectValidationError(context, this.leftPropertyDefinition, obj, this));
            }
            if (PropertyError.IsPropertyError(obj2))
            {
                return(new StoreObjectValidationError(context, this.rightPropertyDefinition, obj2, this));
            }
            bool flag = false;

            switch (this.comparisonOperator)
            {
            case ComparisonOperator.Equal:
                flag = Util.ValueEquals(obj, obj2);
                break;

            case ComparisonOperator.NotEqual:
                flag = !Util.ValueEquals(obj, obj2);
                break;

            case ComparisonOperator.LessThan:
                flag = PropertyComparisonConstraint.LessThan(obj, obj2);
                break;

            case ComparisonOperator.LessThanOrEqual:
                flag = !PropertyComparisonConstraint.LessThan(obj2, obj);
                break;

            case ComparisonOperator.GreaterThan:
                flag = PropertyComparisonConstraint.LessThan(obj2, obj);
                break;

            case ComparisonOperator.GreaterThanOrEqual:
                flag = !PropertyComparisonConstraint.LessThan(obj, obj2);
                break;
            }
            if (flag)
            {
                return(null);
            }
            return(new StoreObjectValidationError(context, this.rightPropertyDefinition, obj2, this));
        }
예제 #14
0
 public bool MoveNext()
 {
     while (this.parentDictionaryEnumerator.MoveNext())
     {
         KeyValuePair <PropertyDefinition, object> keyValuePair = this.parentDictionaryEnumerator.Current;
         if (!PropertyError.IsPropertyNotFound(keyValuePair.Value))
         {
             KeyValuePair <PropertyDefinition, object> keyValuePair2 = this.parentDictionaryEnumerator.Current;
             this.currentItem = keyValuePair2.Key;
             return(true);
         }
     }
     return(false);
 }
예제 #15
0
        internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
        {
            object obj = validatablePropertyBag.TryGetProperty(this.propertyDefinition);

            if (!PropertyError.IsPropertyNotFound(obj))
            {
                PropertyConstraintViolationError propertyConstraintViolationError = this.constraint.Validate(obj, this.propertyDefinition, null);
                if (propertyConstraintViolationError != null)
                {
                    return(new StoreObjectValidationError(context, this.propertyDefinition, obj, this));
                }
            }
            return(null);
        }
예제 #16
0
        private void WriteContact(Stream stream, IStorePropertyBag contact)
        {
            List <byte[]> list = new List <byte[]>(this.properties.Length);

            foreach (PropertyDefinition propertyDefinition in this.properties)
            {
                object obj = contact.TryGetProperty(propertyDefinition);
                if (obj == null || PropertyError.IsPropertyNotFound(obj))
                {
                    obj = string.Empty;
                }
                list.Add(Utf8Csv.EncodeAndEscape(obj.ToString()));
            }
            Utf8Csv.WriteRawRow(stream, list.ToArray());
        }
예제 #17
0
 private static bool PropertyValuesAreEqual(PropertyDefinition property, object x, object y)
 {
     if (!PropertyError.IsPropertyError(x) && !PropertyError.IsPropertyError(y))
     {
         if (property.Type.IsArray)
         {
             Array array  = x as Array;
             Array array2 = y as Array;
             if (array == null || array2 == null || array.Length != array2.Length)
             {
                 return(false);
             }
             for (int i = 0; i < array2.Length; i++)
             {
                 if (!array.GetValue(i).Equals(array2.GetValue(i)))
                 {
                     return(false);
                 }
             }
         }
         else if (!x.Equals(y))
         {
             return(false);
         }
     }
     else
     {
         if (PropertyError.IsPropertyNotFound(x) && !PropertyError.IsPropertyNotFound(y))
         {
             return(false);
         }
         if (PropertyError.IsPropertyNotFound(y) && !PropertyError.IsPropertyNotFound(x))
         {
             return(false);
         }
         if (PropertyError.IsPropertyValueTooBig(x) || PropertyError.IsPropertyValueTooBig(y))
         {
             return(false);
         }
     }
     return(true);
 }
예제 #18
0
 internal static GroupExpansionRecipients RetrieveFromStore(MessageItem messageItem, StorePropertyDefinition propertyDefinition)
 {
     if (messageItem == null)
     {
         return(null);
     }
     try
     {
         object propertyValue = messageItem.TryGetProperty(propertyDefinition);
         if (PropertyError.IsPropertyNotFound(propertyValue))
         {
             return(null);
         }
         if (PropertyError.IsPropertyValueTooBig(propertyValue))
         {
             using (Stream stream = messageItem.OpenPropertyStream(propertyDefinition, PropertyOpenMode.ReadOnly))
             {
                 Encoding encoding = new UnicodeEncoding(false, false);
                 using (StreamReader streamReader = new StreamReader(stream, encoding))
                 {
                     string data = streamReader.ReadToEnd();
                     return(GroupExpansionRecipients.Parse(data));
                 }
             }
         }
         if (PropertyError.IsPropertyError(propertyValue))
         {
             return(null);
         }
         string text = messageItem[propertyDefinition] as string;
         if (!string.IsNullOrEmpty(text))
         {
             return(GroupExpansionRecipients.Parse(text));
         }
     }
     catch (PropertyErrorException)
     {
         return(null);
     }
     return(null);
 }
        internal static void CopyDrmProperties(Item originalItem, Item newItem)
        {
            Util.ThrowOnNullArgument(originalItem, "originalItem");
            Util.ThrowOnNullArgument(newItem, "newItem");
            int?valueAsNullable = originalItem.GetValueAsNullable <int>(MessageItemSchema.DRMRights);

            if (valueAsNullable != null)
            {
                newItem[MessageItemSchema.DRMRights] = valueAsNullable;
            }
            ExDateTime?valueAsNullable2 = originalItem.GetValueAsNullable <ExDateTime>(MessageItemSchema.DRMExpiryTime);

            if (valueAsNullable2 != null)
            {
                newItem[MessageItemSchema.DRMExpiryTime] = valueAsNullable2;
            }
            byte[] valueOrDefault = originalItem.GetValueOrDefault <byte[]>(MessageItemSchema.DRMPropsSignature);
            if (valueOrDefault != null)
            {
                newItem[MessageItemSchema.DRMPropsSignature] = valueOrDefault;
            }
            if (!PropertyError.IsPropertyNotFound(originalItem.TryGetProperty(MessageItemSchema.DRMServerLicenseCompressed)))
            {
                using (Stream stream = originalItem.OpenPropertyStream(MessageItemSchema.DRMServerLicenseCompressed, PropertyOpenMode.ReadOnly))
                {
                    using (Stream stream2 = newItem.OpenPropertyStream(MessageItemSchema.DRMServerLicenseCompressed, PropertyOpenMode.Create))
                    {
                        if (stream != null && stream2 != null)
                        {
                            using (BinaryReader binaryReader = new BinaryReader(stream))
                            {
                                using (BinaryWriter binaryWriter = new BinaryWriter(stream2))
                                {
                                    binaryWriter.Write(binaryReader.ReadBytes(checked ((int)stream.Length)));
                                }
                            }
                        }
                    }
                }
            }
        }
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            object value = propertyBag.GetValue(InternalSchema.FolderWebViewInfo);

            if (PropertyError.IsPropertyNotFound(value))
            {
                return(value);
            }
            byte[] webViewInfo = PropertyBag.CheckPropertyValue <byte[]>(InternalSchema.FolderWebViewInfo, value);
            object result;

            try
            {
                result = FolderHomePageUrlProperty.GetUrlFromWebViewInfo(webViewInfo);
            }
            catch (CorruptDataException ex)
            {
                result = new PropertyError(this, PropertyErrorCode.CorruptedData, ex.Message);
            }
            return(result);
        }
예제 #21
0
        protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
        {
            Participant.Builder builder = new Participant.Builder();
            byte[] valueOrDefault       = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.EntryId);
            if (valueOrDefault != null)
            {
                builder.SetPropertiesFrom(ParticipantEntryId.TryFromEntryId(valueOrDefault));
            }
            builder.DisplayName = (propertyBag.GetValueOrDefault <string>(InternalSchema.TransmitableDisplayName) ?? builder.DisplayName);
            if (!base.Get(propertyBag, builder))
            {
                return(new PropertyError(this, PropertyErrorCode.NotFound));
            }
            RecipientDisplayType?valueAsNullable = propertyBag.GetValueAsNullable <RecipientDisplayType>(InternalSchema.DisplayTypeExInternal);

            if (valueAsNullable != null)
            {
                builder[ParticipantSchema.DisplayTypeEx] = valueAsNullable.Value;
                builder.Origin = (builder.Origin ?? new DirectoryParticipantOrigin());
            }
            else if (PropertyError.IsPropertyNotFound(builder.TryGetProperty(ParticipantSchema.DisplayType)))
            {
                LegacyRecipientDisplayType?valueAsNullable2 = propertyBag.GetValueAsNullable <LegacyRecipientDisplayType>(InternalSchema.DisplayType);
                ObjectType?valueAsNullable3 = propertyBag.GetValueAsNullable <ObjectType>(InternalSchema.ObjectType);
                if (valueAsNullable2 != null)
                {
                    if (valueAsNullable2 != LegacyRecipientDisplayType.MailUser)
                    {
                        builder[ParticipantSchema.DisplayType] = (int)valueAsNullable2.Value;
                    }
                }
                else if (valueAsNullable3 != null && valueAsNullable3 == ObjectType.MAPI_DISTLIST)
                {
                    builder[ParticipantSchema.DisplayType] = 1;
                }
            }
            builder.SetOrDeleteProperty(ParticipantSchema.SendRichInfo, Util.NullIf <object>(propertyBag.GetValueAsNullable <bool>(InternalSchema.SendRichInfo), false));
            builder.SetOrDeleteProperty(ParticipantSchema.SendInternetEncoding, propertyBag.GetValueAsNullable <int>(InternalSchema.SendInternetEncoding));
            return(builder.ToParticipant());
        }
예제 #22
0
        private void ValidateAndFillInDefaults()
        {
            foreach (PropertyDefinition propertyDefinition in CategorySchema.Instance.AllProperties)
            {
                XmlAttributePropertyDefinition xmlAttributePropertyDefinition = propertyDefinition as XmlAttributePropertyDefinition;
                if (xmlAttributePropertyDefinition != null)
                {
                    object obj = this.propertyBag.TryGetProperty(xmlAttributePropertyDefinition);
                    PropertyValidationError[] array = null;
                    if (PropertyError.IsPropertyNotFound(obj) || (array = xmlAttributePropertyDefinition.Validate(null, obj)).Length > 0)
                    {
                        if (xmlAttributePropertyDefinition.HasDefaultValue)
                        {
                            this.propertyBag[xmlAttributePropertyDefinition] = xmlAttributePropertyDefinition.DefaultValue;
                        }
                        else if (array != null && array.Length > 0)
                        {
                            throw new PropertyValidationException(array[0].Description, xmlAttributePropertyDefinition, array);
                        }
                    }
                }
            }
            List <StoreObjectValidationError> list = new List <StoreObjectValidationError>();
            ValidationContext context = new ValidationContext(null);

            foreach (StoreObjectConstraint storeObjectConstraint in CategorySchema.Instance.Constraints)
            {
                StoreObjectValidationError storeObjectValidationError = storeObjectConstraint.Validate(context, this.propertyBag);
                if (storeObjectValidationError != null)
                {
                    list.Add(storeObjectValidationError);
                }
            }
            if (list.Count > 0)
            {
                throw new ObjectValidationException(list[0].Description, list.ToArray());
            }
        }
예제 #23
0
 private void CopyToCalendarItem(Item promotedItem, CalendarItemBase calendarItem, bool itemCreated)
 {
     foreach (PropertyDefinition propertyDefinition in InternetCalendarSchema.ImportUpdate)
     {
         object obj = promotedItem.TryGetProperty(propertyDefinition);
         if (obj != null && !PropertyError.IsPropertyNotFound(obj))
         {
             if (propertyDefinition == CalendarItemBaseSchema.AppointmentRecurrenceBlob && !itemCreated)
             {
                 CalendarItem calendarItem2 = calendarItem as CalendarItem;
                 if (calendarItem2 != null)
                 {
                     InternalRecurrence recurrenceFromItem = CalendarItem.GetRecurrenceFromItem(promotedItem);
                     InternalRecurrence internalRecurrence = new InternalRecurrence(recurrenceFromItem.Pattern, recurrenceFromItem.Range, calendarItem2, recurrenceFromItem.CreatedExTimeZone, recurrenceFromItem.ReadExTimeZone, recurrenceFromItem.StartOffset, recurrenceFromItem.EndOffset);
                     RecurrenceBlobMerger.Merge(null, null, calendarItem.GlobalObjectId, recurrenceFromItem, internalRecurrence);
                     calendarItem2.Recurrence = internalRecurrence;
                     goto IL_9C;
                 }
             }
             calendarItem[propertyDefinition] = obj;
         }
         else
         {
             calendarItem.Delete(propertyDefinition);
         }
         IL_9C :;
     }
     using (TextReader textReader = promotedItem.Body.OpenTextReader(BodyFormat.ApplicationRtf))
     {
         using (TextWriter textWriter = calendarItem.Body.OpenTextWriter(BodyFormat.ApplicationRtf))
         {
             Util.StreamHandler.CopyText(textReader, textWriter);
         }
     }
     calendarItem.CoreItem.Recipients.CopyRecipientsFrom(promotedItem.CoreItem.Recipients);
 }
예제 #24
0
        public void OpenAsReadWrite()
        {
            base.CheckDisposed("PropertyBag::OpenAsReadWrite()");
            ExTraceGlobals.StorageTracer.Information <int>((long)this.GetHashCode(), "AcrPropertyBag::OpenAsReadWrite HashCode = {0}.", this.GetHashCode());
            if (this.Mode != AcrPropertyBag.AcrMode.ReadOnly)
            {
                ExTraceGlobals.StorageTracer.Information <int>((long)this.GetHashCode(), "AcrPropertyBag::Reopen HashCode = {0}. Reopen called when Item was already opened with ItemId.", this.GetHashCode());
                return;
            }
            object obj = this.propertyBag.TryGetProperty(InternalSchema.ChangeKey);

            if (PropertyError.IsPropertyNotFound(obj))
            {
                obj = new byte[]
                {
                    1
                };
            }
            if (obj is byte[])
            {
                this.openChangeKey = (this.currentChangeKey = (byte[])obj);
                this.acrModeHint   = AcrPropertyBag.AcrMode.Passive;
            }
        }
 protected override bool ShouldEnforce(bool isPropertyDirty, object propertyValue)
 {
     return(PropertyError.IsPropertyNotFound(propertyValue) || propertyValue == null);
 }
        internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
        {
            string text = validatablePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string;

            if (!string.IsNullOrEmpty(text) && (ObjectClass.IsCalendarItem(text) || ObjectClass.IsRecurrenceException(text) || ObjectClass.IsMeetingMessage(text)) && validatablePropertyBag.IsPropertyDirty(InternalSchema.AppointmentStateInternal))
            {
                object obj = validatablePropertyBag.TryGetProperty(InternalSchema.AppointmentStateInternal);
                if (obj is int)
                {
                    AppointmentStateFlags appointmentStateFlags = (AppointmentStateFlags)obj;
                    if (EnumValidator <AppointmentStateFlags> .IsValidValue(appointmentStateFlags))
                    {
                        PropertyValueTrackingData originalPropertyInformation = validatablePropertyBag.GetOriginalPropertyInformation(InternalSchema.AppointmentStateInternal);
                        if (originalPropertyInformation.PropertyValueState == PropertyTrackingInformation.Modified && originalPropertyInformation.OriginalPropertyValue != null && !PropertyError.IsPropertyNotFound(originalPropertyInformation.OriginalPropertyValue))
                        {
                            AppointmentStateFlags appointmentStateFlags2 = (AppointmentStateFlags)originalPropertyInformation.OriginalPropertyValue;
                            bool flag  = (appointmentStateFlags2 & AppointmentStateFlags.Received) == AppointmentStateFlags.None;
                            bool flag2 = (appointmentStateFlags & AppointmentStateFlags.Received) == AppointmentStateFlags.None;
                            if (flag != flag2)
                            {
                                return(new StoreObjectValidationError(context, InternalSchema.AppointmentStateInternal, obj, this));
                            }
                        }
                    }
                }
            }
            return(null);
        }
예제 #27
0
        internal virtual void Normalize(PropertyBag participantPropertyBag)
        {
            if (PropertyError.IsPropertyNotFound(participantPropertyBag.TryGetProperty(ParticipantSchema.DisplayName)))
            {
                participantPropertyBag.SetOrDeleteProperty(ParticipantSchema.DisplayName, participantPropertyBag.TryGetProperty(ParticipantSchema.EmailAddress));
            }
            string text = participantPropertyBag.TryGetProperty(ParticipantSchema.DisplayName) as string;

            if (!string.IsNullOrEmpty(text) && text.IndexOfAny(RoutingTypeDriver.BidiMarks) >= 0)
            {
                StringBuilder stringBuilder = new StringBuilder(text.Length);
                bool          flag          = false;
                int           i             = 0;
                string        text2         = text;
                int           j             = 0;
                while (j < text2.Length)
                {
                    char c = text2[j];
                    if (!flag)
                    {
                        goto IL_94;
                    }
                    flag = false;
                    if (!char.IsHighSurrogate(c))
                    {
                        goto IL_94;
                    }
                    stringBuilder.Append(c);
IL_102:
                    j++;
                    continue;
IL_94:
                    if (char.IsLowSurrogate(c))
                    {
                        flag = true;
                        stringBuilder.Append(c);
                        goto IL_102;
                    }
                    if (c == '‪' || c == '‫' || c == '‭' || c == '‮')
                    {
                        i++;
                        stringBuilder.Append(c);
                        goto IL_102;
                    }
                    if (c != '‬')
                    {
                        stringBuilder.Append(c);
                        goto IL_102;
                    }
                    if (i > 0)
                    {
                        i--;
                        stringBuilder.Append(c);
                        goto IL_102;
                    }
                    goto IL_102;
                }
                while (i > 0)
                {
                    stringBuilder.Append('‬');
                    i--;
                }
                participantPropertyBag.SetProperty(ParticipantSchema.DisplayName, stringBuilder.ToString());
            }
        }
예제 #28
0
        protected sealed override bool WriteEnforceRule(ICorePropertyBag propertyBag)
        {
            bool   result          = false;
            bool   isPropertyDirty = propertyBag.IsPropertyDirty(this.propertyToSet);
            object propertyValue   = propertyBag.TryGetProperty(this.propertyToSet);

            if (this.ShouldEnforce(isPropertyDirty, propertyValue))
            {
                TSet    valueOrDefault  = propertyBag.GetValueOrDefault <TSet>(this.propertyToSet);
                TDepend valueOrDefault2 = propertyBag.GetValueOrDefault <TDepend>(this.propertyToDepend);
                TSet    tset;
                if (this.CalculateValue(valueOrDefault2, valueOrDefault, out tset) && (PropertyError.IsPropertyNotFound(propertyValue) || !object.Equals(tset, valueOrDefault)))
                {
                    propertyBag.SetOrDeleteProperty(this.propertyToSet, tset);
                    result = true;
                }
            }
            return(result);
        }
        internal override StoreObjectValidationError Validate(ValidationContext context, IValidatablePropertyBag validatablePropertyBag)
        {
            string text = validatablePropertyBag.TryGetProperty(InternalSchema.ItemClass) as string;

            if (!string.IsNullOrEmpty(text) && (ObjectClass.IsCalendarItem(text) || ObjectClass.IsRecurrenceException(text)) && validatablePropertyBag.IsPropertyDirty(InternalSchema.CalendarOriginatorId))
            {
                object obj = validatablePropertyBag.TryGetProperty(InternalSchema.CalendarOriginatorId);
                if (obj is string)
                {
                    string text2 = (string)obj;
                    PropertyValueTrackingData originalPropertyInformation = validatablePropertyBag.GetOriginalPropertyInformation(InternalSchema.CalendarOriginatorId);
                    if (originalPropertyInformation.PropertyValueState == PropertyTrackingInformation.Modified)
                    {
                        MailboxSession mailboxSession = context.Session as MailboxSession;
                        if (mailboxSession != null && originalPropertyInformation.OriginalPropertyValue != null && !PropertyError.IsPropertyNotFound(originalPropertyInformation.OriginalPropertyValue))
                        {
                            string text3 = (string)originalPropertyInformation.OriginalPropertyValue;
                            int?   num   = CalendarOriginatorIdProperty.Compare(text2, text3);
                            if (num != null && num < 0 && !mailboxSession.Capabilities.CanSetCalendarAPIProperties && mailboxSession.LogonType != LogonType.Transport)
                            {
                                ExTraceGlobals.MeetingMessageTracer.TraceError <string, string>((long)this.GetHashCode(), "CalendarOriginatorIdConstraint::Validate. calendar originator value changed. Original = {0}, Current = {1}", text3, text2);
                                return(new StoreObjectValidationError(context, InternalSchema.CalendarOriginatorId, text2, this));
                            }
                        }
                    }
                }
            }
            return(null);
        }
예제 #30
0
        private ConflictResolutionResult ApplyAcr(PropertyBag acrPropBag, SaveMode saveMode)
        {
            Dictionary <PropertyDefinition, AcrPropertyProfile.ValuesToResolve> valuesToResolve = this.GetValuesToResolve(acrPropBag);
            string valueOrDefault = this.PropertyBag.GetValueOrDefault <string>(InternalSchema.ItemClass, string.Empty);

            if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(valueOrDefault) || ObjectClass.IsMeetingMessage(valueOrDefault))
            {
                LocationIdentifierHelper           locationIdentifierHelper = new LocationIdentifierHelper();
                AcrPropertyProfile.ValuesToResolve valuesToResolve2;
                object serverValue;
                if (valuesToResolve.TryGetValue(InternalSchema.ChangeList, out valuesToResolve2))
                {
                    locationIdentifierHelper.ChangeBuffer = (byte[])valuesToResolve2.ClientValue;
                    serverValue = valuesToResolve2.ServerValue;
                }
                else
                {
                    serverValue = new PropertyError(InternalSchema.ChangeList, PropertyErrorCode.NotFound);
                }
                locationIdentifierHelper.SetLocationIdentifier(53909U, LastChangeAction.AcrPerformed);
                valuesToResolve2 = new AcrPropertyProfile.ValuesToResolve(locationIdentifierHelper.ChangeBuffer, serverValue, null);
                valuesToResolve[InternalSchema.ChangeList] = valuesToResolve2;
            }
            ConflictResolutionResult conflictResolutionResult = this.profile.ResolveConflicts(valuesToResolve);

            if (this.propertiesWrittenAsStream.Count > 0)
            {
                List <PropertyConflict> list = new List <PropertyConflict>(conflictResolutionResult.PropertyConflicts);
                foreach (PropertyDefinition propertyDefinition in this.propertiesWrittenAsStream.Keys)
                {
                    PropertyConflict item = new PropertyConflict(propertyDefinition, null, null, null, null, false);
                    list.Add(item);
                }
                conflictResolutionResult = new ConflictResolutionResult(SaveResult.IrresolvableConflict, list.ToArray());
            }
            if (this.irresolvableChanges || saveMode == SaveMode.FailOnAnyConflict)
            {
                conflictResolutionResult = new ConflictResolutionResult(SaveResult.IrresolvableConflict, conflictResolutionResult.PropertyConflicts);
            }
            if (conflictResolutionResult.SaveStatus != SaveResult.IrresolvableConflict)
            {
                List <PropertyDefinition> list2 = new List <PropertyDefinition>();
                List <PropertyDefinition> list3 = new List <PropertyDefinition>();
                List <object>             list4 = new List <object>();
                if (this.propertyBag == acrPropBag)
                {
                    foreach (PropertyConflict propertyConflict in conflictResolutionResult.PropertyConflicts)
                    {
                        if (propertyConflict.ResolvedValue is PropertyError)
                        {
                            if (PropertyError.IsPropertyNotFound(propertyConflict.ResolvedValue) && (!PropertyError.IsPropertyError(propertyConflict.ClientValue) || !PropertyError.IsPropertyNotFound(propertyConflict.ClientValue)))
                            {
                                list2.Add(propertyConflict.PropertyDefinition);
                            }
                        }
                        else if (propertyConflict.ResolvedValue != propertyConflict.ClientValue)
                        {
                            list3.Add(propertyConflict.PropertyDefinition);
                            list4.Add(propertyConflict.ResolvedValue);
                        }
                    }
                }
                else
                {
                    foreach (PropertyConflict propertyConflict2 in conflictResolutionResult.PropertyConflicts)
                    {
                        if (propertyConflict2.ResolvedValue is PropertyError)
                        {
                            if (PropertyError.IsPropertyNotFound(propertyConflict2.ResolvedValue))
                            {
                                list2.Add(propertyConflict2.PropertyDefinition);
                            }
                        }
                        else if (propertyConflict2.ServerValue != propertyConflict2.ResolvedValue)
                        {
                            list3.Add(propertyConflict2.PropertyDefinition);
                            list4.Add(propertyConflict2.ResolvedValue);
                        }
                    }
                }
                for (int k = 0; k < list2.Count; k++)
                {
                    acrPropBag.Delete(list2[k]);
                }
                for (int l = 0; l < list3.Count; l++)
                {
                    acrPropBag[list3[l]] = list4[l];
                }
            }
            return(conflictResolutionResult);
        }