Looking at the Autofac source code, you'll can see that the implementation of SingleInstance
is this:
public IRegistrationBuilder<TLimit, TActivatorData, TRegistrationStyle> SingleInstance()
{
RegistrationData.Sharing = InstanceSharing.Shared;
RegistrationData.Lifetime = new RootScopeLifetime();
return this;
}
So you'll have to check the ComponentRegistry
for registrations matching those qualities.
public T ResolveSingleton<T>()
{
IComponentRegistration reg;
if (_context.ComponentRegistry.TryGetRegistration(new TypedService(typeof (T)), out reg))
{
if (reg.Lifetime is RootScopeLifetime && reg.Sharing == InstanceSharing.Shared)
return (T) _context.ResolveComponent(reg, Enumerable.Empty<Parameter>());
}
throw new Exception();
}