dependency-injection

An example of a bootstrapper file?

为君一笑 提交于 2020-01-04 05:17:13
问题 Does anyone have a good example of a bootstrapper class I can see for reference.. I can't seem to find one anywhere, searched google but no luck. Searched the helpfile and no luck.. 回答1: If you are searching for a class that that configures the container at the beggining of an application, you can download the latest Prism drop and look for the UnityBootstrapper class. Take into account that this is only registering the necessary services for a Prism application to run, so your bootstrapper

C# and IoC transitive dependencies removed

人盡茶涼 提交于 2020-01-04 04:34:19
问题 I have a solution in which I use IoC (windsor). The projects in the solution are as follows: Interfaces - Holds all the interface contracts I'll use. IoC.Installers - Holds all the installers for my dependencies (has reference to impl. and interfaces) IoC - Holds a singleton class that holds the IoC container. The class performs the initialization process of the container. Console - The project that uses the IoC to resolve dependencies (has reference to interfaces an IoC) The problem: Because

How to access Asp.net Core DI Container from Class

孤者浪人 提交于 2020-01-04 04:09:08
问题 I am learning IoC & DI with Asp.net core. I have setup my dbcontext and other classes to be injected into my controllers. Currently my startup.cs looks like this: // Add framework services. services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddIdentity<ApplicationUser, IdentityRole>(options => { options.Password.RequireDigit = false; options.Password.RequiredLength = 5; options.Password

Dependency injection in abstract class with TypeScript and Angular 5

半腔热情 提交于 2020-01-04 04:01:11
问题 I've got the BaseComponent which got some dependencies injected. The first dependency EntityService is correct and necessary. But AnyOtherService is only used inside the abstract BaseComponent . Instead of injecting it inside the ChildComponent , where it is not used, I'd like to inject it only inside BaseComonent . Why do I have to push it through the ChildComponent towards the BaseComponent ? The best solution would be to encapsulate it inside the BaseComponent . base.component.ts export

Dependency injection in abstract class with TypeScript and Angular 5

99封情书 提交于 2020-01-04 04:01:04
问题 I've got the BaseComponent which got some dependencies injected. The first dependency EntityService is correct and necessary. But AnyOtherService is only used inside the abstract BaseComponent . Instead of injecting it inside the ChildComponent , where it is not used, I'd like to inject it only inside BaseComonent . Why do I have to push it through the ChildComponent towards the BaseComponent ? The best solution would be to encapsulate it inside the BaseComponent . base.component.ts export

Unable to resolve any beans for Type: xxx; Qualifiers: [@javax.enterprise.inject.Any()]

半城伤御伤魂 提交于 2020-01-04 02:57:11
问题 I have a LoginProvider interface: public interface LoginProvider { boolean login(String username, String password); } And 2 different implementations: public class LoginProvider1Impl implements LoginProvider { @Override public boolean login(String username, String password) { ... } } public class LoginProvider2Impl implements LoginProvider { @Override public boolean login(String username, String password) { ... } } Then a producer annotation: @Qualifier @Retention(RetentionPolicy.RUNTIME)

Constructor injection with Quartz.NET 3.0.3 and Simple Injector How To

假如想象 提交于 2020-01-04 02:11:07
问题 I am trying to use Quartz.Net v3.0.3 and Simple Injector in a windows service. I have a job class below which i would like to inject some dependencies such as my logger into. public class JobWorker : IJob { private ILogger _logger; public JobWorker(ILogger logger) { _logger = logger; } public Task Execute(IJobExecutionContext context) { return Task.Run(() =>_logger.Log("Do Work")); } } I tried registering Container.Register<IJob, JobWorker>(); on my DI layer but this doesn't help. If i remove

How do I perform Constructor-based dependency injection with Spring using annotations?

血红的双手。 提交于 2020-01-04 01:53:08
问题 OK, so if I need to put some primitive values in the constructor, how do I do that? @Autowired public CustomBean(String name, @Qualifier("SuperBean") SuperBean superBean) { super(); this.superBean = superBean; this.name = name; } For instance here I am defining that the superBean has the Qualifier "SuperBean", but I'd also like to know how is it possible to use annotations to set the name value here? I know it's possible with xml configuration, but I want to know how to do this with

asp.net MVC - How can I share the same instance of a SqlConnection through different repository classes

喜欢而已 提交于 2020-01-04 01:27:31
问题 I'm creating a new project using MVC5 and plain ADO.NET (just as a learning exercise) and I need to create a repository that registers a model with several related objects that also need to be created at the same time and those objects in turn may need to insert other objects. The easiest solution I can think of is to have a massive method(in the repository) that receives an instance of the parent object(which contains all the related objects that needs to insert) and also have a single

asp.net MVC - How can I share the same instance of a SqlConnection through different repository classes

孤街浪徒 提交于 2020-01-04 01:27:08
问题 I'm creating a new project using MVC5 and plain ADO.NET (just as a learning exercise) and I need to create a repository that registers a model with several related objects that also need to be created at the same time and those objects in turn may need to insert other objects. The easiest solution I can think of is to have a massive method(in the repository) that receives an instance of the parent object(which contains all the related objects that needs to insert) and also have a single