Skip to content

Instantly share code, notes, and snippets.

@stevetalkscode
Last active Nov 14, 2020
Embed
What would you like to do?
Example of using restricted interface to hide Dispose method
public class StartUp
{
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IDoSomething, SomeDisposable>();
}
}
public interface IDoSomething
{
void DoSomething();
}
public class SomeDisposable : IDoSomething, IDisposable
{
public void DoSomething()
{
}
void IDisposable.Dispose()
{
// dispose unmanaged resources here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment