private void WriteProperty(NativeStorePropertyDefinition property, object value)
        {
            value = ExTimeZoneHelperForMigrationOnly.ToLegacyUtcIfDateTime(value);
            switch (property.SpecifiedWith)
            {
            case PropertyTypeSpecifier.PropertyTag:
            {
                PropertyTagPropertyDefinition propertyTagPropertyDefinition = (PropertyTagPropertyDefinition)property;
                TnefPropertyTag propertyTag = (int)propertyTagPropertyDefinition.PropertyTag;
                this.PropertyWriter.WriteProperty(propertyTag, value);
                return;
            }

            case PropertyTypeSpecifier.GuidString:
            {
                GuidNamePropertyDefinition guidNamePropertyDefinition = (GuidNamePropertyDefinition)property;
                TnefPropertyType           propertyType = (TnefPropertyType)guidNamePropertyDefinition.MapiPropertyType;
                this.PropertyWriter.WriteProperty(guidNamePropertyDefinition.Guid, guidNamePropertyDefinition.PropertyName, propertyType, value);
                return;
            }

            case PropertyTypeSpecifier.GuidId:
            {
                GuidIdPropertyDefinition guidIdPropertyDefinition = (GuidIdPropertyDefinition)property;
                TnefPropertyType         propertyType2            = (TnefPropertyType)guidIdPropertyDefinition.MapiPropertyType;
                this.PropertyWriter.WriteProperty(guidIdPropertyDefinition.Guid, guidIdPropertyDefinition.Id, propertyType2, value);
                return;
            }

            default:
                throw new InvalidOperationException(string.Format("Invalid native property specifier: {0}", property.SpecifiedWith));
            }
        }
        private static BlobRecipient ReadRecipient(ExTimeZone timeZone, BinaryReader reader)
        {
            BlobRecipient blobRecipient = null;
            uint          num           = reader.ReadUInt32();

            reader.ReadUInt32();
            if (num > 0U)
            {
                blobRecipient = new BlobRecipient(timeZone);
                for (uint num2 = 0U; num2 < num; num2 += 1U)
                {
                    PropTag propTag;
                    object  value;
                    if (!BlobRecipientParser.ReadPropValue(reader, out propTag, out value))
                    {
                        ExTraceGlobals.StorageTracer.TraceError(0L, "BlobRecipientParser::ReadRecipient. Failed reading property.");
                        return(null);
                    }
                    if (propTag.ValueType() != PropType.Error && !propTag.IsNamedProperty())
                    {
                        try
                        {
                            PropertyTagPropertyDefinition propertyDefinition = PropertyTagPropertyDefinition.CreateCustom(propTag.ToString(), (uint)propTag);
                            blobRecipient[propertyDefinition] = value;
                        }
                        catch (InvalidPropertyTypeException ex)
                        {
                            ExTraceGlobals.StorageTracer.TraceError <PropTag, string>(0L, "BlobRecipientParser::ReadRecipient. Failed creating custom property definition for ptag={0}; exception message={1}", propTag, ex.Message);
                            return(null);
                        }
                    }
                }
            }
            return(blobRecipient);
        }
        protected NativeStorePropertyDefinition CreatePropertyDefinition(TnefPropertyTag propertyTag, TnefNameId?namedProperty)
        {
            PropType tnefType = (PropType)propertyTag.TnefType;

            if (tnefType == PropType.Error || tnefType == PropType.Null || tnefType == PropType.ObjectArray || tnefType == PropType.Unspecified)
            {
                return(null);
            }
            if (tnefType == PropType.Object && propertyTag != TnefPropertyTag.AttachDataObj)
            {
                return(null);
            }
            if (namedProperty == null)
            {
                return(PropertyTagPropertyDefinition.InternalCreateCustom(string.Empty, (PropTag)propertyTag, PropertyFlags.None, NativeStorePropertyDefinition.TypeCheckingFlag.DoNotCreateInvalidType));
            }
            Guid propertySetGuid = namedProperty.Value.PropertySetGuid;

            if (namedProperty.Value.Kind == TnefNameIdKind.Id)
            {
                return(GuidIdPropertyDefinition.InternalCreateCustom(string.Empty, tnefType, propertySetGuid, namedProperty.Value.Id, PropertyFlags.None, NativeStorePropertyDefinition.TypeCheckingFlag.DoNotCreateInvalidType, new PropertyDefinitionConstraint[0]));
            }
            string name = namedProperty.Value.Name;

            if (!GuidNamePropertyDefinition.IsValidName(propertySetGuid, name))
            {
                return(null);
            }
            return(GuidNamePropertyDefinition.InternalCreateCustom(string.Empty, tnefType, propertySetGuid, name, PropertyFlags.None, NativeStorePropertyDefinition.TypeCheckingFlag.DoNotCreateInvalidType, new PropertyDefinitionConstraint[0]));
        }
 private static bool TryReadEntry(BinaryReader reader, out ExternalUser user)
 {
     if (reader.ReadUInt32() == ExternalUserCollection.ptagLocalDirectoryEntryId)
     {
         uint num = reader.ReadUInt32();
         MemoryPropertyBag memoryPropertyBag = new MemoryPropertyBag();
         int num2 = 0;
         while ((long)num2 < (long)((ulong)num))
         {
             uint   num3 = reader.ReadUInt32();
             object obj  = ExternalUserCollection.ReadPropValue(reader, ((PropTag)num3).ValueType(), reader.ReadUInt32());
             if (obj != null)
             {
                 PropertyTagPropertyDefinition prop = PropertyTagPropertyDefinition.CreateCustom(string.Empty, num3);
                 memoryPropertyBag.PreLoadStoreProperty(prop, obj, (int)num);
             }
             num2++;
         }
         memoryPropertyBag.SetAllPropertiesLoaded();
         IDirectPropertyBag directPropertyBag = memoryPropertyBag;
         if (directPropertyBag.IsLoaded(InternalSchema.MemberSIDLocalDirectory) && directPropertyBag.IsLoaded(InternalSchema.MemberExternalIdLocalDirectory) && directPropertyBag.IsLoaded(InternalSchema.MemberEmailLocalDirectory))
         {
             if (!directPropertyBag.IsLoaded(InternalSchema.MemberName))
             {
                 memoryPropertyBag[InternalSchema.MemberName] = directPropertyBag.GetValue(InternalSchema.MemberEmailLocalDirectory);
             }
             user = new ExternalUser(memoryPropertyBag);
             return(true);
         }
     }
     user = null;
     return(false);
 }
Beispiel #5
0
 internal ConversationIdProperty(PropertyTagPropertyDefinition conversationIdPropertyDefinition, string propertyName) : base(propertyName, typeof(ConversationId), PropertyFlags.ReadOnly, PropertyDefinitionConstraint.None, new PropertyDependency[]
 {
     new PropertyDependency(conversationIdPropertyDefinition, PropertyDependencyType.NeedForRead)
 })
 {
     this.conversationIdPropertyDefinition = conversationIdPropertyDefinition;
 }
Beispiel #6
0
        internal static bool IsPropertyTransmittable(NativeStorePropertyDefinition property)
        {
            if (property is NamedPropertyDefinition)
            {
                return(true);
            }
            PropertyTagPropertyDefinition propertyTagPropertyDefinition = (PropertyTagPropertyDefinition)property;

            return(propertyTagPropertyDefinition.IsTransmittable);
        }
        public override bool Equals(object obj)
        {
            if (object.ReferenceEquals(obj, this))
            {
                return(true);
            }
            PropertyTagPropertyDefinition propertyTagPropertyDefinition = obj as PropertyTagPropertyDefinition;

            return(propertyTagPropertyDefinition != null && this.propertyTag == propertyTagPropertyDefinition.propertyTag);
        }
        internal PropTag PropTagFromPropertyDefinition(MapiProp mapiProp, StoreSession storeSession, bool allowUnresolvedHeaders, bool allowCreate, NativeStorePropertyDefinition propertyDefinition)
        {
            PropertyTagPropertyDefinition propertyTagPropertyDefinition = propertyDefinition as PropertyTagPropertyDefinition;

            if (propertyTagPropertyDefinition != null)
            {
                return((PropTag)propertyTagPropertyDefinition.PropertyTag);
            }
            ICollection <PropTag> source = this.PropTagsFromPropertyDefinitions(mapiProp, storeSession, allowUnresolvedHeaders, allowCreate, true, new NativeStorePropertyDefinition[]
            {
                propertyDefinition
            });

            return(source.First <PropTag>());
        }
        private static void WritePropValue(BinaryWriter writer, PropertyDefinition prop, MemoryPropertyBag propertyBag)
        {
            PropertyTagPropertyDefinition propertyTagPropertyDefinition = (PropertyTagPropertyDefinition)prop;

            writer.Write(propertyTagPropertyDefinition.PropertyTag);
            object   obj       = propertyBag.TryGetProperty(propertyTagPropertyDefinition);
            PropType propType  = ((PropTag)propertyTagPropertyDefinition.PropertyTag).ValueType();
            PropType propType2 = propType;

            if (propType2 <= PropType.Binary)
            {
                if (propType2 == PropType.Int)
                {
                    ExternalUserCollection.WriteIntValue(writer, (int)obj);
                    return;
                }
                if (propType2 == PropType.String)
                {
                    ExternalUserCollection.WriteStringValue(writer, (string)obj);
                    return;
                }
                if (propType2 == PropType.Binary)
                {
                    ExternalUserCollection.WriteByteValue(writer, (byte[])obj);
                    return;
                }
            }
            else
            {
                if (propType2 == PropType.IntArray)
                {
                    ExternalUserCollection.WriteArrayValue <int>(writer, (int[])obj, new ExternalUserCollection.WriteValue <int>(ExternalUserCollection.WriteIntValue));
                    return;
                }
                if (propType2 == PropType.StringArray)
                {
                    ExternalUserCollection.WriteArrayValue <string>(writer, (string[])obj, new ExternalUserCollection.WriteValue <string>(ExternalUserCollection.WriteStringValue));
                    return;
                }
                if (propType2 == PropType.BinaryArray)
                {
                    ExternalUserCollection.WriteArrayValue <byte[]>(writer, (byte[][])obj, new ExternalUserCollection.WriteValue <byte[]>(ExternalUserCollection.WriteByteValue));
                    return;
                }
            }
            writer.Write(0U);
        }
        private void StreamProperty(NativeStorePropertyDefinition property, Stream propertyStream)
        {
            Stream stream = null;

            try
            {
                switch (property.SpecifiedWith)
                {
                case PropertyTypeSpecifier.PropertyTag:
                {
                    PropertyTagPropertyDefinition propertyTagPropertyDefinition = (PropertyTagPropertyDefinition)property;
                    TnefPropertyTag propertyTag = (int)propertyTagPropertyDefinition.PropertyTag;
                    stream = this.PropertyWriter.OpenPropertyStream(propertyTag);
                    break;
                }

                case PropertyTypeSpecifier.GuidString:
                {
                    GuidNamePropertyDefinition guidNamePropertyDefinition = (GuidNamePropertyDefinition)property;
                    TnefPropertyType           propertyType = (TnefPropertyType)guidNamePropertyDefinition.MapiPropertyType;
                    stream = this.PropertyWriter.OpenPropertyStream(guidNamePropertyDefinition.Guid, guidNamePropertyDefinition.PropertyName, propertyType);
                    break;
                }

                case PropertyTypeSpecifier.GuidId:
                {
                    GuidIdPropertyDefinition guidIdPropertyDefinition = (GuidIdPropertyDefinition)property;
                    TnefPropertyType         propertyType2            = (TnefPropertyType)guidIdPropertyDefinition.MapiPropertyType;
                    stream = this.PropertyWriter.OpenPropertyStream(guidIdPropertyDefinition.Guid, guidIdPropertyDefinition.Id, propertyType2);
                    break;
                }

                default:
                    throw new InvalidOperationException(string.Format("Invalid native property specifier: {0}", property.SpecifiedWith));
                }
                Util.StreamHandler.CopyStreamData(propertyStream, stream);
            }
            finally
            {
                if (stream != null)
                {
                    stream.Close();
                }
            }
        }
        private static void WriteRecipient(BinaryWriter writer, BlobRecipient recipient)
        {
            List <PropValue> list = new List <PropValue>(recipient.PropertyValues.Count);

            foreach (PropValue item in PropValue.ConvertEnumerator <PropertyDefinition>(recipient.PropertyValues))
            {
                if (!PropertyError.IsPropertyError(item.Value) && !((PropTag)((PropertyTagPropertyDefinition)item.Property).PropertyTag).IsNamedProperty())
                {
                    list.Add(item);
                }
            }
            uint count = (uint)list.Count;
            uint value = 0U;

            writer.Write(count);
            writer.Write(value);
            foreach (PropValue propValue in list)
            {
                PropertyTagPropertyDefinition propertyTagPropertyDefinition = (PropertyTagPropertyDefinition)propValue.Property;
                object value2 = ExTimeZoneHelperForMigrationOnly.ToUtcIfDateTime(propValue.Value);
                BlobRecipientParser.WritePropValue(writer, (PropTag)propertyTagPropertyDefinition.PropertyTag, value2);
            }
        }
        private static PropertyTagPropertyDefinition InternalCreate(string displayName, PropTag propertyTag, PropertyFlags flags, NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, bool isCustom, PropertyDefinitionConstraint[] constraints)
        {
            if (!propertyTag.IsValid())
            {
                throw new ArgumentException("Invalid property tag", "propertyTag");
            }
            PropType propType = propertyTag.ValueType();

            if (propType == PropType.AnsiString || propType == PropType.AnsiStringArray)
            {
                propertyTag = ((propertyTag & (PropTag)4294967265U) | (PropTag)31U);
                propType    = propertyTag.ValueType();
            }
            PropertyTagPropertyDefinition.PropTagKey propTagKey = new PropertyTagPropertyDefinition.PropTagKey(propertyTag);
            PropertyTagPropertyDefinition            result;
            bool flag;

            if (PropertyTagPropertyDefinition.TryFindEquivalentDefinition(propTagKey, isCustom, propType, typeCheckingFlag, out result, out flag))
            {
                return(result);
            }
            if (flag)
            {
                try
                {
                    return(new PropertyTagPropertyDefinition(displayName, propertyTag, propTagKey, flags, isCustom, constraints));
                }
                catch (InvalidPropertyTypeException)
                {
                    if (typeCheckingFlag == NativeStorePropertyDefinition.TypeCheckingFlag.ThrowOnInvalidType)
                    {
                        throw;
                    }
                }
            }
            return(null);
        }
 internal static PropertyTagPropertyDefinition InternalCreateCustom(string displayName, PropTag propertyTag, PropertyFlags flags, NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, PropertyDefinitionConstraint[] constraints)
 {
     return(PropertyTagPropertyDefinition.InternalCreate(displayName, propertyTag, flags | PropertyFlags.Custom, typeCheckingFlag, true, constraints));
 }
 internal static PropertyTagPropertyDefinition InternalCreateCustom(string displayName, PropTag propertyTag, PropertyFlags flags, NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag)
 {
     return(PropertyTagPropertyDefinition.InternalCreateCustom(displayName, propertyTag, flags, typeCheckingFlag, PropertyDefinitionConstraint.None));
 }
 internal static PropertyTagPropertyDefinition InternalCreate(string displayName, PropTag propertyTag, PropertyFlags propertyFlags)
 {
     return(PropertyTagPropertyDefinition.InternalCreate(displayName, propertyTag, propertyFlags, NativeStorePropertyDefinition.TypeCheckingFlag.DisableTypeCheck, false, PropertyDefinitionConstraint.None));
 }
 internal static PropertyTagPropertyDefinition InternalCreate(string displayName, PropTag propertyTag)
 {
     return(PropertyTagPropertyDefinition.InternalCreate(displayName, propertyTag, PropertyFlags.None));
 }
 private PropertyTagPropertyDefinition(string displayName, PropTag propertyTag, PropertyTagPropertyDefinition.PropTagKey key, PropertyFlags flags, bool isCustom, PropertyDefinitionConstraint[] constraints) : base(PropertyTypeSpecifier.PropertyTag, displayName, InternalSchema.ClrTypeFromPropTag(propertyTag), propertyTag.ValueType(), PropertyTagPropertyDefinition.CalculatePropertyTagPropertyFlags(propertyTag, flags), constraints)
 {
     if (propertyTag.IsNamedProperty() || !propertyTag.IsValid())
     {
         throw new ArgumentException("Invalid property tag", "propertyTag");
     }
     this.InternalKey = key;
     this.propertyTag = propertyTag;
 }
        internal static ExDateTime?GetNormalizedTime(PropertyBag.BasicPropertyStore propertyBag, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty)
        {
            ExDateTime?valueAsNullable = propertyBag.GetValueAsNullable <ExDateTime>(utcTimeProperty);

            if (valueAsNullable == null)
            {
                if (legacyUtcTimeProperty != null)
                {
                    valueAsNullable = propertyBag.GetValueAsNullable <ExDateTime>(legacyUtcTimeProperty);
                }
                if (valueAsNullable == null)
                {
                    return(null);
                }
            }
            ExDateTime exDateTime = ExTimeZone.UtcTimeZone.ConvertDateTime(valueAsNullable.Value);

            byte[]     valueOrDefault = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneDefinitionStart);
            ExTimeZone legacyTimeZone;

            if (O12TimeZoneFormatter.TryParseTimeZoneBlob(valueOrDefault, string.Empty, out legacyTimeZone))
            {
                exDateTime = TimeZoneHelper.NormalizeUtcTime(exDateTime, legacyTimeZone);
            }
            exDateTime = StartTimeProperty.DynamicAdjustForAllDayEvent(propertyBag, exDateTime, utcTimeProperty == InternalSchema.MapiEndTime);
            return(new ExDateTime?(propertyBag.TimeZone.ConvertDateTime(exDateTime)));
        }
 public static PropertyTagPropertyDefinition CreateCustom(string displayName, uint propertyTag, params PropertyDefinitionConstraint[] constraints)
 {
     return(PropertyTagPropertyDefinition.CreateCustom(displayName, propertyTag, PropertyFlags.None, constraints));
 }
        internal static ExDateTime?GetWallClockTime(PropertyBag.BasicPropertyStore propertyBag, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty, NativeStorePropertyDefinition[] timeZoneBlobPropertyDefinitions)
        {
            ExDateTime?normalizedTime = StartTimeProperty.GetNormalizedTime(propertyBag, utcTimeProperty, legacyUtcTimeProperty);

            if (normalizedTime == null)
            {
                return(null);
            }
            byte[] array = null;
            foreach (NativeStorePropertyDefinition propertyDefinition in timeZoneBlobPropertyDefinitions)
            {
                array = propertyBag.GetValueOrDefault <byte[]>(propertyDefinition);
                if (array != null)
                {
                    break;
                }
            }
            if (array == null)
            {
                ExTraceGlobals.StorageTracer.TraceWarning(0L, "Could not determine suitable time zone");
            }
            ExTimeZone exTimeZone = StartWallClockProperty.FindBestMatchingTimeZone(array);

            if (exTimeZone != null)
            {
                return(new ExDateTime?(exTimeZone.ConvertDateTime(normalizedTime.Value)));
            }
            return(new ExDateTime?(normalizedTime.Value));
        }
        internal NativeStorePropertyDefinition[] InternalPropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag propertyTypeCheckingFlag, MapiProp mapiProp, StoreSession storeSession, PropTag[] propTags, out int resolvedPropertyCount)
        {
            EnumValidator.ThrowIfInvalid <NativeStorePropertyDefinition.TypeCheckingFlag>(propertyTypeCheckingFlag, "propertyTypeCheckingFlag");
            resolvedPropertyCount = 0;
            NativeStorePropertyDefinition[] array = new NativeStorePropertyDefinition[propTags.Length];
            List <PropertyTagCache.NamedPropertyToResolve> list = null;

            PropTag[] array2 = null;
            for (int i = 0; i < propTags.Length; i++)
            {
                PropTag propTag = propTags[i];
                if (!PropertyTagCache.TryFixPropTagWithErrorType(storeSession, mapiProp, ref array2, ref propTag))
                {
                    ExTraceGlobals.PropertyMappingTracer.TraceError <PropTag>((long)storeSession.GetHashCode(), "Failed to infer the property type for PropertyTag {0:X}", propTag);
                }
                else
                {
                    PropertyTagCache.ChangeStringPropTagTypeToUnicode(ref propTag);
                    int num = propTag.Id();
                    if (num < 32768)
                    {
                        NativeStorePropertyDefinition nativeStorePropertyDefinition = PropertyTagPropertyDefinition.InternalCreateCustom(string.Empty, propTag, PropertyFlags.None, propertyTypeCheckingFlag);
                        array[i] = nativeStorePropertyDefinition;
                        if (nativeStorePropertyDefinition != null)
                        {
                            resolvedPropertyCount++;
                        }
                    }
                    else
                    {
                        if (list == null)
                        {
                            list = new List <PropertyTagCache.NamedPropertyToResolve>();
                        }
                        list.Add(new PropertyTagCache.NamedPropertyToResolve((ushort)num, propTag.ValueType(), i));
                    }
                }
            }
            if (list != null)
            {
                NamedProp[] namedPropsFromIds = NamedPropConverter.GetNamedPropsFromIds(storeSession, mapiProp, from namedPropertyToResolve in list
                                                                                        select namedPropertyToResolve.PropId);
                int num2 = 0;
                foreach (PropertyTagCache.NamedPropertyToResolve namedPropertyToResolve2 in list)
                {
                    NativeStorePropertyDefinition propDefByMapiNamedProp = PropertyTagCache.GetPropDefByMapiNamedProp(namedPropsFromIds[num2++], namedPropertyToResolve2.PropType, propertyTypeCheckingFlag);
                    array[namedPropertyToResolve2.Index] = propDefByMapiNamedProp;
                    if (propDefByMapiNamedProp != null)
                    {
                        resolvedPropertyCount++;
                    }
                    else
                    {
                        ExTraceGlobals.PropertyMappingTracer.TraceDebug <ushort, PropType>((long)storeSession.GetHashCode(), "Failed to resolve a named property from PropertyId {0:X} [{1:X}]", namedPropertyToResolve2.PropId, namedPropertyToResolve2.PropType);
                    }
                }
            }
            return(array);
        }
 internal static ExDateTime?GetNormalizedTime(PropertyBag propertyBag, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty)
 {
     return(StartTimeProperty.GetNormalizedTime((PropertyBag.BasicPropertyStore)propertyBag, utcTimeProperty, legacyUtcTimeProperty));
 }
 public static PropertyTagPropertyDefinition CreateCustom(string displayName, uint propertyTag)
 {
     return(PropertyTagPropertyDefinition.CreateCustom(displayName, propertyTag, PropertyDefinitionConstraint.None));
 }
        internal static object InternalTryGetDateTimeValue(PropertyBag.BasicPropertyStore propertyBag, StorePropertyDefinition property, GuidIdPropertyDefinition mapiUtcTimeProperty, PropertyTagPropertyDefinition mapiLegacyUtcTimeProperty)
        {
            ExDateTime?normalizedTime = StartTimeProperty.GetNormalizedTime(propertyBag, mapiUtcTimeProperty, mapiLegacyUtcTimeProperty);

            if (normalizedTime != null)
            {
                return(normalizedTime.Value);
            }
            return(new PropertyError(property, PropertyErrorCode.NotFound));
        }
 public static PropertyTagPropertyDefinition CreateCustom(string displayName, uint propertyTag, PropertyFlags flags, params PropertyDefinitionConstraint[] constraints)
 {
     return(PropertyTagPropertyDefinition.InternalCreateCustom(displayName, (PropTag)propertyTag, flags, NativeStorePropertyDefinition.TypeCheckingFlag.ThrowOnInvalidType, constraints));
 }
Beispiel #26
0
 private static TnefPropertyTag GetTnefPropertyTag(PropertyTagPropertyDefinition property)
 {
     return((int)property.PropertyTag);
 }
        internal static bool TryFindEquivalentDefinition(PropertyTagPropertyDefinition.PropTagKey key, bool isCustom, PropType type, NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, out PropertyTagPropertyDefinition definition, out bool createNewDefinition)
        {
            createNewDefinition = true;
            if (!isCustom)
            {
                definition = null;
                return(false);
            }
            switch (NativeStorePropertyDefinitionDictionary.TryFindInstance(key, type, out definition))
            {
            case PropertyMatchResult.Found:
                createNewDefinition = false;
                return(true);

            case PropertyMatchResult.TypeMismatch:
                NativeStorePropertyDefinition.OnFailedPropertyTypeCheck(key, type, typeCheckingFlag, out createNewDefinition);
                break;
            }
            return(false);
        }
Beispiel #28
0
        internal static void RecalculateNormalizedTimeProperty(PropertyBag.BasicPropertyStore propertyBag, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty, ExTimeZone newTimeZone)
        {
            if (newTimeZone == null || newTimeZone == ExTimeZone.UtcTimeZone || newTimeZone == ExTimeZone.UnspecifiedTimeZone)
            {
                return;
            }
            ExDateTime?normalizedTime = StartTimeProperty.GetNormalizedTime(propertyBag, utcTimeProperty, legacyUtcTimeProperty);

            if (normalizedTime != null)
            {
                ExDateTime exDateTime = newTimeZone.ConvertDateTime(normalizedTime.Value);
                propertyBag.SetValueWithFixup(utcTimeProperty, exDateTime.ToUtc());
                if (legacyUtcTimeProperty != null)
                {
                    propertyBag.SetValueWithFixup(legacyUtcTimeProperty, exDateTime.ToUtc());
                }
            }
        }
        internal static void DenormalizeTimeProperty(PropertyBag propertyBag, ExDateTime newTime, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty)
        {
            byte[]     valueOrDefault = propertyBag.GetValueOrDefault <byte[]>(InternalSchema.TimeZoneDefinitionStart);
            ExTimeZone legacyTimeZone;

            if (O12TimeZoneFormatter.TryParseTimeZoneBlob(valueOrDefault, string.Empty, out legacyTimeZone))
            {
                ExDateTime exDateTime = TimeZoneHelper.DeNormalizeToUtcTime(newTime, legacyTimeZone);
                propertyBag.SetProperty(utcTimeProperty, exDateTime);
                if (legacyUtcTimeProperty != null)
                {
                    propertyBag.SetProperty(legacyUtcTimeProperty, exDateTime);
                }
            }
        }
        internal static void SetCalendarTime(PropertyBag.BasicPropertyStore propertyBag, GuidIdPropertyDefinition utcTimeProperty, PropertyTagPropertyDefinition legacyUtcTimeProperty, GuidIdPropertyDefinition timeZoneDefinition, bool isEndTime, object value)
        {
            StoreObject      storeObject      = propertyBag.Context.StoreObject;
            CalendarItemBase calendarItemBase = storeObject as CalendarItemBase;

            if (calendarItemBase != null && calendarItemBase.PropertyBag.ExTimeZone != null && calendarItemBase.IsAllDayEventCache == null)
            {
                object obj = IsAllDayEventProperty.CalculateIsAllDayEvent(propertyBag);
                if (obj is bool)
                {
                    calendarItemBase.IsAllDayEventCache = new bool?((bool)obj);
                }
            }
            propertyBag.SetValueWithFixup(utcTimeProperty, value);
            propertyBag.SetValueWithFixup(legacyUtcTimeProperty, value);
            ExTimeZone timeZone = propertyBag.TimeZone;

            if (value is ExDateTime && ((ExDateTime)value).TimeZone != null && ((ExDateTime)value).TimeZone != ExTimeZone.UnspecifiedTimeZone)
            {
                timeZone = ((ExDateTime)value).TimeZone;
            }
            if (timeZone == ExTimeZone.UtcTimeZone)
            {
                if (!(storeObject is CalendarItemOccurrence))
                {
                    propertyBag.Delete(timeZoneDefinition);
                }
            }
            else if (value is ExDateTime && timeZone != ExTimeZone.UnspecifiedTimeZone)
            {
                if (timeZoneDefinition == InternalSchema.TimeZoneDefinitionStart)
                {
                    byte[] timeZoneBlob = O12TimeZoneFormatter.GetTimeZoneBlob(timeZone);
                    StartTimeZoneProperty.RecalculateNormalizedTimeProperty(propertyBag, InternalSchema.MapiEndTime, InternalSchema.MapiPREndDate, timeZone);
                    StartTimeZoneProperty.RecalculateNormalizedTimeProperty(propertyBag, InternalSchema.ReminderNextTime, null, timeZone);
                    StartTimeZoneProperty.SyncRecurringTimeZoneProperties(propertyBag, timeZone, timeZoneBlob);
                    propertyBag.SetValueWithFixup(timeZoneDefinition, timeZoneBlob);
                }
                else
                {
                    byte[] timeZoneBlob2 = O12TimeZoneFormatter.GetTimeZoneBlob(timeZone, (ExDateTime)value);
                    propertyBag.SetValueWithFixup(timeZoneDefinition, timeZoneBlob2);
                }
            }
            if (!isEndTime)
            {
                propertyBag.SetValueWithFixup(InternalSchema.ReminderDueByInternal, value);
            }
            if (storeObject != null)
            {
                Reminder.Adjust(storeObject);
            }
        }