public void Add(MyDelegate myDelegate) { if (myDelegate == null) { throw new ArgumentNullException(nameof(myDelegate)); } if (_methods == myDelegate._methods && _signature == myDelegate._signature) { var newList = new List <MethodInfo>(); newList = newList.Concat(_methods).ToList(); _methods = newList.Concat(_methods).ToList(); } else { if (_methods.Count == 0) { _methods = new List <MethodInfo>(); _signature = myDelegate._signature.Clone(); } else if (!_signature.Equals(myDelegate._signature)) { throw new Exception("Signatures do not coincide"); } foreach (var method in myDelegate._methods) { _methods.Add(method); } } }
public MyDelegate(MethodInfo method) { if (method == null) { throw new ArgumentNullException(); } _methods = new List <MethodInfo> { method }; _signature = new ParametersAndType(method.GetParameters(), method.ReturnType); }
public void Add(MethodInfo method) { if (method == null) { throw new ArgumentNullException(nameof(method)); } if (_methods.Count == 0) { _methods = new List <MethodInfo>(); _signature = new ParametersAndType(method.GetParameters(), method.ReturnType); } else if (!_signature.Equals(method)) { throw new Exception("Signatures do not coincide"); } _methods.Add(method); }