protected virtual void OnBeforeSetItem(ScopeArgs args)
 {
     if (BeforeSetItem != null)
     {
         BeforeSetItem(this, args);
     }
 }
Exemple #2
0
        public override object GetItem(string id, bool throwException)
        {
            ScopeArgs args = new ScopeArgs(id, RuntimeHost.NullValue);

              OnBeforeGetItem(args);
              if (args.Cancel)
              {
            if (args.Value != RuntimeHost.NullValue)
            {
              return args.Value;
            }
            else
            {
              throw new ScriptIdNotFoundException(id);
            }
              }
              args.Value = base.GetItem(id, throwException);

              OnAfterGetItem(args);
              if (args.Cancel)
              {
            throw new ScriptException("Canceled by event-handler");
              }

              return args.Value;
        }
 protected virtual void OnAfterGetItem(ScopeArgs args)
 {
     if (AfterGetItem != null)
     {
         AfterGetItem(this, args);
     }
 }
        public override object GetItem(string id, bool throwException)
        {
            ScopeArgs args = new ScopeArgs(id, RuntimeHost.NullValue);

            OnBeforeGetItem(args);
            if (args.Cancel)
            {
                if (args.Value != RuntimeHost.NullValue)
                {
                    return(args.Value);
                }
                else
                {
                    throw new ScriptIdNotFoundException(id);
                }
            }
            args.Value = base.GetItem(id, throwException);

            OnAfterGetItem(args);
            if (args.Cancel)
            {
                throw new ScriptException("Canceled by event-handler");
            }

            return(args.Value);
        }
        public override void SetItem(string id, object value)
        {
            ScopeArgs args = new ScopeArgs(id, value);

            OnBeforeSetItem(args);
            if (args.Cancel)
            {
                return;
            }

            base.SetItem(id, args.Value);

            OnAfterSetItem(args);
            if (args.Cancel)
            {
                throw new ScriptException("Canceled by event-handler");
            }
        }
Exemple #6
0
        public override void SetItem(string id, object value)
        {
            ScopeArgs args = new ScopeArgs(id, value);

              OnBeforeSetItem(args);
              if (args.Cancel) return;

              base.SetItem(id, args.Value);

              OnAfterSetItem(args);
              if (args.Cancel)
              {
            throw new ScriptException("Canceled by event-handler");
              }
        }
Exemple #7
0
 protected virtual void OnBeforeSetItem(ScopeArgs args)
 {
     if (BeforeSetItem!=null)
     BeforeSetItem(this, args);
 }
Exemple #8
0
 protected virtual void OnAfterSetItem(ScopeArgs args)
 {
     if (AfterSetItem != null)
     AfterSetItem(this, args);
 }
        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);
              //}
        }
 private void CheckContractInvariant(object sender, ScopeArgs args)
 {
     Contract.CheckInv(activeContext);
 }