/// <summary> /// Called to notify listeners of a pattern or custom event. This could could be called by a server implementation or by a proxy's event /// translator. /// </summary> /// <param name="eventId">An AutomationEvent representing this event.</param> /// <param name="provider">The actual server-side element associated with this event.</param> /// <param name="e">Contains information about the event (may be null).</param> public static void RaiseAutomationEvent(AutomationEvent eventId, IRawElementProviderSimple provider, AutomationEventArgs e) { ValidateArgumentNonNull(eventId, "eventId"); ValidateArgumentNonNull(provider, "provider"); ValidateArgumentNonNull(e, "e"); // PRESHARP will flag this as warning 56506/6506:Parameter 'e' to this public method must be validated: A null-dereference can occur here. // False positive, e is checked, see above #pragma warning suppress 6506 if (e.EventId == AutomationElementIdentifiers.AsyncContentLoadedEvent) { AsyncContentLoadedEventArgs asyncArgs = e as AsyncContentLoadedEventArgs; if (asyncArgs == null) { ThrowInvalidArgument("e"); } UiaCoreProviderApi.UiaRaiseAsyncContentLoadedEvent(provider, asyncArgs.AsyncContentLoadedState, asyncArgs.PercentComplete); return; } // PRESHARP will flag this as warning 56506/6506:Parameter 'e' to this public method must be validated: A null-dereference can occur here. // False positive, e is checked, see above #pragma warning suppress 6506 if (e.EventId == WindowPatternIdentifiers.WindowClosedEvent && !(e is WindowClosedEventArgs)) { ThrowInvalidArgument("e"); } // fire to all clients // PRESHARP will flag this as warning 56506/6506:Parameter 'eventId' to this public method must be validated: A null-dereference can occur here. // False positive, eventId is checked, see above #pragma warning suppress 6506 UiaCoreProviderApi.UiaRaiseAutomationEvent(provider, eventId.Id); }
public static void RaiseAutomationEvent(AutomationEvent eventId, IRawElementProviderSimple provider, AutomationEventArgs e) { AutomationInteropProvider.ValidateArgumentNonNull(eventId, "eventId"); AutomationInteropProvider.ValidateArgumentNonNull(provider, "provider"); AutomationInteropProvider.ValidateArgumentNonNull(e, "e"); if (e.EventId == AutomationElementIdentifiers.AsyncContentLoadedEvent) { AsyncContentLoadedEventArgs asyncContentLoadedEventArgs = e as AsyncContentLoadedEventArgs; if (asyncContentLoadedEventArgs == null) { AutomationInteropProvider.ThrowInvalidArgument("e"); } UiaCoreProviderApi.UiaRaiseAsyncContentLoadedEvent(provider, asyncContentLoadedEventArgs.AsyncContentLoadedState, asyncContentLoadedEventArgs.PercentComplete); return; } if (e.EventId == WindowPatternIdentifiers.WindowClosedEvent && !(e is WindowClosedEventArgs)) { AutomationInteropProvider.ThrowInvalidArgument("e"); } UiaCoreProviderApi.UiaRaiseAutomationEvent(provider, eventId.Id); }
public static void RaiseAutomationEvent(AutomationEvent eventId, IRawElementProviderSimple provider, AutomationEventArgs e) { Utility.ValidateArgumentNonNull(eventId, "eventId"); Utility.ValidateArgumentNonNull(provider, "provider"); Utility.ValidateArgumentNonNull(e, "e"); if (e.EventId == AutomationElementIdentifiers.AsyncContentLoadedEvent) { AsyncContentLoadedEventArgs args = e as AsyncContentLoadedEventArgs; if (args == null) { throw new ArgumentException("e"); } UiaCoreProviderApi.UiaRaiseAsyncContentLoadedEvent(provider, args.AsyncContentLoadedState, args.PercentComplete); } else { if ((e.EventId == WindowPatternIdentifiers.WindowClosedEvent) && !(e is WindowClosedEventArgs)) { throw new ArgumentException("e"); } UiaCoreProviderApi.UiaRaiseAutomationEvent(provider, eventId.Id); } }