svn commit: r834619 - in /activemq/activemq-dotnet/Apache.NMS/trunk: ./ src/main/csharp/ src/main/csharp/Util/ src/test/csharp/

View: New views
1 Messages — Rating Filter:   Alert me  

svn commit: r834619 - in /activemq/activemq-dotnet/Apache.NMS/trunk: ./ src/main/csharp/ src/main/csharp/Util/ src/test/csharp/

by jgomes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Author: jgomes
Date: Tue Nov 10 19:22:06 2009
New Revision: 834619

URL: http://svn.apache.org/viewvc?rev=834619&view=rev
Log:
Added extension methods for IMessage, IMessageProducer, and ISession.

Fixes [AMQNET-209]. (See https://issues.apache.org/activemq/browse/AMQNET-209)

Added:
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/MessageExtensions.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/MessageProducerExtensions.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/SessionExtensions.cs
Modified:
    activemq/activemq-dotnet/Apache.NMS/trunk/nant.build
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/Convert.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/XmlUtils.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs
    activemq/activemq-dotnet/Apache.NMS/trunk/vs2008-nms.csproj

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/nant.build
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/nant.build?rev=834619&r1=834618&r2=834619&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/nant.build (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/nant.build Tue Nov 10 19:22:06 2009
@@ -47,12 +47,23 @@
  </target>
 
  <target name="dependency-init" description="Initializes build dependencies">
- <assemblyfileset failonempty="true" id="dependencies">
- <include name="${current.build.framework.assembly.dir}/mscorlib.dll" />
- <include name="${current.build.framework.assembly.dir}/System.dll" />
- <include name="${current.build.framework.assembly.dir}/System.Web.dll" />
- <include name="${current.build.framework.assembly.dir}/System.Xml.dll" />
- </assemblyfileset>
+ <if test="${current.build.framework == 'net-3.5' or current.build.framework == 'mono-2.0'}">
+ <assemblyfileset failonempty="true" id="dependencies">
+ <include name="${current.build.framework.assembly.dir}/mscorlib.dll" />
+ <include name="${current.build.framework.assembly.dir}/System.dll" />
+ <include name="${current.build.framework.assembly.dir}/System.Core.dll" />
+ <include name="${current.build.framework.assembly.dir}/System.Web.dll" />
+ <include name="${current.build.framework.assembly.dir}/System.Xml.dll" />
+ </assemblyfileset>
+ </if>
+ <if test="${current.build.framework != 'net-3.5'}">
+ <assemblyfileset failonempty="true" id="dependencies">
+ <include name="${current.build.framework.assembly.dir}/mscorlib.dll" />
+ <include name="${current.build.framework.assembly.dir}/System.dll" />
+ <include name="${current.build.framework.assembly.dir}/System.Web.dll" />
+ <include name="${current.build.framework.assembly.dir}/System.Xml.dll" />
+ </assemblyfileset>
+ </if>
 
  <assemblyfileset failonempty="true" id="test.dependencies">
  <include name="${current.build.framework.assembly.dir}/mscorlib.dll" />

Added: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/MessageExtensions.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/MessageExtensions.cs?rev=834619&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/MessageExtensions.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/MessageExtensions.cs Tue Nov 10 19:22:06 2009
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Apache.NMS.Util;
+
+namespace Apache.NMS
+{
+#if NET_3_5 || MONO
+ public static class MessageExtensions
+ {
+ /// <summary>
+ /// Deserializes the object from Xml, and returns it.
+ /// </summary>
+ public static object ToObject(this IMessage message)
+ {
+ if(null != message)
+ {
+ return NMSConvert.DeserializeObjFromMessage(message);
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// Deserializes the object from Xml, and returns it.
+ /// </summary>
+ public static T ToObject<T>(this IMessage message) where T : class
+ {
+ if(null != message)
+ {
+ return (T) NMSConvert.DeserializeObjFromMessage(message);
+ }
+
+ return null;
+ }
+ }
+#endif
+}

Added: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/MessageProducerExtensions.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/MessageProducerExtensions.cs?rev=834619&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/MessageProducerExtensions.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/MessageProducerExtensions.cs Tue Nov 10 19:22:06 2009
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Text;
+using Apache.NMS.Util;
+
+namespace Apache.NMS
+{
+#if NET_3_5 || MONO
+ public static class MessageProducerExtensions
+ {
+ /// <summary>
+ /// Extension function to create a text message from an object.  The object must be serializable to XML.
+ /// </summary>
+ public static ITextMessage CreateXmlMessage(this IMessageProducer producer, object obj)
+ {
+ return CreateXmlMessage(producer, obj, Encoding.Unicode);
+ }
+
+ /// <summary>
+ /// Extension function to create a text message from an object.  The object must be serializable to XML.
+ /// </summary>
+ public static ITextMessage CreateXmlMessage(this IMessageProducer producer, object obj, Encoding encoding)
+ {
+ return NMSConvert.SerializeObjToMessage(producer.CreateTextMessage(), obj, encoding);
+ }
+
+ /// <summary>
+ /// Sends the message to the default destination for this producer.  The object must be serializable to XML.
+ /// </summary>
+ public static void Send(this IMessageProducer producer, object objMessage)
+ {
+ producer.Send(producer.CreateXmlMessage(objMessage));
+ }
+
+ /// <summary>
+ /// Sends the message to the default destination for this producer.  The object must be serializable to XML.
+ /// </summary>
+ public static void Send(this IMessageProducer producer, object objMessage, Encoding encoding)
+ {
+ producer.Send(producer.CreateXmlMessage(objMessage, encoding));
+ }
+
+ /// <summary>
+ /// Sends the message to the default destination with the explicit QoS configuration.  The object must be serializable to XML.
+ /// </summary>
+ public static void Send(this IMessageProducer producer, object objMessage, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive)
+ {
+ producer.Send(producer.CreateXmlMessage(objMessage), deliveryMode, priority, timeToLive);
+ }
+
+ /// <summary>
+ /// Sends the message to the default destination with the explicit QoS configuration.  The object must be serializable to XML.
+ /// </summary>
+ public static void Send(this IMessageProducer producer, object objMessage, Encoding encoding, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive)
+ {
+ producer.Send(producer.CreateXmlMessage(objMessage, encoding), deliveryMode, priority, timeToLive);
+ }
+
+ /// <summary>
+ /// Sends the message to the given destination
+ /// </summary>
+ public static void Send(this IMessageProducer producer, IDestination destination, object objMessage)
+ {
+ producer.Send(destination, producer.CreateXmlMessage(objMessage));
+ }
+
+ /// <summary>
+ /// Sends the message to the given destination
+ /// </summary>
+ public static void Send(this IMessageProducer producer, IDestination destination, object objMessage, Encoding encoding)
+ {
+ producer.Send(destination, producer.CreateXmlMessage(objMessage, encoding));
+ }
+
+ /// <summary>
+ /// Sends the message to the given destination with the explicit QoS configuration.  The object must be serializable to XML.
+ /// </summary>
+ public static void Send(this IMessageProducer producer, IDestination destination, object objMessage, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive)
+ {
+ producer.Send(destination, producer.CreateXmlMessage(objMessage), deliveryMode, priority, timeToLive);
+ }
+
+ /// <summary>
+ /// Sends the message to the given destination with the explicit QoS configuration.  The object must be serializable to XML.
+ /// </summary>
+ public static void Send(this IMessageProducer producer, IDestination destination, object objMessage, Encoding encoding, MsgDeliveryMode deliveryMode, MsgPriority priority, TimeSpan timeToLive)
+ {
+ producer.Send(destination, producer.CreateXmlMessage(objMessage, encoding), deliveryMode, priority, timeToLive);
+ }
+ }
+#endif
+}

Added: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/SessionExtensions.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/SessionExtensions.cs?rev=834619&view=auto
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/SessionExtensions.cs (added)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/SessionExtensions.cs Tue Nov 10 19:22:06 2009
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System.Text;
+using Apache.NMS.Util;
+
+namespace Apache.NMS
+{
+#if NET_3_5 || MONO
+ public static class SessionExtensions
+ {
+ /// <summary>
+ /// Extension function to create a text message from an object.  The object must be serializable to XML.
+ /// </summary>
+ public static ITextMessage CreateXmlMessage(this ISession session, object obj)
+ {
+ return CreateXmlMessage(session, obj, Encoding.Unicode);
+ }
+
+ /// <summary>
+ /// Extension function to create a text message from an object.  The object must be serializable to XML.
+ /// </summary>
+ public static ITextMessage CreateXmlMessage(this ISession session, object obj, Encoding encoding)
+ {
+ return NMSConvert.SerializeObjToMessage(session.CreateTextMessage(), obj, encoding);
+ }
+
+ /// <summary>
+ /// Extension function to get the destination by parsing the embedded type prefix.  Default is Queue if no prefix is
+ /// embedded in the destinationName.
+ /// </summary>
+ public static IDestination GetDestination(this ISession session, string destinationName)
+ {
+ return SessionUtil.GetDestination(session, destinationName);
+ }
+
+ /// <summary>
+ /// Extension function to get the destination by parsing the embedded type prefix.
+ /// </summary>
+ public static IDestination GetDestination(this ISession session, string destinationName, DestinationType defaultType)
+ {
+ return SessionUtil.GetDestination(session, destinationName, defaultType);
+ }
+
+ /// <summary>
+ /// Extension function to get the destination by parsing the embedded type prefix.
+ /// </summary>
+ public static IQueue GetQueue(this ISession session, string queueName)
+ {
+ return SessionUtil.GetQueue(session, queueName);
+ }
+
+ /// <summary>
+ /// Extension function to get the destination by parsing the embedded type prefix.
+ /// </summary>
+ public static ITopic GetTopic(this ISession session, string topicName)
+ {
+ return SessionUtil.GetTopic(session, topicName);
+ }
+
+ /// <summary>
+ /// Extension function to delete the named destination by parsing the embedded type prefix.  Default is Queue if no prefix is
+ /// embedded in the destinationName.
+ /// </summary>
+ public static void DeleteDestination(this ISession session, string destinationName)
+ {
+ SessionUtil.DeleteDestination(session, destinationName);
+ }
+
+ /// <summary>
+ /// Extension function to delete the named destination by parsing the embedded type prefix.
+ /// </summary>
+ public static void DeleteDestination(this ISession session, string destinationName, DestinationType defaultType)
+ {
+ SessionUtil.DeleteDestination(session, destinationName, defaultType);
+ }
+
+ /// <summary>
+ /// Extension function to delete the named destination by parsing the embedded type prefix.
+ /// </summary>
+ public static void DeleteQueue(this ISession session, string queueName)
+ {
+ SessionUtil.DeleteDestination(session, queueName);
+ }
+
+ /// <summary>
+ /// Extension function to delete the named destination by parsing the embedded type prefix.
+ /// </summary>
+ public static void DeleteTopic(this ISession session, string topicName)
+ {
+ SessionUtil.DeleteDestination(session, topicName);
+ }
+ }
+#endif
+}

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/Convert.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/Convert.cs?rev=834619&r1=834618&r2=834619&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/Convert.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/Convert.cs Tue Nov 10 19:22:06 2009
@@ -13,117 +13,168 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */
+ */
+
 using System;
-using System.Reflection;
-
-namespace Apache.NMS.Util
-{
-    public class NMSConvert
-    {
-        /// <summary>
-        /// Convert the acknowledgment mode string into AcknowledgementMode enum.
-        /// </summary>
-        /// <param name="ackText"></param>
-        /// <returns>Equivalent enum value.  If unknown string is encounted, it will default to AutoAcknowledge.</returns>
-        public static AcknowledgementMode ToAcknowledgementMode(string ackText)
-        {
-            if(String.Compare(ackText, "AutoAcknowledge", true) == 0)
-            {
-                return AcknowledgementMode.AutoAcknowledge;
-            }
-            else if(String.Compare(ackText, "ClientAcknowledge", true) == 0)
-            {
-                return AcknowledgementMode.ClientAcknowledge;
-            }
-            else if(String.Compare(ackText, "IndividualAcknowledge", true) == 0)
-            {
-                return AcknowledgementMode.IndividualAcknowledge;
-            }
-            else if(String.Compare(ackText, "DupsOkAcknowledge", true) == 0)
-            {
-                return AcknowledgementMode.DupsOkAcknowledge;
-            }
-            else if(String.Compare(ackText, "Transactional", true) == 0)
-            {
-                return AcknowledgementMode.Transactional;
-            }
-            else
-            {
-                return AcknowledgementMode.AutoAcknowledge;
-            }
-        }
-
-        /// <summary>
-        /// Convert an object into a text message.  The object must be serializable to XML.
-        /// </summary>
-        public static ITextMessage ToXmlMessage(IMessageProducer producer, object obj)
-        {
-            ITextMessage message = producer.CreateTextMessage(XmlUtil.Serialize(obj));
-
-            // Embed the type into the message
-            message.NMSType = obj.GetType().FullName;
-            return message;
-        }
-
-        /// <summary>
-        /// Convert an object into a text message.  The object must be serializable to XML.
-        /// </summary>
-        public static ITextMessage ToXmlMessage(ISession session, object obj)
-        {
-            ITextMessage message = session.CreateTextMessage(XmlUtil.Serialize(obj));
-
-            // Embed the type into the message
-            message.NMSType = obj.GetType().FullName;
-            return message;
-        }
-
-        /// <summary>
-        /// Convert a text message into an object.  The object must be serializable from XML.
-        /// </summary>
-        public static object FromXmlMessage(IMessage message)
-        {
-            ITextMessage textMessage = message as ITextMessage;
-
-            if(null == textMessage)
-            {
-                return null;
-            }
-
-            Type objType = GetRuntimeType(textMessage.NMSType);
-            if(null == objType)
-            {
-                Tracer.ErrorFormat("Could not load type for {0} while deserializing XML object.", textMessage.NMSType);
-                return null;
-            }
-
-            return XmlUtil.Deserialize(objType, textMessage.Text);
-        }
-
-        /// <summary>
-        /// Get the runtime type for the class name.  This routine will search all loaded
-        /// assemblies in the current App Domain to find the type.
-        /// </summary>
-        /// <param name="typeName">Full name of the type.</param>
-        /// <returns>Type object if found, or null if not found.</returns>
-        private static Type GetRuntimeType(string typeName)
-        {
-            Type objType = null;
+using System.Reflection;
+using System.Text;
+
+namespace Apache.NMS.Util
+{
+ public class NMSConvert
+ {
+ /// <summary>
+ /// Convert the acknowledgment mode string into AcknowledgementMode enum.
+ /// </summary>
+ /// <param name="ackText"></param>
+ /// <returns>Equivalent enum value.  If unknown string is encounted, it will default to AutoAcknowledge.</returns>
+ public static AcknowledgementMode ToAcknowledgementMode(string ackText)
+ {
+ if(String.Compare(ackText, "AutoAcknowledge", true) == 0)
+ {
+ return AcknowledgementMode.AutoAcknowledge;
+ }
+ else if(String.Compare(ackText, "ClientAcknowledge", true) == 0)
+ {
+ return AcknowledgementMode.ClientAcknowledge;
+ }
+ else if(String.Compare(ackText, "IndividualAcknowledge", true) == 0)
+ {
+ return AcknowledgementMode.IndividualAcknowledge;
+ }
+ else if(String.Compare(ackText, "DupsOkAcknowledge", true) == 0)
+ {
+ return AcknowledgementMode.DupsOkAcknowledge;
+ }
+ else if(String.Compare(ackText, "Transactional", true) == 0)
+ {
+ return AcknowledgementMode.Transactional;
+ }
+ else
+ {
+ return AcknowledgementMode.AutoAcknowledge;
+ }
+ }
+
+ /// <summary>
+ /// Convert an object into a text message.  The object must be serializable to XML.
+ /// </summary>
+#if NET_3_5 || MONO
+ [Obsolete]
+#endif
+ public static ITextMessage ToXmlMessage(IMessageProducer producer, object obj)
+ {
+ return ToXmlMessage(producer, obj, Encoding.Unicode);
+ }
+
+ /// <summary>
+ /// Convert an object into a text message.  The object must be serializable to XML.
+ /// </summary>
+#if NET_3_5 || MONO
+ [Obsolete]
+#endif
+ public static ITextMessage ToXmlMessage(IMessageProducer producer, object obj, Encoding encoding)
+ {
+ return SerializeObjToMessage(producer.CreateTextMessage(), obj, encoding);
+ }
+
+ /// <summary>
+ /// Convert an object into a text message.  The object must be serializable to XML.
+ /// </summary>
+#if NET_3_5 || MONO
+ [Obsolete]
+#endif
+ public static ITextMessage ToXmlMessage(ISession session, object obj)
+ {
+ return ToXmlMessage(session, obj, Encoding.Unicode);
+ }
+
+ /// <summary>
+ /// Convert an object into a text message.  The object must be serializable to XML.
+ /// </summary>
+#if NET_3_5 || MONO
+ [Obsolete]
+#endif
+ public static ITextMessage ToXmlMessage(ISession session, object obj, Encoding encoding)
+ {
+ return SerializeObjToMessage(session.CreateTextMessage(), obj, encoding);
+ }
+
+ /// <summary>
+ /// Convert a text message into an object.  The object must be serializable from XML.
+ /// </summary>
+#if NET_3_5 || MONO
+ [Obsolete]
+#endif
+ public static object FromXmlMessage(IMessage message)
+ {
+ return DeserializeObjFromMessage(message);
+ }
+
+ /// <summary>
+ /// Serialize the object as XML into the Text body of the message.
+ /// Set the NMSType to the full name of the object type.
+ /// </summary>
+ /// <param name="message"></param>
+ /// <param name="obj"></param>
+ /// <param name="encoding"></param>
+ /// <returns></returns>
+ internal static ITextMessage SerializeObjToMessage(ITextMessage message, object obj, Encoding encoding)
+ {
+ // Embed the type into the message
+ message.NMSType = obj.GetType().FullName;
+ message.Text = XmlUtil.Serialize(obj, encoding);
+ return message;
+ }
+
+ /// <summary>
+ /// Deserialize the object from the text message.  The object must be serializable from XML.
+ /// </summary>
+ /// <param name="message"></param>
+ /// <returns></returns>
+ internal static object DeserializeObjFromMessage(IMessage message)
+ {
+ ITextMessage textMessage = message as ITextMessage;
+
+ if(null == textMessage)
+ {
+ return null;
+ }
+
+ Type objType = GetRuntimeType(textMessage.NMSType);
+ if(null == objType)
+ {
+ Tracer.ErrorFormat("Could not load type for {0} while deserializing XML object.", textMessage.NMSType);
+ return null;
+ }
+
+ return XmlUtil.Deserialize(objType, textMessage.Text);
+ }
+
+ /// <summary>
+ /// Get the runtime type for the class name.  This routine will search all loaded
+ /// assemblies in the current App Domain to find the type.
+ /// </summary>
+ /// <param name="typeName">Full name of the type.</param>
+ /// <returns>Type object if found, or null if not found.</returns>
+ private static Type GetRuntimeType(string typeName)
+ {
+ Type objType = null;
 
 #if NETCF
-            objType = Assembly.GetCallingAssembly().GetType(typeName, false);
-#else
-            foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
-            {
-                objType = assembly.GetType(typeName, false, true);
-                if(null != objType)
-                {
-                    break;
-                }
-            }
-#endif
-
-            return objType;
-        }
-    }
-}
+ objType = Assembly.GetCallingAssembly().GetType(typeName, false);
+#else
+ foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
+ {
+ objType = assembly.GetType(typeName, false, true);
+ if(null != objType)
+ {
+ break;
+ }
+ }
+#endif
+
+ return objType;
+ }
+ }
+}

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/XmlUtils.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/XmlUtils.cs?rev=834619&r1=834618&r2=834619&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/XmlUtils.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/XmlUtils.cs Tue Nov 10 19:22:06 2009
@@ -30,7 +30,7 @@
  {
  public static string Serialize(object obj)
  {
- return Serialize(obj, Encoding.UTF8);
+ return Serialize(obj, Encoding.Unicode);
  }
 
  public static string Serialize(object obj, Encoding encoding)

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs?rev=834619&r1=834618&r2=834619&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/test/csharp/XmlMessageTest.cs Tue Nov 10 19:22:06 2009
@@ -71,6 +71,61 @@
  protected static string DESTINATION_NAME = "XmlMessageDestination";
  protected static string TEST_CLIENT_ID = "XmlMessageClientId";
 
+#if NET_3_5 || MONO
+ [Test]
+ public void SendReceiveXmlMessage()
+ {
+ using(IConnection connection = CreateConnection(TEST_CLIENT_ID))
+ {
+ connection.Start();
+ using(ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge))
+ {
+ IDestination destination = session.GetDestination(DESTINATION_NAME);
+ using(IMessageConsumer consumer = session.CreateConsumer(destination))
+ using(IMessageProducer producer = session.CreateProducer(destination))
+ {
+ producer.RequestTimeout = receiveTimeout;
+
+ NMSTestXmlType1 srcIntObject = new NMSTestXmlType1();
+ srcIntObject.crcCheck = 0xbadf00d;
+ srcIntObject.checkType = CheckType.command;
+ producer.Send(srcIntObject);
+
+ NMSTestXmlType2 srcStringObject = new NMSTestXmlType2();
+ srcStringObject.stringCheck = "BadFood";
+ producer.Send(srcStringObject);
+
+ // Demonstrate the ability to generically handle multiple object types
+ // sent to the same consumer.  If only one object type is ever sent to
+ // the destination, then a simple inline cast is all that is necessary
+ // when calling the NMSConvert.FromXmlMessage() function.
+
+ for(int index = 0; index < 2; index++)
+ {
+ object receivedObject = consumer.Receive(receiveTimeout).ToObject();
+ Assert.IsNotNull(receivedObject, "Failed to retrieve XML message object.");
+
+ if(receivedObject is NMSTestXmlType1)
+ {
+ NMSTestXmlType1 destObject = (NMSTestXmlType1) receivedObject;
+ Assert.AreEqual(srcIntObject.crcCheck, destObject.crcCheck, "CRC integer mis-match.");
+ Assert.AreEqual(srcIntObject.checkType, destObject.checkType, "Check type mis-match.");
+ }
+ else if(receivedObject is NMSTestXmlType2)
+ {
+ NMSTestXmlType2 destObject = (NMSTestXmlType2) receivedObject;
+ Assert.AreEqual(srcStringObject.stringCheck, destObject.stringCheck, "CRC string mis-match.");
+ }
+ else
+ {
+ Assert.Fail("Invalid object type.");
+ }
+ }
+ }
+ }
+ }
+ }
+#else
  [Test]
  public void SendReceiveXmlMessage()
  {
@@ -124,5 +179,6 @@
  }
  }
  }
+#endif
  }
 }

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/vs2008-nms.csproj
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/vs2008-nms.csproj?rev=834619&r1=834618&r2=834619&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/vs2008-nms.csproj (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/vs2008-nms.csproj Tue Nov 10 19:22:06 2009
@@ -2,7 +2,7 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.21022</ProductVersion>
+    <ProductVersion>9.0.30729</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{300C1716-0674-4D01-8F5D-151E59A504FE}</ProjectGuid>
     <OutputType>Library</OutputType>
@@ -42,6 +42,7 @@
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="System" />
+    <Reference Include="System.Data" />
     <Reference Include="System.Web" />
     <Reference Include="System.Xml" />
   </ItemGroup>
@@ -74,10 +75,12 @@
     <Compile Include="src\main\csharp\ITextMessage.cs" />
     <Compile Include="src\main\csharp\ITopic.cs" />
     <Compile Include="src\main\csharp\ITrace.cs" />
+    <Compile Include="src\main\csharp\MessageExtensions.cs" />
     <Compile Include="src\main\csharp\MessageEOFException.cs" />
     <Compile Include="src\main\csharp\MessageFormatException.cs" />
     <Compile Include="src\main\csharp\MessageNotReadableException.cs" />
     <Compile Include="src\main\csharp\MessageNotWriteableException.cs" />
+    <Compile Include="src\main\csharp\MessageProducerExtensions.cs" />
     <Compile Include="src\main\csharp\NMSConnectionException.cs" />
     <Compile Include="src\main\csharp\NMSConstants.cs" />
     <Compile Include="src\main\csharp\NMSException.cs" />
@@ -85,6 +88,7 @@
     <Compile Include="src\main\csharp\NMSSecurityException.cs" />
     <Compile Include="src\main\csharp\policies\RedeliveryPolicy.cs" />
     <Compile Include="src\main\csharp\ResourceAllocationException.cs" />
+    <Compile Include="src\main\csharp\SessionExtensions.cs" />
     <Compile Include="src\main\csharp\Tracer.cs" />
     <Compile Include="src\main\csharp\TransactionInProgressException.cs" />
     <Compile Include="src\main\csharp\TransactionRolledBackException.cs" />