Beispiel #1
0
        /// <summary>
        /// Subscribe new subscription.
        /// </summary>
        /// <param name="func">Function.</param>
        /// <returns></returns>
        internal ICallBackSub Subscribe(CallBackAction <TCallBack> func)
        {
            CallBackSub <TCallBack> cbs = new CallBackSub <TCallBack>(this, func);

            foreach (var item in Subscriptions.Array.Span)
            {
                if (item == cbs)
                {
                    throw new Exception("Now subscribed.");
                }
            }
            Subscriptions.Add(cbs);
            return(cbs);
        }
Beispiel #2
0
 /// <summary>
 /// Unsubscribe subscription.
 /// </summary>
 /// <param name="callBackSub"></param>
 internal void Unsubscribe(CallBackSub <TCallBack> callBackSub)
 {
     Subscriptions.Remove(callBackSub);
 }