/[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 526 - (show annotations) (download)
Wed Jun 5 08:03:28 2013 UTC (7 years, 3 months ago) by william
File size: 5155 byte(s)

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

  ViewVC Help
Powered by ViewVC 1.1.22