diff options
| author | Rob Mensching <rob@firegiant.com> | 2022-11-08 14:58:05 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2022-11-08 16:20:25 -0800 |
| commit | c843b47d6233153fa961c6d0e61edf7cedf255bb (patch) | |
| tree | 9eae6badd42d3badb8665b7414b4d44ca48d6ae1 /src/internal/WixInternal.TestSupport/Pushd.cs | |
| parent | 7e498d6348c26583972ea1cdf7d51dadc8f5b792 (diff) | |
| download | wix-c843b47d6233153fa961c6d0e61edf7cedf255bb.tar.gz wix-c843b47d6233153fa961c6d0e61edf7cedf255bb.tar.bz2 wix-c843b47d6233153fa961c6d0e61edf7cedf255bb.zip | |
Separate WixInternal content from official WixToolset namespace
Diffstat (limited to 'src/internal/WixInternal.TestSupport/Pushd.cs')
| -rw-r--r-- | src/internal/WixInternal.TestSupport/Pushd.cs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/internal/WixInternal.TestSupport/Pushd.cs b/src/internal/WixInternal.TestSupport/Pushd.cs new file mode 100644 index 00000000..43737382 --- /dev/null +++ b/src/internal/WixInternal.TestSupport/Pushd.cs | |||
| @@ -0,0 +1,46 @@ | |||
| 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 WixInternal.TestSupport | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.IO; | ||
| 7 | |||
| 8 | public class Pushd : IDisposable | ||
| 9 | { | ||
| 10 | protected bool Disposed { get; private set; } | ||
| 11 | |||
| 12 | public Pushd(string path) | ||
| 13 | { | ||
| 14 | this.PreviousDirectory = Directory.GetCurrentDirectory(); | ||
| 15 | |||
| 16 | Directory.SetCurrentDirectory(path); | ||
| 17 | } | ||
| 18 | |||
| 19 | public string PreviousDirectory { get; } | ||
| 20 | |||
| 21 | #region // IDisposable | ||
| 22 | |||
| 23 | public void Dispose() | ||
| 24 | { | ||
| 25 | this.Dispose(true); | ||
| 26 | GC.SuppressFinalize(this); | ||
| 27 | } | ||
| 28 | |||
| 29 | protected virtual void Dispose(bool disposing) | ||
| 30 | { | ||
| 31 | if (this.Disposed) | ||
| 32 | { | ||
| 33 | return; | ||
| 34 | } | ||
| 35 | |||
| 36 | if (disposing) | ||
| 37 | { | ||
| 38 | Directory.SetCurrentDirectory(this.PreviousDirectory); | ||
| 39 | } | ||
| 40 | |||
| 41 | this.Disposed = true; | ||
| 42 | } | ||
| 43 | |||
| 44 | #endregion | ||
| 45 | } | ||
| 46 | } | ||
