本文整理汇总了C#中Scope.PushScope方法的典型用法代码示例。如果您正苦于以下问题:C# Scope.PushScope方法的具体用法?C# Scope.PushScope怎么用?C# Scope.PushScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scope
的用法示例。
在下文中一共展示了Scope.PushScope方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NestedScopesCanStillFindLocallyDefinedIdentifier
public void NestedScopesCanStillFindLocallyDefinedIdentifier()
{
var scope = new Scope();
var identifier = "A";
scope.DefineIdentifier(identifier, new Value(1));
using (scope.PushScope())
{
scope.DefineIdentifier(identifier, new Value(2));
var actual = scope.FindIdentifier(identifier);
Assert.AreEqual(true, actual.IsDefined);
}
}
示例2: PopScopeDefinesANewMoreDeeplyNestedScope
public void PopScopeDefinesANewMoreDeeplyNestedScope()
{
var scope = new Scope();
var identifier = "A";
var expected = 1234;
scope.DefineIdentifier(identifier, new Value(expected));
scope.PushScope();
scope.DefineIdentifier(identifier, new Value(1));
scope.PopScope();
var actual = scope.FindIdentifier(identifier);
Assert.AreEqual(expected, actual.Value.ToObject());
}
示例3: PushScopeReturnsAnIDisposableWhichPopsScopeAutomatically
public void PushScopeReturnsAnIDisposableWhichPopsScopeAutomatically()
{
var scope = new Scope();
var identifier = "A";
var expected = 1234;
scope.DefineIdentifier(identifier, new Value(expected));
using (scope.PushScope())
{
scope.DefineIdentifier(identifier, new Value(1));
}
var actual = scope.FindIdentifier(identifier);
Assert.AreEqual(expected, actual.Value.ToObject());
}
示例4: NestedScopesReturnsIdentifierFromAncestorIfNotFoundLocally
public void NestedScopesReturnsIdentifierFromAncestorIfNotFoundLocally()
{
var scope = new Scope();
var identifier = "A";
var expected = 2;
scope.DefineIdentifier(identifier, new Value(expected));
using (scope.PushScope())
{
scope.DefineIdentifier("B", new Value(3));
using (scope.PushScope())
{
scope.DefineIdentifier("C", new Value(4));
using (scope.PushScope())
{
scope.DefineIdentifier("D", new Value(5));
using (scope.PushScope())
{
scope.DefineIdentifier("E", new Value(6));
{
scope.DefineIdentifier("F", new Value(7));
var actual = scope.FindIdentifier(identifier);
Assert.AreEqual(expected, actual.Value.ToObject());
}
}
}
}
}
}
示例5: NestedScopesReturnsTheMostDeeplyDefinedInstanceOfAnIdentifier
public void NestedScopesReturnsTheMostDeeplyDefinedInstanceOfAnIdentifier()
{
var scope = new Scope();
var identifier = "A";
var expected = 2;
scope.DefineIdentifier(identifier, new Value(1));
using (scope.PushScope())
{
scope.DefineIdentifier(identifier, new Value(expected));
var actual = scope.FindIdentifier(identifier);
Assert.AreEqual(expected, actual.Value.ToObject());
}
}