// MonoGame - Copyright (C) The MonoGame Team // This file is subject to the terms and conditions defined in // file 'LICENSE.txt', which is part of this source code package. using System; namespace Microsoft.Xna.Framework { /// /// Provides helper methods to make it easier /// to safely raise events. /// internal static class EventHelpers { /// /// Safely raises an event by storing a copy of the event's delegate /// in the parameter and checking it for /// null before invoking it. /// /// /// The object raising the event. /// to be invoked /// The passed to internal static void Raise(object sender, EventHandler handler, TEventArgs e) where TEventArgs : EventArgs { if (handler != null) handler(sender, e); } /// /// Safely raises an event by storing a copy of the event's delegate /// in the parameter and checking it for /// null before invoking it. /// /// The object raising the event. /// to be invoked /// The passed to internal static void Raise(object sender, EventHandler handler, EventArgs e) { if (handler != null) handler(sender, e); } } }