/// <summary> /// Send the Event. Handles all error checking before we try to send the Event. /// </summary> /// <param name="source">The object that is sending a Tranzmit Event</param> /// <param name="payload">The object that contains the data being sent with the Tranzmit event</param> // 3 - Send The Event public void Send(object source, object payload) { List <Errors> Errors = new List <Errors>(); Type dataType = null; if (source == null) { Errors.Add(Tranzmit.Errors.MissingSource); } if (TranzmitEvent == null) { Errors.Add(Tranzmit.Errors.NoSubscribers); } if (payload == null) { Errors.Add(Tranzmit.Errors.MissingPayload); } else { dataType = payload.GetType(); if (dataType != Info.DataType) { Errors.Add(Tranzmit.Errors.WrongDataType); } } if (dataType == null) { Errors.Add(Tranzmit.Errors.MissingDataType); } DeliveryStatuses delieveryStatus; if (Errors.Count == 0) { delieveryStatus = DeliveryStatuses.Success; } else { delieveryStatus = DeliveryStatuses.Failed; } if (delieveryStatus == DeliveryStatuses.Success) { TranzmitEvent.Invoke(source, payload); } Info.Tranzmit.Broadcast_Event_Sent(source, delieveryStatus, Errors, Info.EventName, Info.DataType, dataType, TranzmitEvent); }
/// <summary> /// Fetches the Subscribers (Deleagtes) 'attached' to the Specified Event. This is the only way I can find to get delgates directly from this class. /// </summary> /// <returns>Event Delegates</returns> public List <Delegate> GetSubscribers() { List <Delegate> subscribers = new List <Delegate>(); if (TranzmitEvent != null) { foreach (Delegate subscriber in TranzmitEvent.GetInvocationList()) { subscribers.Add(subscriber); } } return(subscribers); }