public static IServiceCollection AddUserProviderFromMessage(this IServiceCollection builder, Message message)
        {
            builder.AddScoped <IUserProfileProvider, UserProfileProvider>((ctx) =>
            {
                Reference user = message.GetUserDetails();

                UserProfileProvider userProfileProvider = new UserProfileProvider();

                userProfileProvider.SetUser(user.Id, user.Name);

                return(userProfileProvider);
            });

            return(builder);
        }
        public static IServiceCollection AddUserProviderFromRequest(this IServiceCollection builder)
        {
            builder.AddScoped <IUserProfileProvider, UserProfileProvider>((ctx) =>
            {
                IHttpContextAccessor httpContextAccessor = ctx.GetService <IHttpContextAccessor>();

                string userId = httpContextAccessor.HttpContext?.User?.Claims.FirstOrDefault(m => m.Type == ClaimTypes.Sid)?.Value;

                string userName = httpContextAccessor.HttpContext?.User?.Claims.FirstOrDefault(m => m.Type == ClaimTypes.Name)?.Value;

                UserProfileProvider userProfileProvider = new UserProfileProvider();

                userProfileProvider.SetUser(userId, userName);

                return(userProfileProvider);
            });

            return(builder);
        }