Пример #1
0
        public static T ReadFromFile <T>(string fileName) where T : IByteable, new()
        {
            byte[]     b      = File.ReadAllBytes(fileName);
            ByteScribe reader = new ByteScribe(b);

            return(reader.Read <T>());
        }
Пример #2
0
        public static void WriteToFile(IByteable byteable, string fileName)
        {
            byte[]     b      = new byte[byteable.GetSize()];
            ByteScribe writer = new ByteScribe(b);

            writer.Write(byteable);
            File.WriteAllBytes(fileName, b);
        }
Пример #3
0
 void IByteable.Read(ByteScribe writer)
 {
     x = writer.ReadInt();
     y = writer.ReadInt();
 }
Пример #4
0
 //members must be read and written in the same order
 void IByteable.Write(ByteScribe writer)
 {
     writer.Write(x);
     writer.Write(y);
 }