protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { //LifeTimeScope //using (var scope = AutofacConfig.Container.BeginLifetimeScope()) //{ // var Service = scope.Resolve<ISupplierApiProfileService>(); // token = Service.GetToken(); //} var Service = AutofacConfig.Container.Resolve <ISupplierApiProfileService>(); var containerToken = Service.GetToken(); //Construct Injection Service var SupplierApiProfileServiceToken = _supplierApiProfileService.GetToken(); //ComponentContext var cService = _componentContext.Resolve <ISupplierApiProfileService>(); var ComponentContextToken = cService.GetToken(); //TestService var TestServiceToken = _testService.GetToken(); return(base.SendAsync(request, cancellationToken)); }
protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { var Service = AutofacConfig.Container.Resolve <ISupplierApiProfileService>(); var containerToken = Service.GetToken(); request.Properties.Add("containerToken", containerToken); //Construct Injection Service var SupplierApiProfileServiceToken = _supplierApiProfileService.GetToken(); request.Properties.Add("supplierApiProfileServiceToken", SupplierApiProfileServiceToken); //ComponentContext var cService = _componentContext.Resolve <ISupplierApiProfileService>(); var ComponentContextToken = cService.GetToken(); request.Properties.Add("componentContextToken", ComponentContextToken); //LifeTimeScope using (var scope = _lifetimeScope.BeginLifetimeScope()) { var NewScopeService = scope.Resolve <ISupplierApiProfileService>(); var NewLifetimeScopeToken = NewScopeService.GetToken(); request.Properties.Add("newLifetimeScopeToken", NewLifetimeScopeToken); } return(base.SendAsync(request, cancellationToken)); }
// GET api/<controller> public HttpResponseMessage Get() { //IComponentContext var Service = AutofacConfig.Container.Resolve <ISupplierApiProfileService>(); var containerToken = Service.GetToken(); //IComponentContext var cService = ComponentContext.Resolve <ISupplierApiProfileService>(); var componentContextToken = cService.GetToken(); //ISupplierApiProfileService var supplierApiProfileServiceToken = SupplierApiProfileService.GetToken(); return(Request.CreateResponse(HttpStatusCode.OK, new { Handler = new { RootContainerToken = Request.Properties["containerToken"], ComponentContextToken = Request.Properties["componentContextToken"], SupplierApiProfileServiceToken = Request.Properties["supplierApiProfileServiceToken"], NewLifetimeScope = Request.Properties["newLifetimeScopeToken"], }, Action = new { RootContainerToken = containerToken, ComponentContextToken = componentContextToken, SupplierApiProfileServiceToken = supplierApiProfileServiceToken } })); }
public Guid GetToken2() { var token1 = _componentContext.Resolve <ISupplierApiProfileService>().GetToken(); var token2 = _supplierApiProfileService.GetToken(); return(token1); }