/// <summary> 
 /// The save session. 
 /// </summary> 
 /// <param name="session"> 
 /// The session. 
 /// </param> 
 private void Save(Session session)
 {
     SaveEncryptedSettingValue("session_token", session.AccessToken);
     SaveEncryptedSettingValue("session_id", session.Id);
     SaveEncryptedSettingValue("session_expiredate", session.ExpireDate.Ticks.ToString(CultureInfo.InvariantCulture));
     SaveEncryptedSettingValue("session_provider", session.Provider);
     _applicationSettings.LocalSettings[Constants.LoginToken] = true;
 }
        /// <summary> 
        /// Gets the session. 
        /// </summary> 
        /// <returns>The session object.</returns> 
        public Session GetSession()
        {
            var expiryValue = DateTime.MinValue;
            string expiryTicks = LoadEncryptedSettingValue("session_expiredate");
            if (!string.IsNullOrWhiteSpace(expiryTicks))
            {
                long expiryTicksValue;
                if (long.TryParse(expiryTicks, out expiryTicksValue))
                {
                    expiryValue = new DateTime(expiryTicksValue);
                }
            }

            var session = new Session
            {
                AccessToken = LoadEncryptedSettingValue("session_token"),
                Id = LoadEncryptedSettingValue("session_id"),
                ExpireDate = expiryValue,
                Provider = LoadEncryptedSettingValue("session_provider")
            };
            _applicationSettings.LocalSettings[Constants.LoginToken] = true;
            return session;
        }