-
Notifications
You must be signed in to change notification settings - Fork 9
/
AubioObject.cs
40 lines (33 loc) · 967 Bytes
/
AubioObject.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using Aubio.Interop;
using JetBrains.Annotations;
namespace Aubio
{
public abstract class AubioObject : Disposable
{
protected AubioObject(IntPtr handle, bool isDisposable = true)
: base(isDisposable)
{
Handle = handle;
}
private IntPtr Handle { get; }
public static implicit operator IntPtr([NotNull] AubioObject o)
{
if (o == null)
throw new ArgumentNullException(nameof(o));
return o.Handle;
}
protected static IntPtr Create(IntPtr handle)
{
if (handle == IntPtr.Zero)
throw new InvalidOperationException();
return handle;
}
[AssertionMethod]
protected static void ThrowIfNot(bool condition, string message = null)
{
if (!condition)
throw new InvalidOperationException(message);
}
}
}