activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r831002 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/Convert.cs
Date Thu, 29 Oct 2009 15:39:16 GMT
Author: tabish
Date: Thu Oct 29 15:39:16 2009
New Revision: 831002

URL: http://svn.apache.org/viewvc?rev=831002&view=rev
Log:
http://issues.apache.org/activemq/browse/AMQNET-199

Update the Ack mode string converter.

Modified:
    activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/Convert.cs

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=831002&r1=831001&r2=831002&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 Thu Oct 29 15:39:16
2009
@@ -19,107 +19,111 @@
 
 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, "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;
-			}
+    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);
-		}
+            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;
+        /// <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);
+            objType = Assembly.GetCallingAssembly().GetType(typeName, false);
 #else
-			foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
-			{
-				objType = assembly.GetType(typeName, false, true);
-				if(null != objType)
-				{
-					break;
-				}
-			}
+            foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
+            {
+                objType = assembly.GetType(typeName, false, true);
+                if(null != objType)
+                {
+                    break;
+                }
+            }
 #endif
 
-			return objType;
-		}
-	}
+            return objType;
+        }
+    }
 }



Mime
View raw message