Ejemplo n.º 1
0
 /// <summary>
 /// Tests the operation of the context by adding up to 100 test messages.
 /// </summary>
 /// <remarks>
 /// <para>
 /// The only purpose of this method is to permit testing.</para>
 /// </remarks>
 /// <param name="context">The context to test.</param>
 /// <param name="count">The number of messages to add. (Limit &lt;100)</param>
 public static void LoadTestMessages(BuildContext context, int count)
 {
     if (context != null)
     {
         BuildContextEx.nmgTestContext(context.root, Math.Min(100, count));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Posts a message to the message buffer with a custom category.
 /// </summary>
 /// <param name="category">The message category.</param>
 /// <param name="message">The message to post.</param>
 /// <param name="context">The context of the message. (Optional)</param>
 public void Log(string category, string message, Object context)
 {
     if (message != null && message.Length > 0)
     {
         BuildContextEx.nmbcLog(root, string.Format("{0}: {1}{2}"
                                                    , category, message, ContextPart(context)));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Appends log messages to the current context.
        /// </summary>
        /// <param name="messages">The messages to append.</param>
        public void Log(string[] messages)
        {
            if (messages == null || messages.Length == 0)
            {
                return;
            }

            foreach (string msg in messages)
            {
                BuildContextEx.nmbcLog(root, msg);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Appends messages from the specified context to the current context.
        /// </summary>
        /// <param name="fromContext">The context to append the messages from.</param>
        public void AppendMessages(BuildContext fromContext)
        {
            if (fromContext == null || fromContext.MessageCount == 0)
            {
                return;
            }

            string[] msgs = fromContext.GetMessages();
            foreach (string msg in msgs)
            {
                BuildContextEx.nmbcLog(root, msg);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets all messages in the message buffer.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The length of the result will always equal <see cref="MessageCount"/>.
        /// </para>
        /// </remarks>
        /// <returns>
        /// All messages in the message buffer, or a zero length array if there are no messages.
        /// </returns>
        public string[] GetMessages()
        {
            byte[] buffer = new byte[MessagePoolSize];

            int messageCount = BuildContextEx.nmbcGetMessagePool(root
                                                                 , buffer
                                                                 , buffer.Length);

            if (messageCount == 0)
            {
                return(new string[0]);
            }

            string aggregateMsg =
                ASCIIEncoding.ASCII.GetString(buffer);

            char[] delim = { '\0' };
            return(aggregateMsg.Split(delim
                                      , StringSplitOptions.RemoveEmptyEntries));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Clears all messages from the message buffer.
 /// </summary>
 public void ResetLog()
 {
     BuildContextEx.nmbcResetLog(root);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public BuildContext()
 {
     root = BuildContextEx.nmbcAllocateContext(true);
 }