/// <summary>Creates a new <see cref="OutgoingRequestFrame"/> for an operation with a single non-struct /// parameter.</summary> /// <typeparam name="T">The type of the operation's parameter.</typeparam> /// <param name="proxy">A proxy to the target Ice object. This method uses the communicator, identity, facet, /// encoding and context of this proxy to create the request frame.</param> /// <param name="operation">The operation to invoke on the target Ice object.</param> /// <param name="idempotent">True when operation is idempotent, otherwise false.</param> /// <param name="compress">True if the request should be compressed, false otherwise.</param> /// <param name="format">The format to use when writing class instances in case <c>args</c> contains class /// instances.</param> /// <param name="context">An optional explicit context. When non null, it overrides both the context of the /// proxy and the communicator's current context (if any).</param> /// <param name="args">The argument(s) to write into the frame.</param> /// <param name="writer">The <see cref="OutputStreamWriter{T}"/> that writes the arguments into the frame. /// </param> /// <returns>A new OutgoingRequestFrame.</returns> public static OutgoingRequestFrame WithArgs <T>( IObjectPrx proxy, string operation, bool idempotent, bool compress, FormatType format, IReadOnlyDictionary <string, string>?context, T args, OutputStreamWriter <T> writer) { var request = new OutgoingRequestFrame(proxy, operation, idempotent, compress, context); var ostr = new OutputStream(proxy.Protocol.GetEncoding(), request.Data, request.PayloadStart, request.Encoding, format); writer(ostr, args); request.PayloadEnd = ostr.Finish(); if (compress && proxy.Encoding == Encoding.V20) { request.CompressPayload(); } return(request); }
/// <summary>Gets or builds a combined binary context using InitialBinaryContext and _binaryContextOverride. /// This method is used for colocated calls.</summary> internal IReadOnlyDictionary <int, ReadOnlyMemory <byte> > GetBinaryContext() { if (_binaryContextOverride == null) { return(InitialBinaryContext); } else { // Need to marshal/unmarshal this binary context var buffer = new List <ArraySegment <byte> >(); var ostr = new OutputStream(Encoding.V20, buffer); WriteBinaryContext(ostr); ostr.Finish(); return(buffer.AsArraySegment().AsReadOnlyMemory().Read(istr => istr.ReadBinaryContext())); } }