internal void RaiseEvent(RoutedEventArgs args, bool trusted) { if (args == null) { throw new ArgumentNullException("args"); } if (trusted) { RaiseTrustedEvent(args); } else { args.ClearUserInitiated(); UIElement.RaiseEventImpl(this, args); } }
internal void RaiseTrustedEvent(RoutedEventArgs args) { if (args == null) { throw new ArgumentNullException("args"); } // Try/finally to ensure that UserInitiated bit is cleared. args.MarkAsUserInitiated(); try { UIElement.RaiseEventImpl(this, args); } finally { // Clear the bit - just to guarantee it's not used again args.ClearUserInitiated(); } }
/// <summary> /// Raise the events specified by /// <see cref="RoutedEventArgs.RoutedEvent"/> /// </summary> /// <remarks> /// This method is a shorthand for /// <see cref="ContentElement.BuildRoute"/> and /// <see cref="EventRoute.InvokeHandlers"/> /// </remarks> /// <param name="e"> /// <see cref="RoutedEventArgs"/> for the event to /// be raised /// </param> ///<SecurityNote> /// By default clears the user initiated bit. /// To guard against "replay" attacks. ///</SecurityNote> public void RaiseEvent(RoutedEventArgs e) { // VerifyAccess(); if (e == null) { throw new ArgumentNullException("e"); } e.ClearUserInitiated(); UIElement.RaiseEventImpl(this, e); }