TinyIoC Resolve Plugin Contract

How would one go about resolving Plugin contacts using TinyIoC?

Host.exe /w reference to Core.Contract.dll

var container = new TinyIoCContainer();
container.AutoRegister(new[] { Assembly.LoadFrom("Core.Contracts.dll") }, 
                DuplicateImplementationActions.RegisterMultiple);
container.AutoRegister(new[] { Assembly.LoadFrom("EchoCodeAnalysis.dll") }, 
                DuplicateImplementationActions.RegisterMultiple);
var mi = container.Resolve<IService>();

the contract IService in in Core.Contracts.dll and is reference in the host assembly, this is to give the drag and drop plugin a chance to work without recompilation.
In EchoCodeAnalysis.dll we have the actual plugin implementation which is not referenced in the host assembly but share the host of Core.Contracts.dll using the IService.

Core.Contract.dll:

public interface IService
{
    string ID { get; set; }
}

EchoCodeAnalysis.dll:

public class Service : IService
{
    string IService.ID
    {
        get
        {
            throw new NotImplementedException();
        }
        set
        {
            throw new NotImplementedException();
        }
    }
}


Source: dll

Leave a Reply