Exemple #1
0
        /// <summary>
        ///   Logs out the current user.
        /// </summary>
        /// <param name="cancellationToken"> A token that allows for the operation to be cancelled. </param>
        public async Task LogoutAsync(CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (!IsLoggedIn)
            {
                return;
            }

            try
            {
                await Authenticator.Instance.LogoutAsync(_authenticationContext, cancellationToken);
            }
            catch (TaskCanceledException)
            {
                throw;
            }
            catch (Exception e)
            {
                // Ignoring error. It doesn't matter if the logout didn't go through to the server.
                TraceFns.WriteLine(string.Format(StringResources.LogoutFailed, e.Message));
            }
            OnPrincipalChanged();
            OnLoggedOut();
        }
Exemple #2
0
        private void EnsureDelegates()
        {
            if (_configuration.Delegates != null)
            {
                return;
            }

            var i = CompositionContext.GetExportedInstances(typeof(EntityManagerDelegate));

            if (i != null)
            {
                _configuration.WithDelegates(i.OfType <EntityManagerDelegate <T> >().ToArray());
            }

            if (_configuration.Delegates == null || !_configuration.Delegates.Any())
            {
                _configuration.WithDelegates(Composition.GetInstances <EntityManagerDelegate>()
                                             .OfType <EntityManagerDelegate <T> >()
                                             .ToArray());
            }

            TraceFns.WriteLine(_configuration.Delegates.Any()
                                   ? string.Format(StringResources.ProbedForEntityManagerDelegateAndFoundMatch,
                                                   _configuration.Delegates.Count())
                                   : StringResources.ProbedForEntityManagerDelegateAndFoundNoMatch);
        }
Exemple #3
0
        private IPredicateDescription GetQueryFilter()
        {
            try {
                List <PredicateDescription> predicates = new List <PredicateDescription>();

                foreach (var fd in FilterDescriptors)
                {
                    var p = fd.ToPredicateDescription(Query.ElementType);
                    if (p != null)
                    {
                        predicates.Add(p);
                    }
                }

                if (predicates.Count > 0)
                {
                    return(PredicateBuilder.And(predicates.ToArray()));
                }
                else
                {
                    return(null);
                }
            } catch (Exception ex) {
                TraceFns.WriteLine("Filters ignored: " + ex.Message);
                return(null);
            }
        }
Exemple #4
0
 private void WriteTrace()
 {
     if (_instance != null)
     {
         TraceFns.WriteLine(String.Format(StringResources.ProbedForServiceAndFoundMatch, typeof(T).Name,
                                          _instance.GetType().FullName));
     }
     else
     {
         TraceFns.WriteLine(String.Format(StringResources.ProbedForServiceFoundNoMatch, typeof(T).Name));
     }
 }
Exemple #5
0
        /// <summary>
        ///   Logs out the current user.
        /// </summary>
        public void Logout()
        {
            if (!IsLoggedIn)
            {
                return;
            }

            try
            {
                Authenticator.Instance.Logout(_authenticationContext);
            }
            catch (Exception e)
            {
                // Ignoring error. It doesn't matter if the logout didn't go through to the server.
                TraceFns.WriteLine(string.Format(StringResources.LogoutFailed, e.Message));
            }
            OnPrincipalChanged();
            OnLoggedOut();
        }
Exemple #6
0
 public static void TraceWriteLineIf(bool condition, object aObject)
 {
     TraceFns.WriteLineIf(condition, FormatLogMessage(aObject));
 }
Exemple #7
0
 public static void TraceWriteLine(object aObject)
 {
     TraceFns.WriteLine(FormatLogMessage(aObject));
 }