Search code examples
dryioc

What is the equivalent to multiple autofac .As<T>() in DryIoc?


In switching over from Autofac to DryIoc, I have a need to implement something akin to .As<IService1>().As<IService2>().

Given the following class

public interface IService1
{
    void DoStuff {}
}
public interface IService2
{
    void DoThings {}
}
public class SomeService : IService1, IService2
{
    public void DoStuff() {}
    public void DoThings() {}
}

My autofac registration would look like this

builder.RegisterType<SomeService>()
     .As<IService1>()
     .As<IService2>()
     .SingleInstance();

What would the equivalent of this look like in DryIoc?


Solution

  • RegisterMany or RegisterMapping is it. Here is the docs.