mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-26 19:52:38 +00:00
fix nuget build (#3532)
This commit is contained in:
parent
b63349c8d6
commit
cf2fddf760
1 changed files with 40 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue