public async Task InitializeAsync() { try { this.metadata = await this.platformService.LoadFileAsync <SynchronizationMetadata>(SynchronizationMetadata.Filename); if (this.metadata == null) { // do not use this.Workbook as it's null at this point because AttachWorkbook wasn't called yet int launchCount = this.platformService.GetSettingValue <int>(CoreSettings.LaunchCount); if (launchCount > 5) { TrackingManagerHelper.Trace("SynchronizationManager.InitializeAsync: null metadata while launch count is " + launchCount); } this.metadata = new SynchronizationMetadata(); } } catch (Exception) { this.metadata = new SynchronizationMetadata(); } }
public void AttachWorkbook(IWorkbook target) { if (target == null) { throw new ArgumentNullException("target"); } if (this.workbook != null) { throw new InvalidOperationException("Workbook is already attached"); } this.workbook = target; if (this.metadata != null) { this.ActiveService = this.metadata.ActiveProvider; } else { this.metadata = new SynchronizationMetadata(); } this.provider = this.GetProvider(this.metadata.ActiveProvider); if (this.provider != null) { // make sure we have valid information for syncing if (string.IsNullOrEmpty(this.provider.ServerInfo) || string.IsNullOrEmpty(this.provider.LoginInfo)) { this.ActiveService = SynchronizationService.None; } } // listen for changes in the workbook this.RegisterWorkbookEvents(); }