dependency-injection

How to debug Unity resolution?

[亡魂溺海] 提交于 2020-03-18 10:36:32
问题 In a WPF project(with prism) we are using Unity as DI framework. Recently, after we merged two big branches, we were not able to start our application, we were having StackOverflowException . Due to the nature of the exception, we were not able to get his call stack or current values, we were only seing that the issue was comming from Unity due to the namespace. We spent more than 5 hours to find were the issue was occuring: Simplified: We were having 3-4 services(A, B, C and D), each one

Spring inject without autowire annotation

烈酒焚心 提交于 2020-03-17 10:44:27
问题 I find some answer: https://stackoverflow.com/a/21218921/2754014 about Dependency Injection. There isn't any annotation like @Autowired , @Inject or @Resource . let's assume that there isn't any XML configuration for this example TwoInjectionStyles bean (except simple <context:component-scan base-package="com.example" /> . Is it correct to inject without specify annotation? 回答1: From Spring 4.3 annotations are not required for constructor injection. public class MovieRecommender { private

How to inject dependencies in WCF when the Composition Root is on the client

孤街浪徒 提交于 2020-03-16 06:33:10
问题 Before I start I must say that I maybe biting more than I can chew but I am in a desperate learning rampage and I need a lot of help. I am coding an exercise taking the samples from two books: 1. Dependency Injection in .Net by Mark Seemann 2. Professional ASP .Net Design Patterns by Brian Egan and Steve Valenzuela The exercise is implementing the Request/Response messaging pattern using WCF as the service layer AND using Dependency Injection from a Composition Root in the client application.

How to inject dependencies in WCF when the Composition Root is on the client

喜夏-厌秋 提交于 2020-03-16 06:32:08
问题 Before I start I must say that I maybe biting more than I can chew but I am in a desperate learning rampage and I need a lot of help. I am coding an exercise taking the samples from two books: 1. Dependency Injection in .Net by Mark Seemann 2. Professional ASP .Net Design Patterns by Brian Egan and Steve Valenzuela The exercise is implementing the Request/Response messaging pattern using WCF as the service layer AND using Dependency Injection from a Composition Root in the client application.

How to inject primitive variables in Kotlin?

吃可爱长大的小学妹 提交于 2020-03-13 05:57:47
问题 I am using Dagger2 for DI in my Android app, and using this code for injecting classes into my Activity is fine: @field:[Inject ApplicationContext] lateinit var context: Context but, lateinit modifier is not allowed on primitive type properties in Kotlin (for instance Boolean ), how can I do something like this? @field:[Inject Named("isDemo")] lateinit var isDemo: Boolean when I remove lateinit from this code I get this error Dagger does not support injection into private fields 回答1: First,

How to inject primitive variables in Kotlin?

旧城冷巷雨未停 提交于 2020-03-13 05:56:58
问题 I am using Dagger2 for DI in my Android app, and using this code for injecting classes into my Activity is fine: @field:[Inject ApplicationContext] lateinit var context: Context but, lateinit modifier is not allowed on primitive type properties in Kotlin (for instance Boolean ), how can I do something like this? @field:[Inject Named("isDemo")] lateinit var isDemo: Boolean when I remove lateinit from this code I get this error Dagger does not support injection into private fields 回答1: First,

How to inject primitive variables in Kotlin?

*爱你&永不变心* 提交于 2020-03-13 05:56:03
问题 I am using Dagger2 for DI in my Android app, and using this code for injecting classes into my Activity is fine: @field:[Inject ApplicationContext] lateinit var context: Context but, lateinit modifier is not allowed on primitive type properties in Kotlin (for instance Boolean ), how can I do something like this? @field:[Inject Named("isDemo")] lateinit var isDemo: Boolean when I remove lateinit from this code I get this error Dagger does not support injection into private fields 回答1: First,

Inject Service into custom Jackson Serializer

我只是一个虾纸丫 提交于 2020-03-06 03:06:27
问题 Hi I have problem in the following scenario: I'm using Spring 4.xx with Jackson 2.xx and I'm ompelenting a RESTful Web Application. I'm now faced with te problem that I need some custom serialzation for one of my models, so i used a custom serilaizer, but i also need to fetch some data out of the database while serializing. So I tried to inject my Serivce into the Serializer but it always stays null. As far as I have read this happens if you instanciate your object directly, which I guess is

.NET Core DI resolving keyed services using custom delegate returns null

半城伤御伤魂 提交于 2020-03-04 04:55:42
问题 I am struggling with a weird case. I have a .NET Core console application that is setup like this: private static async Task Main(string[] args) { var runAsService = !(Debugger.IsAttached || args.Contains("console")); var builder = new HostBuilder() .ConfigureServices((hostContext, services) => { services.AddLogging(loggingBuilder => { loggingBuilder.AddConsole(); }); services.AddGatewayServers(); services.AddHostedService<GatewayService>(); }); if (runAsService) await builder.RunServiceAsync

How does the ViewModel constructor get the required interfaces?

谁都会走 提交于 2020-03-02 17:12:08
问题 My question based on InventorySampleApp by Microsoft. The ServiceLocator contains method Configure() that register Services and ViewModels. With method GetService<T>() we can get it. For example, ProductView.cs : ViewModel = ServiceLocator.Current.GetService<ProductDetailsViewModel>(); Each *ViewModel contains constructor with interface, for example: public ProductDetailsViewModel(IProductService productService, IFilePickerService filePickerService, ICommonServices commonServices) I can't