Dependency injection in Listener class #444
Answered
by
hazzik
satishviswanathan
asked this question in
General
-
I'm using Fluent NHibernate and trying to set listeners which expects a dependency. I'm trying to resolve the dependency which is registered in Autofac container. An idea how I can change the following code to support dependency injection in Listener class. Registration var configuration = Fluently.Configure()
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<TasksMap>())
.ExposeConfiguration(x =>
{
x.SetListeners(ListenerType.PostCommitUpdate, new[] { typeof(PublishExternalEvents).AssemblyQualifiedName });
})
.Database(OracleManagedDataClientConfiguration.Oracle10.ConnectionString(connectionString)); Lister Class public class PublishExternalEvents : IPostInsertEventListener, IPostDeleteEventListener, IPostUpdateEventListener,
IPostCollectionUpdateEventListener
{
private readonly IDispatch _dispatch;
public PublishExternalEvents(IDispatch dispatch)
{
_dispatch = dispatch;
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
hazzik
Sep 19, 2020
Replies: 1 comment
-
You would need to implement a custom |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
hazzik
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You would need to implement a custom
NHibernate.Bytecode.IObjectsFactory
which supports dependency injections.