示例#1
0
            /// <summary>
            /// Reads a value either from this pool it it has already been read or, when not yet read,
            /// thanks to an actual reader function.
            /// </summary>
            /// <param name="actualReader">Function that will be called if the value must actually be read.</param>
            /// <returns>The value.</returns>
            public T Read(Func <ReadState, ICKBinaryReader, T> actualReader)
            {
                byte b = _r.ReadByte();

                switch (b)
                {
                case 0: return(default(T));

                case 1: return(_objects[_r.ReadNonNegativeSmallInt32()]);

                default:
                {
                    var s = new ReadState(this, b);
                    return(s.SetReadResult(actualReader(s, _r)));
                }
                }
            }