/[RomCheater]/trunk/RomCheater.Core/BitTools.cs
ViewVC logotype

Diff of /trunk/RomCheater.Core/BitTools.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.Core/BitTools.cs	2013/06/05 09:01:44	532
+++ trunk/RomCheater.Core/BitTools.cs	2013/06/05 09:36:14	534
@@ -143,32 +143,34 @@
             switch (name)
             {
                 case "byte":  // unsigned byte
-                    list = new List<T>();
-                    using (MemoryStream ms = new MemoryStream(data))
-                    {
-                        using (BinaryReader br = new BinaryReader(ms))
-                        {
-                            while (br.BaseStream.Position < br.BaseStream.Length) { if (cancelmethod.Invoke()) { break; } list.Add((T)Convert.ChangeType(br.ReadByte(), typeof(T))); }
-                        }
-                    }
-                    break;
+                    //list = new List<T>();
+                    //using (MemoryStream ms = new MemoryStream(data))
+                    //{
+                    //    using (BinaryReader br = new BinaryReader(ms))
+                    //    {
+                    //        while (br.BaseStream.Position < br.BaseStream.Length) { list.Add((T)Convert.ChangeType(br.ReadByte(), typeof(T))); if (cancelmethod.Invoke()) { break; } }
+                    //    }
+                    //}
+                    //break;
+                    throw new NotSupportedException("Conversion from byte[] to byte[] is not supported because the data can be used without conversion.");
                 case "sbyte": // signed byte
-                    list = new List<T>();
-                    using (MemoryStream ms = new MemoryStream(data))
-                    {
-                        using (BinaryReader br = new BinaryReader(ms))
-                        {
-                            while (br.BaseStream.Position < br.BaseStream.Length) { if (cancelmethod.Invoke()) { break; } list.Add((T)Convert.ChangeType(br.ReadSByte(), typeof(T))); }
-                        }
-                    }
-                    break;
+                    //list = new List<T>();
+                    //using (MemoryStream ms = new MemoryStream(data))
+                    //{
+                    //    using (BinaryReader br = new BinaryReader(ms))
+                    //    {
+                    //        while (br.BaseStream.Position < br.BaseStream.Length) { list.Add((T)Convert.ChangeType(br.ReadSByte(), typeof(T))); if (cancelmethod.Invoke()) { break; } }
+                    //    }
+                    //}
+                    //break;
+                    throw new NotSupportedException("Conversion from byte[] to sbyte[] is not supported because the data can be used without conversion.");
                 case "int16": // short  
                     list = new List<T>();
                     using (MemoryStream ms = new MemoryStream(data))
                     {
                         using (BinaryReader br = new BinaryReader(ms))
                         {
-                            while (br.BaseStream.Position < br.BaseStream.Length) { if (cancelmethod.Invoke()) { break; } list.Add((T)Convert.ChangeType(br.ReadInt16(), typeof(T))); }
+                            while (br.BaseStream.Position < br.BaseStream.Length) { list.Add((T)Convert.ChangeType(br.ReadInt16(), typeof(T))); if (cancelmethod.Invoke()) { break; } }
                         }
                     }
                     break;
@@ -178,7 +180,7 @@
                     {
                         using (BinaryReader br = new BinaryReader(ms))
                         {
-                            while (br.BaseStream.Position < br.BaseStream.Length) { if (cancelmethod.Invoke()) { break; } list.Add((T)Convert.ChangeType(br.ReadUInt16(), typeof(T))); }
+                            while (br.BaseStream.Position < br.BaseStream.Length) { list.Add((T)Convert.ChangeType(br.ReadUInt16(), typeof(T))); if (cancelmethod.Invoke()) { break; } }
                         }
                     }
                     break;
@@ -188,7 +190,7 @@
                     {
                         using (BinaryReader br = new BinaryReader(ms))
                         {
-                            while (br.BaseStream.Position < br.BaseStream.Length) { if (cancelmethod.Invoke()) { break; } list.Add((T)Convert.ChangeType(br.ReadInt32(), typeof(T))); }
+                            while (br.BaseStream.Position < br.BaseStream.Length) {  list.Add((T)Convert.ChangeType(br.ReadInt32(), typeof(T))); if (cancelmethod.Invoke()) { break; } }
                         }
                     }
                     break;
@@ -198,7 +200,7 @@
                     {
                         using (BinaryReader br = new BinaryReader(ms))
                         {
-                            while (br.BaseStream.Position < br.BaseStream.Length) { if (cancelmethod.Invoke()) { break; } list.Add((T)Convert.ChangeType(br.ReadUInt32(), typeof(T))); }
+                            while (br.BaseStream.Position < br.BaseStream.Length) {  list.Add((T)Convert.ChangeType(br.ReadUInt32(), typeof(T))); if (cancelmethod.Invoke()) { break; } }
                         }
                     }
                     break;
@@ -208,7 +210,7 @@
                     {
                         using (BinaryReader br = new BinaryReader(ms))
                         {
-                            while (br.BaseStream.Position < br.BaseStream.Length) { if (cancelmethod.Invoke()) { break; } list.Add((T)Convert.ChangeType(br.ReadInt64(), typeof(T))); }
+                            while (br.BaseStream.Position < br.BaseStream.Length) {list.Add((T)Convert.ChangeType(br.ReadInt64(), typeof(T))); if (cancelmethod.Invoke()) { break; } }
                         }
                     }
                     break;
@@ -218,7 +220,7 @@
                     {
                         using (BinaryReader br = new BinaryReader(ms))
                         {
-                            while (br.BaseStream.Position < br.BaseStream.Length) { if (cancelmethod.Invoke()) { break; } list.Add((T)Convert.ChangeType(br.ReadUInt64(), typeof(T))); }
+                            while (br.BaseStream.Position < br.BaseStream.Length) { list.Add((T)Convert.ChangeType(br.ReadUInt64(), typeof(T))); if (cancelmethod.Invoke()) { break; } }
                         }
                     }
                     break;

 

  ViewVC Help
Powered by ViewVC 1.1.22