-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStaticMemberFinalizer.cs
More file actions
45 lines (41 loc) · 1.73 KB
/
StaticMemberFinalizer.cs
File metadata and controls
45 lines (41 loc) · 1.73 KB
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
// =================================================================================================================================
// Copyright (c) RapidField LLC. Licensed under the MIT License. See LICENSE.txt in the project root for license information.
// =================================================================================================================================
using RapidField.SolidInstruments.Core.ArgumentValidation;
using System;
using System.Diagnostics;
namespace RapidField.SolidInstruments.Core
{
/// <summary>
/// Encapsulates finalization for static members of a class or structure.
/// </summary>
public class StaticMemberFinalizer
{
/// <summary>
/// Initializes a new instance of the <see cref="StaticMemberFinalizer" /> class.
/// </summary>
/// <param name="finalizeAction">
/// An action that is invoked when the object is finalized.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="finalizeAction" /> is <see langword="null" />.
/// </exception>
public StaticMemberFinalizer(Action finalizeAction)
{
FinalizeAction = finalizeAction.RejectIf().IsNull(nameof(finalizeAction));
}
/// <summary>
/// Finalizes the current instance of the <see cref="StaticMemberFinalizer" /> class.
/// </summary>
[DebuggerHidden]
~StaticMemberFinalizer()
{
FinalizeAction();
}
/// <summary>
/// Represents an action that is invoked when the object is finalized.
/// </summary>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private readonly Action FinalizeAction;
}
}