forked from marcpabst/PdfiumLight
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPdfLibrary.cs
48 lines (39 loc) · 932 Bytes
/
PdfLibrary.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
41
42
43
44
45
46
47
48
using System;
namespace PdfiumLight
{
internal class PdfLibrary : IDisposable
{
private static readonly object _syncRoot = new object();
private static PdfLibrary _library;
public static void EnsureLoaded()
{
lock (_syncRoot)
{
if (_library is null)
_library = new PdfLibrary();
}
}
private bool _disposed;
private PdfLibrary()
{
NativeMethods.FPDF_AddRef();
}
~PdfLibrary()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!_disposed)
{
NativeMethods.FPDF_Release();
_disposed = true;
}
}
}
}