Author: chug
Date: Thu Jan 16 20:00:36 2014
New Revision: 1558899

URL: http://svn.apache.org/r1558899
Log:
QPID-5481: Messaging API Update - 1520416 Message setProperties(Variant::Map&) 
added

The .NET binding already had a Properties setter but it behaved worked by doing 
recursive property Add and not a wholesale replace. This patch calls the new 
setProperty method to get the correct behavior.

The Properties property does non trivial calls into the unmanaged code. This
patch also intercepts unmanaged exceptions  from get and set and relays them 
into managed space.

Modified:
    qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/Message.h

Modified: qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/Message.h
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/Message.h?rev=1558899&r1=1558898&r2=1558899&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/Message.h (original)
+++ qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/Message.h Thu Jan 16 20:00:36 
2014
@@ -29,6 +29,7 @@
 #include "QpidMarshal.h"
 #include "Address.h"
 #include "Duration.h"
+#include "QpidException.h"
 #include "TypeTranslator.h"
 
 namespace Org {
@@ -376,17 +377,27 @@ namespace Messaging {
                 msclr::lock lk(privateLock);
                 ThrowIfDisposed();
 
-                ::qpid::types::Variant::Map map;
+                System::Exception ^ newException = nullptr;
 
-                map = nativeObjPtr->getProperties();
-
-                System::Collections::Generic::Dictionary<
-                    System::String^, System::Object^> ^ dict =
-                    gcnew System::Collections::Generic::Dictionary<
-                    System::String^, System::Object^> ;
+                System::Collections::Generic::Dictionary<System::String^, 
System::Object^> ^ dict =
+                    gcnew 
System::Collections::Generic::Dictionary<System::String^, System::Object^> ;
 
+                try
+                {
+                    ::qpid::types::Variant::Map map;
+                    map = nativeObjPtr->getProperties();
+                    TypeTranslator::NativeToManaged(map, dict);
+                }
+                catch (const ::qpid::types::Exception & error)
+                {
+                    String ^ errmsg = gcnew String(error.what());
+                    newException    = gcnew QpidException(errmsg);
+                }
 
-                TypeTranslator::NativeToManaged(map, dict);
+                if (newException != nullptr)
+                {
+                    throw newException;
+                }
 
                 return dict;
             }
@@ -398,10 +409,23 @@ namespace Messaging {
                 msclr::lock lk(privateLock);
                 ThrowIfDisposed();
 
-                for each (System::Collections::Generic::KeyValuePair
-                    <System::String^, System::Object^> kvp in properties)
+                System::Exception ^ newException = nullptr;
+
+                try
+                {
+                    ::qpid::types::Variant::Map variantMap;
+                    TypeTranslator::ManagedToNative(properties, variantMap);
+                    nativeObjPtr->setProperties(variantMap);
+                }
+                catch (const ::qpid::types::Exception & error)
+                {
+                    String ^ errmsg = gcnew String(error.what());
+                    newException    = gcnew QpidException(errmsg);
+                }
+
+                if (newException != nullptr)
                 {
-                    SetProperty(kvp.Key, kvp.Value);
+                    throw newException;
                 }
             }
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to