unitycontainer / configuration

Unity.Configuration package
Apache License 2.0
13 stars 13 forks source link

One type registered as more different services like autofac #9

Closed jiangxiangji closed 5 years ago

jiangxiangji commented 6 years ago

One type registered as more different services is required. xml configuration of autofac like this: `

Autofac.Example.Calculator.Addition.Add, Autofac.Example.Calculator.Addition
    <services name="Operation" type="Autofac.Example.Calculator.Api.IOperation" />
    <services name="AddOperation" type="Autofac.Example.Calculator.Api.IAddOperation" />
</components>`
ENikS commented 6 years ago

It is done by registering a type with proper lifetime and then registering different interfaces for the type:

RegisterType<MyType>(new ..Lifetime);
RegisterType<IMyType1, MyType>();
RegisterType<IMyType2, MyType>();
RegisterType<IMyType3, MyType>();
ENikS commented 5 years ago

Added new method to do just that.