示例#1
0
        /// <summary>
        /// Adds a time field to the current active message. Please note that all times and dates are expressed in UTC. The format of value must be "HH:MM:SS" or "HH:MM:SS.mmm" (where mmm is the milliseconds). libmdf 1.0.24 accepts up to nanoseconds resolution, i.e. "HH:MM:SS.nnnnnnnnn".
        /// </summary>
        /// <param name="tag">The field tag.</param>
        /// <param name="value">The time 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_time.</remarks>
        public bool AddTime(uint tag, string value)
        {
            ThrowIfDisposed();
            if (string.IsNullOrEmpty(value))
            {
                return(false);
            }

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

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