Ejemplo n.º 1
0
        public void TestMemberAccess()
        {
            AccessTestExpressionOwner owner   = new AccessTestExpressionOwner();
            ExpressionContext         context = new ExpressionContext(null, owner);

            // Private field, access should be denied
            this.AssertCompileException("privateField1", context);

            // Private field but with override allowing access
            var e = new DynamicExpression("privateField2", ExpressionLanguage.Flee);

            // Private field but with override denying access
            this.AssertCompileException("privateField3", context, new BoundExpressionOptions
            {
                AllowPrivateAccess = true
            });

            // Public field, access should be denied
            this.AssertCompileException("PublicField1", context);

            // Public field, access should be allowed
            e = new DynamicExpression("publicField1", ExpressionLanguage.Flee);
        }
Ejemplo n.º 2
0
        public void TestMemberAccess()
        {
            AccessTestExpressionOwner owner = new AccessTestExpressionOwner();
            ExpressionContext context = new ExpressionContext(null, owner);

            // Private field, access should be denied
            this.AssertCompileException("privateField1", context);

            // Private field but with override allowing access
            var e = new DynamicExpression("privateField2", ExpressionLanguage.Flee);

            // Private field but with override denying access
            this.AssertCompileException("privateField3", context, new BoundExpressionOptions
            {
                AllowPrivateAccess = true
            });

            // Public field, access should be denied
            this.AssertCompileException("PublicField1", context);

            // Public field, access should be allowed
            e = new DynamicExpression("publicField1", ExpressionLanguage.Flee);
        }