예제 #1
0
		public RequestMessage(string targetService, string targetMethod, ParamTuple[] @params, string[] paramTypes)
		{
			TargetService = targetService;
			TargetMethod = targetMethod;
			Params = @params;
			ParamTypes = paramTypes;
		}
		public Tuple<object, Type> Dispatch(string service, string methodName, ParamTuple[] parameters, string[] paramsTypeNames)
		{
			var tuple = _resolver(service);
			var instance = tuple.Item1;
			var targetType = tuple.Item2;

			Type[] paramTypes;
			MethodInfo method;

			if (paramsTypeNames == null) // remote caller didnt supply param types, so we try to resolve it without overload support
			{
				method = ResolveMethodWithoutOverloadSupport(targetType, methodName);
				paramTypes = method.GetParameters().Select(p => p.ParameterType).ToArray();
			}
			else // parameter types were supplied, so we try to resolve the exact method
			{
				paramTypes = this._serialization.DeserializeParameterTypes(paramsTypeNames);
				method = ResolveMethod(targetType, methodName, paramTypes);
			}


			var args = this._serialization.DeserializeParams(parameters, paramTypes) ?? new object[0];

			var result = method.Invoke(instance, args);

			return Tuple.Create(result, method.ReturnType);
		}
예제 #3
0
		public static object[] ParamTupleToObjects(ParamTuple[] parameters, Type[] parametersTypes)
		{
			if (parametersTypes.Length == 0) return null;

			// Not using linq for perf reasons

			var args = new object[parameters.Length];

			for (int i = 0; i < args.Length; i++)
			{
				args[i] = Serialization.DeserializeParamTuple(parameters[i], parametersTypes[i]);
			}

			return args;
		}
예제 #4
0
		public static ParamTuple[] ParametersToParamTuple(object[] arguments, Type[] parametersTypes)
		{
			if (arguments == null) return null;
			if (parametersTypes.Length == 0) return null;

			// Not using linq for perf reasons

			var retArray = new ParamTuple[parametersTypes.Length];

			for (int i = 0; i < retArray.Length; i++)
			{
				// var pTuple = Serialization.BuildParamTuple(parametersTypes[i], arguments[i]);
				var pTuple = Serialization.BuildParamTuple(arguments[i].GetType(), arguments[i]);
				retArray[i] = pTuple;
			}

			return retArray;
		}
		public override object[] DeserializeParams(ParamTuple[] parameters, Type[] paramTypes)
		{
			return Builder.ParamTupleToObjects(parameters, paramTypes);
		}