diff options
Diffstat (limited to 'src/WixToolset.Data/IntermediateFieldContext.cs')
-rw-r--r-- | src/WixToolset.Data/IntermediateFieldContext.cs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/WixToolset.Data/IntermediateFieldContext.cs b/src/WixToolset.Data/IntermediateFieldContext.cs new file mode 100644 index 00000000..a29a63c4 --- /dev/null +++ b/src/WixToolset.Data/IntermediateFieldContext.cs | |||
@@ -0,0 +1,38 @@ | |||
1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
2 | |||
3 | namespace WixToolset.Data | ||
4 | { | ||
5 | using System; | ||
6 | |||
7 | public class IntermediateFieldContext : IDisposable | ||
8 | { | ||
9 | private string previous; | ||
10 | private bool disposed; | ||
11 | |||
12 | public IntermediateFieldContext(string context) | ||
13 | { | ||
14 | this.previous = IntermediateFieldExtensions.valueContext; | ||
15 | |||
16 | IntermediateFieldExtensions.valueContext = context; | ||
17 | } | ||
18 | |||
19 | public void Dispose() | ||
20 | { | ||
21 | Dispose(true); | ||
22 | GC.SuppressFinalize(this); | ||
23 | } | ||
24 | |||
25 | protected virtual void Dispose(bool disposing) | ||
26 | { | ||
27 | if (!this.disposed) | ||
28 | { | ||
29 | if (disposing) | ||
30 | { | ||
31 | IntermediateFieldExtensions.valueContext = this.previous; | ||
32 | } | ||
33 | |||
34 | this.disposed = true; | ||
35 | } | ||
36 | } | ||
37 | } | ||
38 | } | ||