public override object Execute(Object o, IList args)
        {
            IStackWalk permission = null;

            try
            {
                permission = CreateStackWalk();
                if (this.PermitOnly)
                {
                    permission.PermitOnly();
                }
                else
                {
                    permission.Deny();
                }
                return(this.Invoker.Execute(o, args));
            }
            finally
            {
                if (permission != null)
                {
                    if (this.PermitOnly)
                    {
                        CodeAccessPermission.RevertPermitOnly();
                    }
                    else
                    {
                        CodeAccessPermission.RevertDeny();
                    }
                }
            }
        }
Esempio n. 2
0
        public object Eval(string expression, IDictionary <object, object> args)
        {
            var       sources = _codeGenerator.GetSources(_code, expression, _namespaces, _definitions);
            _Assembly asm     = _compilerImpl.Compile(sources, _references);
            var       obj     = (IComparer <IDictionary <object, object> >)asm.CreateInstance("CoApp.Eval.GeneratedCode.Foo");
            var       result  = new Dictionary <object, object>();

            _permissions.PermitOnly();
            obj.Compare(args, result);
            return(result[String.Empty]);
        }