protected override object InternalTryGetValue(PropertyBag.BasicPropertyStore propertyBag)
 {
     byte[] valueOrDefault = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.PropertyChangeMetadataRaw);
     if (valueOrDefault == null)
     {
         CalendarItemOccurrence calendarItemOccurrence = propertyBag.Context.StoreObject as CalendarItemOccurrence;
         if (calendarItemOccurrence == null)
         {
             return(null);
         }
         return(calendarItemOccurrence.OccurrencePropertyBag.ComputeChangeMetadataBasedOnLoadedProperties());
     }
     else
     {
         if (valueOrDefault.Length == 0)
         {
             return(null);
         }
         object result;
         try
         {
             result = PropertyChangeMetadata.Parse(valueOrDefault);
         }
         catch (PropertyChangeMetadataFormatException ex)
         {
             result = new PropertyError(this, PropertyErrorCode.CorruptedData, ex.Message);
         }
         return(result);
     }
 }
        public void MarkAsMasterPropertyOverride(string propertyName)
        {
            int index;

            if (PropertyChangeMetadata.TryGetMetadataIndexForProperty(propertyName, out index))
            {
                this.masterPropertyOverrideGroupsBitArray[index] = true;
            }
        }
        protected override void InternalSetValue(PropertyBag.BasicPropertyStore propertyBag, object value)
        {
            PropertyChangeMetadata propertyChangeMetadata = value as PropertyChangeMetadata;

            if (propertyChangeMetadata == null)
            {
                throw new ArgumentException("value");
            }
            propertyBag.SetValue(InternalSchema.PropertyChangeMetadataRaw, propertyChangeMetadata.ToByteArray());
        }
        public static PropertyChangeMetadata.PropertyGroup GetGroupForPropertyName(string propertyName)
        {
            int num;

            if (!PropertyChangeMetadata.TryGetMetadataIndexForProperty(propertyName, out num))
            {
                return(null);
            }
            return(PropertyChangeMetadata.ListOfTrackedPropertyGroups[num]);
        }
 public byte[] ToByteArray()
 {
     byte[] result;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
         {
             binaryWriter.Write(1);
             binaryWriter.Write(this.flags);
             byte[] array = new byte[PropertyChangeMetadata.GetByteArraySize(this.masterPropertyOverrideGroupsBitArray.Length)];
             ((ICollection)this.masterPropertyOverrideGroupsBitArray).CopyTo(array, 0);
             binaryWriter.Write(array.Length);
             binaryWriter.Write(array);
             binaryWriter.Flush();
             result = memoryStream.ToArray();
         }
     }
     return(result);
 }
        public static PropertyChangeMetadata Merge(PropertyChangeMetadata metadata1, PropertyChangeMetadata metadata2)
        {
            if (metadata1 == null && metadata2 == null)
            {
                return(null);
            }
            metadata1 = (metadata1 ?? new PropertyChangeMetadata());
            metadata2 = (metadata2 ?? new PropertyChangeMetadata());
            PropertyChangeMetadata propertyChangeMetadata = new PropertyChangeMetadata();
            BitArray bitArray  = propertyChangeMetadata.masterPropertyOverrideGroupsBitArray;
            BitArray bitArray2 = metadata1.masterPropertyOverrideGroupsBitArray;
            BitArray bitArray3 = metadata2.masterPropertyOverrideGroupsBitArray;
            int      length    = Math.Max(Math.Max(((ICollection)bitArray2).Count, ((ICollection)bitArray3).Count), ((ICollection)bitArray).Count);

            bitArray2.Length = length;
            bitArray3.Length = length;
            bitArray.Length  = length;
            bitArray.Or(bitArray2);
            bitArray.Or(bitArray3);
            propertyChangeMetadata.flags = (metadata1.flags | metadata2.flags);
            return(propertyChangeMetadata);
        }
 static PropertyChangeMetadata()
 {
     PropertyChangeMetadata.PropertyNameToPropertyAndIndex = new Dictionary <string, PropertyChangeMetadata.PropertyAndIndex>();
     for (int i = 0; i < PropertyChangeMetadata.ListOfTrackedPropertyGroups.Length; i++)
     {
         PropertyChangeMetadata.PropertyGroup propertyGroup = PropertyChangeMetadata.ListOfTrackedPropertyGroups[i];
         if (propertyGroup != null)
         {
             StorePropertyDefinition storeProperty = propertyGroup.StoreProperty;
             if (storeProperty != null && !(storeProperty is NativeStorePropertyDefinition))
             {
                 PropertyChangeMetadata.CheckAndAddProperty(storeProperty.Name, storeProperty, propertyGroup, i);
             }
             else if (propertyGroup.IsBitField)
             {
                 PropertyChangeMetadata.CheckAndAddProperty(propertyGroup.Name, null, propertyGroup, i);
             }
             foreach (NativeStorePropertyDefinition nativeStorePropertyDefinition in PropertyChangeMetadata.ListOfTrackedPropertyGroups[i])
             {
                 PropertyChangeMetadata.CheckAndAddProperty(nativeStorePropertyDefinition.Name, nativeStorePropertyDefinition, propertyGroup, i);
             }
         }
     }
 }
Пример #8
0
        private void CopyMeetingRequestProperties(CalendarItemBase calendarItem, bool preserveLocalExceptions)
        {
            long size = calendarItem.Body.Size;

            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(42101U);
            if (!base.IsRepairUpdateMessage || (this.ChangeHighlight & ChangeHighlightProperties.BodyProps) == ChangeHighlightProperties.BodyProps)
            {
                Body.CopyBody(this, calendarItem, false);
                this.CopyNlgPropertiesTo(calendarItem);
            }
            ChangeHighlightProperties changeHighlight = this.ChangeHighlight;

            this.ProcessChangeHighlights(calendarItem, calendarItem.Body.Size, size);
            MeetingMessageType meetingMessageType = base.GetValueOrDefault <MeetingMessageType>(InternalSchema.MeetingRequestType, MeetingMessageType.NewMeetingRequest);

            if (meetingMessageType == MeetingMessageType.PrincipalWantsCopy)
            {
                if (calendarItem.IsNew)
                {
                    meetingMessageType = MeetingMessageType.NewMeetingRequest;
                    ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; Meeting type is PrincipalWantsCopy and calendar item just created.", this.GlobalObjectId);
                }
                else
                {
                    meetingMessageType = base.GetValueOrDefault <MeetingMessageType>(InternalSchema.OriginalMeetingType, MeetingMessageType.NewMeetingRequest);
                    ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, MeetingMessageType>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; Meeting type is PrincipalWantsCopy. Will use OriginalMeetingType {1}", this.GlobalObjectId, meetingMessageType);
                }
            }
            base.LocationIdentifierHelperInstance.SetLocationIdentifier(60533U, LastChangeAction.CopyMeetingRequestProperties);
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(35957U, LastChangeAction.CopyMeetingRequestProperties);
            if (MeetingMessageType.NewMeetingRequest == meetingMessageType || calendarItem.IsNew)
            {
                ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; {1}", this.GlobalObjectId, "Copying WriteOnCreate properties onto calendar item.");
                calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(52341U);
                CalendarItemBase.CopyPropertiesTo(this, calendarItem, MeetingMessage.WriteOnCreateProperties);
                if (base.IsSeriesMessage)
                {
                    CalendarItemBase.CopyPropertiesTo(this, calendarItem, MeetingMessage.WriteOnCreateSeriesProperties);
                }
                Reminder.EnsureMinutesBeforeStartIsInRange(calendarItem, this.consumerDefaultMinutesBeforeStart);
                if (base.IsRepairUpdateMessage)
                {
                    int?valueAsNullable = base.GetValueAsNullable <int>(CalendarItemBaseSchema.ItemVersion);
                    if (valueAsNullable != null)
                    {
                        calendarItem[CalendarItemBaseSchema.ItemVersion] = valueAsNullable;
                    }
                }
            }
            if (meetingMessageType == MeetingMessageType.NewMeetingRequest || (!base.IsRepairUpdateMessage && meetingMessageType == MeetingMessageType.FullUpdate))
            {
                calendarItem.ResponseType = ResponseType.NotResponded;
                BusyType valueOrDefault  = base.GetValueOrDefault <BusyType>(InternalSchema.IntendedFreeBusyStatus, BusyType.Busy);
                BusyType valueOrDefault2 = base.GetValueOrDefault <BusyType>(InternalSchema.FreeBusyStatus, BusyType.Tentative);
                calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(58485U);
                calendarItem[InternalSchema.IntendedFreeBusyStatus] = valueOrDefault;
                calendarItem[InternalSchema.FreeBusyStatus]         = ((valueOrDefault != BusyType.Free) ? valueOrDefault2 : BusyType.Free);
            }
            ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; {1}", this.GlobalObjectId, "Copying properties onto calendar item.");
            byte[]       largeBinaryProperty = base.PropertyBag.GetLargeBinaryProperty(InternalSchema.AppointmentRecurrenceBlob);
            CalendarItem calendarItem2       = calendarItem as CalendarItem;
            bool         flag = false;

            if (largeBinaryProperty != null && calendarItem2 != null)
            {
                calendarItem2.SuppressUpdateRecurrenceTimeOffset = true;
                this.CopyRecurrenceBlob(calendarItem2, largeBinaryProperty, preserveLocalExceptions);
                flag = true;
            }
            else if (calendarItem.CalendarItemType == CalendarItemType.RecurringMaster)
            {
                CalendarItem calendarItem3 = calendarItem as CalendarItem;
                if (calendarItem3 != null)
                {
                    calendarItem3.Recurrence = null;
                }
            }
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(62581U);
            if (calendarItem is CalendarItem)
            {
                PropertyChangeMetadataProcessingFlags propertyChangeMetadataProcessingFlags = calendarItem.GetValueOrDefault <PropertyChangeMetadataProcessingFlags>(CalendarItemSchema.PropertyChangeMetadataProcessingFlags, PropertyChangeMetadataProcessingFlags.None);
                propertyChangeMetadataProcessingFlags |= PropertyChangeMetadataProcessingFlags.OverrideMetadata;
                calendarItem[CalendarItemSchema.PropertyChangeMetadataProcessingFlags] = propertyChangeMetadataProcessingFlags;
            }
            if (this.ShouldPreserveAttendeesChanges(calendarItem))
            {
                ExTraceGlobals.MeetingMessageTracer.Information <GlobalObjectId, string>((long)this.GetHashCode(), "Storage.MeetingRequest.CopyMeetingRequestProperties: GOID={0}; {1}", this.GlobalObjectId, "Will copy properties trying to preserve attendee's changes.");
                CalendarItemBase.CopyPropertiesTo(this, calendarItem, CalendarItemProperties.NonPreservableMeetingMessageProperties);
                PreservableMeetingMessageProperty.CopyPreserving(new PreservablePropertyContext(this, calendarItem, changeHighlight));
                if (calendarItem is CalendarItem)
                {
                    PropertyChangeMetadata valueOrDefault3        = calendarItem.GetValueOrDefault <PropertyChangeMetadata>(InternalSchema.PropertyChangeMetadata);
                    PropertyChangeMetadata valueOrDefault4        = base.GetValueOrDefault <PropertyChangeMetadata>(InternalSchema.PropertyChangeMetadata);
                    PropertyChangeMetadata propertyChangeMetadata = PropertyChangeMetadata.Merge(valueOrDefault3, valueOrDefault4);
                    if (propertyChangeMetadata != null)
                    {
                        calendarItem[InternalSchema.PropertyChangeMetadata] = propertyChangeMetadata;
                    }
                }
            }
            else
            {
                if (calendarItem.CalendarItemType == CalendarItemType.RecurringMaster || calendarItem.CalendarItemType == CalendarItemType.Single)
                {
                    calendarItem.DeleteProperties(MeetingMessage.DisplayTimeZoneProperties);
                }
                if (calendarItem is CalendarItem)
                {
                    CalendarItemBase.CopyPropertiesTo(this, calendarItem, new PropertyDefinition[]
                    {
                        InternalSchema.PropertyChangeMetadataRaw
                    });
                }
                CalendarItemBase.CopyPropertiesTo(this, calendarItem, MeetingMessage.MeetingMessageProperties);
            }
            string valueOrDefault5 = base.GetValueOrDefault <string>(InternalSchema.AppointmentClass);

            if (valueOrDefault5 != null && ObjectClass.IsDerivedClass(valueOrDefault5, "IPM.Appointment"))
            {
                calendarItem.ClassName = valueOrDefault5;
            }
            Microsoft.Exchange.Data.Storage.Item.CopyCustomPublicStrings(this, calendarItem);
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(54389U);
            CalendarItemBase.CopyPropertiesTo(this, calendarItem, new PropertyDefinition[]
            {
                InternalSchema.TimeZoneDefinitionRecurring
            });
            if (meetingMessageType == MeetingMessageType.InformationalUpdate && !calendarItem.IsCalendarItemTypeOccurrenceOrException)
            {
                Sensitivity?valueAsNullable2 = base.GetValueAsNullable <Sensitivity>(InternalSchema.Sensitivity);
                if (valueAsNullable2 != null && calendarItem.Sensitivity != Sensitivity.Private && Enum.IsDefined(typeof(Sensitivity), valueAsNullable2.Value))
                {
                    calendarItem.Sensitivity = valueAsNullable2.Value;
                }
            }
            calendarItem.LocationIdentifierHelperInstance.SetLocationIdentifier(50293U);
            calendarItem.Reminder.Adjust();
            if (flag && calendarItem2 != null)
            {
                calendarItem2.ReloadRecurrence();
            }
        }
        public bool IsMasterPropertyOverride(string propertyName)
        {
            int index;

            return(!PropertyChangeMetadata.TryGetMetadataIndexForProperty(propertyName, out index) || this.AreAllPropertiesExceptions || this.masterPropertyOverrideGroupsBitArray[index]);
        }
 public static PropertyChangeMetadata.PropertyGroup GetGroupForProperty(StorePropertyDefinition property)
 {
     return(PropertyChangeMetadata.GetGroupForPropertyName(property.Name));
 }