/// <summary> /// Do not call this method directly. Call App.Kp2a.LoadDatabase instead. /// </summary> public void LoadData(IKp2aApp app, IOConnectionInfo iocInfo, MemoryStream databaseData, CompositeKey compositeKey, ProgressDialogStatusLogger status, IDatabaseFormat databaseFormat) { PwDatabase pwDatabase = new PwDatabase(); IFileStorage fileStorage = _app.GetFileStorage(iocInfo); Stream s = databaseData ?? fileStorage.OpenFileForRead(iocInfo); var fileVersion = _app.GetFileStorage(iocInfo).GetCurrentFileVersionFast(iocInfo); PopulateDatabaseFromStream(pwDatabase, s, iocInfo, compositeKey, status, databaseFormat); try { LastFileVersion = fileVersion; status.UpdateSubMessage(""); Root = pwDatabase.RootGroup; PopulateGlobals(Root); KpDatabase = pwDatabase; SearchHelper = new SearchDbHelper(app); _databaseFormat = databaseFormat; CanWrite = databaseFormat.CanWrite && !fileStorage.IsReadOnly(iocInfo); Loaded = true; } catch (Exception) { Clear(); throw; } }
/// <summary> /// Do not call this method directly. Call App.Kp2a.LoadDatabase instead. /// </summary> public void LoadData(IKp2aApp app, IOConnectionInfo iocInfo, MemoryStream databaseData, CompositeKey compositeKey, ProgressDialogStatusLogger status, IDatabaseFormat databaseFormat) { PwDatabase pwDatabase = new PwDatabase(); IFileStorage fileStorage = _app.GetFileStorage(iocInfo); Stream s = databaseData ?? fileStorage.OpenFileForRead(iocInfo); var fileVersion = _app.GetFileStorage(iocInfo).GetCurrentFileVersionFast(iocInfo); PopulateDatabaseFromStream(pwDatabase, s, iocInfo, compositeKey, status, databaseFormat); try { LastFileVersion = fileVersion; status.UpdateSubMessage(""); Root = pwDatabase.RootGroup; PopulateGlobals(Root); Loaded = true; KpDatabase = pwDatabase; SearchHelper = new SearchDbHelper(app); _databaseFormat = databaseFormat; CanWrite = databaseFormat.CanWrite && !fileStorage.IsReadOnly(iocInfo); } catch (Exception) { Clear(); throw; } }