/// <summary>
 /// Clear previously saved authentication context
 /// Call this in your Sign out flow
 /// </summary>
 public void ClearSavedAuthentication()
 {
     if (SaveAuthContextExists())
     {
         IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
         file.DeleteFile("AuthFile");
         _AuthContext = new CRMAuthenticationContext();
     }
 }
        /// <summary>
        /// helper method to load the context from encrypted isolated storage
        /// </summary>
        private void LoadAuthContext()
        {
            IsolatedStorageFile       file       = IsolatedStorageFile.GetUserStoreForApplication();
            IsolatedStorageFileStream readstream = new IsolatedStorageFileStream("AuthFile", System.IO.FileMode.Open, FileAccess.Read, file);

            // Read the PIN from the file.
            Stream reader = new StreamReader(readstream).BaseStream;

            byte[] pinArray = new byte[reader.Length];

            reader.Read(pinArray, 0, pinArray.Length);
            reader.Close();
            readstream.Close();

            // Decrypt the PIN by using the Unprotect method.
            byte[] PinByte = ProtectedData.Unprotect(pinArray, null);

            // Convert the PIN from byte to string and display it in the text box.
            var objData = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length);

            _AuthContext = JsonConvert.DeserializeObject <CRMAuthenticationContext>(objData);
        }
 /// <summary>
 /// Clear previously saved authentication context
 /// Call this in your Sign out flow
 /// </summary>
 public void ClearSavedAuthentication()
 {
     if (SaveAuthContextExists())
     {
         IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
         file.DeleteFile("AuthFile");
         _AuthContext = new CRMAuthenticationContext();
     }
 }
        /// <summary>
        /// helper method to load the context from encrypted isolated storage
        /// </summary>
        private void LoadAuthContext()
        {
            IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
            IsolatedStorageFileStream readstream = new IsolatedStorageFileStream("AuthFile", System.IO.FileMode.Open, FileAccess.Read, file);

            // Read the PIN from the file.
            Stream reader = new StreamReader(readstream).BaseStream;
            byte[] pinArray = new byte[reader.Length];

            reader.Read(pinArray, 0, pinArray.Length);
            reader.Close();
            readstream.Close();

            // Decrypt the PIN by using the Unprotect method.
            byte[] PinByte = ProtectedData.Unprotect(pinArray, null);

            // Convert the PIN from byte to string and display it in the text box.
            var objData = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length);

            _AuthContext = JsonConvert.DeserializeObject<CRMAuthenticationContext>(objData);


        }