Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thanks for your comments guys, I took them into consideration, and found a solution that (while not the best) will work for what I need done.</p> <p>I ended up created a Description attribute that I added to each enum value, then creating a 'GetDescription' extension method on Enum. Then, whenever I flag an Error, its description gets writen out to the console/file/window or w/e.</p> <p>I suppose I should have exposed some more of ILog's methods for this solution to have been found.</p> <p>New FlagError Method:</p> <pre><code>public void FlagError (Enum errorCode) { int errorValue = Convert.ToInt32 (errorCode); if (errorValue == 0 || errorValue == int.MinValue || errorValue != (errorValue &amp; -errorValue)) { WriteError ("ErrorCode {0}: {1}", errorValue, errorCode.GetDescription ()); m_errorCode = int.MinValue; throw new IndexOutOfRangeException (); } if ((m_errorCode &amp; errorValue) == errorValue) return; WriteError ("ErrorCode {0}: {1}", errorValue, errorCode.GetDescription ()); m_errorCode += errorValue; } </code></pre> <p>GetDescription Extention Method:</p> <pre><code>public static string GetDescription (this Enum @enum) { StringBuilder builder; var descriptionAttributes = @enum.GetType () .GetCustomAttributes ( typeof (DescriptionAttribute), false) as DescriptionAttribute []; if (descriptionAttributes == null || descriptionAttributes.Length == 0) return string.Empty; builder = new StringBuilder (); foreach (DescriptionAttribute description in descriptionAttributes) { builder.Append (description.Description); builder.AppendLine (); } return builder.ToString (); } </code></pre> <p>Description Attribute:</p> <pre><code>public sealed class DescriptionAttribute : Attribute { public DescriptionAttribute (string description) { m_description = description; } public string Description { get { return m_description; } } private readonly string m_description; } </code></pre> <p>If anyone has any additional input, I would love to hear it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload