コード例 #1
0
ファイル: Database.cs プロジェクト: pp3345/keepass2android
        /// <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;
            }
        }
コード例 #2
0
ファイル: Database.cs プロジェクト: pythe/wristpass
        /// <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;
            }
        }