Example #1
0
 protected virtual void OnAfterSetItem(ScopeArgs args)
 {
     if (AfterSetItem != null)
     {
         AfterSetItem(this, args);
     }
 }
Example #2
0
 protected virtual void OnBeforeSetItem(ScopeArgs args)
 {
     if (BeforeSetItem != null)
     {
         BeforeSetItem(this, args);
     }
 }
Example #3
0
    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));
      }
    }
Example #4
0
        protected override void OnFirstRun()
        {
            base.OnFirstRun();

            object memberExprValue;

            if (ScopeArgs.TryGetValue(this.varName, out memberExprValue))
            {
                InitializeValueFn(memberExprValue);
            }
            else
            {
                staticValueFn = DataBinder.CompileStaticAccessToString(memberExpr);
            }
        }
Example #5
0
        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);
            //}
        }
Example #6
0
        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);
            }
        }
Example #7
0
        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));
            }
        }
Example #8
0
        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;
                }
            }
        }
Example #9
0
    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;
    }
Example #10
0
        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);
        }
Example #11
0
 protected virtual void OnBeforeGetItem(ScopeArgs args)
 {
   if (BeforeGetItem != null)
     BeforeGetItem(this, args);
 }
Example #12
0
 protected virtual void OnAfterSetItem(ScopeArgs args)
 {
   if (AfterSetItem != null)
     AfterSetItem(this, args);
 }
Example #13
0
 private void CheckContractInvariant(object sender, ScopeArgs args)
 {
     _contract.CheckInv(_activeContext);
 }