Пример #1
0
        private MethodData GetMethodData(MethodCall methodCall)
        {
            MethodBase method = methodCall.MethodBase;

            if (_methodDataCache.TryGetMethodData(method, out MethodData methodData))
            {
                return(methodData);
            }

            bool canCacheMessageData;

            Type declaringType = method.DeclaringType;

            if (declaringType == typeof(object) && method == typeof(object).GetMethod("GetType"))
            {
                canCacheMessageData = true;
                methodData          = new MethodData(method, MethodType.GetType);
            }
            else if (declaringType.IsAssignableFrom(_serviceChannel.GetType()))
            {
                canCacheMessageData = true;
                methodData          = new MethodData(method, MethodType.Channel);
            }
            else
            {
                ProxyOperationRuntime operation = _proxyRuntime.GetOperation(method, methodCall.Args, out canCacheMessageData);

                if (operation == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.SFxMethodNotSupportedOnCallback1, method.Name)));
                }

                MethodType methodType;

                if (operation.IsTaskCall(methodCall))
                {
                    methodType = MethodType.TaskService;
                }
                else if (operation.IsSyncCall(methodCall))
                {
                    methodType = MethodType.Service;
                }
                else if (operation.IsBeginCall(methodCall))
                {
                    methodType = MethodType.BeginService;
                }
                else
                {
                    methodType = MethodType.EndService;
                }

                methodData = new MethodData(method, methodType, operation);
            }

            if (canCacheMessageData)
            {
                _methodDataCache.SetMethodData(methodData);
            }

            return(methodData);
        }