Beispiel #1
0
 public static void Write(this IO.EndianWriter s, QuaternionF v)
 {
     s.Write(v.X);
     s.Write(v.Y);
     s.Write(v.Z);
     s.Write(v.W);
 }
Beispiel #2
0
        /// <summary>Write a <typeparamref name="TEnum"/> value to a stream</summary>
        /// <param name="s">Stream to write to</param>
        /// <param name="value">Value to write to the stream</param>
        /// <remarks>
        /// Uses <typeparamref name="TEnum"/>'s underlying <see cref="TypeCode"/> to
        /// decide how big of a numeric type to write to the stream.
        /// </remarks>
        public static void Write(IO.EndianWriter s, TEnum value)
        {
            Contract.Requires(s != null);

            ulong stream_value = Reflection.EnumValue <TEnum> .ToUInt64(value);

            switch (Reflection.EnumUtil <TEnum> .UnderlyingTypeCode)
            {
            case TypeCode.Byte:
            case TypeCode.SByte: s.Write((byte)stream_value);
                break;

            case TypeCode.Int16:
            case TypeCode.UInt16: s.Write((ushort)stream_value);
                break;

            case TypeCode.Int32:
            case TypeCode.UInt32: s.Write((uint)stream_value);
                break;

            case TypeCode.Int64:
            case TypeCode.UInt64: s.Write(stream_value);
                break;

            default:
                throw new Debug.UnreachableException();
            }
        }
Beispiel #3
0
 public static void Write(this IO.EndianWriter s, Vector4f v)
 {
     s.Write(v.X);
     s.Write(v.Y);
     s.Write(v.Z);
     s.Write(v.W);
 }
Beispiel #4
0
        public static void Write(this Guid value, IO.EndianWriter s, bool respectEndian = true)
        {
            byte[] data = value.ToByteArray();

            if (respectEndian)
            {
                Bitwise.ByteSwap.SwapInt32(data, 0);
                Bitwise.ByteSwap.SwapInt16(data, sizeof(uint));
                Bitwise.ByteSwap.SwapInt16(data, sizeof(uint) + sizeof(ushort));
            }

            s.Write(data);
        }
 public void Write(EndianWriter s)
 {
     Contract.Requires(s != null);
 }
Beispiel #6
0
 /// <summary>
 /// Write a serializable object to an endian stream
 /// </summary>
 /// <typeparam name="T">Reference type implementing <see cref="IO.IEndianStreamable"/></typeparam>
 /// <param name="s"></param>
 /// <param name="theObj"></param>
 public static void WriteObject <T>(this IO.EndianWriter s, T theObj)
     where T : class, IO.IEndianStreamable
 {
     theObj.Write(s);
 }
Beispiel #7
0
 /// <summary>
 /// Write a serializable value type to an endian stream
 /// </summary>
 /// <typeparam name="T">Value type implementing <see cref="IO.IEndianStreamable"/></typeparam>
 /// <param name="s"></param>
 /// <param name="value"></param>
 public static void WriteObject <T>(this IO.EndianWriter s, ref T value)
     where T : struct, IO.IEndianStreamable
 {
     value.Write(s);
 }
Beispiel #8
0
 public static void Write(this string value, IO.EndianWriter s, Text.StringStorageEncoding encoding)
 {
     s.Write(value, encoding);
 }
Beispiel #9
0
 public static void Write(this string value, IO.EndianWriter s, Memory.Strings.StringStorage storage)
 {
     s.Write(value, storage);
 }
Beispiel #10
0
 public static void Write(this string value, IO.EndianWriter s)
 {
     s.Write(value);
 }
Beispiel #11
0
 public static void Write(this byte[] value, IO.EndianWriter s, int index, int count)
 {
     s.Write(value, index, count);
 }
Beispiel #12
0
 public static void Write(this byte[] value, IO.EndianWriter s)
 {
     s.Write(value, 0, value.Length);
 }
Beispiel #13
0
 public static void Write(this IO.EndianWriter s, Plane3f v)
 {
     s.Write(v.Normal);
     s.Write(v.D);
 }
Beispiel #14
0
 public static void Write(this double value, IO.EndianWriter s) => s.Write(value);
Beispiel #15
0
 public static void Write(this float value, IO.EndianWriter s) => s.Write(value);
Beispiel #16
0
 public static void Write(this ulong value, IO.EndianWriter s) => s.Write(value);