blob: 43737382f266541d513809ef185b9df7ab7f6d3f (
plain)
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
|
// 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.
namespace WixInternal.TestSupport
{
using System;
using System.IO;
public class Pushd : IDisposable
{
protected bool Disposed { get; private set; }
public Pushd(string path)
{
this.PreviousDirectory = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(path);
}
public string PreviousDirectory { get; }
#region // IDisposable
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (this.Disposed)
{
return;
}
if (disposing)
{
Directory.SetCurrentDirectory(this.PreviousDirectory);
}
this.Disposed = true;
}
#endregion
}
}
|