public static IServiceProvider GetServiceProvider(this IValidationContext context)
        {
            var serviceProvider =
                (context.GetValidationContext().RootContextData.TryGetValue(Constants.ServiceProviderKeyLiteral, out var serviceProviderObject)
                    ? serviceProviderObject as IServiceProvider : null)
                ?? ServiceLocator.GetServiceProvider();

            if (serviceProvider == null)
            {
                throw new InvalidOperationException("Could not get a service provider for validation. Either use a ValidationContextProvider or register a global service provider in ServiceLocator.");
            }

            return(serviceProvider);
        }
 internal static void SetServiceProvider(this IValidationContext context, IServiceProvider serviceProvider)
 {
     context.GetValidationContext().RootContextData[Constants.ServiceProviderKeyLiteral] = serviceProvider;
 }