public ServiceCallParam(OnceCallParam param, Action <object> callback, CancellationToken token, BufferBlockStream stream) { Action = param.Action; Args = param.Args; StreamLength = param.StreamLength; Callback = callback; Token = token; Stream = stream; Header = param.Header; }
private static object[] GetArgs(ParameterInfo[] ps, object[] psValue, Action <object> callback, CancellationToken token, BufferBlockStream stream) { var psList = ps.ToList(); var dic = new Dictionary <int, object>(); //Action<> var found = psList.FirstOrDefault(i => i.ParameterType.IsGenericType && i.ParameterType.GetGenericTypeDefinition() == typeof(Action <>)); if (found != null) { dic.Add(psList.IndexOf(found), ActionHelper.ConvertAction(callback, found.ParameterType.GetGenericArguments()[0])); } //CancellationToken found = psList.FirstOrDefault(i => i.ParameterType == typeof(CancellationToken?) || i.ParameterType == typeof(CancellationToken)); if (found != null) { dic.Add(psList.IndexOf(found), token); } //Stream found = psList.FirstOrDefault(i => i.ParameterType == typeof(Stream)); if (found != null) { dic.Add(psList.IndexOf(found), stream); } List <object> objs = new List <object>(); var psValueList = psValue.ToList(); //Sort params for (int i = 0; i < ps.Length; i++) { if (dic.Keys.Any(j => j == i)) { objs.Add(dic[i]); } else { objs.Add(psValueList[0]); psValueList.RemoveAt(0); } } return(objs.ToArray()); }