dependency-injection

Autofac dependency injection in implementation of OAuthAuthorizationServerProvider

≯℡__Kan透↙ 提交于 2019-12-18 03:10:14
问题 I am creating a Web Api application and I want to use bearer tokens for the user authentication. I implemented the token logic, following this post and everything seems to work fine. NOTE: I am not using the ASP.NET Identity Provider. Instead I have created a custom User entity and services for it. public class Startup { public void Configuration(IAppBuilder app) { ConfigureOAuth(app); var config = new HttpConfiguration(); var container = DependancyConfig.Register(); var dependencyResolver =

Injecting Properties using Spring & annotation @Value

两盒软妹~` 提交于 2019-12-18 02:41:40
问题 I am trying to load a properties file into a Spring bean and then inject that bean into a class. The only part I can't get to work seems to be using the @Resource reference.Can someone connect the last piece for me? I get a null value every time. Doesn't seem to want to inject the value. [EDIT] - I originally thought using the @Resource was the best way but the proposed solution I found easier. I saw this solution in another post: Reference Solution Link: Inject Property Value into Spring -

Dependency Injection (using SimpleInjector) and OAuthAuthorizationServerProvider

≯℡__Kan透↙ 提交于 2019-12-18 02:15:35
问题 New to Dependency Injection, so this is probably a simple matter, but i have tried and cant figure it out, i am using Simple Injector. I have a WebApi that uses SimpleInjector perfectly fine, now i would like to implement security using OAuth. To do this i started to follow this tutorial, which is very helpful, but doesnt use Dependancy Injection http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/ I have my global.asax file looking like this, to

Singletons in Dagger 1.x

戏子无情 提交于 2019-12-18 02:14:12
问题 When using Dagger, I found that I'm getting multiple instances of a singleton when I inject it wherever I need it. I've annotated the class and the provides method with @Singleton . Can anyone think of why this is happening? Edit: If it helps, I have followed the same structure for my app as the sample application in Dagger's GitHub (https://github.com/square/dagger/tree/master/examples/android-activity-graphs). I'm trying to get the Singleton in the base activity and a couple of third party

Resolving windows in Structure Map or how to manage multiple windows in WPF MVVM?

雨燕双飞 提交于 2019-12-17 23:39:39
问题 I have been reading Mark Seeman's book on dependency injection in .NET and I'm struggling to configure composition root in WPF application. My container will be registered in the application startup method: protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var container = new Container(); container.Configure(r => { r.For<IAccountServices>().Use<AccountServicesProxy>(); r.For<MainWindow>().Use<MainWindow>(); }); } This makes sense as the application startup represents

How do I use AndroidInjection class in custom views or other android classes?

与世无争的帅哥 提交于 2019-12-17 23:30:21
问题 My issue with the Android-specific pattern is, if you use their AndroidInjection class, there is no way to members inject other objects besides Activities / Fragments /custom views/adapters, except with the Application Component. This is because you cannot get a reference the the Subcomponent ( AndroidInjector ) used to inject Activities / Fragments . This makes injecting Dialogs (if you use DialogFragments ). The AndroidInjection class seems to support just the core Android types. 回答1: What

Play Framework: Dependency Inject Action Builder

白昼怎懂夜的黑 提交于 2019-12-17 23:27:34
问题 since Play Framework 2.4 there is the possibility to use dependency injection (with Guice). Before I used objects (for example AuthenticationService ) in my ActionBuilders: object AuthenticatedAction extends ActionBuilder[AuthenticatedRequest] { override def invokeBlock[A](request: Request[A], block: (AuthenticatedRequest[A]) => Future[Result]): Future[Result] = { ... AuthenticationService.authenticate (...) ... } } Now AuthenticationService is not an object anymore, but a class. How can I

Which DI container will satisfy this

旧时模样 提交于 2019-12-17 22:34:43
问题 This is what I want from DI container: public class Class { public Class(IDependency dependency, string data) { } } var obj = di.Resolve<Class>(() => new Class(null, "test")); Points of interest: Can resolve both dependency and data in constructor. Can use type-safe syntax to pass constructor parameters (exact syntax may vary). Yes I can do it myself by getting constructor arguments from (Expression.Body as NewExpression) - but I'll need a way to detect what arguments are registered in the

DIP vs. DI vs. IoC [closed]

强颜欢笑 提交于 2019-12-17 22:34:32
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . For about 2 months I've been reading everything I can find for these 3 topics and I'm not yet sure I got it. Dependency Inversion

How to inject Grails services into src/groovy classes

前提是你 提交于 2019-12-17 22:24:32
问题 Grails 2.4.x here. If I created a Grails service using grails create-service com.example.Widget , then how can I inject a reference of that service (a "bean") into a class under src/groovy ? This is actually not explained anywhere in the official Grails docs, and extensive searching turned back nadda. 回答1: 1) You can use Spring Beans to inject a service into a non-artefact groovy file, using resources.groovy : MyClass.groovy class MyClass { def widgetService ... } resources.groovy beans = {