private PropTag GetPropertyTagFromNamedProperty(NamedPropertyDefinition propertyDefinition)
            {
                NamedProp    namedProp        = propertyDefinition.GetKey().NamedProp;
                NamedPropMap namedPropertyMap = this.parent.NamedPropertyMap;
                ushort       num;

                if (!namedPropertyMap.TryGetPropIdFromNamedProp(namedProp, out num) && (!this.parent.ResolveAllNamedProperties(this.currentIndex) || !namedPropertyMap.TryGetPropIdFromNamedProp(namedProp, out num)))
                {
                    num = 0;
                }
                if (num != 0)
                {
                    return(PropTagHelper.PropTagFromIdAndType((int)num, propertyDefinition.MapiPropertyType));
                }
                if (!this.parent.storeSession.Capabilities.IsReadOnly && (!this.parent.allowUnresolvedHeaders || namedProp.Guid != WellKnownPropertySet.InternetHeaders || (namedProp.Guid == WellKnownPropertySet.InternetHeaders && PropertyDefinitionToPropTagCollection.PromotableInternetHeaders.Contains(namedProp.Name))))
                {
                    LocalizedString localizedString = ServerStrings.ExInvalidNamedProperty(propertyDefinition.ToString());
                    ExTraceGlobals.StorageTracer.TraceError(0L, localizedString);
                    throw new StoragePermanentException(localizedString);
                }
                return(PropTag.Unresolved);
            }
        private bool ResolveAllNamedProperties(int startFrom)
        {
            if (this.resolved)
            {
                return(false);
            }
            this.resolved = true;
            NamedPropMap namedPropMap = this.NamedPropertyMap;
            IEnumerator <NativeStorePropertyDefinition> enumerator = this.properties.GetEnumerator();

            for (int i = 0; i < startFrom - 1; i++)
            {
                enumerator.MoveNext();
            }
            List <NamedProp> list  = null;
            List <NamedProp> list2 = null;

            while (enumerator.MoveNext())
            {
                NativeStorePropertyDefinition nativeStorePropertyDefinition = enumerator.Current;
                if (nativeStorePropertyDefinition.SpecifiedWith != PropertyTypeSpecifier.PropertyTag)
                {
                    NamedProp namedProp = ((NamedPropertyDefinition)nativeStorePropertyDefinition).GetKey().NamedProp;
                    ushort    num;
                    if (!namedPropMap.TryGetPropIdFromNamedProp(namedProp, out num))
                    {
                        if (namedProp.Guid == WellKnownPropertySet.InternetHeaders && !PropertyDefinitionToPropTagCollection.PromotableInternetHeaders.Contains(namedProp.Name))
                        {
                            if (list2 == null)
                            {
                                list2 = new List <NamedProp>(20);
                            }
                            list2.Add(namedProp);
                        }
                        else
                        {
                            if (list == null)
                            {
                                list = new List <NamedProp>(20);
                            }
                            list.Add(namedProp);
                        }
                    }
                }
            }
            if (this.allowCreate == this.allowCreateHeaders && list2 != null)
            {
                if (list == null)
                {
                    list = list2;
                }
                else
                {
                    list.AddRange(list2);
                }
                list2 = null;
            }
            this.GetIdsFromNamedPropsWithRetry(this.allowCreate, list);
            this.GetIdsFromNamedPropsWithRetry(this.allowCreateHeaders, list2);
            return(true);
        }
Ejemplo n.º 3
0
        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);
        }