/// <summary> /// Creates a fresh instance using the <paramref name="user" />. /// </summary> /// <param name="user">The claim principal user.</param> /// <returns>The user or <c>null</c> if none could be determined.</returns> public static ClaimBasedUser Create(ClaimsPrincipal user) { if (user == null) { return null; } var result = new ClaimBasedUser { Values = new Dictionary<string, string>() }; typeof(ClaimTypes).GetPublicConstants().ToList().ForEach( c => { result.Values.Add(c.Name, user.GetPropertyValue(c.GetRawConstantValue().ToString())); }); return result; }