示例#1
0
        private void ElementEvictCallback(NamedPropMap namedPropMapEvicted)
        {
            int num = namedPropMapEvicted.UnregisterSizeChangedDelegate();

            Interlocked.Add(ref this.currentMappingSize, -num);
            this.perfCounters.NamedPropertyCacheEntries.IncrementBy((long)(-(long)num));
        }
示例#2
0
        public static NamedProp[] GetNamedPropsFromIds(StoreSession session, MapiProp mapiProp, ICollection <ushort> propIds)
        {
            int count = propIds.Count;

            NamedProp[]   array   = new NamedProp[count];
            List <ushort> list    = new List <ushort>();
            List <int>    list2   = new List <int>();
            NamedPropMap  mapping = NamedPropMapCache.Default.GetMapping(session);
            int           num     = 0;

            foreach (ushort num2 in propIds)
            {
                if (num2 < 32768)
                {
                    throw new ArgumentOutOfRangeException(string.Format("PropId is not in the range of named props.  PropId = 0x{0:x}.", num2));
                }
                NamedProp namedProp = null;
                if (mapping != null && mapping.TryGetNamedPropFromPropId(num2, out namedProp))
                {
                    array[num] = namedProp;
                }
                else
                {
                    list.Add(num2);
                    list2.Add(num);
                }
                num++;
            }
            int num3 = 0;

            while (list.Count > 0)
            {
                int           count2 = Math.Min(list.Count, 256);
                List <ushort> range  = list.GetRange(0, count2);
                NamedProp[]   array2 = NamedPropConverter.MapiGetNamesFromIds(session, mapiProp, range);
                if (mapping != null)
                {
                    mapping.AddMapping(false, range, array2);
                }
                for (int i = 0; i < array2.Length; i++)
                {
                    int num4 = list2[i + num3 * 256];
                    array[num4] = array2[i];
                }
                list.RemoveRange(0, count2);
                num3++;
            }
            return(array);
        }
示例#3
0
        internal NamedPropMap GetMapping(string signature)
        {
            if (string.IsNullOrEmpty(signature))
            {
                return(null);
            }
            bool         flag;
            NamedPropMap result = this.lru.Get(signature, out flag);

            if (flag)
            {
                NamedPropertyDefinition.NamedPropertyKey.ClearUnreferenced();
            }
            return(result);
        }
            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 void GetIdsFromNamedProps(bool allowCreate, IList <NamedProp> namedProps)
        {
            PropTag[]    array        = null;
            StoreSession storeSession = this.storeSession;
            object       thisObject   = null;
            bool         flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                array = this.mapiProp.GetIDsFromNames(allowCreate, namedProps);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetIDFromNames, ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PropertyDefinitionToPropTagCollection.GetIdsFromNamedProps failed.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetIDFromNames, ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PropertyDefinitionToPropTagCollection.GetIdsFromNamedProps failed.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            ushort[] array2 = new ushort[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                PropTag propTag = array[i];
                array2[i] = ((propTag == PropTag.Unresolved) ? 0 : ((ushort)propTag.Id()));
            }
            NamedPropMap namedPropMap = this.NamedPropertyMap;

            namedPropMap.AddMapping(allowCreate, array2, namedProps);
        }
        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);
        }
示例#7
0
 public static MiddleTierStoragePerformanceCountersInstance GetPerfCounters()
 {
     return(NamedPropMap.GetPerfCounters());
 }
示例#8
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);
        }