internal MethodShuntKey(MethodShuntSource source, MethodInfo method) : base(method) { if (source == null) { throw new ArgumentNullException(nameof(source)); } this.Source = source; }
public static MethodShuntSource CreateSource(MethodInfo method) { if (method == null) { throw new ArgumentNullException(nameof(method)); } var source = new MethodShuntSource(method); MethodShunt.shuntDic.Add(source, new HashSet <MethodShuntKey>()); return(source); }
public static MethodShuntKey Register(MethodShuntSource source, MethodInfo method) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (method == null) { throw new ArgumentNullException(nameof(method)); } var key = new MethodShuntKey(source, method); MethodShunt.shuntDic[source].Add(key); return(key); }
public static MethodShuntResult DynamicInvokeShunt(this object target, MethodShuntSource source, params object[] parameters) { if (source == null) { throw new ArgumentNullException(nameof(source)); } if (MethodShunt.shuntDic.ContainsKey(source)) { foreach (var key in MethodShunt.shuntDic[source]) { if (MethodShunt.DynamicInvokeShuntInternal(target, key, parameters, out object returnValue)) { return(new MethodShuntResult(true, returnValue)); } } } return(MethodShuntResult.Unsuccess); }