Пример #1
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;
        }
Пример #2
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;
        }
Пример #3
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;
     }
 }