/// <summary>
        /// Adds the specified extension to the registry
        /// </summary>
        public void Add(Extension extension)
        {
            ProtoPreconditions.CheckNotNull(extension, nameof(extension));

            extensions.Add(new ObjectIntPair <Type>(extension.TargetType, extension.FieldNumber), extension);
        }
 /// <summary>
 /// Converts the given message into a byte string in protobuf encoding.
 /// </summary>
 /// <param name="message">The message to convert.</param>
 /// <returns>The message data as a byte string.</returns>
 public static ByteString ToByteString(this IMessage message)
 {
     ProtoPreconditions.CheckNotNull(message, "message");
     return(ByteString.AttachBytes(message.ToByteArray()));
 }
        /// <summary>
        /// Removes the specified extension from the set
        /// </summary>
        /// <param name="item">The extension</param>
        /// <returns><c>true</c> if the extension was removed, otherwise <c>false</c></returns>
        public bool Remove(Extension item)
        {
            ProtoPreconditions.CheckNotNull(item, nameof(item));

            return(extensions.Remove(new ObjectIntPair <Type>(item.TargetType, item.FieldNumber)));
        }