| 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 readonly 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 | this.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 | } |