dependency-injection

Angular2 Dependency Injection - make sense or it's just overengineering?

久未见 提交于 2019-12-24 06:31:02
问题 As documentation says Dependency Injection is a powerful pattern for managing code dependencies But does Angular's DI has any sense? Let's say we have an HeroComponent living in the HeroModule, and it uses HeroService. To use it in HeroComponent we have to: Import HeroService in HeroModule Inject HeroService in module providers Import HeroService in HeroComponent Add type or add injected service to component's parameters. Why don't just import HeroService into HeroComponent? We can export its

How to avoid Cyclic Dependencies when using Dependency Injection?

我们两清 提交于 2019-12-24 06:13:26
问题 I am relatively new to the concept dependency injection, so I am unsure about how it prevents cyclic dependencies. Let's say I have followed projects (the sample project structure might not be good but please bear with me) Project A: Domain Layer IRepository Project B: RepositoryImpl --> implement IRepository interface In this case Project B will need to reference Project A. But to set up Project A, let's say Unity Container, Project A will need to reference Project B in order to have

Upgraded to AngularDart 0.13.0 and getting errors about routing and di

最后都变了- 提交于 2019-12-24 05:04:20
问题 I upgraded to AngularDart 0.13.0 and I am receiving the errors below. What is the correct way to initialize the RoutingModule with the new di package 2.0.1? In main.dart I have: class RoutingModule extends Module { RoutingModule() { bind(RouteInitializerFn, toValue: myRouteInitializer); bind(NgRoutingUsePushState, toFactory: (_) => new NgRoutingUsePushState.value(false)); } } Let me know if you think any other Modules would be relevant. The rest are just simple bind(Component); statements. I

How to filter a collection of beans using a collection of regex in Spring?

北城以北 提交于 2019-12-24 04:44:06
问题 I want to autowire a collection of beans using Spring in annotaion mode. I've tried this something like the below ... @Configuration @ComponentScan(basePackages = "mypkg", includeFilters = @Filter(type = FilterType.REGEX, pattern = {"regex1", "regex2"}), excludeFilters = @Filter(type = FilterType.REGEX, pattern = "regex3")) public class BeanCollector { @Autowired private List<MyBean> myBeans; @Bean(name = "beans") public List<MyBean> getMyBeans() { return myBeans; } } This code works pretty

How do I get around type erasure on Akka receive method

只愿长相守 提交于 2019-12-24 04:42:07
问题 I'm using cake pattern in Scala 2.10 to inject required trait to my actor acording to some bussiness logic: I have several types f Events: sealed abstract class Event(val timeStamp:Long) case class StudentEvent(override val timeStamp:Long, studentId:Long) extends Event(timeStamp:Long) case class TeacherEvent(override val timeStamp:Long, teacherIdId:Long) extends Event(timeStamp:Long) Now I have traits which implement action for each type of event: Abstract: trait Action[T <: Event] { def act

.Net Dependency injection in unit of work pattern using repositories

一曲冷凌霜 提交于 2019-12-24 04:23:09
问题 I'm a relative noob to the concept of Dependency Injection, and have been trying to glean the best practices before starting a new project. Looking at the top answer to Dependency injection in unit of work pattern using repositories I understand the approach, but the example code seems to be missing something, and I'm stumped... The definition of the interface IRepository is shown as: public interface IRepository { void Submit(); } But when the interface is used as part of the definition of

symfony2 bundle extension is not loaded after renaming the bundle

爷,独闯天下 提交于 2019-12-24 03:53:25
问题 I have created a new bundle called PostalAddressBundle and i created a service inside it called ss_postal_address. Everything was working fine. But i decided to rename the bundle to AddressBundle instead of PostalAddressBundle, i renamed all namespace and all things related to it. Everything is working but not the service (ss_postal_address). I cleared the cache, but nothing happens.. this is the content of services.xml file: <parameters> <parameter key="ss_address.entity.address.class"

Dependency injection without Ninject

落爺英雄遲暮 提交于 2019-12-24 03:48:17
问题 I've been reading up on dependency injection and what I understand from it is that you basically just pass instances from the top on 1 location (for example App.xml.cs down to the View, it ViewModel and the classes the ViewModel uses and so on. Hopefully understanding this correctly I started trying to implement this. I have a class Localizer : ILocalizer with the following constructor: Localizer(ResourceDictionary appResDic, string projectName, string languagesDirectoryName, string

Dependency injection, delayed injection praxis

亡梦爱人 提交于 2019-12-24 03:32:08
问题 A simple(and lengthy) question, and not a simple answer. Working with some DI frameworks(Spring, Guice) I came to a conclusion that some of the praxis presented by others is not so simple to implement. I really seem stuck on this level. I will try to present this as simple as possible, even though some of the details will probably be lost. I hope the question will be clear. Say I have a StringValidator, a simple class with a responsibility to validate strings. package test; import java.util

Is there a way to implicitly convert an implicit parameter in Scala?

依然范特西╮ 提交于 2019-12-24 03:27:49
问题 Is there a way to make this work (Scala 2.8.1): class A class B def f(implicit b: B) {} implicit val a = new A implicit def aToB(a: A) = new B f(a) // works ok f // error: could not find implicit value for parameter b: B Actually my problem is with Lift's (2.2) dependency injection, i'm trying to convert Vendor[T] to T and implicitly require it in a class constructor without adding imports after each val: object DependencyFactory extends Factory { implicit def vendorToVal[T](vendor: Vendor[T]