IShellWindowFactory should take the version number also
This commit is contained in:
1 parent
2c4bceca45
commit
ec7bd46cbb
3 files changed
+10
-7
No files matched your search
@@ -42,8 +42,8 @@ namespace bts.shell
|
||||
|
||||
public Task<IShellWindow> create(Stream load_stream) {
|
||||
if (try_deserialize(load_stream, out ShellSerializationHeader header)) {
|
||||
if (header.name == _tsf.name) return _tsf.load_window(load_stream);
|
||||
if (header.name == _mvf.name) return _mvf.load_window(load_stream);
|
||||
if (header.name == _tsf.name) return _tsf.load_window(load_stream, header.version);
|
||||
if (header.name == _mvf.name) return _mvf.load_window(load_stream, header.version);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace bts.shell {
|
||||
|
||||
public Task<IShellWindow> create(Stream load_stream) {
|
||||
if (try_deserialize(load_stream, out ShellSerializationHeader header)) {
|
||||
if (header.name == _lf.name) return _lf.load_window(load_stream);
|
||||
if (header.name == _lf.name) return _lf.load_window(load_stream, header.version);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace bts.shell {
|
||||
interface IShellWindowFactory : IDisposable {
|
||||
string name { get; }
|
||||
int version { get; }
|
||||
Task<IShellWindow> load_window(Stream load_stream);
|
||||
Task<IShellWindow> load_window(Stream load_stream, int version);
|
||||
}
|
||||
|
||||
abstract class ShellWindowFactory<T> : IShellWindowFactory {
|
||||
@@ -28,9 +28,12 @@ namespace bts.shell {
|
||||
}
|
||||
public abstract Task<IShellWindow> load(T state);
|
||||
|
||||
public Task<IShellWindow> load_window(Stream load_stream) {
|
||||
var t = ProtoBuf.Serializer.DeserializeWithLengthPrefix<T>(load_stream, ProtoBuf.PrefixStyle.Fixed32);
|
||||
return load(t);
|
||||
public Task<IShellWindow> load_window(Stream load_stream, int version) {
|
||||
if (version == this.version) {
|
||||
var t = ProtoBuf.Serializer.DeserializeWithLengthPrefix<T>(load_stream, ProtoBuf.PrefixStyle.Fixed32);
|
||||
return load(t);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public void save(T data, Stream output) {
|
||||
var header = new ShellSerializationHeader() {
|
||||
|
||||
Reference in new issue
Block a user