public static void dbg_RWString() { System.IO.MemoryStream str = new System.IO.MemoryStream(); StreamAccessor ac = new StreamAccessor(str); ac.Write("今日は", EncodingType.NoSpecified); ac.Stream.Position = 0; dumpMemoryStream(str); System.Console.WriteLine(ac.Read <string>(EncodingType.NoSpecified)); }
public static void dbg_RWScheduledClass() { System.IO.MemoryStream str = new System.IO.MemoryStream(); StreamAccessor ac = new StreamAccessor(str); TargetClass t1 = new TargetClass(); t1.Init(); t1.WriteToConsole(); ac.Write(t1, EncodingType.NoSpecified); ac.Stream.Position = 0; dumpMemoryStream(str); TargetClass t2 = ac.Read <TargetClass>(); t2.WriteToConsole(); }
public static void dbg_RWPrimitiveTypes() { System.IO.MemoryStream str = new System.IO.MemoryStream(); StreamAccessor ac = new StreamAccessor(str); ac.Write((byte)1, EncodingType.U1); ac.Write((sbyte)2, EncodingType.I1); ac.Write((short)3, EncodingType.I2); ac.Write((short)4, EncodingType.I2BE); ac.Write((ushort)5, EncodingType.U2); ac.Write((ushort)6, EncodingType.U2BE); ac.Write((int)7, EncodingType.I3); ac.Write((int)8, EncodingType.I3BE); ac.Write((int)9, EncodingType.Int28); ac.Write((int)10, EncodingType.Int28BE); ac.Write((int)11, EncodingType.I4); ac.Write((int)12, EncodingType.I4BE); ac.Write((uint)13, EncodingType.U3); ac.Write((uint)14, EncodingType.U3BE); ac.Write((uint)15, EncodingType.UInt28); ac.Write((uint)16, EncodingType.UInt28BE); ac.Write((uint)17, EncodingType.U4); ac.Write((uint)18, EncodingType.U4BE); ac.Write((long)19, EncodingType.I8); ac.Write((long)20, EncodingType.I8BE); ac.Write((ulong)21, EncodingType.U8); ac.Write((ulong)22, EncodingType.U8BE); str.Position = 0; System.Console.WriteLine(ac.ReadByte(EncodingType.U1)); System.Console.WriteLine(ac.ReadSByte(EncodingType.I1)); System.Console.WriteLine(ac.ReadInt16(EncodingType.I2)); System.Console.WriteLine(ac.ReadInt16(EncodingType.I2BE)); System.Console.WriteLine(ac.ReadUInt16(EncodingType.U2)); System.Console.WriteLine(ac.ReadUInt16(EncodingType.U2BE)); System.Console.WriteLine(ac.ReadInt32(EncodingType.I3)); System.Console.WriteLine(ac.ReadInt32(EncodingType.I3BE)); System.Console.WriteLine(ac.ReadInt32(EncodingType.Int28)); System.Console.WriteLine(ac.ReadInt32(EncodingType.Int28BE)); System.Console.WriteLine(ac.ReadInt32(EncodingType.I4)); System.Console.WriteLine(ac.ReadInt32(EncodingType.I4BE)); System.Console.WriteLine(ac.ReadUInt32(EncodingType.U3)); System.Console.WriteLine(ac.ReadUInt32(EncodingType.U3BE)); System.Console.WriteLine(ac.ReadUInt32(EncodingType.UInt28)); System.Console.WriteLine(ac.ReadUInt32(EncodingType.UInt28BE)); System.Console.WriteLine(ac.ReadUInt32(EncodingType.U4)); System.Console.WriteLine(ac.ReadUInt32(EncodingType.U4BE)); System.Console.WriteLine(ac.ReadInt64(EncodingType.I8)); System.Console.WriteLine(ac.ReadInt64(EncodingType.I8BE)); System.Console.WriteLine(ac.ReadUInt64(EncodingType.U8)); System.Console.WriteLine(ac.ReadUInt64(EncodingType.U8BE)); // 結果: // ulong 及び long の読み書きを修正 // →OK }