示例#1
0
        /// <summary>
        /// Adds a list field to the current active message. A list field is a space separated list of instrument references. The first position in the value can be:
        /// <para>'+'   (the supplied list should be added to the current value)<br/>
        /// '-' (the supplied list should be removed from the current value)<br/>
        /// '=' (the supplied list is the current value)</para>
        /// If there is no such prefix it is interpreted as if it was prefixed with a '='.  There is a current soft limit of 1.000.000 instrument references per list.
        /// </summary>
        /// <param name="tag">The field tag.</param>
        /// <param name="value">The list field value.</param>
        /// <returns><see langword="true" /> if the field was successfully added, or <see langword="false" /> if the value could not be added (because there was no more memory, the message handle does not contain any messages, or the supplied value is not of the type specified).</returns>
        /// <exception cref="ObjectDisposedException">The <see cref="Message"/> instance has been disposed.</exception>
        /// <remarks>The corresponding native function is mdf_message_add_list.</remarks>
        public bool AddList(uint tag, string value)
        {
            ThrowIfDisposed();
            if (value == null)
            {
                return(_nativeImplementation.mdf_message_add_list(Handle, tag, IntPtr.Zero) == 1);
            }

            byte *bytes = stackalloc byte[value.Length + 1];

            if (!TryGetAsciiBytes(value, bytes))
            {
                return(false);
            }
            return(_nativeImplementation.mdf_message_add_list(Handle, tag, (IntPtr)bytes) == 1);
        }