System.Runtime.Serialization.Plists.BinaryPlistWriter.WriteReferenceInteger C# (CSharp) Method

WriteReferenceInteger() private static method

Writes the given value using the number of bytes indicated by the specified size to the given BinaryWriter.
private static WriteReferenceInteger ( BinaryWriter writer, long value, int size ) : int
writer System.IO.BinaryWriter The to write to.
value long The value to write.
size int The size of the integer to write.
return int
        private static int WriteReferenceInteger(BinaryWriter writer, long value, int size)
        {
            byte[] buffer;

            switch (size)
            {
                case 1:
                    buffer = new byte[] { (byte)value };
                    break;
                case 2:
                    buffer = BitConverter.GetBytes(((short)value).ToBigEndianConditional());
                    break;
                case 4:
                    buffer = BitConverter.GetBytes(((int)value).ToBigEndianConditional());
                    break;
                case 8:
                    buffer = BitConverter.GetBytes(value.ToBigEndianConditional());
                    break;
                default:
                    throw new ArgumentException("The reference size must be one of 1, 2, 4 or 8. The specified reference size was: " + size, "size");
            }

            writer.Write(buffer, 0, buffer.Length);
            return buffer.Length;
        }