protected virtual void OnAfterSetItem(ScopeArgs args) { if (AfterSetItem != null) { AfterSetItem(this, args); } }
protected virtual void OnBeforeSetItem(ScopeArgs args) { if (BeforeSetItem != null) { BeforeSetItem(this, args); } }
public override void CreateVariable(string id, object value) { var args = new ScopeArgs(id, value, ScopeOperation.Create); OnBeforeSetItem(args); if (args.Cancel) return; base.CreateVariable(id, value); OnAfterSetItem(args); if (args.Cancel) { throw new ScriptIdNotFoundException(string.Format(Strings.IdProcessingCanceledByUser, id)); } }
protected override void OnFirstRun() { base.OnFirstRun(); object memberExprValue; if (ScopeArgs.TryGetValue(this.varName, out memberExprValue)) { InitializeValueFn(memberExprValue); } else { staticValueFn = DataBinder.CompileStaticAccessToString(memberExpr); } }
private void ScopeBeforeSetItem(IScriptScope sender, ScopeArgs args) { //TODO: Performance improvement. Should be evaluated once per function call List <string> globalNames = GetGlobalNames(activeContext); if (globalNames.Contains(args.Name)) { SetToParentScope(sender.Parent, args.Name, args.Value); args.Cancel = true; } //if (!sender.HasVariable(args.Name)) //{ // args.Cancel = SetToParentScope(sender.Parent, args.Name, args.Value); //} }
protected override void OnFirstRun() { base.OnFirstRun(); object memberExprValue; if (ScopeArgs.TryGetValue(this.varName, out memberExprValue)) { valueFn = this.ReferencesSelf ? Convert.ToString : DataBinder.CompileToString(memberExprValue.GetType(), modelMemberExpr); } else { staticValueFn = DataBinder.CompileStaticAccessToString(memberExpr); } }
public override void CreateVariable(string id, object value) { var args = new ScopeArgs(id, value, ScopeOperation.Create); OnBeforeSetItem(args); if (args.Cancel) { return; } base.CreateVariable(id, value); OnAfterSetItem(args); if (args.Cancel) { throw new ScriptIdNotFoundException(string.Format(Strings.IdProcessingCanceledByUser, id)); } }
private void ScopeBeforeSetItem(IScriptScope sender, ScopeArgs args) { if (_globalNames.Contains(args.Name)) { switch (args.Operation) { case ScopeOperation.Set: ScriptQualifiedName.SetToParentScope(sender.Parent, args.Name, args.Value); args.Cancel = true; break; case ScopeOperation.Create: throw new ScriptExecutionException(string.Format(Strings.LocalIdConflictWithGlobalList, args.Name)); default: break; } } }
public override object GetItem(string id, bool throwException) { var args = new ScopeArgs(id, RuntimeHost.NullValue, ScopeOperation.Get); OnBeforeGetItem(args); if (args.Cancel) { if (args.Value != RuntimeHost.NullValue) return args.Value; throw new ScriptIdNotFoundException(id); } args.Value = base.GetItem(id, throwException); OnAfterGetItem(args); if (args.Cancel) { throw new ScriptIdNotFoundException(string.Format(Strings.IdProcessingCanceledByUser, id)); } return args.Value; }
public override object GetItem(string id, bool throwException) { var args = new ScopeArgs(id, RuntimeHost.NullValue, ScopeOperation.Get); OnBeforeGetItem(args); if (args.Cancel) { if (args.Value != RuntimeHost.NullValue) { return(args.Value); } throw new ScriptIdNotFoundException(id); } args.Value = base.GetItem(id, throwException); OnAfterGetItem(args); if (args.Cancel) { throw new ScriptIdNotFoundException(string.Format(Strings.IdProcessingCanceledByUser, id)); } return(args.Value); }
protected virtual void OnBeforeGetItem(ScopeArgs args) { if (BeforeGetItem != null) BeforeGetItem(this, args); }
protected virtual void OnAfterSetItem(ScopeArgs args) { if (AfterSetItem != null) AfterSetItem(this, args); }
private void CheckContractInvariant(object sender, ScopeArgs args) { _contract.CheckInv(_activeContext); }