public static void DeSerialize(byte[] buffer, Binary binary) { Reader reader = new Reader(); reader.Load(buffer, 0, buffer.Length); binary.Read(ref reader); reader.Close(); }
public static T DeSerialize <T>(byte[] buffer) where T : Binary { Reader reader = new Reader(); reader.Load(buffer, 0, buffer.Length); T instance = DeSerialize <T>(reader); reader.Close(); return(instance); }
public static T DeSerializeFromFile <T>(string path) where T : Binary { T instance = null; if (File.Exists(path)) { using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); Reader reader = new Reader(); reader.Load(buffer, 0, buffer.Length); instance = DeSerialize <T>(reader); reader.Close(); } } return(instance); }