/[RomCheater]/trunk/RomCheater.Logging/EnumNameValuePair.cs
ViewVC logotype

Annotation of /trunk/RomCheater.Logging/EnumNameValuePair.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 111 - (hide annotations) (download)
Thu May 10 13:55:44 2012 UTC (8 years, 8 months ago) by william
File size: 1030 byte(s)
add support for implictly converting binary bit flags to enum-like values

1 william 111 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5    
6     namespace RomCheater.Logging
7     {
8     public class EnumNameValuePair<TName,TValue>
9     where TValue : IConvertible
10     {
11     #region implicit operators
12     public static implicit operator TValue(EnumNameValuePair<TName, TValue> o) { return o.Value; }
13     public static implicit operator TName(EnumNameValuePair<TName, TValue> o) { return o.Name; }
14     #endregion
15     public EnumNameValuePair() : this(default(TName)) { }
16     public EnumNameValuePair(TName name) : this(name, default(TValue)) { }
17     public EnumNameValuePair(TName name, TValue value)
18     {
19     this.Name = name;
20     this.Value = value;
21     }
22     public TName Name { get; protected set; }
23     public TValue Value { get; protected set; }
24     public override string ToString()
25     {
26     return string.Format("[{0}: 0x{1:x8}]", Name.ToString(), Value);
27     }
28     }
29     }

  ViewVC Help
Powered by ViewVC 1.1.22