예제 #1
0
        // methods and properties

        public void CheckAccess(WxeFunction function)
        {
            ArgumentUtility.CheckNotNull("function", function);

            if (SecurityFreeSection.IsActive)
            {
                return;
            }

            WxeDemandTargetPermissionAttribute attribute = GetPermissionAttribute(function.GetType());

            if (attribute == null)
            {
                return;
            }

            WxeDemandMethodPermissionAttributeHelper helper = new WxeDemandMethodPermissionAttributeHelper(function.GetType(), attribute);
            SecurityClient securityClient = SecurityClient.CreateSecurityClientFromConfiguration();

            switch (helper.MethodType)
            {
            case MethodType.Instance:
                securityClient.CheckMethodAccess(helper.GetSecurableObject(function), helper.MethodName);
                break;

            case MethodType.Static:
                securityClient.CheckStaticMethodAccess(helper.SecurableClass, helper.MethodName);
                break;

            case MethodType.Constructor:
                securityClient.CheckConstructorAccess(helper.SecurableClass);
                break;

            default:
                throw new InvalidOperationException(string.Format(
                                                        "Value '{0}' is not supported by the MethodType property of the WxeDemandMethodPermissionAttribute.",
                                                        helper.MethodType));
            }
        }
 public WxeVariablesContainer(WxeFunction function, object[] actualParameters)
     : this(ArgumentUtility.CheckNotNull("function", function), actualParameters, GetParameterDeclarations(function.GetType()))
 {
 }