internal static Binder GetCreateInstance(string dbName) { lock (_instanceLocker) { if (_instance == null || _instance._isDisposed) { _instance = new Binder(dbName); } return _instance; } }
protected override async Task OpenMayOverrideAsync(object args = null) { var briefcase = Briefcase.GetCreateInstance(); await briefcase.OpenAsync().ConfigureAwait(false); await briefcase.OpenCurrentBinderAsync().ConfigureAwait(false); _binder = briefcase.CurrentBinder; if (_binder != null) { await _binder.OpenCurrentFolderAsync(); } RaisePropertyChanged_UI(nameof(Binder)); _runtimeData = RuntimeData.Instance; RaisePropertyChanged_UI(nameof(RuntimeData)); }
private async Task ContinueAfterPickAsync(StorageFolder fromDir, Binder binder) { Logger.Add_TPL("ContinueAfterPickAsync() starting", Logger.AppEventsLogFilename, Logger.Severity.Info, false); bool isImported = false; try { if (binder != null && fromDir != null) { _animationStarter.StartAnimation(AnimationStarter.Animations.Updating); isImported = await binder.ImportFoldersAsync(fromDir).ConfigureAwait(false); Logger.Add_TPL("ContinueAfterPickAsync(): isImported = " + isImported, Logger.AppEventsLogFilename, Logger.Severity.Info, false); Logger.Add_TPL("ContinueAfterPickAsync(): binder is open = " + binder.IsOpen, Logger.AppEventsLogFilename, Logger.Severity.Info, false); Logger.Add_TPL("ContinueAfterPickAsync(): binder is disposed = " + binder.IsDisposed, Logger.AppEventsLogFilename, Logger.Severity.Info, false); } } catch (Exception ex) { await Logger.AddAsync(ex.ToString(), Logger.AppEventsLogFilename).ConfigureAwait(false); } _animationStarter.EndAllAnimations(); _animationStarter.StartAnimation(isImported ? AnimationStarter.Animations.Success : AnimationStarter.Animations.Failure); IsImportingFolders = false; }
public Task DeleteFolderAsync(Binder.FolderPreview fp) { return RunFunctionIfOpenAsyncT(async delegate { var binder = _binder; if (binder != null && fp != null) { if (await binder.RemoveFolderAsync(fp.FolderId).ConfigureAwait(false)) { SetIsDirty(true, true, 0); } } }); }
public BinderCoverVM(Binder binder, AnimationStarter animationStarter) { if (binder == null) throw new ArgumentNullException("BinderCoverVM ctor: binder may not be null"); if (animationStarter == null) throw new ArgumentNullException("BinderCoverVM ctor: animationStarter may not be null"); _binder = binder; RaisePropertyChanged_UI(nameof(Binder)); _metaBriefcase = MetaBriefcase.OpenInstance; if (_metaBriefcase == null) throw new ArgumentNullException("BinderCoverVM ctor: MetaBriefcase may not be null"); RaisePropertyChanged_UI(nameof(MetaBriefcase)); _animationStarter = animationStarter; }
private void CopyFrom(Binder source) { SetIdsForCatFilter(source._catIdForFldFilter); SetIdsForFldFilter(source._catIdForCatFilter, source._fldDscIdForFldFilter, source._fldValIdForFldFilter); SetFilter(source._whichFilter); SetDBName(source._dbName); CurrentFolderId = source._currentFolderId; // CurrentFolder will be updated later }
private async Task<bool> CloseCurrentBinder2Async() { var cb = _currentBinder; if (cb != null) { bool wasOpen = await cb.CloseAsync().ConfigureAwait(false); cb.Dispose(); _currentBinder = null; // don't use CurrentBinder here, it triggers stuff return wasOpen; } return false; }
private async Task<bool> UpdateCurrentBinder2Async(bool openTheBinder) { if (string.IsNullOrEmpty(_currentBinderName)) { await CloseCurrentBinder2Async().ConfigureAwait(false); RaisePropertyChanged_UI(nameof(CurrentBinder)); return false; } if ((_currentBinder == null && !string.IsNullOrEmpty(_currentBinderName)) || (_currentBinder != null && _currentBinder.DBName != _currentBinderName)) { await CloseCurrentBinder2Async().ConfigureAwait(false); _currentBinder = Binder.GetCreateInstance(_currentBinderName); if (openTheBinder) await _currentBinder.OpenAsync().ConfigureAwait(false); RaisePropertyChanged_UI(nameof(CurrentBinder)); // notify the UI once the data has been loaded return true; } if (_currentBinder != null) { if (openTheBinder) await _currentBinder.OpenAsync().ConfigureAwait(false); RaisePropertyChanged_UI(nameof(CurrentBinder)); return true; } return false; }