Ejemplo n.º 1
0
            /// <summary>
            /// Given a type, constructs a string to represent the cache region key
            /// for that type's cache domain.
            /// </summary>
            /// <param name="type">
            /// The type for which to generate a cache region key.
            /// </param>
            /// <returns>
            /// A <see cref="String" /> containing a generated cache region key for
            /// <paramref name="type" />.
            /// </returns>
            /// <remarks>
            /// <para>
            /// The method is not guaranteed to return the same value for repeated
            /// calls with the same type.  The returned value is cached after the
            /// first call for a given type, and the method is never called again
            /// for that type.
            /// </para>
            /// </remarks>
            private static string ConstructRegionForType(Type type)
            {
                Contract.Requires(type != null, "The type cannot be null.");
                Contract.Ensures(Contract.Result <string>() != null);

                byte[] bytes = BitConverter.GetBytes(Interlocked.Increment(ref currentKeyIndex));

                if (BitConverter.IsLittleEndian)
                {
                    Array.Reverse(bytes);
                }

                return(EveCache.ByteArrayToShortString(bytes));
            }