ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater.Logging/EnumNameValuePair.cs
Revision: 111
Committed: Thu May 10 13:55:44 2012 UTC (11 years, 6 months ago) by william
File size: 1030 byte(s)
Log Message:
add support for implictly converting binary bit flags to enum-like values

File Contents

# User Rev Content
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     }