public ParsingScope(ParsingScopes parsingScopes, ParsingScope parent, RangeAddress address) { _parsingScopes = parsingScopes; Parent = parent; Address = address; ScopeId = Guid.NewGuid(); }
/// <summary> /// Removes the current scope, setting the calling scope to current. /// </summary> /// <param name="parsingScope"></param> public virtual void KillScope(ParsingScope parsingScope) { _scopes.Pop(); if (_scopes.Count() == 0) { _lifetimeEventHandler.ParsingCompleted(); } }
/// <summary> /// Creates a new <see cref="ParsingScope"/> and puts it on top of the stack. /// </summary> /// <param name="address"></param> /// <returns></returns> public virtual ParsingScope NewScope(RangeAddress address) { ParsingScope scope; if (_scopes.Count() > 0) { scope = new ParsingScope(this, _scopes.Peek(), address); } else { scope = new ParsingScope(this, address); } _scopes.Push(scope); return scope; }
/// <summary> /// Creates a new <see cref="ParsingScope"/> and puts it on top of the stack. /// </summary> /// <param name="address"></param> /// <returns></returns> public virtual ParsingScope NewScope(RangeAddress address) { ParsingScope scope; if (_scopes.Count() > 0) { scope = new ParsingScope(this, _scopes.Peek(), address); } else { scope = new ParsingScope(this, address); } _scopes.Push(scope); return(scope); }
public void ScopeShouldCallKillScopeOnDispose() { var scope = new ParsingScope(_parsingScopes, _factory.Create("A1")); ((IDisposable)scope).Dispose(); _parsingScopes.AssertWasCalled(x => x.KillScope(scope)); }
public void ConstructorShouldSetParent() { var parent = new ParsingScope(_parsingScopes, _factory.Create("A1")); var scope = new ParsingScope(_parsingScopes, parent, _factory.Create("A2")); Assert.AreEqual(parent, scope.Parent); }
public void ConstructorShouldSetAddress() { var expectedAddress = _factory.Create("A1"); var scope = new ParsingScope(_parsingScopes, expectedAddress); Assert.AreEqual(expectedAddress, scope.Address); }
public void Setup() { _parsingContext = ParsingContext.Create(); _scope = _parsingContext.Scopes.NewScope(RangeAddress.Empty); }