public SyncMethodInfoRpcOperation(Func <object> instanceProvider, MethodInfo method, string procedureName) : base(procedureName) { mInstanceProvider = instanceProvider; mMethod = method; mMethodInvoker = MethodInvokeGenerator.CreateInvokeMethod(method); if (method.ReturnType != typeof(void)) { mHasResult = true; } else { mHasResult = false; } mCollectionResultTreatment = method.GetCollectionResultTreatment(); mHelper = new MethodInfoHelper(method); mParameters = method.GetParameters() .Where(x => !x.IsOut) .Select(parameter => new RpcParameter(parameter)) .ToArray(); mResultExtractor = WampResultExtractor.GetResultExtractor(this); if (method.ReturnsTuple()) { mResultExtractor = WampResultExtractor.GetValueTupleResultExtractor(method); } }
public AsyncMethodInfoRpcOperation(Func <object> instanceProvider, MethodInfo method, string procedureName) : base(procedureName) { mInstanceProvider = instanceProvider; mMethod = method; mMethodInvoker = MethodInvokeGenerator.CreateTaskInvokeMethod(method); if (method.ReturnType != typeof(Task)) { mHasResult = true; } else { mHasResult = false; } mCollectionResultTreatment = method.GetCollectionResultTreatment(); IEnumerable <ParameterInfo> parameterInfos = method.GetParameters(); if (parameterInfos.LastOrDefault()?.ParameterType == typeof(CancellationToken)) { mSupportsCancellation = true; parameterInfos = parameterInfos.Take(parameterInfos.Count() - 1); } mParameters = parameterInfos .Select(parameter => new RpcParameter(parameter)) .ToArray(); mResultExtractor = WampResultExtractor.GetResultExtractor(this); if (method.ReturnsTuple()) { mResultExtractor = WampResultExtractor.GetValueTupleResultExtractor(method); } }
protected virtual object[] GetResultArguments(object result) { IWampResultExtractor extractor = WampResultExtractor.GetResultExtractor(this); return(extractor.GetArguments(result)); }