Replaces the context path of the storage, dispose of the returned IDisposable to restore the Storage's previous ContextPath.
Syntax
Parameters
- contextPath
- The full context path to change to
Return Value
Context can be disposed to restore the previous state
Example
Library/Library.Test/TestStorage.cs
C# | Copy Code |
---|
Assert.IsNull(Store.ContextPath);
using (Store.SetContext("a"))
{
Assert.AreEqual("a", Store.ContextPath);
using (Store.SetContext("b"))
Assert.AreEqual("b", Store.ContextPath);
Assert.AreEqual("a", Store.ContextPath);
}
Assert.IsNull(Store.ContextPath);
using (Store.SetContext("a"))
{
Assert.AreEqual("a", Store.ContextPath);
Store.SetContext("b");
Assert.AreEqual("b", Store.ContextPath);
}
Assert.IsNull(Store.ContextPath); |
VB.NET | Copy Code |
---|
Assert.IsNull(Store.ContextPath)
Using Store.SetContext("a")
Assert.AreEqual("a", Store.ContextPath)
Using Store.SetContext("b")
Assert.AreEqual("b", Store.ContextPath)
End Using
Assert.AreEqual("a", Store.ContextPath)
End Using
Assert.IsNull(Store.ContextPath)
Using Store.SetContext("a")
Assert.AreEqual("a", Store.ContextPath)
Store.SetContext("b")
Assert.AreEqual("b", Store.ContextPath)
End Using
Assert.IsNull(Store.ContextPath) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also