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

GetIntegerBytes() private static method

Gets a big-endian byte array that corresponds to the given integer value.
private static GetIntegerBytes ( long value ) : byte[]
value long The integer value to get bytes for.
return byte[]
        private static byte[] GetIntegerBytes(long value)
        {
            // See AddIntegerCount() for why this is restricting use
            // of the most significant bit.
            if (value >= 0 && value < 128)
            {
                return new byte[] { (byte)value };
            }
            else if (value >= short.MinValue && value <= short.MaxValue)
            {
                return BitConverter.GetBytes(((short)value).ToBigEndianConditional());
            }
            else if (value >= int.MinValue && value <= int.MaxValue)
            {
                return BitConverter.GetBytes(((int)value).ToBigEndianConditional());
            }
            else
            {
                return BitConverter.GetBytes(value.ToBigEndianConditional());
            }
        }