示例#1
0
        /// <summary>Writes a request header body This implementation is slightly more efficient than the generated code
        /// because it avoids the allocation of a string[] to write the location.</summary>
        internal static void WriteIce2RequestHeaderBody(
            this OutputStream ostr,
            Identity identity,
            string facet,
            IReadOnlyList <string> location,
            string operation,
            bool idempotent,
            DateTime deadline,
            IReadOnlyDictionary <string, string> context)
        {
            Debug.Assert(ostr.Encoding == Encoding);

            // All bits are set to true by default, and true means the corresponding value is set.
            BitSequence bitSequence = ostr.WriteBitSequence(5);

            identity.IceWrite(ostr);
            if (facet.Length > 0)
            {
                ostr.WriteString(facet);
            }
            else
            {
                bitSequence[0] = false;
            }

            if (location.Count > 0)
            {
                ostr.WriteSequence(location, OutputStream.IceWriterFromString);
            }
            else
            {
                bitSequence[1] = false;
            }

            ostr.WriteString(operation);

            if (idempotent)
            {
                ostr.WriteBool(true);
            }
            else
            {
                bitSequence[2] = false;
            }

            bitSequence[3] = false; // TODO: source for priority.

            // DateTime.MaxValue represents an infinite deadline and it is encoded as -1
            ostr.WriteVarLong(
                deadline == DateTime.MaxValue ? -1 : (long)(deadline - DateTime.UnixEpoch).TotalMilliseconds);

            if (context.Count > 0)
            {
                ostr.WriteDictionary(context, OutputStream.IceWriterFromString, OutputStream.IceWriterFromString);
            }
            else
            {
                bitSequence[4] = false;
            }
        }
示例#2
0
        /// <summary>Writes a request header body without constructing an Ice2RequestHeaderBody instance. This
        /// implementation is slightly more efficient than the generated code because it avoids the allocation of a
        /// string[] to write the location.</summary>
        internal static void WriteIce2RequestHeaderBody(
            this OutputStream ostr,
            Identity identity,
            string facet,
            IReadOnlyList <string> location,
            string operation,
            bool idempotent)
        {
            Debug.Assert(ostr.Encoding == Encoding);
            BitSequence bitSequence = ostr.WriteBitSequence(4); // bit set to true (set) by default

            identity.IceWrite(ostr);
            if (facet.Length > 0)
            {
                ostr.WriteString(facet);
            }
            else
            {
                bitSequence[0] = false;
            }

            if (location.Count > 0)
            {
                ostr.WriteSequence(location, OutputStream.IceWriterFromString);
            }
            else
            {
                bitSequence[1] = false;
            }

            ostr.WriteString(operation);

            if (idempotent)
            {
                ostr.WriteBool(true);
            }
            else
            {
                bitSequence[2] = false;
            }

            bitSequence[3] = false; // TODO: source for priority.
        }
示例#3
0
        internal static void WriteProxyData20(
            this OutputStream ostr,
            Identity identity,
            Protocol protocol,
            Encoding encoding,
            IReadOnlyList <string> location,
            InvocationMode invocationMode,
            string facet)
        {
            Debug.Assert(ostr.Encoding == Encoding.V20);

            BitSequence bitSequence = ostr.WriteBitSequence(5);

            identity.IceWrite(ostr);

            if (protocol != Protocol.Ice2)
            {
                ostr.Write(protocol);
            }
            else
            {
                bitSequence[0] = false;
            }

            if (encoding != Encoding.V20)
            {
                encoding.IceWrite(ostr);
            }
            else
            {
                bitSequence[1] = false;
            }

            if (location.Count > 0)
            {
                ostr.WriteSequence(location, OutputStream.IceWriterFromString);
            }
            else
            {
                bitSequence[2] = false;
            }

            // We only write a non-null invocation mode for ice1.
            if (protocol == Protocol.Ice1 && invocationMode != InvocationMode.Twoway)
            {
                ostr.Write(invocationMode);
            }
            else
            {
                bitSequence[3] = false;
            }

            if (facet.Length > 0)
            {
                ostr.WriteString(facet);
            }
            else
            {
                bitSequence[4] = false;
            }
        }