public void SaveSettingsFile() { this.AccountsHive.AccessData(true, k => { AccountSettingList o = new AccountSettingList(); foreach (var adapter in this.Inbox.EnumAdapters()) { o.List.Add(new AccountSetting { Guid = adapter.Guid, ProviderName = adapter.AdapterName, AppClientId = adapter.AppCredential?.ClientId !, AppClientSecret = adapter.AppCredential?.ClientSecret !, UserAccessToken = adapter.UserCredential?.AccessToken ! });
public FastReader() { try { this.Inbox = new Inbox(new InboxOptions(recordRealtimeTextLog: true)); this.Inbox.StateChangeEventListener.RegisterCallback(async(caller, type, state, args) => { UpdatedCallback(); await Task.CompletedTask; }); this.AccountsHive = Hive.LocalAppSettingsEx["Accounts"]; this.AccountsHive.AccessData(true, k => { var initial = new AccountSettingList(); AccountSettingList o = k.Get("AccountList", initial) !; foreach (AccountSetting account in o.List) { if (account.ProviderName._IsSamei(Consts.InboxProviderNames.Slack_Old)) { account.ProviderName = Consts.InboxProviderNames.Slack_App; } InboxAdapter a = this.Inbox.AddAdapter(account.Guid, account.ProviderName, new InboxAdapterAppCredential { ClientId = account.AppClientId, ClientSecret = account.AppClientSecret }); if (account.UserAccessToken._IsFilled()) { a.Start(new InboxAdapterUserCredential { AccessToken = account.UserAccessToken }); } else if (account.ProviderName._IsSamei(Consts.InboxProviderNames.Slack_User)) { // Special: Slack legacy tokens a.Start(new InboxAdapterUserCredential()); } } }); } catch { this._DisposeSafe(); throw; } }