コード例 #1
0
 /// <summary>
 /// Adding a delegate for reacting to noise from current entity when the delegate is called
 /// </summary>
 /// <param name="method">Delegate</param>
 public void AddHearer(HearDelegate method)
 {
     if (!HearContains(method))
     {
         _hearingDelegates += method;
     }
 }
コード例 #2
0
 /// <summary>
 /// Removing a delegate for reacting to noise from current entity when the delegate is called
 /// </summary>
 /// <param name="method"></param>
 public void RemoveHearer(HearDelegate method)
 {
     if (HearContains(method))
     {
         _hearingDelegates -= method;
     }
 }
コード例 #3
0
 /// <summary>
 /// Shows whether given method contains in _hearingDelegates delegates
 /// </summary>
 /// <param name="method"></param>
 private bool HearContains(HearDelegate method)
 {
     if (_hearingDelegates != null)
     {
         System.Delegate[] list = _hearingDelegates.GetInvocationList();
         foreach (System.Delegate deleg in list)
         {
             if ((System.Delegate)method == deleg)
             {
                 return(true);
             }
         }
         return(false);
     }
     return(false);
 }