VoimiX
VoimiX

Reputation: 1200

ObjectFactory.GetInstance analog in LightInject IoC container

Is there any analog of "ObjectFactory.GetInstance" in LightInject IoC container?

For example, I need to resolve interface in my custom behaivour attribute which is inherited from IServiceBehavior, but by default interface I need is not resolved.

public class MyInspectorAttribute : Attribute, IOperationBehavior, IParameterInspector, IServiceBehavior
{
    public IExternalService ExternalServiceInstance { get; set; } //always null

    public void AddBindingParameters(OperationDescription operationDescription, BindingParameterCollection bindingParameters) { }

    public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation) { }

    public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
    {
       dispatchOperation.ParameterInspectors.Add(this); 
    }

    public void Validate(OperationDescription operationDescription) { }

    public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)
    {
        Console.WriteLine("Operation {0} returned: result = {1}", operationName, returnValue);
    }
}

public class CompositionRoot : ICompositionRoot
{
    public void Compose(IServiceRegistry serviceRegistry)
    {
        serviceRegistry.Register<IService1, Service1>();
        serviceRegistry.Register<IExternalService,ExternalService>();
    }
}

Upvotes: 0

Views: 232

Answers (1)

seesharper
seesharper

Reputation: 3379

I am the author of LightInject and I am afraid that you have provided too little information about what you are trying to do. If this is related to WCF, create an issue in the LightInject.Wcf repo (https://github.com/seesharper/LightInject.Wcf) and provide a simple "working" example of what you are trying to do

Upvotes: 0

Related Questions