コード例 #1
0
        /// <summary>
        /// Returns the header with the specified ID if present in the
        /// collection or <c>null</c>.
        /// </summary>
        /// <param name="id">The <see cref="MsgHeaderID" /></param>
        /// <returns>The requested <see cref="MsgHeader" /> or <c>null</c>.</returns>
        public MsgHeader this[MsgHeaderID id]
        {
            get
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].HeaderID == id)
                    {
                        return(list[i]);
                    }
                }

                return(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="headerID">The header ID.</param>
        /// <param name="contents">The header contents.</param>
        public MsgHeader(MsgHeaderID headerID, byte[] contents)
        {
            if (contents == null)
            {
                throw new ArgumentNullException("contents");
            }

            if (contents.Length > ushort.MaxValue)
            {
                throw new ArgumentException("[contents] cannot exceed 65535 bytes.");
            }

            this.HeaderID = headerID;
            this.Contents = contents;
        }
コード例 #3
0
 /// <summary>
 /// Adds or modifies a message header in the collection.
 /// </summary>
 /// <param name="headerID">The <see cref="MsgHeaderID" /></param>
 /// <param name="contents">The header value encoded into a byte array.</param>
 /// <exception cref="InvalidOperationException">Thrown if a header with this ID is already present.</exception>
 public void Set(MsgHeaderID headerID, byte[] contents)
 {
     Set(new MsgHeader(headerID, contents));
 }