private bool TakeFacebookLoggedInAction(FacebookOAuthResult facebookOAuthResult) { if (facebookOAuthResult == null) { // the user closed the FacebookLoginDialog, so do nothing. MessageBox.Show("Cancelled!"); } else if (facebookOAuthResult.IsSuccess) { m_AccessToken = facebookOAuthResult.AccessToken; m_ProviderName = LoginProvider.Facebook; CognitoSyncSettingsConfiguration.Credentials.Clear(); CognitoSyncSettingsConfiguration.Credentials.AddLogin(Constants.CognitoSyncProviderName_Facebook, m_AccessToken); // plugins are persistant and next call return the same object var plugin = CognitoSyncSettings.GetPlugin <ICognitoSyncSettingsPlugin>(); plugin.SynchronizeDataset(); return(true); } else { MessageBox.Show(facebookOAuthResult.ErrorDescription); } return(false); }
void UpdateUI() { this.UIThread(() => { CognitoSyncSettings.LoadSettings(); // set static settings this.boolValue.Checked = CognitoSyncSettings.Boolean; if (m_textCounter <= 0) { this.textValue.Text = CognitoSyncSettings.Text; } else { m_textCounter--; } this.enumValue.SelectedIndex = (int)CognitoSyncSettings.Enum; // set dynamic settings var cognitoSyncSettings = CognitoSyncSettings.GetPlugin <ICognitoSyncSettingsPlugin>(); var dynamicCognitoSyncSettings = (IDynamicSettingsPlugin)cognitoSyncSettings; dynamicCognitoSyncSettings.LoadSettings(); SetDynamicCheckBox(this.dynamicValue1, dynamicCognitoSyncSettings); SetDynamicCheckBox(this.dynamicValue2, dynamicCognitoSyncSettings); SetDynamicCheckBox(this.dynamicValue3, dynamicCognitoSyncSettings); SetDynamicCheckBox(this.dynamicValue4, dynamicCognitoSyncSettings); SetDynamicCheckBox(this.dynamicValue5, dynamicCognitoSyncSettings); SetDynamicCheckBox(this.dynamicValue6, dynamicCognitoSyncSettings); }); }
static void SetupAdvexpSettings() { SettingsConfiguration.EncryptionServiceID = "Advexp.Settings.Sample"; Advexp.SettingsBaseConfiguration.RegisterSettingsPlugin <ICognitoSyncSettingsPlugin, CognitoSyncSettingsPlugin>(); Amazon.AWSConfigs.ApplicationName = Constants.FacebookAppName; CognitoSyncSettingsConfiguration.Config = new AmazonCognitoSyncConfig() { RegionEndpoint = Constants.CognitoSyncRegion, }; CognitoSyncSettingsConfiguration.Credentials = new CognitoAWSCredentials(Constants.CognitoSyncIdentityPoolId, Constants.CognitoSyncIdentityRegion); // plugins are persistant and next call will return the same object var plugin = CognitoSyncSettings.GetPlugin <ICognitoSyncSettingsPlugin>(); plugin.OnSyncSuccess += (object sender, SyncSuccessEventArgs e) => { }; plugin.OnSyncFailure += (object sender, SyncFailureEventArgs e) => { }; plugin.OnDatasetDeleted = delegate(Dataset ds) { // Do clean up if necessary // returning true informs the corresponding dataset can be purged in the local storage and return false retains the local dataset return(true); }; plugin.OnDatasetMerged = delegate(Dataset dataset, List <string> datasetNames) { // returning true allows the Synchronize to continue and false stops it return(true); }; plugin.OnSyncConflict = delegate(Dataset dataset, List <SyncConflict> conflicts) { var resolvedRecords = new List <Amazon.CognitoSync.SyncManager.Record>(); foreach (SyncConflict conflictRecord in conflicts) { // SyncManager provides the following default conflict resolution methods: // ResolveWithRemoteRecord - overwrites the local with remote records // ResolveWithLocalRecord - overwrites the remote with local records // ResolveWithValue - to implement your own logic resolvedRecords.Add(conflictRecord.ResolveWithRemoteRecord()); } // resolves the conflicts in local storage dataset.Resolve(resolvedRecords); // on return true the synchronize operation continues where it left, // returning false cancels the synchronize operation return(true); }; }
void SetDynamicSettingValue(CheckBox checkBox) { var cognitoSyncSettings = CognitoSyncSettings.GetPlugin <ICognitoSyncSettingsPlugin>(); var ds = (IDynamicSettingsPlugin)cognitoSyncSettings; var settingName = checkBox.Name; bool value = checkBox.Checked; ds.SetSetting(settingName, value); ds.SaveSetting(settingName); }
bool TakeGoogleLoggedInAction(string token) { if (!String.IsNullOrEmpty(token)) { m_AccessToken = token; m_ProviderName = LoginProvider.Google; CognitoSyncSettingsConfiguration.Credentials.Clear(); CognitoSyncSettingsConfiguration.Credentials.AddLogin(Constants.CognitoSyncProviderName_Google, token); // plugins are persistant and next call return the same object var plugin = CognitoSyncSettings.GetPlugin <ICognitoSyncSettingsPlugin>(); plugin.SynchronizeDataset(); return(true); } else { MessageBox.Show("Incorrect access token."); } return(false); }
public Form1() { // plugins are persistant and next call will return the same object var plugin = CognitoSyncSettings.GetPlugin <ICognitoSyncSettingsPlugin>(); plugin.OnSyncSuccess += (object sender, SyncSuccessEventArgs e) => { m_enableEnumComboBoxEvent = false; Invoke(new MethodInvoker(UpdateUI)); m_enableEnumComboBoxEvent = true; }; m_enableEnumComboBoxEvent = false; InitializeComponent(); var enumDataSource = new List <string>(Enum.GetNames(typeof(EEnumValues))); this.enumValue.DataSource = enumDataSource; UpdateUI(); m_enableEnumComboBoxEvent = true; }
private void SynchronizeDataset_Click(object sender, EventArgs e) { var plugin = CognitoSyncSettings.GetPlugin <ICognitoSyncSettingsPlugin>(); plugin.SynchronizeDataset(); }