private IList <Object> PopulateStreamHandlers(Type[] paramTypes, IList <Object> arguments) { IList <Object> rv = new List <Object>(); bool firstStream = true; IEnumerator <Object> argIt = arguments.GetEnumerator(); foreach (Type paramType in paramTypes) { if (StreamHandlerUtil.IsAdaptableToObjectStreamHandler(paramType)) { if (!firstStream) { throw new InvalidOperationException("At most one stream handler is supported"); } ObjectStreamHandler osh = new RemoteResultsHandler(_connection); rv.Add(StreamHandlerUtil.AdaptFromObjectStreamHandler(paramType, osh)); firstStream = false; } else { argIt.MoveNext(); rv.Add(argIt.Current); } } return(rv); }
/// <summary> /// Partitions arguments into regular arguments and /// stream arguments. /// </summary> /// <param name="paramTypes">The param types of the method</param> /// <param name="arguments">The passed-in arguments. As a /// side-effect will be set to just the regular arguments.</param> /// <returns>The stream handler arguments.</returns> private static ObjectStreamHandler ExtractStreamHandler(Type[] paramTypes, IList <Object> arguments) { ObjectStreamHandler rv = null; IList <Object> filteredArguments = new List <Object>(); for (int i = 0; i < paramTypes.Length; i++) { Type paramType = paramTypes[i]; object arg = arguments[i]; if (StreamHandlerUtil.IsAdaptableToObjectStreamHandler(paramType)) { ObjectStreamHandler handler = StreamHandlerUtil.AdaptToObjectStreamHandler(paramType, arg); if (rv != null) { throw new InvalidOperationException("Multiple stream handlers not supported"); } rv = handler; } else { filteredArguments.Add(arg); } } arguments.Clear(); CollectionUtil.AddAll(arguments, filteredArguments); return(rv); }