private void TranslatePtag(ref int ptag) { PropTag propTag = (PropTag)ptag; if (!propTag.IsNamedProperty()) { return; } NamedPropMapper.Mapping mapping = this.sourceMapper.ById[propTag.Id()]; if (mapping == null) { MrsTracer.Service.Warning("Proptag 0x{0:X} could not be mapped to a namedprop in the source mailbox, not translating.", new object[] { propTag }); return; } NamedPropMapper.Mapping mapping2 = this.targetMapper.ByNamedProp[mapping.NPData]; if (mapping2 != null) { ptag = (int)PropTagHelper.PropTagFromIdAndType(mapping2.PropId, propTag.ValueType()); return; } MrsTracer.Service.Warning("NamedProp {0} (source ptag 0x{1:X}) could not be mapped in the target mailbox, not translating.", new object[] { mapping.NPData, propTag }); }
private int GetIntValue(PropTag tag) { if (this.mailboxProperties == null) { return(0); } int num = tag.Id(); foreach (PropValue propValue in this.mailboxProperties) { if (propValue.PropTag.Id() == num) { int result; if (propValue.PropType == PropType.Int) { result = propValue.GetInt(); } else { result = 0; } return(result); } } return(0); }
internal static PropTag NormalizeTag(PropTag tag) { PropType propType = tag.ValueType() & (PropType)(-12289); if (propType == PropType.AnsiString) { propType = ((tag.ValueType() & PropType.MultiValueFlag) | PropType.String); tag = PropTagHelper.PropTagFromIdAndType(tag.Id(), propType); } else { propType = (tag.ValueType() & (PropType)(-8193)); tag = PropTagHelper.PropTagFromIdAndType(tag.Id(), propType); } return(tag); }
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 PropTagKey(PropTag propertyTag) { if (propertyTag.IsApplicationSpecific()) { this.propertyTag = propertyTag; return; } this.propertyTag = PropTagHelper.PropTagFromIdAndType(propertyTag.Id(), PropType.Unspecified); }
private void EnumeratePtag(ref int ptag) { PropTag propTag = (PropTag)ptag; if (!propTag.IsNamedProperty()) { return; } this.sourceMapper.ById.AddKey(propTag.Id()); }
private static void ChangeStringPropTagTypeToUnicode(ref PropTag propTag) { PropType propType = propTag.ValueType(); int propId = propTag.Id(); if (propType == PropType.AnsiString) { propTag = PropTagHelper.PropTagFromIdAndType(propId, PropType.String); return; } if (propType == PropType.AnsiStringArray) { propTag = PropTagHelper.PropTagFromIdAndType(propId, PropType.StringArray); } }
private static bool TryFixPropTagWithErrorType(StoreSession session, MapiProp mapiProp, ref PropTag[] completePropTagList, ref PropTag propTag) { if (propTag.ValueType() != PropType.Error && propTag.ValueType() != PropType.Unspecified) { return(true); } if (completePropTagList == null) { object thisObject = null; bool flag = false; try { if (session != null) { session.BeginMapiCall(); session.BeginServerHealthCall(); flag = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } completePropTagList = mapiProp.GetPropList(); } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.ExGetPropsFailed, ex, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("PropertyTagCache.IsGoodMapiPropTag failed.", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.ExGetPropsFailed, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[] { string.Format("PropertyTagCache.IsGoodMapiPropTag failed.", new object[0]), ex2 }); } finally { try { if (session != null) { session.EndMapiCall(); if (flag) { session.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } } int num = propTag.Id(); for (int i = 0; i < completePropTagList.Length; i++) { if (completePropTagList[i].Id() == num) { propTag = completePropTagList[i]; return(true); } } return(false); }
internal static ushort[] GetIdsFromNamedProps(StoreSession session, MapiProp mapiProp, bool createNamedProperties, List <NamedProp> namedProps) { int count = namedProps.Count; ushort[] array = new ushort[count]; List <NamedProp> list = new List <NamedProp>(count); List <NamedProp> list2 = new List <NamedProp>(count); List <int> list3 = new List <int>(count); List <int> list4 = new List <int>(count); NamedPropMap mapping = NamedPropMapCache.Default.GetMapping(session); for (int i = 0; i < count; i++) { NamedProp namedProp = namedProps[i]; bool flag = false; ushort num; if (mapping != null && mapping.TryGetPropIdFromNamedProp(namedProp, out num)) { array[i] = num; flag = true; } if (!flag) { if (namedProp.Guid == WellKnownPropertySet.InternetHeaders) { list2.Add(namedProp); list4.Add(i); } else { list.Add(namedProp); list3.Add(i); } } } list.AddRange(list2); list3.AddRange(list4); if (list.Count > 0) { PropTag[] array2 = NamedPropConverter.MapiGetIdsFromNames(session, mapiProp, createNamedProperties, list); ushort[] array3 = new ushort[array2.Length]; for (int j = 0; j < array2.Length; j++) { PropTag propTag = array2[j]; if (propTag == PropTag.Unresolved) { array3[j] = 0; } else { array3[j] = (ushort)propTag.Id(); } } if (mapping != null) { mapping.AddMapping(createNamedProperties, array3, list); } for (int k = 0; k < array3.Length; k++) { array[list3[k]] = array3[k]; } } return(array); }
internal static PropTag GetSingleValuePropTag(PropTag tag) { return(PropTagHelper.PropTagFromIdAndType(tag.Id(), tag.ValueType() & (PropType)(-12289))); }
internal static PropTag GetMultiValuePropTag(PropTag tag) { return(PropTagHelper.PropTagFromIdAndType(tag.Id(), tag.ValueType() | PropType.MultiValueFlag)); }