コード例 #1
0
 /// <summary>Gets the value at the given index.</summary>
 protected override object Get(int index)
 {
     if (rawBuffer == null)
     {
         // Use the _Buffer instead:
         return(LittleConverter.ToInt16(_Buffer.buffer, (index * 2) + ByteOffset));
     }
     return(rawBuffer[index]);
 }
コード例 #2
0
        /// <summary>
        /// Puts an unknown object into this array.
        /// Note that the value is always expected to be a value type.
        /// </summary>
        protected override void Set(int index, object value)
        {
            short sValue = (value is double) ? (short)((double)value) : (short)value;

            if (rawBuffer == null)
            {
                // Use the _Buffer instead:
                LittleConverter.GetBytes(sValue, _Buffer.buffer, (index * 2) + ByteOffset);
                return;
            }
            // Get it as a short and put it in:
            rawBuffer[index] = sValue;
        }
コード例 #3
0
        protected override void FillBuffer()
        {
            int length     = Length;
            int byteOffset = ByteOffset;

            for (int i = 0; i < length; i++)
            {
                var value = rawBuffer[i];
                LittleConverter.GetBytes(value, _Buffer.buffer, byteOffset);
                byteOffset += 2;
            }

            // Remove the fast buffer:
            rawBuffer = null;
        }
コード例 #4
0
 /// <summary>
 /// Gets or sets the given entry in the array.
 /// </summary>
 public short this[int index] {
     get{
         if (rawBuffer == null)
         {
             // Use the _Buffer instead:
             return(LittleConverter.ToInt16(_Buffer.buffer, (index * 2) + ByteOffset));
         }
         return(rawBuffer[index]);
     }
     set{
         if (rawBuffer == null)
         {
             // Use the _Buffer instead:
             LittleConverter.GetBytes(value, _Buffer.buffer, (index * 2) + ByteOffset);
             return;
         }
         rawBuffer[index] = value;
     }
 }