示例#1
0
 /// <summary>
 ///     Tries to get the item associated with the specified index from the cached and, if it's not found, reads it through
 ///     <see cref="ReadItem" /> and caches it.
 /// </summary>
 /// <param name="index">The item's index.</param>
 /// <returns>The read item.</returns>
 public TItem this[DataCenterIndex index]
 {
     get
     {
         if (cachedItems.TryGetValue(index, out var value))
         {
             return(value);
         }
         var valueAddress = GetAddress(index);
         return(cachedItems[index] = ReadItem(valueAddress));
     }
 }
示例#2
0
 /// <summary>
 ///     When overridden in a derived class, retrieves the absolute address of an item given its index.
 /// </summary>
 /// <param name="regionIndex">The item's index.</param>
 /// <returns>The item's address.</returns>
 public abstract int GetAddress(DataCenterIndex regionIndex);
示例#3
0
 /// <summary>
 ///     Gets the address of the first character of the string at the specified index.
 /// </summary>
 /// <param name="regionIndex">The index of the first character of the string.</param>
 /// <returns>The address of the first character of the string.</returns>
 public override int GetAddress(DataCenterIndex regionIndex)
 {
     return(Characters.GetAddress(regionIndex));
 }
示例#4
0
        /// <summary>
        ///     Gets the address of an item given its index.
        /// </summary>
        /// <param name="regionIndex">The item's index.</param>
        /// <returns>The item's address.</returns>
        public override int GetAddress(DataCenterIndex regionIndex)
        {
            var bucket = Buckets[regionIndex.BucketIndex];

            return((int)bucket.FirstValueAddress + regionIndex.ItemIndex * bucket.ValueSize);
        }