EventDelegate.Equals C# (CSharp) Method

Equals() public method

Equality operator.
public Equals ( object obj ) : bool
obj object
return bool
	public override bool Equals (object obj)
	{
		if (obj == null)
		{
			return !isValid;
		}

		if (obj is Callback)
		{
			Callback callback = obj as Callback;
#if REFLECTION_SUPPORT
			if (callback.Equals(mCachedCallback)) return true;
			MonoBehaviour mb = callback.Target as MonoBehaviour;
			return (mTarget == mb && string.Equals(mMethodName, GetMethodName(callback)));
#elif UNITY_FLASH
			return (callback == mCachedCallback);
#else
			return callback.Equals(mCachedCallback);
#endif
		}
		
		if (obj is EventDelegate)
		{
			EventDelegate del = obj as EventDelegate;
			return (mTarget == del.mTarget && string.Equals(mMethodName, del.mMethodName));
		}
		return false;
	}

Usage Example

 public static void Add(List <EventDelegate> list, EventDelegate.Callback callback, bool oneShot)
 {
     if (list != null)
     {
         int i     = 0;
         int count = list.Count;
         while (i < count)
         {
             EventDelegate eventDelegate = list[i];
             if (eventDelegate != null && eventDelegate.Equals(callback))
             {
                 return;
             }
             i++;
         }
         list.Add(new EventDelegate(callback)
         {
             oneShot = oneShot
         });
     }
     else
     {
         Debug.LogWarning("Attempting to add a callback to a list that's null");
     }
 }
All Usage Examples Of EventDelegate::Equals