fix nuget build (#3532)

This commit is contained in:
Yulong Wang 2020-04-15 10:30:11 -07:00 committed by GitHub
parent b63349c8d6
commit cf2fddf760
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1836,4 +1836,44 @@ namespace Microsoft.ML.OnnxRuntime.Tests
}
}
// A Disposable list is a list of IDisposable objects. All elements will be disposed when the container is disposed.
internal class DisposableList<T> : List<T>, IDisposableReadOnlyCollection<T>
where T : IDisposable
{
public DisposableList() { }
public DisposableList(int count) : base(count) { }
#region IDisposable Support
private bool disposedValue = false; // To detect redundant calls
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
for (int i = 0; i < this.Count; i++)
{
this[i]?.Dispose();
}
this.Clear();
}
disposedValue = true;
}
}
~DisposableList()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
}
}