Creating a Singleton with Multiple Service Registrations Using DryIoc
<h1>The Problem</h1>

<p>I'm trying to register a singleton using DryIoc, but container is returning multiple instances of my singleton class. The singleton class is registered as the implementation type for multiple different service interfaces. When any of the aforementioned service interfaces is requested from DryIoc, I expect to get the same instance of my singleton class back, but that's not happening and I don't know why.</p>

<h1>An Example</h1>

<p>Here's a basic example of what I'm trying to do. In this example, I have a class, <code>Foo</code> that I would like to use as the singleton implementation for interfaces <code>IFoo</code> and <code>IBar</code>. In other words, when either <code>IFoo</code> or <code>IBar</code> are resolved from the container, I'd like for the same instance of <code>Foo</code> to be returned.</p>

<h3>The Service Interfaces</h3>

<pre class="lang-cs prettyprint-override"><code>interface IFoo
{   
}
interface IBar
{   
}
</code></pre>

<h3>The Singleton (Implementation) Class</h3>

<pre class="lang-cs prettyprint-override"><code>class Foo : IFoo, IBar
{
}
</code></pre>

<h3>The Test</h3>

<pre class="lang-cs prettyprint-override"><code>Container container = new Container();
container.Register&lt;IFoo, Foo&gt;(Reuse.Singleton);
container.Register&lt;IBar, Foo&gt;(Reuse.Singleton);

object foo = container.Resolve&lt;IFoo&gt;();
object bar = container.Resolve&lt;IBar&gt;();
Assert.AreSame(foo, bar); // Why does this fail?
</code></pre>

<h1>Considered Solutions</h1>

<p>I've considered using DryIoc's <code>RegisterInstance</code> method but that would require the class to be manually created and I'm trying to avoid that because, unlike the simplified example above, the real-world class has dependencies of its own.</p>