/// <summary>
 /// Returns a user-friendly name for an accelerator type.
 /// </summary>
 /// <param name="acceleratorType">The accelerator to return a name for.</param>
 /// <returns>A user friendly name.</returns>
 /// <remarks>
 /// Adapted from https://codereview.stackexchange.com/questions/157871/method-that-returns-description-attribute-of-enum-value.</remarks>
 public static string ToFriendlyName(this AcceleratorType acceleratorType)
 {
     return
         (acceleratorType
          .GetType()
          .GetMember(acceleratorType.ToString())
          .FirstOrDefault()
          ?.GetCustomAttribute <DescriptionAttribute>()
          ?.Description
          ?? acceleratorType.ToString());
 }
示例#2
0
 /// <summary>
 /// Prints general header information that should appear at the top.
 /// </summary>
 /// <param name="writer">The target text writer to write to.</param>
 protected virtual void PrintHeader(TextWriter writer)
 {
     writer.Write("Device: ");
     writer.WriteLine(Name);
     writer.Write("  Accelerator Type:                        ");
     writer.WriteLine(AcceleratorType.ToString());
 }