Ejemplo n.º 1
0
        /// <summary>
        /// This handles proxy calls to the hostService
        /// </summary>
        /// <param name="parameters">The list of method parameters</param>
        /// <typeparam name="T">Return reference type of the calling method</typeparam>
        /// <returns>The response of the invocation on the host object</returns>
        protected T InvokeOnHostService <T>(params object[] parameters)
        {
            var callingMethod = GetCallingMethod();
            var methodInfo    = PriseProxy.FindMethodOnObject(callingMethod as MethodInfo, this);

            if (methodInfo.GetParameters().Count() != parameters.Count())
            {
                throw new ReverseProxyException($"The number of parameters provided to this ReverseProxy {parameters?.Count()} do not match the actual parameter count of the hostService method ({methodInfo.GetParameters().Count()}). Did you forget to provide the correct number of parameters?");
            }

            return((T)this.Invoke(hostService, methodInfo, parameters ?? new object[] { }));
        }
Ejemplo n.º 2
0
        public static TProxyType CreateProxy <TProxyType>(
            object remoteObject,
            IParameterConverter parameterConverter = null,
            IResultConverter resultConverter       = null)
        {
            if (parameterConverter == null)
            {
                parameterConverter = new PassthroughParameterConverter();
            }

            if (resultConverter == null)
            {
                resultConverter = new PassthroughResultConverter();
            }

            var proxy = PriseProxy <TProxyType> .Create();

            ((PriseProxy <TProxyType>)proxy)
            .SetRemoteObject(remoteObject)
            .SetParameterConverter(parameterConverter)
            .SetResultConverter(resultConverter);

            return((TProxyType)proxy);
        }
Ejemplo n.º 3
0
 private object Invoke(object hostService, MethodInfo methodInfo, object[] parameters) => PriseProxy.Invoke(hostService, methodInfo, parameters ?? new object[] { }, new JsonSerializerParameterConverter(), new JsonSerializerResultConverter());