internal static void ResolveAndFilterPropertyValues(NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, StoreSession storeSession, MapiProp mapiProp, ExTimeZone exTimeZone, PropValue[] mapiPropValues, out NativeStorePropertyDefinition[] propertyDefinitions, out PropTag[] mapiPropTags, out object[] propertyValues) { PropTag[] array = new PropTag[mapiPropValues.Length]; for (int i = 0; i < mapiPropValues.Length; i++) { array[i] = mapiPropValues[i].PropTag; } int num; NativeStorePropertyDefinition[] array2 = PropertyTagCache.Cache.InternalPropertyDefinitionsFromPropTags(typeCheckingFlag, mapiProp, storeSession, array, out num); propertyDefinitions = new NativeStorePropertyDefinition[num]; mapiPropTags = new PropTag[num]; propertyValues = new object[num]; int num2 = 0; for (int j = 0; j < array2.Length; j++) { if (array2[j] != null) { object valueFromPropValue = MapiPropertyBag.GetValueFromPropValue(storeSession, exTimeZone, array2[j], mapiPropValues[j]); propertyDefinitions[num2] = array2[j]; mapiPropTags[num2] = PropTagHelper.PropTagFromIdAndType(array[j].Id(), array2[j].MapiPropertyType); propertyValues[num2] = valueFromPropValue; num2++; } } }
protected static void OnFailedPropertyTypeCheck(object key, PropType type, NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, out bool createNewDefinition) { switch (typeCheckingFlag) { case NativeStorePropertyDefinition.TypeCheckingFlag.DoNotCreateInvalidType: case NativeStorePropertyDefinition.TypeCheckingFlag.AllowCompatibleType: createNewDefinition = false; return; case NativeStorePropertyDefinition.TypeCheckingFlag.DisableTypeCheck: createNewDefinition = true; return; } throw new InvalidPropertyTypeException(ServerStrings.ExInvalidPropertyType(key.ToString(), type.ToString())); }
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); }
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)); }
private bool TryGetPropertyDefinitionsFromPropertyTags(StoreSession session, ICorePropertyBag corePropertyBag, uint[] propertyTags, NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, out NativeStorePropertyDefinition[] propertyDefinitions, out uint unresolvablePropTag) { Util.ThrowOnNullArgument(session, "session"); Util.ThrowOnNullArgument(corePropertyBag, "corePropertyBag"); Util.ThrowOnNullArgument(propertyTags, "propertyTags"); EnumValidator.ThrowIfInvalid <NativeStorePropertyDefinition.TypeCheckingFlag>(typeCheckingFlag, PropertyTagCache.validOptionSet); unresolvablePropTag = 0U; PropTag[] array = new PropTag[propertyTags.Length]; for (int i = 0; i < propertyTags.Length; i++) { array[i] = (PropTag)propertyTags[i]; } propertyDefinitions = this.PropertyDefinitionsFromPropTags(typeCheckingFlag, PersistablePropertyBag.GetPersistablePropertyBag(corePropertyBag).MapiProp, session, array); for (int j = 0; j < propertyDefinitions.Length; j++) { if (propertyDefinitions[j] == null) { unresolvablePropTag = (uint)array[j]; return(false); } } return(true); }
public NativeStorePropertyDefinition[] PropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag propertyTypeCheckingFlag, MapiProp mapiProp, StoreSession storeSession, params PropTag[] propTags) { int num; return(this.InternalPropertyDefinitionsFromPropTags(propertyTypeCheckingFlag, mapiProp, storeSession, propTags, out num)); }
private static NativeStorePropertyDefinition GetPropDefByMapiNamedProp(NamedProp prop, PropType type, NativeStorePropertyDefinition.TypeCheckingFlag propertyTypeCheckingFlag) { if (prop == null) { return(null); } switch (prop.Kind) { case NamedPropKind.Id: return(GuidIdPropertyDefinition.InternalCreateCustom(string.Empty, type, prop.Guid, prop.Id, PropertyFlags.None, propertyTypeCheckingFlag, new PropertyDefinitionConstraint[0])); case NamedPropKind.String: if (GuidNamePropertyDefinition.IsValidName(prop.Guid, prop.Name)) { return(GuidNamePropertyDefinition.InternalCreate(string.Empty, InternalSchema.ClrTypeFromPropTagType(type), type, prop.Guid, prop.Name, PropertyFlags.None, propertyTypeCheckingFlag, true, PropertyDefinitionConstraint.None)); } return(null); default: throw new ArgumentOutOfRangeException("prop.Kind"); } }
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 GuidNamePropertyDefinition InternalCreate(string displayName, Type propertyType, PropType mapiPropType, Guid propertyGuid, string propertyName, PropertyFlags flags, NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, bool isCustom, params PropertyDefinitionConstraint[] constraints) { if (!GuidNamePropertyDefinition.IsValidName(propertyGuid, propertyName)) { throw new ArgumentException("Invalid property name for property", "propertyName"); } if (mapiPropType == PropType.AnsiString) { mapiPropType = PropType.String; propertyType = typeof(string); } else if (mapiPropType == PropType.AnsiStringArray) { mapiPropType = PropType.StringArray; propertyType = typeof(string[]); } NamedProp namedProp = new NamedProp(propertyGuid, propertyName); NamedProp namedProp2 = WellKnownNamedProperties.Find(namedProp); if (namedProp2 != null) { namedProp = namedProp2; } else { namedProp = NamedPropertyDefinition.NamedPropertyKey.GetSingleton(namedProp); } GuidNamePropertyDefinition.GuidNameKey guidNameKey = new GuidNamePropertyDefinition.GuidNameKey(namedProp); GuidNamePropertyDefinition result; bool flag; if (GuidNamePropertyDefinition.TryFindEquivalentDefinition(guidNameKey, isCustom, mapiPropType, typeCheckingFlag, out result, out flag)) { return(result); } if (!flag) { return(null); } return(new GuidNamePropertyDefinition(displayName, propertyType, mapiPropType, guidNameKey, flags, isCustom, constraints)); }
internal static GuidNamePropertyDefinition InternalCreateCustom(string displayName, PropType mapiPropType, Guid propertyGuid, string propertyName, PropertyFlags flags, NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, params PropertyDefinitionConstraint[] constraints) { Type propertyType = InternalSchema.ClrTypeFromPropTagType(mapiPropType); return(GuidNamePropertyDefinition.InternalCreate(displayName, propertyType, mapiPropType, propertyGuid, propertyName, flags | PropertyFlags.Custom, typeCheckingFlag, true, constraints)); }
internal static GuidIdPropertyDefinition InternalCreate(string displayName, Type propertyType, PropType mapiPropType, Guid propertyGuid, int dispId, PropertyFlags flags, NativeStorePropertyDefinition.TypeCheckingFlag typeCheckingFlag, bool isCustom, params PropertyDefinitionConstraint[] constraints) { if (mapiPropType == PropType.AnsiString) { mapiPropType = PropType.String; propertyType = typeof(string); } else if (mapiPropType == PropType.AnsiStringArray) { mapiPropType = PropType.StringArray; propertyType = typeof(string[]); } NamedProp namedProp = new NamedProp(propertyGuid, dispId); NamedProp namedProp2 = WellKnownNamedProperties.Find(namedProp); if (namedProp2 != null) { namedProp = namedProp2; } else { namedProp = NamedPropertyDefinition.NamedPropertyKey.GetSingleton(namedProp); } GuidIdPropertyDefinition.GuidIdKey guidIdKey = new GuidIdPropertyDefinition.GuidIdKey(namedProp); bool flag; if (propertyGuid == WellKnownPropertySet.InternetHeaders) { NativeStorePropertyDefinition.OnFailedPropertyTypeCheck(guidIdKey, mapiPropType, typeCheckingFlag, out flag); return(null); } GuidIdPropertyDefinition result; if (GuidIdPropertyDefinition.TryFindEquivalentDefinition(guidIdKey, isCustom, mapiPropType, typeCheckingFlag, out result, out flag)) { return(result); } if (!flag) { return(null); } return(new GuidIdPropertyDefinition(displayName, propertyType, mapiPropType, guidIdKey, flags, isCustom, constraints)); }