/[RomCheater]/trunk/RomCheater/Docking/MemorySearch/DataTypeConverter.cs
ViewVC logotype

Contents of /trunk/RomCheater/Docking/MemorySearch/DataTypeConverter.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Tue Jun 5 00:13:29 2012 UTC (8 years, 3 months ago) by william
File size: 2858 byte(s)
+ import search code from PCSX2 Ram Dump (no need to re-invent the wheel...plus it cuts down on code refactoring time)

1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace RomCheater.Docking.MemorySearch
7 {
8 public class DataTypeConverter
9 {
10 public DataTypeConverter()
11 {
12 this.Value = 0;
13 }
14 public DataTypeConverter(object value)
15 {
16 this.Value = value;
17 }
18 private object _Value;
19 public object Value
20 {
21 get { return _Value; }
22 set { _Value = value; }
23 }
24 }
25 #region DataTypeConverter Extensions
26 public static class DataTypeConverterExtensions
27 {
28 private static object GetSafeConversionString(this DataTypeConverter val)
29 {
30 //StringBuilder builder = new StringBuilder();
31 object vals = 0;
32 if (val.Value != null) vals = val.Value;
33 //builder.Append(vals.ToString());
34 //return builder.ToString();
35 return vals;
36 }
37 public static byte ToByte(this DataTypeConverter val)
38 {
39 return Convert.ToByte(val.GetSafeConversionString());
40 }
41 public static sbyte ToSByte(this DataTypeConverter val)
42 {
43 return Convert.ToSByte(val.GetSafeConversionString());
44 }
45 public static Int16 ToInt16(this DataTypeConverter val)
46 {
47 return Convert.ToInt16(val.GetSafeConversionString());
48 }
49 public static Int32 ToInt32(this DataTypeConverter val)
50 {
51 return Convert.ToInt32(val.GetSafeConversionString());
52 }
53 public static Int64 ToInt64(this DataTypeConverter val)
54 {
55 return Convert.ToInt64(val.GetSafeConversionString());
56 }
57 public static UInt16 ToUInt16(this DataTypeConverter val)
58 {
59 return Convert.ToUInt16(val.GetSafeConversionString());
60 }
61 public static UInt32 ToUInt32(this DataTypeConverter val)
62 {
63 return Convert.ToUInt32(val.GetSafeConversionString());
64 }
65 public static UInt64 ToUInt64(this DataTypeConverter val)
66 {
67 return Convert.ToUInt64(val.GetSafeConversionString());
68 }
69 public static Single ToSingle(this DataTypeConverter val)
70 {
71 return Convert.ToSingle(val.ToUInt32());
72 }
73 public static double ToDouble(this DataTypeConverter val)
74 {
75 return Convert.ToDouble(val.ToUInt32());
76 }
77 public static decimal ToDecimal(this DataTypeConverter val)
78 {
79 return Convert.ToDecimal(val.ToUInt32());
80 }
81 //public static string ToString(this MaskedHexBox val)
82 //{
83 // return Convert.ToString(val.ToUInt32(), 16);
84 //}
85 }
86 #endregion
87 }

  ViewVC Help
Powered by ViewVC 1.1.22