Ejemplo n.º 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));
     }
 }
Ejemplo n.º 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);
Ejemplo n.º 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));
 }
Ejemplo n.º 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);
        }