activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgo...@apache.org
Subject svn commit: r807804 - /activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/URISupport.cs
Date Tue, 25 Aug 2009 21:02:14 GMT
Author: jgomes
Date: Tue Aug 25 21:02:13 2009
New Revision: 807804

URL: http://svn.apache.org/viewvc?rev=807804&view=rev
Log:
Applied slightly modified version of patch from Daniel Ellis.  Optimized lookup of Field only
if we did not find a Property.
Fixes [AMQNET-174]. (See https://issues.apache.org/activemq/browse/AMQNET-174)

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

Modified: activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/URISupport.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/URISupport.cs?rev=807804&r1=807803&r2=807804&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/URISupport.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS/trunk/src/main/csharp/Util/URISupport.cs Tue Aug 25
21:02:13 2009
@@ -100,12 +100,26 @@
 															| BindingFlags.Instance
 															| BindingFlags.IgnoreCase);
 
-					if(null == prop)
+					if(null != prop)
 					{
-						throw new NMSException(string.Format("no such property: {0} on class: {1}", bareKey,
target.GetType().Name));
+						prop.SetValue(target, Convert.ChangeType(map[key], prop.PropertyType, CultureInfo.InvariantCulture),
null);
+					}
+					else
+					{
+						FieldInfo field = type.GetField(bareKey,
+															BindingFlags.FlattenHierarchy
+															| BindingFlags.Public
+															| BindingFlags.Instance
+															| BindingFlags.IgnoreCase);
+						if(null != field)
+						{
+							field.SetValue(target, Convert.ChangeType(map[key], field.FieldType, CultureInfo.InvariantCulture));
+						}
+						else
+						{
+							throw new NMSException(string.Format("No such property or field: {0} on class: {1}",
bareKey, target.GetType().Name));
+						}
 					}
-
-					prop.SetValue(target, Convert.ChangeType(map[key], prop.PropertyType, CultureInfo.InvariantCulture),
null);
 				}
 			}
 		}
@@ -299,9 +313,9 @@
 
 			// Start with original URI
 #if NET_1_0 || NET_1_1
-            String ssp = uri.AbsoluteUri.Trim();
+			String ssp = uri.AbsoluteUri.Trim();
 #else
-            String ssp = uri.OriginalString.Trim();
+			String ssp = uri.OriginalString.Trim();
 #endif
 
 			ssp = stripPrefix(ssp, "failover:");



Mime
View raw message