Skip to content

Registration of dependencies outside the registrar #18

@magarich228

Description

@magarich228

Hello, can I access IUnityContainer and register a dependency in it somewhere outside the RegisterInternal method?

public class MyRegistrar : RegistrarBase<IUnityContainer> 
{
    protected override void RegisterInternal(IUnityContainer container)
    {
        //
    }
}

I have such a situation on my project that tests are launched only from the code like this:

public XmlNode SomeMethod(LargeObject obj)
{
    var testPackage = new TestPackage(Assembly.GetExecutingAssembly().Location);
    var runner = TestEngineActivator.CreateInstance().GetRunner(testPackage);
    var result = runner.Run(null, TestFilter.Empty);
    return result;
}

In the code above there is some object of LargeObject type, which exemplar I cannot create manually in the RegisterInternal method. I need to somehow register it in IUnityContainer for injection into the test, preferably directly in the SomeMethod method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions