Skip to content

Instantly share code, notes, and snippets.

@stevetalkscode
Last active November 14, 2020 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevetalkscode/929a5278b6613e3c11d291c7ec0c5e89 to your computer and use it in GitHub Desktop.
Save stevetalkscode/929a5278b6613e3c11d291c7ec0c5e89 to your computer and use it in GitHub Desktop.
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