ReuseScope.Request outside of a HTTP request

Can I confirm what happens when you use a dependency that is registered for ReuseScope.Request, but it is resolved in the AppHost.Configure() method during configuration?

For example:

public override void Configure(Container container)
{
    base.Configure(container);

    container.Register<MyClass, IMyClass>.ReuseWithin(ReuseScope.Request);

    ...

    var a = container.Resolve<IMyClass>();
    a.DoSomething();
}

Is it right to assume that if it is resolved outside an IRequest then instancing falls back to ReuseScope.None? i.e. transient i.e. a new instance every call to Resolve<T>()?

I believe it’s transient since there’s not Request Context to persist against but it’s not defined behavior you should rely on and there’s no lifecycle hook to automatically dispose it if it’s an IDisposable. Just create the instance in C#, i.e. outside the IOC.

OK, thanks,

I am looking at creating a child container, and re-registering the needed components in that child container as (ReuseScope.Container), and leave the components alone in the main container (registered as ReuseScope.Request).
Then, I can resolve in the child container, and do my work during Configure()