public static ServiceDescriptor DisposableSingleton <TService>([NotNull] IDisposable instance) { instance.AssertNotNull("instance != null"); (instance is TService).AssertTrue("Instance doesn't impelement service " + typeof(TService)); return(new ServiceDescriptor { ServiceType = typeof(TService), ImplementationInstance = instance, Lifetime = ServiceLifetime.Singleton, ShouldBeDisposed = true }); }