Skip to content

Factory: Add 'CreateRunAndRelease' mechanism #88

@bartelink

Description

@bartelink

When building command processors which need to deterministically release dependent IDisposable resources, one often needs to perform a sequence as follows:

var handler = _kernel.Get( typeof(T) );
try
{
handler.Handle( request)
}
finally
{
_kernel.Release( handler );
}

It would be neat to have support in Ninject.Extensions.Factory to allow one to define an interface as follows and have it auto-implemented:

interface IHandlerFactory
{
void CreateRunAndRelease(Action action);
void CreateRunAndRelease(Type service, Action action);
}

Side note: This would probably build on a lower level Ninject.Extensions.NamedScope facility to create an IDisposable RAII ScopeBlock object (i.e., a proper reimplementation of Activation Blocks)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions