You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2007/01/12 17:29:50 UTC

svn commit: r495630 - in /incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire: EndianSupport.cs OpenWireBinaryReader.cs OpenWireBinaryWriter.cs

Author: chirino
Date: Fri Jan 12 08:29:49 2007
New Revision: 495630

URL: http://svn.apache.org/viewvc?view=rev&rev=495630
Log:
Applied patch in AMQ-866

Modified:
    incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/EndianSupport.cs
    incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryReader.cs
    incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryWriter.cs

Modified: incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/EndianSupport.cs
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/EndianSupport.cs?view=diff&rev=495630&r1=495629&r2=495630
==============================================================================
--- incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/EndianSupport.cs (original)
+++ incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/EndianSupport.cs Fri Jan 12 08:29:49 2007
@@ -93,7 +93,28 @@
 				(((ulong)( (byte)(x >> 48) )) << 8  ) |
 				(((ulong)( (byte)(x >> 56) )) );
         }
-		
-	}
+
+        public static double SwitchEndian(double x)
+        {
+            MemoryStream ms = new MemoryStream();
+            BinaryWriter bw = new BinaryWriter(ms);
+            bw.Write(x);
+            bw.Flush();
+            ms = new MemoryStream(SwitchEndian(ms.ToArray()));
+            BinaryReader br = new BinaryReader(ms);
+            return br.ReadDouble();           
+        }
+
+        public static byte[] SwitchEndian(byte[] x)
+        {
+            byte[] rc = new byte[x.Length];
+            int j = x.Length-1;
+            for(int i=0; i < x.Length; i++ ) {
+                rc[i] = x[j];
+                j--;
+            }
+            return rc;
+        }
+    }
 }
 

Modified: incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryReader.cs
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryReader.cs?view=diff&rev=495630&r1=495629&r2=495630
==============================================================================
--- incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryReader.cs (original)
+++ incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryReader.cs Fri Jan 12 08:29:49 2007
@@ -224,8 +224,12 @@
             // TODO: implement a better exception
             return new IOException("Data format error!");
         }
-		
-		
+
+        public override double ReadDouble()
+        {
+            return EndianSupport.SwitchEndian(base.ReadDouble());
+        }
+
 	}
 }
 

Modified: incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryWriter.cs
URL: http://svn.apache.org/viewvc/incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryWriter.cs?view=diff&rev=495630&r1=495629&r2=495630
==============================================================================
--- incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryWriter.cs (original)
+++ incubator/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/OpenWire/OpenWireBinaryWriter.cs Fri Jan 12 08:29:49 2007
@@ -189,8 +189,16 @@
                 Write((short)-1);
             }
 		}
-    }
-	
-	
+
+        /// <summary>
+        /// Method Write
+        /// </summary>
+        /// <param name="value">A  double</param>
+        public override void Write(double value)
+        {
+            base.Write(EndianSupport.SwitchEndian(value));
+        }
+		
+    }	
 }