From 6991d18b7d5f776afc21b970caced01b2cb19034 Mon Sep 17 00:00:00 2001 From: "Charles E. Rolke" Date: Thu, 16 Jan 2014 20:00:36 +0000 Subject: 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. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1558899 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/bindings/qpid/dotnet/src/Message.h | 46 ++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'qpid/cpp/bindings') diff --git a/qpid/cpp/bindings/qpid/dotnet/src/Message.h b/qpid/cpp/bindings/qpid/dotnet/src/Message.h index aa436ed48d..2b64ef90f3 100644 --- a/qpid/cpp/bindings/qpid/dotnet/src/Message.h +++ b/qpid/cpp/bindings/qpid/dotnet/src/Message.h @@ -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 ^ dict = + gcnew System::Collections::Generic::Dictionary ; + 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 - 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; } } } -- cgit v1.2.1