dependency-injection

Autofac registration and disposal issues

♀尐吖头ヾ 提交于 2019-12-13 01:14:57
问题 I'm using entity framework 6 and Autofac in my web application. I inject unit of work with DbContext inside, both externally owned so I can dispose them myself. DbContext registered PerLifetimeScope, Unit of work is a factory, therefore registered as per dependency. When Executing the first http Get action everthing works fine and I see the unit of work with the context are disposed after the response is coming from the db which is great. My issue is that whenever I execute a second request,

How does Python implement Dependency Injection since it has no Interfaces?

笑着哭i 提交于 2019-12-13 00:59:02
问题 As I understand it, a client (the core program) needs to have a common type to allow a plugin, another object, etc. to be passed successfully to a client. I saw this answer on SO here, What is dependency injection? In Java, passing by constructor using an prescript Interface makes sense. From the SO question mentioned, public SomeClass (MyClass myObject) { this.myObject = myObject; } As I understand it, MyClass is a type defined by an Interface. myObject implements that, is required to in

Using Unity Framework, inject into System.Windows.Forms.Form page

巧了我就是萌 提交于 2019-12-13 00:40:35
问题 I have a form: public partial class mdiAuthenticationForm : Form { public Services.Authentication.IAuthentication Authenticator { get; set; public Services.Authentication.IAuthorization Authorizor { get; set; } and I want to inject concrete classes for the two attributes above. I have a type for each of them, and am using the app.config for the configuration information. But, I don't want to create an interface for each page, just to inject, so, how can I inject into each page? Basically,

Unable to resolve AutoFac Keyed service with KeyFilterAttribute not working

自闭症网瘾萝莉.ら 提交于 2019-12-13 00:23:58
问题 I have a generic UnitOfWork pattern implementation and these UnitOfWork objects are dependencies to my service classes. Below snippets should help the reader understand my code setup: IUnitOfWork interface public interface IUnitOfWork<out TContext> where TContext : IDbContext UnitOfWork class public sealed class UnitOfWork<TContext> : IDisposable, IUnitOfWork<IDbContext> where TContext : IDbContext { private static readonly ILog Log = LogManager.GetLogger(typeof(UnitOfWork<TContext>));

Jersey constructor with parameters

妖精的绣舞 提交于 2019-12-12 23:13:07
问题 I want to use a DAO in my RESTful service developed with Jersey, so the DAO implementation should be injected via the constructor of the service: @Path("eventscheduler) public class EventSchedulerService { private IEventSchedulerDao dao; public EventSchedulerService(IEventSchedulerDao dao) { this.dao = dao; } } However, I know Jersey expects a default constructor to setup everything correctly. I have been trying to figure out how to do this for a while but surprisingly this seems to be an

How to configure nested dependency for spring tests?

冷暖自知 提交于 2019-12-12 22:26:18
问题 The error I'm getting has to do with parsing the properties before injecting in to the Test class. I end up with ${property.name} when the property is injected. However the configuration of the Test class seems very wrong considering there are nested dependencies. Specific error: Caused by: java.net.URISyntaxException: Illegal character in authority at index 8: https://${sqs.endpoint} I've got a config class to load a specific prop for a @Bean : @Configuration public class AWSConfig { private

Bower dependency found in unit test Angular 1.2, but cannot be found Angular 1.5

柔情痞子 提交于 2019-12-12 22:24:53
问题 I have an issue while upgrading Angular from 1.2.28 to 1.5.5. The code itself runs like a charm, but my tests began to fail with the following message. Unknown provider: storeProvider <- store <- translateStorage I use "a0-angular-storage": "0.0.15" as a storeProvider which provides 'store' via angular.module('angular-storage.store', ['angular-storage.internalStore']) .provider('store', function() { ...} [EDIT:] removed all the code and referred to a github repo where i could reproduce the

Simple Injector: RegisterInitializer does not always fire

佐手、 提交于 2019-12-12 22:22:47
问题 I use the RegisterInitializer method to inject properties in base types as follows: container.RegisterInitializer<BaseHandler>(handler => { handler.Context = container.GetInstance<HandlerContext>(); }); This works great, but the RegisterInitializer doesn't get fired on all registered types that inherit from BaseHandler. It doesn't seem to run when I call new myself: var url = ConfigurationManager.AppSettings["NotificationServiceUrl"]; container.Register<Handler<NotifyCustomerMessage>>(() =>

Dependency Injection and Code Obfuscation

冷暖自知 提交于 2019-12-12 20:53:35
问题 In Mark Seemann's book Dependency Injection in .NET, he states that more people are using DI containers with AUTO-REGISTRATION support where the container can resolve instances of the required concrete types without almost any sort of prior configuration, and this goes well with the convention over configuration architecture approach. but this made me wonder if i used an obfuscator wouldn't this break the code base and cause the container to fail because the conventions have changed ? 回答1:

Autofac resolve in deep layer

流过昼夜 提交于 2019-12-12 20:34:23
问题 I'm having hard time integrating autofac in my applcation.. My application integrates with other applications, when a connection to another application is made its being maintained by a fitting "Protocol" object // This class is inherited by a few other classes public abstract class Protocol I have a layer that is run by it's own thread and handles connection requests. For each kind of request a different kind of protocol is created (a different protocol object) // For example lets say every