M
M
Michael2016-02-19 21:23:36
.NET
Michael, 2016-02-19 21:23:36

How to Resolve for Action parameters in autofac?

Here is an example:

public class TaskWrapper : ITaskWrapper
{
    public TaskWrapper(Action action)
    {
        this.action = action;
    }
}

public void Connect()
{
    Program.Container.Resolve<TaskWrapper>(new NamedParameter("action", ToConnect)); // не работает!
    Program.Container.Resolve<TaskWrapper>(new TypedParameter(typeof(Action), ToConnect)); // не работает!
}

private void ToConnect()
{
    // some code...
}

As you can see, NamedParameter and TypedParameter do not allow this, or do they allow it? But how?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question