Esempio n. 1
0
        private static bool ExecuteCommandBinding(object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
        {
            // Asserting a permission in the case that the command was user initiated
            // and the command is a secure command. We can do this safely because at
            // the time the binding was setup, we demanded the permission.
            ISecureCommand secureCommand = e.Command as ISecureCommand;
            bool           elevate       = e.UserInitiated && (secureCommand != null) && (secureCommand.UserInitiatedPermission != null);

            if (elevate)
            {
                secureCommand.UserInitiatedPermission.Assert(); //BlessedAssert
            }
            try
            {
                commandBinding.OnExecuted(sender, e);
            }
            finally
            {
                if (elevate)
                {
                    CodeAccessPermission.RevertAssert();
                }
            }

            return(e.Handled);
        }
Esempio n. 2
0
        private static bool ExecuteCommandBinding(object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
        {
            // Asserting a permission in the case that the command was user initiated
            // and the command is a secure command. We can do this safely because at
            // the time the binding was setup, we demanded the permission.
            ISecureCommand secureCommand = e.Command as ISecureCommand;
            bool elevate = e.UserInitiated && (secureCommand != null) && (secureCommand.UserInitiatedPermission != null);

            if (elevate)
            {
                secureCommand.UserInitiatedPermission.Assert(); //BlessedAssert
            }
            try
            {
                commandBinding.OnExecuted(sender, e);
            }
            finally
            {
                if (elevate)
                {
                    CodeAccessPermission.RevertAssert();
                }
            }

            return e.Handled;
        }
Esempio n. 3
0
 private static bool ExecuteCommandBinding(object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding)
 {
     commandBinding.OnExecuted(sender, e);
     return(e.Handled);
 }