You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jg...@apache.org on 2009/02/17 20:27:23 UTC

svn commit: r745205 - in /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src: main/csharp/CommonAssemblyInfo.cs main/csharp/OpenWire/OpenWireBinaryWriter.cs main/csharp/State/ConnectionState.cs test/csharp/CommonAssemblyInfo.cs

Author: jgomes
Date: Tue Feb 17 19:27:22 2009
New Revision: 745205

URL: http://svn.apache.org/viewvc?rev=745205&view=rev
Log:
Applied patch submitted by Jan Willem.  Thanks, Jan!
Fixes [AMQNET-128]. (See https://issues.apache.org/activemq/browse/AMQNET-128)

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/State/ConnectionState.cs
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs?rev=745205&r1=745204&r2=745205&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/CommonAssemblyInfo.cs Tue Feb 17 19:27:22 2009
@@ -5,7 +5,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.3053
+//     Runtime Version:2.0.50727.3082
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs?rev=745205&r1=745204&r2=745205&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/OpenWire/OpenWireBinaryWriter.cs Tue Feb 17 19:27:22 2009
@@ -14,26 +14,26 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-using Apache.NMS.ActiveMQ.Commands;
 using System;
 using System.Collections;
 using System.IO;
-using System.Text;
 
 namespace Apache.NMS.ActiveMQ.OpenWire
 {
-    /// <summary>
+	/// <summary>
 	/// A BinaryWriter that switches the endian orientation of the write opperations so that they
 	/// are compatible with marshalling used by OpenWire.
-    /// </summary>
+	/// </summary>
 	[CLSCompliant(false)]
-    public class OpenWireBinaryWriter : BinaryWriter
-    {
-		
-		public OpenWireBinaryWriter(Stream output) : base(output)
+	public class OpenWireBinaryWriter : BinaryWriter
+	{
+		public const int MAXSTRINGLEN = short.MaxValue;
+
+		public OpenWireBinaryWriter(Stream output)
+			: base(output)
 		{
 		}
-				
+
 		/// <summary>
 		/// Method Write
 		/// </summary>
@@ -42,7 +42,7 @@
 		{
 			base.Write(EndianSupport.SwitchEndian(value));
 		}
-		
+
 		/// <summary>
 		/// Method Write
 		/// </summary>
@@ -51,7 +51,7 @@
 		{
 			base.Write(EndianSupport.SwitchEndian(value));
 		}
-		
+
 		/// <summary>
 		/// Method Write
 		/// </summary>
@@ -61,7 +61,7 @@
 			int x = EndianSupport.SwitchEndian(value);
 			base.Write(x);
 		}
-		
+
 		/// <summary>
 		/// Method Write
 		/// </summary>
@@ -71,12 +71,13 @@
 		public override void Write(char[] chars, int index, int count)
 		{
 			char[] t = new char[count];
-			for( int i=0; i < count; i++ ) {
-				t[index+i] = EndianSupport.SwitchEndian(t[index+i]);
+			for(int i = 0; i < count; i++)
+			{
+				t[index + i] = EndianSupport.SwitchEndian(t[index + i]);
 			}
 			base.Write(t);
 		}
-		
+
 		/// <summary>
 		/// Method Write
 		/// </summary>
@@ -85,7 +86,7 @@
 		{
 			Write(chars, 0, chars.Length);
 		}
-		
+
 		/// <summary>
 		/// Method Write
 		/// </summary>
@@ -94,18 +95,18 @@
 		{
 			base.Write(EndianSupport.SwitchEndian(value));
 		}
-				
-		
+
+
 		/// <summary>
 		/// Method Write
 		/// </summary>
 		/// <param name="ch">A  char</param>
 		public override void Write(char ch)
 		{
-			base.Write( (byte)( ( ch>>8 ) & 0xFF ) );
-			base.Write( (byte)( ch & 0xFF ) );
+			base.Write((byte) ((ch >> 8) & 0xFF));
+			base.Write((byte) (ch & 0xFF));
 		}
-		
+
 		/// <summary>
 		/// Method Write
 		/// </summary>
@@ -114,7 +115,7 @@
 		{
 			base.Write(EndianSupport.SwitchEndian(value));
 		}
-		
+
 		/// <summary>
 		/// Method Write
 		/// </summary>
@@ -123,91 +124,211 @@
 		{
 			base.Write(EndianSupport.SwitchEndian(value));
 		}
-				
-				
+
+		public override void Write(String text)
+		{
+			foreach(string textPackage in new StringPackageSplitter(text))
+			{
+				WriteString(textPackage);
+			}
+		}
+
 		/// <summary>
 		/// Method Write
 		/// </summary>
 		/// <param name="text">A  string</param>
-		public override void Write(String text)
+		private void WriteString(String text)
+		{
+			if(text != null)
+			{
+				if(text.Length > OpenWireBinaryWriter.MAXSTRINGLEN)
+				{
+					throw new IOException(String.Format("Cannot marshall string longer than: {0} characters, supplied string was: {1} characters", OpenWireBinaryWriter.MAXSTRINGLEN, text.Length));
+				}
+
+				int strlen = text.Length;
+				short utflen = 0;
+				int c = 0;
+				int count = 0;
+
+				char[] charr = text.ToCharArray();
+
+				for(int i = 0; i < strlen; i++)
+				{
+					c = charr[i];
+					if((c >= 0x0001) && (c <= 0x007F))
+					{
+						utflen++;
+					}
+					else if(c > 0x07FF)
+					{
+						utflen += 3;
+					}
+					else
+					{
+						utflen += 2;
+					}
+				}
+
+				Write((short) utflen);
+
+				byte[] bytearr = new byte[utflen];
+				for(int i = 0; i < strlen; i++)
+				{
+					c = charr[i];
+					if((c >= 0x0001) && (c <= 0x007F))
+					{
+						bytearr[count++] = (byte) c;
+					}
+					else if(c > 0x07FF)
+					{
+						bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
+						bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
+						bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+					}
+					else
+					{
+						bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
+						bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
+					}
+				}
+
+				Write(bytearr);
+
+			}
+			else
+			{
+				Write((short) -1);
+			}
+		}
+
+		/// <summary>
+		/// Method Write
+		/// </summary>
+		/// <param name="value">A  double</param>
+		public override void Write(float value)
 		{
-            if (text != null)
-            {
-				if( text.Length > short.MaxValue ) {
-					throw new IOException("Cannot marshall string longer than: "+short.MaxValue+" characters, supplied steing was: "+text.Length+" characters");
-				}
-                short strlen = (short)text.Length;
-                short utflen = 0;
-                int c, count = 0;
-                
-                char[] charr = text.ToCharArray();
-                
-                for (int i = 0; i < strlen; i++)
-                {
-                    c = charr[i];
-                    if ((c >= 0x0001) && (c <= 0x007F))
-                    {
-                        utflen++;
-                    }
-                    else if (c > 0x07FF)
-                    {
-                        utflen += 3;
-                    }
-                    else
-                    {
-                        utflen += 2;
-                    }
-                }
-                
-                Write(utflen);
-                byte[] bytearr = new byte[utflen];
-                for (int i = 0; i < strlen; i++)
-                {
-                    c = charr[i];
-                    if ((c >= 0x0001) && (c <= 0x007F))
-                    {
-                        bytearr[count++] = (byte) c;
-                    }
-                    else if (c > 0x07FF)
-                    {
-                        bytearr[count++] = (byte) (0xE0 | ((c >> 12) & 0x0F));
-                        bytearr[count++] = (byte) (0x80 | ((c >> 6) & 0x3F));
-                        bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
-                    }
-                    else
-                    {
-                        bytearr[count++] = (byte) (0xC0 | ((c >> 6) & 0x1F));
-                        bytearr[count++] = (byte) (0x80 | ((c >> 0) & 0x3F));
-                    }
-                }
-				
-                Write(bytearr);
-                
-            }
-            else
-            {
-                Write((short)-1);
-            }
-		}
-
-        /// <summary>
-        /// Method Write
-        /// </summary>
-        /// <param name="value">A  double</param>
-        public override void Write(float value)
-        {
-            base.Write(EndianSupport.SwitchEndian(value));
-        }
-		
-        /// <summary>
-        /// Method Write
-        /// </summary>
-        /// <param name="value">A  double</param>
-        public override void Write(double value)
-        {
-            base.Write(EndianSupport.SwitchEndian(value));
-        }
-		
-    }
+			base.Write(EndianSupport.SwitchEndian(value));
+		}
+
+		/// <summary>
+		/// Method Write
+		/// </summary>
+		/// <param name="value">A  double</param>
+		public override void Write(double value)
+		{
+			base.Write(EndianSupport.SwitchEndian(value));
+		}
+	}
+
+	#region StringPackageSplitter
+
+	/// <summary>
+	/// StringPackageSplitter
+	/// </summary>
+	class StringPackageSplitter : IEnumerable
+	{
+		public StringPackageSplitter(string value)
+		{
+			this.value = value;
+		}
+
+		/// <summary>
+		/// Emumerator class for StringPackageSplitter
+		/// </summary>
+		class StringPackageSplitterEnumerator : IEnumerator
+		{
+			/// <summary>
+			/// </summary>
+			/// <param name="parent"></param>
+			public StringPackageSplitterEnumerator(StringPackageSplitter parent)
+			{
+				this.parent = parent;
+			}
+
+			private int Position = -1;
+			private StringPackageSplitter parent;
+
+			#region IEnumerator Members
+
+			public string Current
+			{
+				get
+				{
+					int delta = parent.value.Length - Position;
+
+					if(delta >= OpenWireBinaryWriter.MAXSTRINGLEN)
+					{
+						return parent.value.Substring(Position, OpenWireBinaryWriter.MAXSTRINGLEN);
+					}
+					else
+					{
+						return parent.value.Substring(Position, delta);
+					}
+				}
+			}
+
+			#endregion
+
+			#region IDisposable Members
+
+			public void Dispose()
+			{
+			}
+
+			#endregion
+
+			#region IEnumerator Members
+
+			object IEnumerator.Current
+			{
+				get { return parent.value.Substring(Position, OpenWireBinaryWriter.MAXSTRINGLEN); }
+			}
+
+			public bool MoveNext()
+			{
+				if(parent.value == null)
+				{
+					return false;
+				}
+
+				if(Position == -1)
+				{
+					Position = 0;
+					return true;
+				}
+
+				if((Position + OpenWireBinaryWriter.MAXSTRINGLEN) < parent.value.Length)
+				{
+					Position += OpenWireBinaryWriter.MAXSTRINGLEN;
+					return true;
+				}
+				else
+				{
+					return false;
+				}
+			}
+
+			public void Reset()
+			{
+				Position = -1;
+			}
+
+			#endregion
+		}
+
+		private String value;
+
+		#region IEnumerable Members
+
+		IEnumerator IEnumerable.GetEnumerator()
+		{
+			return new StringPackageSplitterEnumerator(this);
+		}
+
+		#endregion
+	}
+
+	#endregion // END StringPackageSplitter
 }
 

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/State/ConnectionState.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/State/ConnectionState.cs?rev=745205&r1=745204&r2=745205&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/State/ConnectionState.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/State/ConnectionState.cs Tue Feb 17 19:27:22 2009
@@ -127,7 +127,7 @@
 					}
 					System.Diagnostics.Debug.Assert(false,
 						string.Format("Session '{0}' did not exist in the sessions collection.\n\nSessions:-\n{1}", id, sessionList));
-					throw;
+					throw ex;
 				}
 				#endif
 			}

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs?rev=745205&r1=745204&r2=745205&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/test/csharp/CommonAssemblyInfo.cs Tue Feb 17 19:27:22 2009
@@ -5,7 +5,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.3053
+//     Runtime Version:2.0.50727.3082
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.