|
namespace Storm.Plugins.Classes
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Storm;
using Storm.Plugins;
using Storm.Plugins.Attributes;
using Storm.Plugins.Classes;
using Storm.Plugins.Enums;
using Storm.Plugins.Interfaces;
/// <summary>
/// Class used for storing debug messages from the PluginManager.
/// </summary>
public static class Console
{
#region Fields
// The one and only text member.
private static string _text = "";
// List fields.
private static List<string> _normals = new List<string>();
private static List<string> _warnings = new List<string>();
private static List<string> _errors = new List<string>();
public static event EventHandler TextAdded;
#endregion
#region Properties
/// <summary>
/// Gets the text of the Console.
/// </summary>
public static string Text
{ get { return _text; } }
/// <summary>
/// Gets a list of all normal messages in the Console.
/// </summary>
public static List<string> NormalMessages
{ get { return _normals; } }
/// <summary>
/// Gets a list of all messages containing warnings in the Console.
/// </summary>
public static List<string> WarningMessages
{ get { return _warnings; } }
/// <summary>
/// Gets a list of all messages containing errors in the Console.
/// </summary>
public static List<string> ErrorMessages
{ get { return _errors; } }
#endregion
#region Methods
/// <summary>
/// Adds a message to the console.
/// </summary>
/// <param name="message">Message to add.</param>
/// <param name="messageType">MessageType of the message to add. This determines the message's prefix.</param>
public static void AddMessage(string message, MessageType messageType)
{
if (messageType == MessageType.Normal)
{
_text += message + "\r\n";
_normals.Add(message);
}
else if (messageType == MessageType.Warning)
{
_text += "Warning: " + message + "\r\n";
_warnings.Add(message);
}
else if (messageType == MessageType.Error)
{
_text += "Error: " + message + "\r\n";
_errors.Add(message);
}
if (TextAdded != null)
TextAdded(null, EventArgs.Empty);
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.