Ejemplo n.º 1
0
        /// <summary>
        /// Gets a web account by type.
        /// </summary>
        /// <param name="type">Type enum of the web account.</param>
        /// <returns>WebAccount instance if found else null.</returns>
        private async Task <WebAccount> GetWebAccount(WebAccountTypes type)
        {
            var details = this.GetWebAccountInfo(type);

            WebAccount account = null;

            if (details != null)
            {
                WebAccountProvider provider = await GetProvider(details.ProviderID, details.Authority);

                if (provider != null)
                {
                    account = await WebAuthenticationCoreManager.FindAccountAsync(provider, details.AccountID);
                }

                // The account has been deleted if FindAccountAsync returns null
                if (account == null)
                {
                    this.DeleteUsersWebAccountDetails(type);
                }
            }
            return(account);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Deletes an authenticated account from storage.
 /// </summary>
 /// <param name="type">Enum type representing the web account to delete.</param>
 private void DeleteUsersWebAccountDetails(WebAccountTypes type)
 {
     Platform.Current.Storage.SaveSetting("WAM_" + type.ToString(), null, ApplicationData.Current.RoamingSettings, SerializerTypes.Json);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Indicates whether or not an account is stored in storage.
 /// </summary>
 /// <param name="type">Enum type of the web account to check if stored info exists or not.</param>
 /// <returns>True if stored info exists else false.</returns>
 private bool HasWebAccountInfo(WebAccountTypes type)
 {
     return Platform.Current.Storage.ContainsSetting("WAM_" + type.ToString(), ApplicationData.Current.RoamingSettings);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Retrieves an authenticated account details from storage.
 /// </summary>
 /// <param name="type"></param>
 /// <returns>WebAccountInfo instance if found else null.</returns>
 private WebAccountInfo GetWebAccountInfo(WebAccountTypes type)
 {
     return Platform.Current.Storage.LoadSetting<WebAccountInfo>("WAM_" + type.ToString(), ApplicationData.Current.RoamingSettings, SerializerTypes.Json);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a web account by type.
        /// </summary>
        /// <param name="type">Type enum of the web account.</param>
        /// <returns>WebAccount instance if found else null.</returns>
        private async Task<WebAccount> GetWebAccount(WebAccountTypes type)
        {
            var details = this.GetWebAccountInfo(type);

            WebAccount account = null;
            if (details != null)
            {
                WebAccountProvider provider = await GetProvider(details.ProviderID, details.Authority);
                if (provider != null)
                    account = await WebAuthenticationCoreManager.FindAccountAsync(provider, details.AccountID);

                // The account has been deleted if FindAccountAsync returns null
                if (account == null)
                    this.DeleteUsersWebAccountDetails(type);
            }
            return account;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Deletes an authenticated account from storage.
 /// </summary>
 /// <param name="type">Enum type representing the web account to delete.</param>
 private void DeleteUsersWebAccountDetails(WebAccountTypes type)
 {
     PlatformBase.CurrentCore.Storage.SaveSetting("WAM_" + type.ToString(), null, ApplicationData.Current.RoamingSettings, SerializerTypes.Json);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Indicates whether or not an account is stored in storage.
 /// </summary>
 /// <param name="type">Enum type of the web account to check if stored info exists or not.</param>
 /// <returns>True if stored info exists else false.</returns>
 private bool HasWebAccountInfo(WebAccountTypes type)
 {
     return(PlatformBase.CurrentCore.Storage.ContainsSetting("WAM_" + type.ToString(), ApplicationData.Current.RoamingSettings));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Retrieves an authenticated account details from storage.
 /// </summary>
 /// <param name="type"></param>
 /// <returns>WebAccountInfo instance if found else null.</returns>
 private WebAccountInfo GetWebAccountInfo(WebAccountTypes type)
 {
     return(PlatformBase.CurrentCore.Storage.LoadSetting <WebAccountInfo>("WAM_" + type.ToString(), ApplicationData.Current.RoamingSettings, SerializerTypes.Json));
 }