private static void WriteToConsole(this IdentityInfo identity, int indentationLevel) { // Identity. WritePropertyToConsole("Source\t\t", identity.Source, indentationLevel); WritePropertyToConsole("Application\t", identity.Application, indentationLevel); WritePropertyToConsole("Is Authenticated", identity.IsAuthenticated.ToString(), indentationLevel); WritePropertyToConsole("Name\t\t", identity.Name, indentationLevel); WritePropertyToConsole("Authentication Type", identity.AuthenticationType, indentationLevel); if (identity.RoleNames != null && identity.RoleNames.Any()) { WritePropertyToConsole("Application Roles", string.Join(", ", identity.RoleNames), indentationLevel); } if (identity.GroupNames != null && identity.GroupNames.Any()) { WritePropertyToConsole("Groups\t\t", string.Join(", ", identity.GroupNames), indentationLevel); } // Claims. Console.WriteLine(); Console.WriteLine(GetIndentationPrefix(indentationLevel) + "Claims:"); foreach (var claim in identity.Claims) { WritePropertyToConsole(" Type", claim.Type, indentationLevel, ConsoleColor.Magenta); WritePropertyToConsole(" Value", claim.Value, indentationLevel); if (!string.IsNullOrWhiteSpace(claim.Remark)) { WritePropertyToConsole(" Remark", claim.Remark, indentationLevel, ConsoleColor.Gray); } Console.WriteLine(); } // Related Application Identities. if (identity.RelatedApplicationIdentities != null && identity.RelatedApplicationIdentities.Any()) { Console.WriteLine(); Console.WriteLine(GetIndentationPrefix(indentationLevel) + "Related Application Identities:"); foreach (var relatedApplicationIdentity in identity.RelatedApplicationIdentities) { Console.WriteLine(); WriteToConsole(relatedApplicationIdentity, indentationLevel + 1); } } }
public static void WriteToConsole(this IdentityInfo identity) { identity.WriteToConsole(0); }