public static IIronLeveldb Build(this IIronLeveldbStorge storge, IronLeveldbOptions options) { var manifestContent = storge.GetCurrentDescriptorContent(); // TODO base version var b = new Version.Builder(storge, options, null); using (var manifestStream = manifestContent.AsStream()) { foreach (var stream in new RecoverLogRecordsStream(manifestStream)) { var versionEdit = VersionEdit.DecodeFrom(stream); b.With(versionEdit); } } var current = b.Build(); return(new IronLeveldbStub(options, current, () => { var es = new List <Exception>(); try { storge.Dispose(); } catch (Exception e) { es.Add(e); } try { current.Dispose(); } catch (Exception e) { es.Add(e); } if (es.Count > 1) { throw new AggregateException(es); } if (es.Count == 1) { throw es.First(); } })); }