Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Maybe someone will find this useful as well:</p> <pre><code>/// &lt;summary&gt; /// Represents your player class. /// &lt;/summary&gt; class Player { /// &lt;summary&gt; /// Gets or sets the health of the player. /// &lt;/summary&gt; [DebugExtensions.DebugMePlease()] public int Health { get; set; } /// &lt;summary&gt; /// Gets or sets the name of the player. /// &lt;/summary&gt; public string Name { get; set; } /// &lt;summary&gt; /// Gets a string representation of the player object. /// &lt;/summary&gt; /// &lt;returns&gt;The player object as string representation.&lt;/returns&gt; public override string ToString() { return this.Name; } } /// &lt;summary&gt; /// Contains some extensions useful for debugging. /// &lt;/summary&gt; public static class DebugExtensions { /// &lt;summary&gt; /// Represents our custom attribute called "DebugMePlease". /// Properties marked with this attribute will be printed automatically. /// &lt;/summary&gt; public class DebugMePlease : Attribute { } /// &lt;summary&gt; /// Continas all objects that shall be monitored. /// &lt;/summary&gt; public static List&lt;object&gt; DebugList { get; set; } /// &lt;summary&gt; /// Initializes static members of the &lt;see cref="DebugExtensions"/&gt; class. /// &lt;/summary&gt; static DebugExtensions() { DebugList = new List&lt;object&gt;(); } /// &lt;summary&gt; /// Prints the values of all objects in the debugList. /// &lt;/summary&gt; public static void Print() { foreach (object o in DebugList) { var members = from member in o.GetType().GetProperties() from attribute in member.GetCustomAttributes(typeof(DebugMePlease), true) select member; foreach (var z in members) { Console.WriteLine(string.Format("{0}, {1}: {2}", o.ToString(), z.Name, z.GetValue(o))); } } } } /// &lt;summary&gt; /// Contains the entry point of our application. /// &lt;/summary&gt; public class Program { /// &lt;summary&gt; /// The entry point of our application. /// &lt;/summary&gt; /// &lt;param name="args"&gt;Possibly specified command line arguments.&lt;/param&gt; public static void Main(string[] args) { Player t = new Player(); t.Name = "Chuck Norris"; t.Health = int.MaxValue; // Becaus it's Chuck Norris ;-) // Add the object to the debug list. DebugExtensions.DebugList.Add(t); // Print all properties marked with the "DebugMePlease" attribute. DebugExtensions.Print(); // Change something. t.Health = 0; // Print again and hopefully be happy. DebugExtensions.Print(); Console.ReadLine(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    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