CheckNoSpaceLeft() публичный Метод

Verifies that SpaceLeft returns zero. It's common to create a byte array that is exactly big enough to hold a message, then write to it with a CodedOutputStream. Calling CheckNoSpaceLeft after writing verifies that the message was actually as big as expected, which can help bugs.
public CheckNoSpaceLeft ( ) : void
Результат void
Пример #1
0
            internal ByteString Build()
            {
                output.CheckNoSpaceLeft();

                // We can be confident that the CodedOutputStream will not modify the
                // underlying bytes anymore because it already wrote all of them.  So,
                // no need to make a copy.
                return(new ByteString(buffer));
            }
Пример #2
0
        /// <summary>
        /// Serializes the message to a byte array and returns it. This is
        /// just a trivial wrapper around WriteTo(ICodedOutputStream).
        /// </summary>
        /// <returns></returns>
        public byte[] ToByteArray()
        {
            byte[]            data   = new byte[SerializedSize];
            CodedOutputStream output = CodedOutputStream.CreateInstance(data);

            WriteTo(output);
            output.CheckNoSpaceLeft();
            return(data);
        }
Пример #3
0
        public byte[] ToByteArray()
        {
            byte[]            array             = new byte[this.SerializedSize];
            CodedOutputStream codedOutputStream = CodedOutputStream.CreateInstance(array);

            this.WriteTo(codedOutputStream);
            codedOutputStream.CheckNoSpaceLeft();
            return(array);
        }