/// <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(); }
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); }
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); } }
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)); } }
/// <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(); }
public static void TraceWriteLineIf(bool condition, object aObject) { TraceFns.WriteLineIf(condition, FormatLogMessage(aObject)); }
public static void TraceWriteLine(object aObject) { TraceFns.WriteLine(FormatLogMessage(aObject)); }