dependency-injection

How to instantiate Angular components with parameters?

孤人 提交于 2021-01-03 07:01:17
问题 I've been trying to instantiate components by passing parameters like nameFilter = new FilterComponent("Name"); but I'm getting this error: NullInjectorError: No provider for String! I believe dependency injection causes this as I don't get any errors if I don't inject anything to component. So what exactly causes this and how can I fix it? Here's the component code import { Component, OnInit, Inject } from '@angular/core'; @Component({ selector: 'app-filter', templateUrl: './filter.component

How to instantiate Angular components with parameters?

纵然是瞬间 提交于 2021-01-03 06:59:52
问题 I've been trying to instantiate components by passing parameters like nameFilter = new FilterComponent("Name"); but I'm getting this error: NullInjectorError: No provider for String! I believe dependency injection causes this as I don't get any errors if I don't inject anything to component. So what exactly causes this and how can I fix it? Here's the component code import { Component, OnInit, Inject } from '@angular/core'; @Component({ selector: 'app-filter', templateUrl: './filter.component

.NET 4.7.2 Dependency Injection in ASP.NET WebForms Website - Constructor injection not working

空扰寡人 提交于 2021-01-02 05:46:17
问题 We are currently working with an older project (ASP.NET Web Forms Website) and trying to see if we can set up dependency injection for it. Need to emphasize: this is NOT a Web Application project... it's the older type, the Website. It is currently targeting .NET 4.7.2: <httpRuntime targetFramework="4.7.2" /> So far, we've included the NuGet package: <package id="Microsoft.AspNet.WebFormsDependencyInjection.Unity" version="1.0.0" targetFramework="net472" /> Defined some dummy interface and

(Interface) A circular dependency was detected for the service of type

馋奶兔 提交于 2021-01-01 04:22:34
问题 I have 2 interfaces: public interface IPedidoService { UsuarioDrogueria CUsuarioDrogueria(string userId, int idDrogueria); List<PedidoComboProducto> CPedidosCombosProductos(int idcombo, int idPedido); } public interface IEmailService { void SendEmailAttachment(string email, string subject, string archive); void SendNotificationEmail(List<Pedido> pedidos, string email, Drogueria drog); void SendNotificationEmailADM(Pedido pedido) ; } I want to use the functions from IEmailService inside

(Interface) A circular dependency was detected for the service of type

浪尽此生 提交于 2021-01-01 04:22:31
问题 I have 2 interfaces: public interface IPedidoService { UsuarioDrogueria CUsuarioDrogueria(string userId, int idDrogueria); List<PedidoComboProducto> CPedidosCombosProductos(int idcombo, int idPedido); } public interface IEmailService { void SendEmailAttachment(string email, string subject, string archive); void SendNotificationEmail(List<Pedido> pedidos, string email, Drogueria drog); void SendNotificationEmailADM(Pedido pedido) ; } I want to use the functions from IEmailService inside

How to use Dependency Injection in .Net core Console Application

て烟熏妆下的殇ゞ 提交于 2020-12-29 03:47:15
问题 I have to add data to my database using a Console Application. In the Main() method I added: var services = new ServiceCollection(); var serviceProvider = services.BuildServiceProvider(); var connection = @"Server = (localdb)\mssqllocaldb; Database = CryptoCurrency; Trusted_Connection = True; ConnectRetryCount = 0"; services.AddDbContext<CurrencyDbContext>(options => options.UseSqlServer(connection)); In another class I add functionality to work with database, and made it like a Web Api

How to use Dependency Injection in .Net core Console Application

泪湿孤枕 提交于 2020-12-29 03:44:34
问题 I have to add data to my database using a Console Application. In the Main() method I added: var services = new ServiceCollection(); var serviceProvider = services.BuildServiceProvider(); var connection = @"Server = (localdb)\mssqllocaldb; Database = CryptoCurrency; Trusted_Connection = True; ConnectRetryCount = 0"; services.AddDbContext<CurrencyDbContext>(options => options.UseSqlServer(connection)); In another class I add functionality to work with database, and made it like a Web Api

How and when to dispose my objects?

霸气de小男生 提交于 2020-12-27 03:18:50
问题 In my backend service I use unit of work pattern. I was wondering if I'm missing something related to disposing objects. First, this is the code I have so far, which works. The service just calls a request handler: [GlobalExceptionHandlerBehaviour(typeof(GlobalExceptionHandler))] public class CustomerService : ICustomerService { public void AddCustomer(AddCustomerRequest request) { ObjectFactory.GetInstance<AddCustomerRequestHandler>().Execute(request); } } The request handler looks like:

How and when to dispose my objects?

大城市里の小女人 提交于 2020-12-27 03:17:37
问题 In my backend service I use unit of work pattern. I was wondering if I'm missing something related to disposing objects. First, this is the code I have so far, which works. The service just calls a request handler: [GlobalExceptionHandlerBehaviour(typeof(GlobalExceptionHandler))] public class CustomerService : ICustomerService { public void AddCustomer(AddCustomerRequest request) { ObjectFactory.GetInstance<AddCustomerRequestHandler>().Execute(request); } } The request handler looks like:

How and when to dispose my objects?

只谈情不闲聊 提交于 2020-12-27 03:15:15
问题 In my backend service I use unit of work pattern. I was wondering if I'm missing something related to disposing objects. First, this is the code I have so far, which works. The service just calls a request handler: [GlobalExceptionHandlerBehaviour(typeof(GlobalExceptionHandler))] public class CustomerService : ICustomerService { public void AddCustomer(AddCustomerRequest request) { ObjectFactory.GetInstance<AddCustomerRequestHandler>().Execute(request); } } The request handler looks like: