A game about forced loneliness, made by TACStudios
1using System; 2 3namespace UnityEngine.Rendering 4{ 5 /// <summary> 6 /// Delegate utility class. 7 /// </summary> 8 public static class DelegateUtility 9 { 10 /// <summary> 11 /// Cast a delegate. 12 /// </summary> 13 /// <param name="source">Source delegate.</param> 14 /// <param name="type">Type of the delegate.</param> 15 /// <returns>Cast delegate.</returns> 16 public static Delegate Cast(Delegate source, Type type) 17 { 18 if (source == null) 19 return null; 20 Delegate[] delegates = source.GetInvocationList(); 21 if (delegates.Length == 1) 22 return Delegate.CreateDelegate(type, 23 delegates[0].Target, delegates[0].Method); 24 Delegate[] delegatesDest = new Delegate[delegates.Length]; 25 for (int nDelegate = 0; nDelegate < delegates.Length; nDelegate++) 26 delegatesDest[nDelegate] = Delegate.CreateDelegate(type, 27 delegates[nDelegate].Target, delegates[nDelegate].Method); 28 return Delegate.Combine(delegatesDest); 29 } 30 } 31}