You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.1 KiB
57 lines
1.1 KiB
using UnityEngine;
|
|
|
|
using System;
|
|
|
|
namespace OpenCVForUnity
|
|
{
|
|
abstract public class DisposableObject : IDisposable
|
|
{
|
|
|
|
public bool IsDisposed { get; protected set; }
|
|
|
|
public bool IsEnabledDispose { get; set; }
|
|
|
|
protected DisposableObject()
|
|
: this(true)
|
|
{
|
|
}
|
|
|
|
protected DisposableObject(bool isEnabledDispose)
|
|
{
|
|
IsEnabledDispose = isEnabledDispose;
|
|
IsDisposed = false;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Dispose(true);
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
{
|
|
if (!IsDisposed)
|
|
{
|
|
|
|
if (disposing)
|
|
{
|
|
}
|
|
|
|
IsDisposed = true;
|
|
}
|
|
}
|
|
|
|
~DisposableObject()
|
|
{
|
|
Dispose(false);
|
|
}
|
|
|
|
public void ThrowIfDisposed()
|
|
{
|
|
if (IsDisposed)
|
|
throw new ObjectDisposedException(GetType().FullName);
|
|
}
|
|
|
|
}
|
|
}
|