Beispiel #1
0
        /// <summary>Validates the specified API request context resolver.</summary>
        /// <param name="contextResolver">The API request context resolver.</param>
        /// <returns></returns>
        public async Task <IList <ApiValidationResult> > Validate(IApiRequestContextResolver contextResolver)
        {
            var context = contextResolver?.GetContext();

            if (context != null)
            {
                IEndpointValidator validator = null;

                try
                {
                    if (context.RequestServices != null)
                    {
                        validator = context.RequestServices.GetService(Type.GetType(ValidatorType.AssemblyQualifiedName)) as IEndpointValidator;
                    }
                }
                catch { }

                if (validator == null)
                {
                    try
                    {
                        validator = Activator.CreateInstance(Type.GetType(ValidatorType.AssemblyQualifiedName)) as IEndpointValidator;
                    }
                    catch { }
                }

                if (validator != null)
                {
                    return(await validator.Validate(contextResolver).ConfigureAwait(false));
                }
            }

            return(null);
        }
Beispiel #2
0
 public HttpDiagnosticListenerObserver(
     IEnumerable <IContextInjector <TContext, HttpRequestMessage> > contextInjectors,
     IEndpointValidator endpointValidator,
     IOutgoingRequestNotifier <TContext, HttpRequestMessage, HttpResponseMessage> requestNotifier)
 {
     this.endpointValidator = endpointValidator;
     this.contextInjectors  = new List <IContextInjector <TContext, HttpRequestMessage> >(contextInjectors);
     this.requestNotifier   = requestNotifier;
 }
Beispiel #3
0
 /// <summary>
 /// Sets <see cref="IEndpointValidator"/>
 /// </summary>
 /// <param name="endpointValidator"><see cref="IEndpointValidator"/> instance</param>
 /// <returns>Current <see cref="Configuration{TContext,TOutRequest,TOutResponse}"/> for chaining</returns>
 public Configuration <TContext, TOutRequest, TOutResponse> WithEndpointValidator(IEndpointValidator endpointValidator)
 {
     EndpointValidator = endpointValidator;
     return(this);
 }