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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 249 - (show annotations) (download)
Sun Jun 3 16:09:05 2012 UTC (8 years, 6 months ago) by william
File size: 5116 byte(s)
change address from uint to int

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 interface IResultDataType
9 {
10 int Address { get; set; }
11 bool IsFrozen { get; set; }
12 bool IsUnsigned { get; set; }
13 object Value { get; set; }
14 SearchDataTypes ValueType { get; set; }
15 }
16 public class ResultDataType : IResultDataType
17 {
18
19 public ResultDataType(int address) { this.Address = address; }
20 public ResultDataType(int address, bool isfrozen) : this(address) { this.IsFrozen = isfrozen; }
21 public ResultDataType(int address, bool isfrozen, object value, SearchDataTypes ValueType) : this(address, isfrozen, value) { this.ValueType = ValueType; }
22 public ResultDataType(int address, bool isfrozen, object value)
23 : this(address, isfrozen)
24 {
25 this.Value = value;
26 this.ValueType = SearchDataTypes._8bits;
27 if (value.GetType() == typeof(sbyte) || value.GetType() == typeof(byte))
28 {
29 this.ValueType = SearchDataTypes._8bits;
30 }
31 else if (value.GetType() == typeof(short) || value.GetType() == typeof(ushort))
32 {
33 this.ValueType = SearchDataTypes._16bits;
34 }
35 else if (value.GetType() == typeof(int) || value.GetType() == typeof(uint))
36 {
37 this.ValueType = SearchDataTypes._32bits;
38 }
39 else if (value.GetType() == typeof(long) || value.GetType() == typeof(ulong))
40 {
41 this.ValueType = SearchDataTypes._64bits;
42 }
43 else
44 {
45 this.ValueType = SearchDataTypes._8bits;
46 }
47 this.IsUnsigned = true;
48 }
49 public ResultDataType(int address, bool isfrozen, byte value) : this(address, isfrozen) { this.Value = (object)value; this.ValueType = SearchDataTypes._8bits; this.IsUnsigned = true; }
50 public ResultDataType(int address, bool isfrozen, sbyte value) : this(address, isfrozen) { this.Value = (object)value; this.ValueType = SearchDataTypes._8bits; }
51 public ResultDataType(int address, bool isfrozen, ushort value) : this(address, isfrozen) { this.Value = (object)value; this.ValueType = SearchDataTypes._16bits; this.IsUnsigned = true; }
52 public ResultDataType(int address, bool isfrozen, short value) : this(address, isfrozen) { this.Value = (object)value; this.ValueType = SearchDataTypes._16bits; }
53 public ResultDataType(int address, bool isfrozen, uint value) : this(address, isfrozen) { this.Value = (object)value; this.ValueType = SearchDataTypes._32bits; this.IsUnsigned = true; }
54 public ResultDataType(int address, bool isfrozen, int value) : this(address, isfrozen) { this.Value = (object)value; this.ValueType = SearchDataTypes._32bits; }
55 public ResultDataType(int address, bool isfrozen, ulong value) : this(address, isfrozen) { this.Value = (object)value; this.ValueType = SearchDataTypes._64bits; this.IsUnsigned = true; }
56 public ResultDataType(int address, bool isfrozen, long value) : this(address, isfrozen) { this.Value = (object)value; this.ValueType = SearchDataTypes._64bits; }
57
58 #region IResultDataType Members
59
60 private int _address;
61 private bool _isfrozen;
62 private object _value;
63 private SearchDataTypes _valuetype;
64 private bool _IsUnsigned = false;
65
66 public int Address { get { return _address; } set { _address = value; } }
67 public bool IsFrozen { get { return _isfrozen; } set { _isfrozen = value; } }
68 public object Value { get { return _value; } set { _value = value; } }
69 public SearchDataTypes ValueType { get { return _valuetype; } set { _valuetype = value; } }
70
71 public bool IsUnsigned { get { return _IsUnsigned; } set { _IsUnsigned = value; } }
72 #endregion
73
74 public override string ToString()
75 {
76 string value_out = "";
77
78 switch (this.ValueType)
79 {
80 case SearchDataTypes._8bits:
81 value_out = string.Format("0x{0:x2}", this.Value);
82 break;
83 case SearchDataTypes._16bits:
84 value_out = string.Format("0x{0:x4}", this.Value);
85 break;
86 case SearchDataTypes._32bits:
87 value_out = string.Format("0x{0:x8}", this.Value);
88 break;
89 case SearchDataTypes._64bits:
90 value_out = string.Format("0x{0:x16}", this.Value);
91 break;
92 }
93
94 StringBuilder builder = new StringBuilder();
95 builder.Append("{");
96 builder.AppendFormat("0x{0:x8},{1},{2}",
97 this.Address,
98 value_out,
99 this.IsFrozen);
100 builder.Append("}");
101 return builder.ToString();
102 }
103 }
104 }

  ViewVC Help
Powered by ViewVC 1.1.22