question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IOC Question - is possible to resolve Object with some additional parameters?

See original GitHub issue

Hello, I have class which implement ITransistentDependeci inteface. This class have one constructor:

        public class Test : ITransientDependency
        {
            public Test(string param,  IOPManager manager)
            {

            }
        }

IOPManager is a DomainService with is registered in IOC, param is some additional param Is possible to resolve Test object from IOC with properly injected IOPManager manager and manualy passed string param ?

Somethink like: var instance = IocManager.IocContainer.Resolve(testType, new { param = "test"});

Or exist some workaround when i need to have Constructor with custom parameters and use ABP Services / Managers in class ?

Thanks for help / tips !

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
hikalkancommented, Aug 30, 2016

This will work:

var instance = IocManager.IocContainer.Resolve<Test>(new { param = "test"});

Do not forget to release manually resolved instances.

1reaction
hikalkancommented, Aug 30, 2016

This works:

IocManager.Resolve(operationTypeToExecute , new { param = "test"});
Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - How to resolve instances with constructor parameters ...
I'm trying to build my own inversion of control container. Right now I store the objects with their types in a dictionary and...
Read more >
IoC, Unity and passing parameters (or a way to avoid doing ...
When this happens it seems I'm no longer following an IoC pattern. The kicker here is that I cannot have the SPWeb object...
Read more >
Understanding Dependency Injection in .NET Core
Resolution : this feature allows the IoC Container to resolve a dependency by creating an object and injecting it into the requesting class....
Read more >
5. The IoC container
It is a process whereby objects define their dependencies, that is, the other objects they work with, only through constructor arguments, arguments to...
Read more >
Blazor constructor injection. NET Core comes with thin but rich ...
NET Core comes with thin but rich and powerful built-in dependency injection mechanism we can use to inject instances to controllers and some...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found