示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        protected virtual object[] GetResultArguments(object result)
        {
            IWampResultExtractor extractor = WampResultExtractor.GetResultExtractor(this);

            return(extractor.GetArguments(result));
        }