public Task InitializeAsync(IApiActionInitializationContext initializationContext, CancellationToken cancellationToken) { if (initializationContext == null) { throw new ArgumentNullException(nameof(initializationContext)); } AbstractModel = initializationContext.AbstractModel ?? new AbstractModel(); _httpContext = initializationContext.HttpContext; _apiActionAuthorizationProvider = _httpContext.RequestServices.GetRequiredService <IAuthFilterProvider>(); _responseAbstractFactory = _httpContext.RequestServices.GetRequiredService <IApiActionResponseAbstractFactory>(); if (typeof(TRequest) == typeof(AbstractModel)) { Data = (TRequest)(object)AbstractModel; } else { Data = initializationContext.HttpContext.RequestServices.GetRequiredService <IRequestModelFactory>() .Create <TRequest>(initializationContext.AbstractModel); } // InitializeAsync Items return(AppendedInitializeAsync(initializationContext, cancellationToken)); }
protected override async Task AppendedInitializeAsync(IApiActionInitializationContext initializationContext, CancellationToken cancellationToken) { await base.AppendedInitializeAsync(initializationContext, cancellationToken); _webSocketTunnelHttpContext = initializationContext.HttpContext as IHasWebSocketTunnel; CommandId = initializationContext.HttpContext.TraceIdentifier; }
protected override Task AppendedInitializeAsync(IApiActionInitializationContext initializationContext, CancellationToken cancellationToken) { if (initializationContext == null) { throw new ArgumentNullException(nameof(initializationContext)); } var services = initializationContext.HttpContext.RequestServices; _defaultVersion = services.GetRequiredService <IRequestVersionProvider>() .Get(initializationContext.HttpContext, initializationContext.RouteValues); _hostName = initializationContext.HttpContext.Request.Host.Value; return(Task.FromResult(true)); }
protected virtual Task AppendedInitializeAsync(IApiActionInitializationContext initializationContext, CancellationToken cancellationToken) { return(Task.FromResult(true)); }