Пример #1
0
        private Func <object, object[], object> BuildAction(WampMethodInfo wampMethod)
        {
            Func <object, object[], object> method =
                MethodInvokeGenerator.CreateInvokeMethod(wampMethod.Method);

            return(method);
        }
Пример #2
0
        public MethodInfoSubscriber(object instance, MethodInfo method, string topic)
            : base()
        {
            mLogger   = LogProvider.GetLogger(typeof(MethodInfoSubscriber) + "." + topic);
            mInstance = instance;
            mMethod   = method;

            if (method == null)
            {
                throw new ArgumentNullException(nameof(method));
            }

            mMethodInvoker = MethodInvokeGenerator.CreateInvokeMethod(method);

            if (method.ReturnType != typeof(void))
            {
                throw new ArgumentException("Expected return type of void from method " + method.Name,
                                            nameof(method));
            }

            if (method.GetParameters().Any(x => x.ParameterType.IsByRef || x.IsOut))
            {
                throw new ArgumentException("Expected not out/ref parameters from method " + method.Name,
                                            nameof(method));
            }

            mParameters = method.GetParameters()
                          .Select(x => new LocalParameter(x))
                          .ToArray();
        }
        public SyncMethodInfoRpcOperation(object instance, MethodInfo method, string procedureName) :
            base(procedureName)
        {
            mInstance      = instance;
            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();
        }
Пример #4
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);
            }
        }