Example #1
0
        /// <summary>
        /// Reads context values from a message, sets current context to them, and returns a cookie to restore previous context
        /// </summary>
        public MessageContextCookie ReadContextsIntoCookie(UnsafeReader reader)
        {
            var numContextValues = reader.ReadShort();

            Assertion.Assert(numContextValues <= myCounterpartHandlers.Count, "We know of {0} other side keys, received {1} instead", myCounterpartHandlers.Count, numContextValues);
            for (var i = 0; i < numContextValues; i++)
            {
                myCounterpartHandlers[i].ReadValueAndPush(SerializationContext, reader);
            }
            return(new MessageContextCookie(this, numContextValues));
        }