From 077b8b25ab7fac22daf8494feb125cd5c73b95ac Mon Sep 17 00:00:00 2001 From: Ted Ross Date: Wed, 9 Jun 2010 11:59:38 +0000 Subject: QPID-2589 Cleanup pass to address function naming, capitalization rules, change Qpid messaging 'list' representation from List<> to Collection<>, some exception cleanup. Patch from Chuck Rolke git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@952968 13f79535-47bb-0310-9956-ffa450edef68 --- .../csharp.direct.receiver.cs | 16 +- .../csharp.direct.sender/csharp.direct.sender.cs | 14 +- .../csharp.map.callback.receiver.cs | 47 ++-- .../csharp.map.callback.sender.cs | 19 +- .../csharp.map.receiver/csharp.map.recevier.cs | 21 +- .../csharp.map.sender/csharp.map.sender.cs | 17 +- cpp/bindings/qpid/dotnet/src/Address.cpp | 50 ++--- cpp/bindings/qpid/dotnet/src/Address.h | 34 +-- cpp/bindings/qpid/dotnet/src/Connection.cpp | 128 +++++------ cpp/bindings/qpid/dotnet/src/Connection.h | 30 +-- cpp/bindings/qpid/dotnet/src/Duration.h | 29 ++- cpp/bindings/qpid/dotnet/src/Message.cpp | 99 ++++----- cpp/bindings/qpid/dotnet/src/Message.h | 75 ++++--- cpp/bindings/qpid/dotnet/src/QpidException.h | 16 +- cpp/bindings/qpid/dotnet/src/QpidMarshal.h | 11 +- cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h | 31 +-- cpp/bindings/qpid/dotnet/src/ReadMe.txt | 8 +- cpp/bindings/qpid/dotnet/src/Receiver.cpp | 99 ++++----- cpp/bindings/qpid/dotnet/src/Receiver.h | 61 +++--- cpp/bindings/qpid/dotnet/src/Sender.cpp | 22 +- cpp/bindings/qpid/dotnet/src/Sender.h | 18 +- cpp/bindings/qpid/dotnet/src/Session.cpp | 243 +++++++++------------ cpp/bindings/qpid/dotnet/src/Session.h | 48 ++-- cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp | 122 ++++++----- cpp/bindings/qpid/dotnet/src/TypeTranslator.h | 47 ++-- .../qpid/dotnet/src/org.apache.qpid.messaging.rc | 6 +- .../dotnet/src/org.apache.qpid.messaging.vcproj | 6 +- .../src/sessionreceiver/Properties/AssemblyInfo.cs | 4 +- .../dotnet/src/sessionreceiver/sessionreceiver.cs | 38 ++-- .../dotnet/test/messaging.test/messaging.test.cs | 16 +- 30 files changed, 689 insertions(+), 686 deletions(-) (limited to 'cpp') diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs b/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs index 4888023830..98531ebcce 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.direct.receiver/csharp.direct.receiver.cs @@ -23,7 +23,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using org.apache.qpid.messaging; +using Org.Apache.Qpid.Messaging; namespace CSharpDirect { @@ -54,20 +54,20 @@ namespace CSharpDirect Connection conn = new Connection(host); - conn.open(); + conn.Open(); - if (!conn.isOpen()) + if (!conn.IsOpen()) { Console.WriteLine("Failed to open connection to host : {0}", host); } else { - Session sess = conn.createSession(); + Session sess = conn.CreateSession(); Duration dura = new Duration(3600000); // wait forever - Receiver rcv = sess.createReceiver(addr); + Receiver rcv = sess.CreateReceiver(addr); Message msg = new Message(""); @@ -75,8 +75,8 @@ namespace CSharpDirect { try { - Message msg2 = rcv.fetch(dura); - Console.WriteLine("Rcvd msg {0} : {1}", i, msg2.getContent()); + Message msg2 = rcv.Fetch(dura); + Console.WriteLine("Rcvd msg {0} : {1}", i, msg2.GetContent()); } catch (Exception e) { @@ -84,7 +84,7 @@ namespace CSharpDirect } } - conn.close(); + conn.Close(); } } } diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs b/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs index 1fe56aa8a9..71ab75ccae 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.direct.sender/csharp.direct.sender.cs @@ -23,7 +23,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using org.apache.qpid.messaging; +using Org.Apache.Qpid.Messaging; namespace csharp.direct.sender { @@ -50,26 +50,26 @@ namespace csharp.direct.sender Connection conn = new Connection(host); - conn.open(); + conn.Open(); - if (!conn.isOpen()) + if (!conn.IsOpen()) { Console.WriteLine("Failed to open connection to host : {0}", host); } else { - Session sess = conn.createSession(); + Session sess = conn.CreateSession(); - Sender snd = sess.createSender(addr); + Sender snd = sess.CreateSender(addr); for (int i = 0; i < nMsg; i++) { Message msg = new Message(String.Format("Test Message {0}", i)); - snd.send(msg); + snd.Send(msg); } - conn.close(); + conn.Close(); } } } diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs index e7294c6e1a..2ef78545b6 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.receiver/csharp.map.callback.receiver.cs @@ -21,10 +21,11 @@ using System; using System.Collections.Generic; -using org.apache.qpid.messaging; -using org.apache.qpid.messaging.sessionreceiver; +using System.Collections.ObjectModel; +using Org.Apache.Qpid.Messaging; +using Org.Apache.Qpid.Messaging.SessionReceiver; -namespace org.apache.qpid.messaging.examples +namespace Org.Apache.Qpid.Messaging.Examples { /// /// A class with functions to display structured messages. @@ -50,7 +51,7 @@ namespace org.apache.qpid.messaging.examples else if (QpidTypeCheck.ObjectIsList(kvp.Value)) { Console.WriteLine("Key: {0}, Value: List", kvp.Key); - ShowList((List)kvp.Value, level + 1); + ShowList((Collection)kvp.Value, level + 1); } else Console.WriteLine("Key: {0}, Value: {1}, Type: {2}", @@ -63,7 +64,7 @@ namespace org.apache.qpid.messaging.examples /// /// The AMQP list /// Nested depth - public static void ShowList(List list, int level) + public static void ShowList(Collection list, int level) { foreach (object obj in list) { @@ -77,7 +78,7 @@ namespace org.apache.qpid.messaging.examples else if (QpidTypeCheck.ObjectIsList(obj)) { Console.WriteLine("List"); - ShowList((List)obj, level + 1); + ShowList((Collection)obj, level + 1); } else Console.WriteLine("Value: {0}, Type: {1}", @@ -92,24 +93,24 @@ namespace org.apache.qpid.messaging.examples /// The Message public static void ShowMessage(Message message) { - if ("amqp/map" == message.getContentType()) + if ("amqp/map" == message.GetContentType()) { Console.WriteLine("Received a Dictionary"); Dictionary content = new Dictionary(); - message.getContent(content); + message.GetContent(content); ShowDictionary(content, 0); } - else if ("amqp/list" == message.getContentType()) + else if ("amqp/list" == message.GetContentType()) { Console.WriteLine("Received a List"); - List content = new List(); - message.getContent(content); + Collection content = new Collection(); + message.GetContent(content); ShowList(content, 0); } else { Console.WriteLine("Received a String"); - Console.WriteLine(message.getContent()); + Console.WriteLine(message.GetContent()); } } } @@ -147,7 +148,7 @@ namespace org.apache.qpid.messaging.examples // // Acknowledge the receipt of all received messages. // - receiver.getSession().acknowledge(); + receiver.GetSession().Acknowledge(); } @@ -170,7 +171,7 @@ namespace org.apache.qpid.messaging.examples Console.WriteLine("The details of the message body's types and values are shown."); Console.WriteLine(); Console.WriteLine(" url = target address for 'new Connection(url)'"); - Console.WriteLine(" addr = address for 'session.createReceiver(addr)'"); + Console.WriteLine(" addr = address for 'session.CreateReceiver(addr)'"); Console.WriteLine(" nSec = time in seconds to keep the receiver callback open"); Console.WriteLine(); Console.WriteLine("Default values:"); @@ -211,20 +212,20 @@ namespace org.apache.qpid.messaging.examples // Create and open an AMQP connection to the broker URL // Connection connection = new Connection(url); - connection.open(); + connection.Open(); // // Create a session. // - Session session = connection.createSession(); + Session session = connection.CreateSession(); // // Receive through callback // // Create callback server and implicitly start it // - sessionreceiver.server cbServer = - new sessionreceiver.server(session, this); + SessionReceiver.CallbackServer cbServer = + new SessionReceiver.CallbackServer(session, this); // // The callback server is running and executing callbacks on a @@ -235,12 +236,12 @@ namespace org.apache.qpid.messaging.examples // Create a receiver for the direct exchange using the // routing key "map_example". // - Receiver receiver = session.createReceiver(addr); + Receiver receiver = session.CreateReceiver(addr); // // Establish a capacity // - receiver.setCapacity(100); + receiver.SetCapacity(100); // // Wait so many seconds for messages to arrive. @@ -250,13 +251,13 @@ namespace org.apache.qpid.messaging.examples // // Stop the callback server. // - cbServer.close(); + cbServer.Close(); // // Close the receiver and the connection. // - receiver.close(); - connection.close(); + receiver.Close(); + connection.Close(); } } diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.cs index a097267f5f..761ac0aac2 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.callback.sender/csharp.map.callback.sender.cs @@ -21,11 +21,12 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; -using org.apache.qpid.messaging; +using Org.Apache.Qpid.Messaging; -namespace org.apache.qpid.messaging.examples +namespace Org.Apache.Qpid.Messaging.Examples { class MapSender { @@ -42,7 +43,7 @@ namespace org.apache.qpid.messaging.examples Console.WriteLine("messages to a named exchange with a routing key."); Console.WriteLine(); Console.WriteLine(" url = target address for 'new Connection(url)'"); - Console.WriteLine(" addr = address for 'session.createReceiver(addr)'"); + Console.WriteLine(" addr = address for 'session.CreateReceiver(addr)'"); Console.WriteLine(" count = number of messages to send"); Console.WriteLine(); Console.WriteLine("Default values:"); @@ -82,14 +83,14 @@ namespace org.apache.qpid.messaging.examples // Create and open an AMQP connection to the broker URL // Connection connection = new Connection(url); - connection.open(); + connection.Open(); // // Create a session and a sender to the direct exchange using the // routing key "map_example". // - Session session = connection.createSession(); - Sender sender = session.createSender(addr); + Session session = connection.CreateSession(); + Sender sender = session.CreateSender(addr); // // Create structured content for the message. This example builds a @@ -97,7 +98,7 @@ namespace org.apache.qpid.messaging.examples // Dictionary content = new Dictionary(); Dictionary subMap = new Dictionary(); - List colors = new List(); + Collection colors = new Collection(); content["id"] = 987654321; content["name"] = "Widget"; @@ -120,12 +121,12 @@ namespace org.apache.qpid.messaging.examples // Message message = new Message(content); for (UInt32 i = 0; i 0) url = args[0]; @@ -38,37 +37,37 @@ namespace org.apache.qpid.messaging.examples // Create and open an AMQP connection to the broker URL // Connection connection = new Connection(url); - connection.open(); + connection.Open(); // // Create a session and a receiver fir the direct exchange using the // routing key "map_example". // - Session session = connection.createSession(); - Receiver receiver = session.createReceiver("amq.direct/map_example"); + Session session = connection.CreateSession(); + Receiver receiver = session.CreateReceiver("amq.direct/map_example"); // // Fetch the message from the broker (wait indefinitely by default) // - Message message = receiver.fetch(new Duration(60000)); + Message message = receiver.Fetch(new Duration(60000)); // // Extract the structured content from the message. // Dictionary content = new Dictionary(); - message.getContent(content); + message.GetContent(content); Console.WriteLine("Received: {0}", content); // // Acknowledge the receipt of all received messages. // - session.acknowledge(); + session.Acknowledge(); // // Close the receiver and the connection. // - receiver.close(); - connection.close(); + receiver.Close(); + connection.Close(); } } } diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs index 2890367599..d1ccc65f2c 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs @@ -21,11 +21,12 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; -using org.apache.qpid.messaging; +using Org.Apache.Qpid.Messaging; -namespace org.apache.qpid.messaging.examples +namespace Org.Apache.Qpid.Messaging.examples { class MapSender { @@ -39,14 +40,14 @@ namespace org.apache.qpid.messaging.examples // Create and open an AMQP connection to the broker URL // Connection connection = new Connection(url); - connection.open(); + connection.Open(); // // Create a session and a sender to the direct exchange using the // routing key "map_example". // - Session session = connection.createSession(); - Sender sender = session.createSender("amq.direct/map_example"); + Session session = connection.CreateSession(); + Sender sender = session.CreateSender("amq.direct/map_example"); // // Create structured content for the message. This example builds a @@ -54,7 +55,7 @@ namespace org.apache.qpid.messaging.examples // Dictionary content = new Dictionary(); Dictionary subMap = new Dictionary(); - List colors = new List(); + Collection colors = new Collection(); content["id"] = 987654321; content["name"] = "Widget"; @@ -76,12 +77,12 @@ namespace org.apache.qpid.messaging.examples // via the sender. // Message message = new Message(content); - sender.send(message, true); + sender.Send(message, true); // // Close the connection. // - connection.close(); + connection.Close(); } } } diff --git a/cpp/bindings/qpid/dotnet/src/Address.cpp b/cpp/bindings/qpid/dotnet/src/Address.cpp index 8b48a2037f..f0bbe13bbb 100644 --- a/cpp/bindings/qpid/dotnet/src/Address.cpp +++ b/cpp/bindings/qpid/dotnet/src/Address.cpp @@ -30,10 +30,10 @@ #include "QpidTypeCheck.h" #include "TypeTranslator.h" -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Address is a managed wrapper for a qpid::messaging::Address @@ -58,10 +58,10 @@ namespace messaging { System::String ^, System::Object ^> ^ options) : addressp(new ::qpid::messaging::Address()) { - setName(name); - setSubject(subject); - setOptions(options); - setType(""); + SetName(name); + SetSubject(subject); + SetOptions(options); + SetType(""); } @@ -72,10 +72,10 @@ namespace messaging { System::String ^ type) : addressp(new ::qpid::messaging::Address()) { - setName(name); - setSubject(subject); - setOptions(options); - setType(type); + SetName(name); + SetSubject(subject); + SetOptions(options); + SetType(type); } @@ -114,12 +114,12 @@ namespace messaging { // // name // - System::String ^ Address::getName() + System::String ^ Address::GetName() { return gcnew System::String(addressp->getName().c_str()); } - void Address::setName(System::String ^ name) + void Address::SetName(System::String ^ name) { addressp->::qpid::messaging::Address::setName(QpidMarshal::ToNative(name)); } @@ -127,21 +127,21 @@ namespace messaging { // // subject // - System::String ^ Address::getSubject() + System::String ^ Address::GetSubject() { return gcnew System::String(addressp->getSubject().c_str()); } - void Address::setSubject(System::String ^ subject) + void Address::SetSubject(System::String ^ subject) { - addressp->setName(QpidMarshal::ToNative(subject)); + addressp->setSubject(QpidMarshal::ToNative(subject)); } // // options // System::Collections::Generic::Dictionary< - System::String ^, System::Object ^> ^ Address::getOptions() + System::String ^, System::Object ^> ^ Address::GetOptions() { ::qpid::types::Variant::Map map; System::Collections::Generic::Dictionary< @@ -149,37 +149,37 @@ namespace messaging { gcnew System::Collections::Generic::Dictionary< System::String ^, System::Object ^>; map = addressp->getOptions(); - TypeTranslator::NativeToManaged(newMap, map); + TypeTranslator::NativeToManaged(map, newMap); return newMap; } - void Address::setOptions(System::Collections::Generic::Dictionary< + void Address::SetOptions(System::Collections::Generic::Dictionary< System::String ^, System::Object ^> ^ options) { ::qpid::types::Variant::Map map; - TypeTranslator::ManagedToNative(map, options); + TypeTranslator::ManagedToNative(options, map); addressp->setOptions(map); } // // type // - System::String ^ Address::getType() + System::String ^ Address::GetType() { return gcnew System::String(addressp->getType().c_str()); } - void Address::setType(System::String ^ type) + void Address::SetType(System::String ^ type) { addressp->setName(QpidMarshal::ToNative(type)); } // - // str + // ToString // - System::String ^ Address::str() + System::String ^ Address::ToStr() { return gcnew System::String(addressp->str().c_str()); } diff --git a/cpp/bindings/qpid/dotnet/src/Address.h b/cpp/bindings/qpid/dotnet/src/Address.h index 72eed76eb0..60e24da2f0 100644 --- a/cpp/bindings/qpid/dotnet/src/Address.h +++ b/cpp/bindings/qpid/dotnet/src/Address.h @@ -27,11 +27,10 @@ #include "qpid/messaging/Address.h" - -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Address is a managed wrapper for a qpid::messaging::Address @@ -43,10 +42,10 @@ namespace messaging { // Kept object deletion code void Cleanup(); - public: // The kept object in the Messaging C++ DLL ::qpid::messaging::Address * addressp; + public: Address(); Address(System::String ^ address); @@ -69,21 +68,26 @@ namespace messaging { !Address(); // Address(const Address % rhs); - System::String ^ getName(); - void setName(System::String ^ name); + property ::qpid::messaging::Address * NativeAddress + { + ::qpid::messaging::Address * get () { return addressp; } + } + + System::String ^ GetName(); + void SetName(System::String ^ name); - System::String ^ getSubject(); - void setSubject(System::String ^ subject); + System::String ^ GetSubject(); + void SetSubject(System::String ^ subject); System::Collections::Generic::Dictionary< - System::String ^, System::Object ^> ^ getOptions(); + System::String ^, System::Object ^> ^ GetOptions(); - void setOptions(System::Collections::Generic::Dictionary< + void SetOptions(System::Collections::Generic::Dictionary< System::String ^, System::Object ^> ^ options); - System::String ^ getType(); - void setType(System::String ^ type); + System::String ^ GetType(); + void SetType(System::String ^ type); - System::String ^ str(); + System::String ^ ToStr(); }; }}}} diff --git a/cpp/bindings/qpid/dotnet/src/Connection.cpp b/cpp/bindings/qpid/dotnet/src/Connection.cpp index 4936e18c4e..590cc5e69a 100644 --- a/cpp/bindings/qpid/dotnet/src/Connection.cpp +++ b/cpp/bindings/qpid/dotnet/src/Connection.cpp @@ -33,10 +33,10 @@ #include "QpidException.h" #include "TypeTranslator.h" -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Connection is a managed wrapper for a qpid::messaging::Connection @@ -56,7 +56,7 @@ namespace messaging { { for each (System::Collections::Generic::KeyValuePair kvp in options) { - setOption(kvp.Key, kvp.Value); + SetOption(kvp.Key, kvp.Value); } } @@ -94,7 +94,7 @@ namespace messaging { } - void Connection::setOption(System::String ^ name, System::Object ^ value) + void Connection::SetOption(System::String ^ name, System::Object ^ value) { ::qpid::types::Variant entryValue; TypeTranslator::ManagedToNativeObject(value, entryValue); @@ -102,31 +102,31 @@ namespace messaging { connectionp->::qpid::messaging::Connection::setOption(entryName, entryValue); } - void Connection::open() + void Connection::Open() { connectionp->open(); } - System::Boolean Connection::isOpen() + System::Boolean Connection::IsOpen() { return connectionp->isOpen(); } - void Connection::close() + void Connection::Close() { connectionp->close(); } // - // createTransactionalSession() + // CreateTransactionalSession() // - Session ^ Connection::createTransactionalSession() + Session ^ Connection::CreateTransactionalSession() { - return createTransactionalSession(""); + return CreateTransactionalSession(""); } - Session ^ Connection::createTransactionalSession(System::String ^ name) + Session ^ Connection::CreateTransactionalSession(System::String ^ name) { System::Exception ^ newException = nullptr; ::qpid::messaging::Session * sessionp = NULL; @@ -148,42 +148,44 @@ namespace messaging { String ^ errmsg = gcnew String(error.what()); newException = gcnew QpidException(errmsg); } - catch (const std::exception & error) - { - String ^ errmsg = gcnew String(error.what()); - newException = gcnew QpidException(errmsg); - } - catch ( ... ) - { - newException = gcnew QpidException("Connection::createTransactionalSession unknown error"); - } finally { // Clean up and throw on caught exceptions if (newException != nullptr) { - if (sessionp != NULL) - { - delete sessionp; - } - throw newException; + if (newSession != nullptr) + { + delete newSession; + } + else + { + if (sessionp != NULL) + { + delete sessionp; + } + } } } - return newSession; + if (newException != nullptr) + { + throw newException; + } + + return newSession; } // - // createSession() + // CreateSession() // - Session ^ Connection::createSession() + Session ^ Connection::CreateSession() { - return createSession(""); + return CreateSession(""); } - Session ^ Connection::createSession(System::String ^ name) + Session ^ Connection::CreateSession(System::String ^ name) { System::Exception ^ newException = nullptr; ::qpid::messaging::Session * sessionp = NULL; @@ -205,33 +207,35 @@ namespace messaging { String ^ errmsg = gcnew String(error.what()); newException = gcnew QpidException(errmsg); } - catch (const std::exception & error) - { - String ^ errmsg = gcnew String(error.what()); - newException = gcnew QpidException(errmsg); - } - catch ( ... ) - { - newException = gcnew QpidException("Connection::createSession unknown error"); - } finally { // Clean up and throw on caught exceptions if (newException != nullptr) { - if (sessionp != NULL) - { - delete sessionp; - } - throw newException; + if (newSession != nullptr) + { + delete newSession; + } + else + { + if (sessionp != NULL) + { + delete sessionp; + } + } } } + if (nullptr != newException) + { + throw newException; + } + return newSession; } - Session ^ Connection::getSession(System::String ^ name) + Session ^ Connection::GetSession(System::String ^ name) { System::Exception ^ newException = nullptr; ::qpid::messaging::Session * sess = NULL; @@ -250,28 +254,30 @@ namespace messaging { String ^ errmsg = gcnew String(error.what()); newException = gcnew QpidException(errmsg); } - catch (const std::exception & error) - { - String ^ errmsg = gcnew String(error.what()); - newException = gcnew QpidException(errmsg); - } - catch ( ... ) - { - newException = gcnew QpidException("Connection::getSession unknown error"); - } finally { // Clean up and throw on caught exceptions if (newException != nullptr) { - if (sess != NULL) - { - delete sess; - } - throw newException; + if (newSession != nullptr) + { + delete newSession; + } + else + { + if (sess != NULL) + { + delete sess; + } + } } } + if (nullptr != newException) + { + throw newException; + } + return newSession; } }}}} diff --git a/cpp/bindings/qpid/dotnet/src/Connection.h b/cpp/bindings/qpid/dotnet/src/Connection.h index 894a96d224..e93e0781f3 100644 --- a/cpp/bindings/qpid/dotnet/src/Connection.h +++ b/cpp/bindings/qpid/dotnet/src/Connection.h @@ -28,10 +28,10 @@ #include "qpid/messaging/Connection.h" #include "qpid/messaging/Session.h" -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Connection is a managed wrapper for a qpid::messaging::Connection @@ -59,20 +59,20 @@ namespace messaging { ~Connection(); !Connection(); - void setOption(System::String ^ name, System::Object ^ value); + void SetOption(System::String ^ name, System::Object ^ value); - void open(); - System::Boolean isOpen(); - void close(); + void Open(); + System::Boolean IsOpen(); + void Close(); - // createTransactionalSession() - Session ^ createTransactionalSession(); - Session ^ createTransactionalSession(System::String ^ name); + // CreateTransactionalSession() + Session ^ CreateTransactionalSession(); + Session ^ CreateTransactionalSession(System::String ^ name); - // createSession() - Session ^ createSession(); - Session ^ createSession(System::String ^ name); + // CreateSession() + Session ^ CreateSession(); + Session ^ CreateSession(System::String ^ name); - Session ^ getSession(System::String ^ name); + Session ^ GetSession(System::String ^ name); }; }}}} diff --git a/cpp/bindings/qpid/dotnet/src/Duration.h b/cpp/bindings/qpid/dotnet/src/Duration.h index b7d2bf147e..8bbfa561f0 100644 --- a/cpp/bindings/qpid/dotnet/src/Duration.h +++ b/cpp/bindings/qpid/dotnet/src/Duration.h @@ -25,17 +25,17 @@ #include #include -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Duration is a time interval in milliseconds. /// It is a managed equivalent of ::qpid::messaging::Duration /// - public ref class Duration + public ref class Duration sealed { private: System::UInt64 milliseconds; @@ -69,10 +69,25 @@ namespace messaging { Duration ^ result = gcnew Duration(multiplier * dur->Milliseconds); return result; } - }; - public ref class DurationConstants + static Duration ^ Multiply (Duration ^ dur, const System::UInt64 multiplier) + { + Duration ^ result = gcnew Duration(dur->Milliseconds * multiplier); + return result; + } + + static Duration ^ Multiply (const System::UInt64 multiplier, Duration ^ dur) + { + Duration ^ result = gcnew Duration(multiplier * dur->Milliseconds); + return result; + } + }; + + public ref class DurationConstants sealed { + private: + DurationConstants::DurationConstants() {} + public: static Duration ^ FORVER; static Duration ^ IMMEDIATE; diff --git a/cpp/bindings/qpid/dotnet/src/Message.cpp b/cpp/bindings/qpid/dotnet/src/Message.cpp index 193a2eb976..3f748f177c 100644 --- a/cpp/bindings/qpid/dotnet/src/Message.cpp +++ b/cpp/bindings/qpid/dotnet/src/Message.cpp @@ -36,10 +36,10 @@ #include "QpidException.h" #include "TypeTranslator.h" -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Message is a managed wrapper for a ::qpid::messaging::Message @@ -52,19 +52,16 @@ namespace messaging { } // Create from string - Message::Message(System::String ^ string) : - messagep(new ::qpid::messaging::Message(QpidMarshal::ToNative(string))) + Message::Message(System::String ^ theStr) : + messagep(new ::qpid::messaging::Message(QpidMarshal::ToNative(theStr))) { } // Create from object - Message::Message(System::Object ^ objp) : + Message::Message(System::Object ^ theValue) : messagep(new ::qpid::messaging::Message(QpidMarshal::ToNative(""))) { - ::qpid::types::Variant * variantp = 0; - std::string * variantsp = 0; - - if (QpidTypeCheck::ObjectIsMap(objp)) + if (QpidTypeCheck::ObjectIsMap(theValue)) { // Create a mapped message using given dictionary @@ -72,7 +69,7 @@ namespace messaging { ::qpid::types::Variant::Map newMap; // Add the map variables to the map - TypeTranslator::ManagedToNative(newMap, (QpidMap ^)objp); + TypeTranslator::ManagedToNative((QpidMap ^)theValue, newMap); // Set message content type messagep->setContentType("ampq/map"); @@ -80,7 +77,7 @@ namespace messaging { // Insert the map into the message ::qpid::messaging::encode(newMap, *messagep, QpidMarshal::ToNative("amqp/map")); } - else if (QpidTypeCheck::ObjectIsList(objp)) + else if (QpidTypeCheck::ObjectIsList(theValue)) { // Create a list message using given list @@ -88,7 +85,7 @@ namespace messaging { ::qpid::types::Variant::List newList; // Add the list variables to the list - TypeTranslator::ManagedToNative(newList, (QpidList ^)objp); + TypeTranslator::ManagedToNative((QpidList ^)theValue, newList); // Set message content type messagep->setContentType("ampq/list"); @@ -99,7 +96,7 @@ namespace messaging { else { // Create a binary string message - messagep->setContent(QpidMarshal::ToNative(objp->ToString())); + messagep->setContent(QpidMarshal::ToNative(theValue->ToString())); } } @@ -145,12 +142,12 @@ namespace messaging { // // ReplyTo // - void Message::setReplyTo(Address ^ address) + void Message::SetReplyTo(Address ^ address) { - messagep->setReplyTo(*(address->addressp)); + messagep->setReplyTo(*(address->NativeAddress)); } - Address ^ Message::getReplyTo() + Address ^ Message::GetReplyTo() { const ::qpid::messaging::Address & addrp = messagep->::qpid::messaging::Message::getReplyTo(); @@ -162,12 +159,12 @@ namespace messaging { // // Subject // - void Message::setSubject(System::String ^ subject) + void Message::SetSubject(System::String ^ subject) { messagep->setSubject(QpidMarshal::ToNative(subject)); } - System::String ^ Message::getSubject() + System::String ^ Message::GetSubject() { return gcnew String(messagep->getSubject().c_str()); } @@ -176,26 +173,26 @@ namespace messaging { // // ContentType // - void Message::setContentType(System::String ^ ct) + void Message::SetContentType(System::String ^ ct) { messagep->setContentType(QpidMarshal::ToNative(ct)); } - System::String ^ Message::getContentType() + System::String ^ Message::GetContentType() { - return gcnew String(messagep->getContentType().c_str()); + return gcnew String(messagep->::qpid::messaging::Message::getContentType().c_str()); } // // MessageId // - void Message::setMessageId(System::String ^ mId) + void Message::SetMessageId(System::String ^ messageId) { - messagep->setMessageId(QpidMarshal::ToNative(mId)); + messagep->setMessageId(QpidMarshal::ToNative(messageId)); } - System::String ^ Message::getMessageId() + System::String ^ Message::GetMessageId() { return gcnew String(messagep->getMessageId().c_str()); } @@ -204,12 +201,12 @@ namespace messaging { // // UserId // - void Message::setUserId(System::String ^ uId) + void Message::SetUserId(System::String ^ uId) { messagep->setUserId(QpidMarshal::ToNative(uId)); } - System::String ^ Message::getUserId() + System::String ^ Message::GetUserId() { return gcnew String(messagep->getUserId().c_str()); } @@ -218,12 +215,12 @@ namespace messaging { // // CorrelationId // - void Message::setCorrelationId(System::String ^ cId) + void Message::SetCorrelationId(System::String ^ correlationId) { - messagep->setCorrelationId(QpidMarshal::ToNative(cId)); + messagep->setCorrelationId(QpidMarshal::ToNative(correlationId)); } - System::String ^ Message::getCorrelationId() + System::String ^ Message::GetCorrelationId() { return gcnew String(messagep->getCorrelationId().c_str()); } @@ -232,12 +229,12 @@ namespace messaging { // // Priority // - void Message::setPriority(unsigned char priority) + void Message::SetPriority(unsigned char priority) { messagep->setPriority(priority); } - unsigned char Message::getPriority() + unsigned char Message::GetPriority() { return messagep->getPriority(); } @@ -246,44 +243,44 @@ namespace messaging { // // Ttl // - void Message::setTtl(Duration ^ ttl) + void Message::SetTtl(Duration ^ ttl) { ::qpid::messaging::Duration dur(ttl->Milliseconds); messagep->setTtl(dur); } - Duration ^ Message::getTtl() + Duration ^ Message::GetTtl() { Duration ^ dur = gcnew Duration(messagep->getTtl().getMilliseconds()); return dur; } - void Message::setDurable(bool durable) + void Message::SetDurable(bool durable) { messagep->setDurable(durable); } - bool Message::getDurable() + bool Message::GetDurable() { return messagep->getDurable(); } - bool Message::getRedelivered() + bool Message::GetRedelivered() { return messagep->getRedelivered(); } - void Message::setRedelivered(bool redelivered) + void Message::SetRedelivered(bool redelivered) { messagep->setRedelivered(redelivered); } System::Collections::Generic::Dictionary< - System::String^, System::Object^> ^ Message::getProperties() + System::String^, System::Object^> ^ Message::GetProperties() { ::qpid::types::Variant::Map map; @@ -294,19 +291,19 @@ namespace messaging { gcnew System::Collections::Generic::Dictionary< System::String^, System::Object^> ; - TypeTranslator::NativeToManaged(dict, map); + TypeTranslator::NativeToManaged(map, dict); return dict; } - void Message::setContent(System::String ^ content) + void Message::SetContent(System::String ^ content) { messagep->setContent(QpidMarshal::ToNative(content)); } - System::String ^ Message::getContent() + System::String ^ Message::GetContent() { return gcnew String(messagep->getContent().c_str()); } @@ -315,7 +312,7 @@ namespace messaging { // // User wants to extract a Dictionary from the message // - void Message::getContent(System::Collections::Generic::Dictionary< + void Message::GetContent(System::Collections::Generic::Dictionary< System::String^, System::Object^> ^ dict) { @@ -324,14 +321,14 @@ namespace messaging { ::qpid::messaging::decode(*messagep, map, QpidMarshal::ToNative("amqp/map")); - TypeTranslator::NativeToManaged(dict, map); + TypeTranslator::NativeToManaged(map, dict); } // // User wants to extract a list from the message // - void Message::getContent(System::Collections::Generic::List< + void Message::GetContent(System::Collections::ObjectModel::Collection< System::Object^> ^ list) { // allocate a native messaging::List @@ -341,22 +338,22 @@ namespace messaging { ::qpid::messaging::decode(*messagep, nativeList, QpidMarshal::ToNative("amqp/list")); // translate native list into user's managed list - TypeTranslator::NativeToManaged(list, nativeList); + TypeTranslator::NativeToManaged(nativeList, list); } // // User wants content as bytes. // result array must be correct size already // - void Message::getRaw(array ^ arr) + void Message::GetRaw(array ^ arr) { System::UInt32 size = messagep->getContentSize(); if (0 == size) - throw gcnew QpidException("Message::getRaw - message size is zero"); + throw gcnew QpidException("Message::GetRaw - message size is zero"); if (arr->Length != size) - throw gcnew QpidException("Message::getRaw - receive buffer is too small"); + throw gcnew QpidException("Message::GetRaw - receive buffer is too small"); const char * ptr = messagep->getContentPtr(); @@ -369,7 +366,7 @@ namespace messaging { } - System::UInt64 Message::getContentSize() + System::UInt64 Message::GetContentSize() { return messagep->getContentSize(); } diff --git a/cpp/bindings/qpid/dotnet/src/Message.h b/cpp/bindings/qpid/dotnet/src/Message.h index ab06588634..0a932a907b 100644 --- a/cpp/bindings/qpid/dotnet/src/Message.h +++ b/cpp/bindings/qpid/dotnet/src/Message.h @@ -26,10 +26,10 @@ #include "qpid/messaging/Message.h" -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { ref class Address; ref class Duration; @@ -45,15 +45,18 @@ namespace messaging { // Kept object deletion code void Cleanup(); + // The kept object in the Messaging C++ DLL + ::qpid::messaging::Message * messagep; + public: // Create empty message Message(); // Create from String - Message(System::String ^ string); + Message(System::String ^ theStr); // Create from object - Message(System::Object ^ obj); + Message(System::Object ^ theValue); // TODO: Create from bytes // Message(System::Byte [] ^ bytes); @@ -67,62 +70,64 @@ namespace messaging { // Copy constructor Message(const Message % rhs); - // The kept object in the Messaging C++ DLL - ::qpid::messaging::Message * messagep; + property ::qpid::messaging::Message * NativeMessage + { + ::qpid::messaging::Message * get () { return messagep; } + } - void setReplyTo(Address ^ address); - Address ^ getReplyTo(); + void SetReplyTo(Address ^ address); + Address ^ GetReplyTo(); - void setSubject(System::String ^ subject); - System::String ^ getSubject(); + void SetSubject(System::String ^ subject); + System::String ^ GetSubject(); - void setContentType(System::String ^ ct); - System::String ^ getContentType(); + void SetContentType(System::String ^ ct); + System::String ^ GetContentType(); - void setMessageId(System::String ^ mId); - System::String ^ getMessageId(); + void SetMessageId(System::String ^ messageId); + System::String ^ GetMessageId(); - void setUserId(System::String ^ uId); - System::String ^ getUserId(); + void SetUserId(System::String ^ uId); + System::String ^ GetUserId(); - void setCorrelationId(System::String ^ cId); - System::String ^ getCorrelationId(); + void SetCorrelationId(System::String ^ correlationId); + System::String ^ GetCorrelationId(); - void setPriority(unsigned char priority); - unsigned char getPriority(); + void SetPriority(unsigned char priority); + unsigned char GetPriority(); - void setTtl(Duration ^ ttl); - Duration ^ getTtl(); + void SetTtl(Duration ^ ttl); + Duration ^ GetTtl(); - void setDurable(bool durable); - bool getDurable(); + void SetDurable(bool durable); + bool GetDurable(); - bool getRedelivered(); - void setRedelivered(bool redelivered); + bool GetRedelivered(); + void SetRedelivered(bool redelivered); System::Collections::Generic::Dictionary< - System::String^, System::Object^> ^ getProperties(); + System::String^, System::Object^> ^ GetProperties(); - void setContent(System::String ^ content); + void SetContent(System::String ^ content); //TODO:: void setContent(Bytes{} bytes, offset, length); // get content as string - System::String ^ getContent(); + System::String ^ GetContent(); // get content as dictionary - void getContent(System::Collections::Generic::Dictionary< + void GetContent(System::Collections::Generic::Dictionary< System::String^, System::Object^> ^ dict); // get content as map - void getContent(System::Collections::Generic::List< + void GetContent(System::Collections::ObjectModel::Collection< System::Object^> ^); // get content as bytes - void getRaw(cli::array ^ arr); + void GetRaw(cli::array ^ arr); - System::UInt64 getContentSize(); + System::UInt64 GetContentSize(); //TODO: EncodingException diff --git a/cpp/bindings/qpid/dotnet/src/QpidException.h b/cpp/bindings/qpid/dotnet/src/QpidException.h index eecc54526b..c63f245f74 100644 --- a/cpp/bindings/qpid/dotnet/src/QpidException.h +++ b/cpp/bindings/qpid/dotnet/src/QpidException.h @@ -19,19 +19,23 @@ #pragma once -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { using namespace System; +[Serializable] public ref class QpidException : System::Exception { public: - QpidException() : System::Exception() {} - QpidException(String^ estring) : System::Exception(estring) {} + QpidException() + : System::Exception() {} + + QpidException(String^ estring) + : System::Exception(estring) {} }; diff --git a/cpp/bindings/qpid/dotnet/src/QpidMarshal.h b/cpp/bindings/qpid/dotnet/src/QpidMarshal.h index 7b523464b1..a8266ba5da 100644 --- a/cpp/bindings/qpid/dotnet/src/QpidMarshal.h +++ b/cpp/bindings/qpid/dotnet/src/QpidMarshal.h @@ -22,10 +22,10 @@ using namespace System; using namespace System::Text; -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { @@ -33,6 +33,9 @@ namespace messaging { private ref class QpidMarshal { +private: + QpidMarshal::QpidMarshal() {} + public: /// diff --git a/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h b/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h index 2e87c3e376..47f391fb05 100644 --- a/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h +++ b/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h @@ -24,10 +24,10 @@ #include #include -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// QpidTypeCheck determines if a given managed object represents @@ -35,7 +35,7 @@ namespace messaging { /// // The supported mapping is: /// * a managed Dictionary and a Qpid Messaging Map - /// * a managed List and a Qpid Messaging List + /// * a managed Collection and a Qpid Messaging List /// typedef System::Collections::Generic::Dictionary< @@ -43,33 +43,38 @@ namespace messaging { System::Object^> QpidMap; - typedef System::Collections::Generic::List< + typedef System::Collections::ObjectModel::Collection< System::Object^> QpidList; - private ref class QpidTypeCheckConstants + private ref class QpidTypeCheckConstants sealed { + private: + QpidTypeCheckConstants::QpidTypeCheckConstants() {} + public: static System::Type const ^ const mapTypeP = System::Type::GetType( "System.Collections.Generic.Dictionary`2[System.String,System.Object]"); static System::Type const ^ const listTypeP = System::Type::GetType( - "System.Collections.Generic.List`1[System.Object]"); + "System.Collections.ObjectModel.Collection`1[System.Object]"); }; - public ref class QpidTypeCheck + public ref class QpidTypeCheck sealed { + private: + QpidTypeCheck::QpidTypeCheck() {} public: - static bool ObjectIsMap (System::Object ^ object) + static bool ObjectIsMap (System::Object ^ theValue) { - return (*object).GetType() == QpidTypeCheckConstants::mapTypeP; + return (*theValue).GetType() == QpidTypeCheckConstants::mapTypeP; } - static bool ObjectIsList(System::Object ^ object) + static bool ObjectIsList(System::Object ^ theValue) { - return (*object).GetType() == QpidTypeCheckConstants::listTypeP; + return (*theValue).GetType() == QpidTypeCheckConstants::listTypeP; } }; }}}} diff --git a/cpp/bindings/qpid/dotnet/src/ReadMe.txt b/cpp/bindings/qpid/dotnet/src/ReadMe.txt index a75e35bbf3..a17f04325e 100644 --- a/cpp/bindings/qpid/dotnet/src/ReadMe.txt +++ b/cpp/bindings/qpid/dotnet/src/ReadMe.txt @@ -1,13 +1,13 @@ ======================================================================== - DYNAMIC LINK LIBRARY : org.apache.qpid.messaging Project Overview + DYNAMIC LINK LIBRARY : Org.Apache.Qpid.Messaging Project Overview ======================================================================== -AppWizard has created this org.apache.qpid.messaging DLL for you. +AppWizard has created this Org.Apache.Qpid.Messaging DLL for you. This file contains a summary of what you will find in each of the files that -make up your org.apache.qpid.messaging application. +make up your Org.Apache.Qpid.Messaging application. -org.apache.qpid.messaging.vcproj +Org.Apache.Qpid.Messaging.vcproj This is the main project file for VC++ projects generated using an Application Wizard. It contains information about the version of Visual C++ that generated the file, and information about the platforms, configurations, and project features selected with the diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.cpp b/cpp/bindings/qpid/dotnet/src/Receiver.cpp index d647315620..15f8572a53 100644 --- a/cpp/bindings/qpid/dotnet/src/Receiver.cpp +++ b/cpp/bindings/qpid/dotnet/src/Receiver.cpp @@ -34,10 +34,10 @@ #include "Duration.h" #include "QpidException.h" -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Receiver is a managed wrapper for a ::qpid::messaging::Receiver @@ -85,30 +85,30 @@ namespace messaging { } // - // get(message) + // Get(message) // - bool Receiver::get(Message ^ mmsgp) + bool Receiver::Get(Message ^ mmsgp) { - return get(mmsgp, DurationConstants::FORVER); + return Get(mmsgp, DurationConstants::FORVER); } - bool Receiver::get(Message ^ mmsgp, Duration ^ durationp) + bool Receiver::Get(Message ^ mmsgp, Duration ^ durationp) { ::qpid::messaging::Duration dur((*durationp).Milliseconds); - return receiverp->Receiver::get(*(mmsgp->messagep), dur); + return receiverp->Receiver::get(*(mmsgp->NativeMessage), dur); } // - // message = get() + // message = Get() // - Message ^ Receiver::get() + Message ^ Receiver::Get() { - return get(DurationConstants::FORVER); + return Get(DurationConstants::FORVER); } - Message ^ Receiver::get(Duration ^ durationp) + Message ^ Receiver::Get(Duration ^ durationp) { System::Exception ^ newException = nullptr; ::qpid::messaging::Message * msgp = NULL; @@ -133,58 +133,54 @@ namespace messaging { String ^ errmsg = gcnew String(error.what()); newException = gcnew QpidException(errmsg); } - catch (const std::exception & error) - { - String ^ errmsg = gcnew String(error.what()); - newException = gcnew QpidException(errmsg); - } - catch ( ... ) - { - newException = gcnew QpidException("Receiver:get unknown error"); - } finally { - // Clean up and throw on caught exceptions if (newException != nullptr) { if (msgp != NULL) { delete msgp; } - - throw newException; + if (newMessage != nullptr) + { + delete newMessage; + } } } + if (newException != nullptr) + { + throw newException; + } return newMessage; } // - // fetch(message) + // Fetch(message) // - bool Receiver::fetch(Message ^ mmsgp) + bool Receiver::Fetch(Message ^ mmsgp) { - return fetch(mmsgp, DurationConstants::FORVER); + return Fetch(mmsgp, DurationConstants::FORVER); } - bool Receiver::fetch(Message ^ mmsgp, Duration ^ durationp) + bool Receiver::Fetch(Message ^ mmsgp, Duration ^ durationp) { ::qpid::messaging::Duration dur((*durationp).Milliseconds); - return receiverp->::qpid::messaging::Receiver::fetch(*((*mmsgp).messagep), dur); + return receiverp->::qpid::messaging::Receiver::fetch(*((*mmsgp).NativeMessage), dur); } // - // message = fetch() + // message = Fetch() // - Message ^ Receiver::fetch() + Message ^ Receiver::Fetch() { - return fetch(DurationConstants::FORVER); + return Fetch(DurationConstants::FORVER); } - Message ^ Receiver::fetch(Duration ^ durationp) + Message ^ Receiver::Fetch(Duration ^ durationp) { System::Exception ^ newException = nullptr; ::qpid::messaging::Message * msgp = NULL; @@ -209,64 +205,59 @@ namespace messaging { String ^ errmsg = gcnew String(error.what()); newException = gcnew QpidException(errmsg); } - catch (const std::exception & error) - { - String ^ errmsg = gcnew String(error.what()); - newException = gcnew QpidException(errmsg); - } - catch ( ... ) - { - newException = gcnew QpidException("Receiver:fetch unknown error"); - - } finally { - // Clean up and throw on caught exceptions if (newException != nullptr) { if (msgp != NULL) { delete msgp; } - - throw newException; + if (newMessage != nullptr) + { + delete newMessage; + } } } + if (newException != nullptr) + { + throw newException; + } return newMessage; } - void Receiver::setCapacity(System::UInt32 capacity) + void Receiver::SetCapacity(System::UInt32 capacity) { receiverp->setCapacity(capacity); } - System::UInt32 Receiver::getCapacity() + System::UInt32 Receiver::GetCapacity() { return receiverp->getCapacity(); } - System::UInt32 Receiver::getAvailable() + System::UInt32 Receiver::GetAvailable() { return receiverp->getAvailable(); } - System::UInt32 Receiver::getUnsettled() + System::UInt32 Receiver::GetUnsettled() { return receiverp->getUnsettled(); } - void Receiver::close() + void Receiver::Close() { receiverp->close(); } - System::String ^ Receiver::getName() + System::String ^ Receiver::GetName() { return gcnew System::String(receiverp->getName().c_str()); } - Session ^ Receiver::getSession() + Session ^ Receiver::GetSession() { return parentSession; } diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.h b/cpp/bindings/qpid/dotnet/src/Receiver.h index 26d0402a3c..0dc2f6120f 100644 --- a/cpp/bindings/qpid/dotnet/src/Receiver.h +++ b/cpp/bindings/qpid/dotnet/src/Receiver.h @@ -35,10 +35,10 @@ namespace messaging { class ReceiverImpl {}; }} -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Mreceiver is a managed wrapper for a ::qpid::messaging::Receiver @@ -57,38 +57,43 @@ namespace messaging { // Kept object deletion code void Cleanup(); - public: // The kept object in the Messaging C++ DLL ::qpid::messaging::Receiver * receiverp; + public: Receiver(::qpid::messaging::Receiver * r, Session ^ sessRef); ~Receiver(); !Receiver(); Receiver(const Receiver ^ rhs); - // get(message) - bool get(Message ^ mmsgp); - bool get(Message ^ mmsgp, Duration ^ durationp); - - // message = get() - Message ^ get(); - Message ^ get(Duration ^ durationp); - - // fetch(message) - bool fetch(Message ^ mmsgp); - bool fetch(Message ^ mmsgp, Duration ^ duration); - - // message = fetch() - Message ^ fetch(); - Message ^ fetch(Duration ^ durationp); - - void setCapacity(System::UInt32 capacity); - System::UInt32 getCapacity(); - System::UInt32 getAvailable(); - System::UInt32 getUnsettled(); - void close(); - System::String ^ getName(); - Session ^ getSession(); + property ::qpid::messaging::Receiver * NativeReceiver + { + ::qpid::messaging::Receiver * get () { return receiverp; } + } + + // Get(message) + bool Get(Message ^ mmsgp); + bool Get(Message ^ mmsgp, Duration ^ durationp); + + // message = Get() + Message ^ Get(); + Message ^ Get(Duration ^ durationp); + + // Fetch(message) + bool Fetch(Message ^ mmsgp); + bool Fetch(Message ^ mmsgp, Duration ^ duration); + + // message = Fetch() + Message ^ Fetch(); + Message ^ Fetch(Duration ^ durationp); + + void SetCapacity(System::UInt32 capacity); + System::UInt32 GetCapacity(); + System::UInt32 GetAvailable(); + System::UInt32 GetUnsettled(); + void Close(); + System::String ^ GetName(); + Session ^ GetSession(); }; }}}} diff --git a/cpp/bindings/qpid/dotnet/src/Sender.cpp b/cpp/bindings/qpid/dotnet/src/Sender.cpp index 1708359104..e0911b38db 100644 --- a/cpp/bindings/qpid/dotnet/src/Sender.cpp +++ b/cpp/bindings/qpid/dotnet/src/Sender.cpp @@ -30,10 +30,10 @@ #include "Sender.h" #include "Message.h" -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Sender a managed wrapper for a ::qpid::messaging::Sender @@ -79,25 +79,25 @@ namespace messaging { } // - // send(msg) + // Send(msg) // - void Sender::send(Message ^ mmsgp) + void Sender::Send(Message ^ mmsgp) { - send(mmsgp, false); + Send(mmsgp, false); } - void Sender::send(Message ^ mmsgp, bool sync) + void Sender::Send(Message ^ mmsgp, bool sync) { - senderp->::qpid::messaging::Sender::send(*((*mmsgp).messagep), sync); + senderp->::qpid::messaging::Sender::send(*((*mmsgp).NativeMessage), sync); } - void Sender::close() + void Sender::Close() { senderp->close(); } - Session ^ Sender::getSession() + Session ^ Sender::GetSession() { return parentSession; } diff --git a/cpp/bindings/qpid/dotnet/src/Sender.h b/cpp/bindings/qpid/dotnet/src/Sender.h index 17f7e822c4..705c7d5b65 100644 --- a/cpp/bindings/qpid/dotnet/src/Sender.h +++ b/cpp/bindings/qpid/dotnet/src/Sender.h @@ -34,10 +34,10 @@ namespace messaging { class SenderImpl {}; }} -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Sender is a managed wrapper for a ::qpid::messaging::Sender @@ -65,11 +65,11 @@ namespace messaging { !Sender(); Sender(const Sender % rhs); - // send(message) - void send(Message ^ mmsgp); - void send(Message ^ mmsgp, bool sync); + // Send(message) + void Send(Message ^ mmsgp); + void Send(Message ^ mmsgp, bool sync); - void close(); + void Close(); property System::UInt32 Capacity { @@ -95,6 +95,6 @@ namespace messaging { } } - Session ^ getSession(); + Session ^ GetSession(); }; }}}} diff --git a/cpp/bindings/qpid/dotnet/src/Session.cpp b/cpp/bindings/qpid/dotnet/src/Session.cpp index c070f10333..c8d85b00ee 100644 --- a/cpp/bindings/qpid/dotnet/src/Session.cpp +++ b/cpp/bindings/qpid/dotnet/src/Session.cpp @@ -35,10 +35,10 @@ #include "Message.h" #include "QpidException.h" -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Session is a managed wrapper for a ::qpid::messaging::Session @@ -84,110 +84,93 @@ namespace messaging { } } - void Session::close() + void Session::Close() { sessionp->close(); } - void Session::commit() + void Session::Commit() { sessionp->commit(); } - void Session::rollback() + void Session::Rollback() { sessionp->rollback(); } - void Session::acknowledge() + void Session::Acknowledge() { - acknowledge(false); + Acknowledge(false); } - void Session::acknowledge(bool sync) + void Session::Acknowledge(bool sync) { sessionp->acknowledge(sync); } - void Session::reject(Message ^ message) + void Session::Reject(Message ^ message) { - sessionp->::qpid::messaging::Session::reject(*(message->messagep)); + sessionp->::qpid::messaging::Session::reject(*(message->NativeMessage)); } - void Session::release(Message ^ message) + void Session::Release(Message ^ message) { - sessionp->::qpid::messaging::Session::release(*(message->messagep)); + sessionp->::qpid::messaging::Session::release(*(message->NativeMessage)); } - void Session::sync() + void Session::Sync() { - sync(true); + Sync(true); } - void Session::sync(bool block) + void Session::Sync(bool block) { sessionp->sync(block); } // next(receiver) - bool Session::nextReceiver(Receiver ^ rcvr) + bool Session::NextReceiver(Receiver ^ rcvr) { - return nextReceiver(rcvr, DurationConstants::FORVER); + return NextReceiver(rcvr, DurationConstants::FORVER); } - bool Session::nextReceiver(Receiver ^ rcvr, Duration ^ timeout) + bool Session::NextReceiver(Receiver ^ rcvr, Duration ^ timeout) { System::Exception ^ newException = nullptr; - try - { + try + { + // create a duration object ::qpid::messaging::Duration dur(timeout->Milliseconds); - return sessionp->nextReceiver(*(rcvr->receiverp), dur); + // wait for the next received message + return sessionp->nextReceiver(*(rcvr->NativeReceiver), dur); } catch (const ::qpid::types::Exception & error) - { + { String ^ errmsg = gcnew String(error.what()); - if (errmsg = "No message to fetch") - { - // on timeout return null + if ("No message to fetch" == errmsg){ return false; } newException = gcnew QpidException(errmsg); } - catch (const std::exception & error) - { - String ^ errmsg = gcnew String(error.what()); - newException = gcnew QpidException(errmsg); - } - catch ( ... ) - { - newException = gcnew QpidException("Session::nextReceiver unknown error"); - } - finally - { - // Clean up and throw on caught exceptions - if (newException != nullptr) - { - if (sessionp != NULL) - { - delete sessionp; - } + if (newException != nullptr) + { + throw newException; + } - throw newException; - } - } return true; } // receiver = next() - Receiver ^ Session::nextReceiver() + Receiver ^ Session::NextReceiver() { - return nextReceiver(DurationConstants::FORVER); + return NextReceiver(DurationConstants::FORVER); } - Receiver ^ Session::nextReceiver(Duration ^ timeout) + Receiver ^ Session::NextReceiver(Duration ^ timeout) { System::Exception ^ newException = nullptr; @@ -205,41 +188,23 @@ namespace messaging { catch (const ::qpid::types::Exception & error) { String ^ errmsg = gcnew String(error.what()); - if (errmsg = "No message to fetch") + if ("No message to fetch" == errmsg) { - // on timeout return null return nullptr; } newException = gcnew QpidException(errmsg); } - catch (const std::exception & error) - { - String ^ errmsg = gcnew String(error.what()); - newException = gcnew QpidException(errmsg); - } - catch ( ... ) - { - newException = gcnew QpidException("Session::nextReceiver unknown error"); - } - finally - { - // Clean up and throw on caught exceptions - if (newException != nullptr) - { - if (sessionp != NULL) - { - delete sessionp; - } + if (newException != nullptr) + { + throw newException; + } - throw newException; - } - } - return nullptr; + return nullptr; } - Sender ^ Session::createSender (System::String ^ address) + Sender ^ Session::CreateSender (System::String ^ address) { System::Exception ^ newException = nullptr; ::qpid::messaging::Sender * senderp = NULL; @@ -261,41 +226,39 @@ namespace messaging { String ^ errmsg = gcnew String(error.what()); newException = gcnew QpidException(errmsg); } - catch (const std::exception & error) - { - String ^ errmsg = gcnew String(error.what()); - newException = gcnew QpidException(errmsg); - } - catch ( ... ) - { - newException = gcnew QpidException("Session::createSender unknown error"); - - } finally { - // Clean up and throw on caught exceptions if (newException != nullptr) { - if (senderp != NULL) - { - delete senderp; - } - - throw newException; + if (newSender != nullptr) + { + delete newSender; + } + else + { + if (senderp != NULL) + { + delete senderp; + } + } } } + if (newException != nullptr) + { + throw newException; + } return newSender; } - Receiver ^ Session::createReceiver(System::String ^ address) + Receiver ^ Session::CreateReceiver(System::String ^ address) { System::Exception ^ newException = nullptr; ::qpid::messaging::Receiver * receiverp = NULL; Receiver ^ newReceiver = nullptr; - try - { + try + { // allocate a native receiver receiverp = new ::qpid::messaging::Receiver; @@ -306,39 +269,37 @@ namespace messaging { newReceiver = gcnew Receiver(receiverp, this); } catch (const ::qpid::types::Exception & error) - { + { String ^ errmsg = gcnew String(error.what()); newException = gcnew QpidException(errmsg); } - catch (const std::exception & error) - { - String ^ errmsg = gcnew String(error.what()); - newException = gcnew QpidException(errmsg); - } - catch ( ... ) - { - newException = gcnew QpidException("Session::createReceiver unknown error"); - - } - finally - { - // Clean up and throw on caught exceptions + finally + { if (newException != nullptr) - { - if (sessionp != NULL) - { - delete sessionp; - } - - throw newException; + { + if (newReceiver != nullptr) + { + delete newReceiver; + } + else + { + if (receiverp != NULL) + { + delete receiverp; + } + } } } + if (newException != nullptr) + { + throw newException; + } return newReceiver; } - Receiver ^ Session::createReceiver() + Receiver ^ Session::CreateReceiver() { System::Exception ^ newException = nullptr; ::qpid::messaging::Receiver * receiverp = NULL; @@ -357,35 +318,33 @@ namespace messaging { String ^ errmsg = gcnew String(error.what()); newException = gcnew QpidException(errmsg); } - catch (const std::exception & error) - { - String ^ errmsg = gcnew String(error.what()); - newException = gcnew QpidException(errmsg); - } - catch ( ... ) - { - newException = gcnew QpidException("Session::createReceiver unknown error"); - - } - finally - { - // Clean up and throw on caught exceptions + finally + { if (newException != nullptr) - { - if (sessionp != NULL) - { - delete sessionp; - } - - throw newException; + { + if (newReceiver != nullptr) + { + delete newReceiver; + } + else + { + if (receiverp != NULL) + { + delete receiverp; + } + } } } + if (newException != nullptr) + { + throw newException; + } return newReceiver; } - Sender ^ Session::getSender(System::String ^ name) + Sender ^ Session::GetSender(System::String ^ name) { ::qpid::messaging::Sender * sender = new ::qpid::messaging::Sender; @@ -398,7 +357,7 @@ namespace messaging { - Receiver ^ Session::getReceiver(System::String ^ name) + Receiver ^ Session::GetReceiver(System::String ^ name) { ::qpid::messaging::Receiver * receiver = new ::qpid::messaging::Receiver; @@ -411,12 +370,12 @@ namespace messaging { - Connection ^ Session::getConnection() + Connection ^ Session::GetConnection() { return parentConnectionp; } - void Session::checkError() + void Session::CheckError() { sessionp->checkError(); } diff --git a/cpp/bindings/qpid/dotnet/src/Session.h b/cpp/bindings/qpid/dotnet/src/Session.h index 3212f050c1..babb99d30e 100644 --- a/cpp/bindings/qpid/dotnet/src/Session.h +++ b/cpp/bindings/qpid/dotnet/src/Session.h @@ -36,10 +36,10 @@ namespace messaging { class SessionImpl {}; }} -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Session is a managed wrapper for a ::qpid::messaging::Session @@ -70,15 +70,15 @@ namespace messaging { !Session(); Session(const Session % rhs); - void close(); - void commit(); - void rollback(); - void acknowledge(); - void acknowledge(bool sync); - void reject(Message ^); - void release(Message ^); - void sync(); - void sync(bool block); + void Close(); + void Commit(); + void Rollback(); + void Acknowledge(); + void Acknowledge(bool sync); + void Reject(Message ^); + void Release(Message ^); + void Sync(); + void Sync(bool block); property System::UInt32 Receivable { @@ -91,28 +91,28 @@ namespace messaging { } // next(receiver) - bool nextReceiver(Receiver ^); - bool nextReceiver(Receiver ^, Duration ^ timeout); + bool NextReceiver(Receiver ^ rcvr); + bool NextReceiver(Receiver ^ rcvr, Duration ^ timeout); // receiver = next() - Receiver ^ nextReceiver(); - Receiver ^ nextReceiver(Duration ^ timeout); + Receiver ^ NextReceiver(); + Receiver ^ NextReceiver(Duration ^ timeout); - Sender ^ createSender (System::String ^ address); - Receiver ^ createReceiver(System::String ^ address); - Receiver ^ createReceiver(); + Sender ^ CreateSender (System::String ^ address); + Receiver ^ CreateReceiver(System::String ^ address); + Receiver ^ CreateReceiver(); - Sender ^ getSender(System::String ^ name); - Receiver ^ getReceiver(System::String ^ name); + Sender ^ GetSender(System::String ^ name); + Receiver ^ GetReceiver(System::String ^ name); - Connection ^ getConnection(); + Connection ^ GetConnection(); property System::Boolean HasError { System::Boolean get () { return sessionp->hasError(); } } - void checkError(); + void CheckError(); }; }}}} diff --git a/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp b/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp index 3fbe1e204f..d463e668c3 100644 --- a/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp +++ b/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp @@ -29,10 +29,10 @@ #include "QpidTypeCheck.h" #include "QpidMarshal.h" -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// Translate between managed and native types. @@ -42,11 +42,12 @@ namespace messaging { // The given object is a Dictionary. // Add its elements to the qpid map. // - void TypeTranslator::ManagedToNative(::qpid::types::Variant::Map & theMapp, - QpidMap ^ theObjp) + void TypeTranslator::ManagedToNative(QpidMap ^ theDictionary, + ::qpid::types::Variant::Map & qpidMap) { // iterate the items, converting each to a variant and adding to the map - for each (System::Collections::Generic::KeyValuePair kvp in theObjp) + for each (System::Collections::Generic::KeyValuePair + kvp in theDictionary) { if (QpidTypeCheck::ObjectIsMap(kvp.Value)) { @@ -55,7 +56,7 @@ namespace messaging { ::qpid::types::Variant::Map newMap; // Add the map variables to the map - ManagedToNative(newMap, (QpidMap ^)kvp.Value); + ManagedToNative((QpidMap ^)kvp.Value, newMap); // Create a variant entry for the inner map std::auto_ptr<::qpid::types::Variant> newVariantp(new ::qpid::types::Variant(newMap)); @@ -64,7 +65,7 @@ namespace messaging { std::string entryName = QpidMarshal::ToNative(kvp.Key); // Add inner map to outer map - theMapp.insert(std::make_pair(entryName, *newVariantp)); + qpidMap.insert(std::make_pair(entryName, *newVariantp)); } else if (QpidTypeCheck::ObjectIsList(kvp.Value)) { @@ -73,7 +74,7 @@ namespace messaging { ::qpid::types::Variant::List newList; // Add the List variables to the list - ManagedToNative(newList, (QpidList ^)kvp.Value); + ManagedToNative((QpidList ^)kvp.Value, newList); // Create a variant entry for the inner map ::qpid::types::Variant::List newVariant(newList); @@ -84,7 +85,7 @@ namespace messaging { std::string entryName = QpidMarshal::ToNative(kvp.Key); // Add inner list to outer map - theMapp.insert(std::make_pair(entryName, newVariant)); + qpidMap.insert(std::make_pair(entryName, newVariant)); } else { @@ -92,7 +93,7 @@ namespace messaging { ::qpid::types::Variant entryValue; ManagedToNativeObject(kvp.Value, entryValue); std::string entryName = QpidMarshal::ToNative(kvp.Key); - theMapp.insert(std::make_pair(entryName, entryValue)); + qpidMap.insert(std::make_pair(entryName, entryValue)); } } } @@ -103,11 +104,11 @@ namespace messaging { // The given object is a List. // Add its elements to the qpid list. // - void TypeTranslator::ManagedToNative(::qpid::types::Variant::List & theListp, - QpidList ^ theObjp) + void TypeTranslator::ManagedToNative(QpidList ^ theList, + ::qpid::types::Variant::List & qpidList) { // iterate the items, converting each to a variant and adding to the map - for each (System::Object ^ listObj in theObjp) + for each (System::Object ^ listObj in theList) { if (QpidTypeCheck::ObjectIsMap(listObj)) { @@ -116,13 +117,13 @@ namespace messaging { ::qpid::types::Variant::Map newMap; // Add the map variables to the map - ManagedToNative(newMap, (QpidMap ^)listObj); + ManagedToNative((QpidMap ^)listObj, newMap); // Create a variant entry for the inner map std::auto_ptr<::qpid::types::Variant> newVariantp(new ::qpid::types::Variant(newMap)); // Add inner map to outer list - theListp.push_back(*newVariantp); + qpidList.push_back(*newVariantp); } else if (QpidTypeCheck::ObjectIsList(listObj)) { @@ -131,20 +132,20 @@ namespace messaging { ::qpid::types::Variant::List newList; // Add the List variables to the list - ManagedToNative(newList, (QpidList ^)listObj); + ManagedToNative((QpidList ^)listObj, newList); // Create a variant entry for the inner list std::auto_ptr<::qpid::types::Variant> newVariantp(new ::qpid::types::Variant(newList)); // Add inner list to outer list - theListp.push_back(*newVariantp); + qpidList.push_back(*newVariantp); } else { // Add a simple native type to list ::qpid::types::Variant entryValue; ManagedToNativeObject(listObj, entryValue); - theListp.push_back(entryValue); + qpidList.push_back(entryValue); } } } @@ -155,57 +156,57 @@ namespace messaging { // Returns a variant representing simple native type object. // Not to be called for Map/List objects. // - void TypeTranslator::ManagedToNativeObject(System::Object ^ theObjp, - ::qpid::types::Variant & targetp) + void TypeTranslator::ManagedToNativeObject(System::Object ^ managedValue, + ::qpid::types::Variant & qpidVariant) { - System::Type ^ typeP = (*theObjp).GetType(); + System::Type ^ typeP = (*managedValue).GetType(); System::TypeCode typeCode = System::Type::GetTypeCode( typeP ); switch (typeCode) { case System::TypeCode::Boolean : - targetp = System::Convert::ToBoolean(theObjp); + qpidVariant = System::Convert::ToBoolean(managedValue, System::Globalization::CultureInfo::InvariantCulture); break; case System::TypeCode::Byte : - targetp = System::Convert::ToByte(theObjp); + qpidVariant = System::Convert::ToByte(managedValue, System::Globalization::CultureInfo::InvariantCulture); break; case System::TypeCode::UInt16 : - targetp = System::Convert::ToUInt16(theObjp); + qpidVariant = System::Convert::ToUInt16(managedValue, System::Globalization::CultureInfo::InvariantCulture); break; case System::TypeCode::UInt32 : - targetp = System::Convert::ToUInt32(theObjp); + qpidVariant = System::Convert::ToUInt32(managedValue, System::Globalization::CultureInfo::InvariantCulture); break; case System::TypeCode::UInt64 : - targetp = System::Convert::ToUInt64(theObjp); + qpidVariant = System::Convert::ToUInt64(managedValue, System::Globalization::CultureInfo::InvariantCulture); break; case System::TypeCode::Char : case System::TypeCode::SByte : - targetp = System::Convert::ToSByte(theObjp); + qpidVariant = System::Convert::ToSByte(managedValue, System::Globalization::CultureInfo::InvariantCulture); break; case System::TypeCode::Int16 : - targetp = System::Convert::ToInt16(theObjp); + qpidVariant = System::Convert::ToInt16(managedValue, System::Globalization::CultureInfo::InvariantCulture); break; case System::TypeCode::Int32 : - targetp = System::Convert::ToInt32(theObjp); + qpidVariant = System::Convert::ToInt32(managedValue, System::Globalization::CultureInfo::InvariantCulture); break; case System::TypeCode::Int64 : - targetp = System::Convert::ToInt64(theObjp); + qpidVariant = System::Convert::ToInt64(managedValue, System::Globalization::CultureInfo::InvariantCulture); break; case System::TypeCode::Single : - targetp = System::Convert::ToSingle(theObjp); + qpidVariant = System::Convert::ToSingle(managedValue, System::Globalization::CultureInfo::InvariantCulture); break; case System::TypeCode::Double : - targetp = System::Convert::ToDouble(theObjp); + qpidVariant = System::Convert::ToDouble(managedValue, System::Globalization::CultureInfo::InvariantCulture); break; case System::TypeCode::String : @@ -213,10 +214,10 @@ namespace messaging { std::string rString; System::String ^ rpString; - rpString = System::Convert::ToString(theObjp); + rpString = System::Convert::ToString(managedValue, System::Globalization::CultureInfo::InvariantCulture); rString = QpidMarshal::ToNative(rpString); - targetp = rString; - targetp.setEncoding(QpidMarshal::ToNative("utf8")); + qpidVariant = rString; + qpidVariant.setEncoding(QpidMarshal::ToNative("utf8")); } break; @@ -232,11 +233,12 @@ namespace messaging { // Given a user Dictionary and a qpid map, // extract the qpid elements and put them into the dictionary. // - void TypeTranslator::NativeToManaged(QpidMap ^ dict, ::qpid::types::Variant::Map & map) + void TypeTranslator::NativeToManaged(::qpid::types::Variant::Map & qpidMap, + QpidMap ^ dict) { // For each object in the message map, // create a .NET object and add it to the dictionary. - for (::qpid::types::Variant::Map::const_iterator i = map.begin(); i != map.end(); ++i) { + for (::qpid::types::Variant::Map::const_iterator i = qpidMap.begin(); i != qpidMap.end(); ++i) { // Get the name System::String ^ elementName = gcnew String(i->first.c_str()); @@ -299,7 +301,7 @@ namespace messaging { { QpidMap ^ newDict = gcnew QpidMap(); - NativeToManaged(newDict, variant.asMap()); + NativeToManaged(variant.asMap(), newDict); dict[elementName] = newDict; break; @@ -309,7 +311,7 @@ namespace messaging { { QpidList ^ newList = gcnew QpidList(); - NativeToManaged(newList, variant.asList()); + NativeToManaged(variant.asList(), newList); dict[elementName] = newList; break; @@ -322,10 +324,10 @@ namespace messaging { } - void TypeTranslator::NativeToManaged(QpidList ^ vList, ::qpid::types::Variant::List & qpidList) + void TypeTranslator::NativeToManaged(::qpid::types::Variant::List & qpidList, QpidList ^ managedList) { - // For each object in the message map, - // create a .NET object and add it to the dictionary. + // For each object in the qpidList + // create a .NET object and add it to the managed List. for (::qpid::types::Variant::List::const_iterator i = qpidList.begin(); i != qpidList.end(); ++i) { ::qpid::types::Variant variant = *i; @@ -334,62 +336,62 @@ namespace messaging { switch (vType) { case ::qpid::types::VAR_BOOL: - (*vList).Add(variant.asBool()); + (*managedList).Add(variant.asBool()); break; case ::qpid::types::VAR_UINT8: - (*vList).Add(variant.asUint8()); + (*managedList).Add(variant.asUint8()); break; case ::qpid::types::VAR_UINT16: - (*vList).Add(variant.asUint16()); + (*managedList).Add(variant.asUint16()); break; case ::qpid::types::VAR_UINT32: - (*vList).Add(variant.asUint32()); + (*managedList).Add(variant.asUint32()); break; case ::qpid::types::VAR_UINT64: - (*vList).Add(variant.asUint64()); + (*managedList).Add(variant.asUint64()); break; case ::qpid::types::VAR_INT8: - (*vList).Add(variant.asInt8()); + (*managedList).Add(variant.asInt8()); break; case ::qpid::types::VAR_INT16: - (*vList).Add(variant.asInt16()); + (*managedList).Add(variant.asInt16()); break; case ::qpid::types::VAR_INT32: - (*vList).Add(variant.asInt32()); + (*managedList).Add(variant.asInt32()); break; case ::qpid::types::VAR_INT64: - (*vList).Add(variant.asInt64()); + (*managedList).Add(variant.asInt64()); break; case ::qpid::types::VAR_FLOAT: - (*vList).Add(variant.asFloat()); + (*managedList).Add(variant.asFloat()); break; case ::qpid::types::VAR_DOUBLE: - (*vList).Add(variant.asDouble()); + (*managedList).Add(variant.asDouble()); break; case ::qpid::types::VAR_STRING: { System::String ^ elementValue = gcnew System::String(variant.asString().c_str()); - (*vList).Add(elementValue); + (*managedList).Add(elementValue); break; } case ::qpid::types::VAR_MAP: { QpidMap ^ newDict = gcnew QpidMap(); - NativeToManaged(newDict, variant.asMap()); + NativeToManaged(variant.asMap(), newDict); - (*vList).Add(newDict); + (*managedList).Add(newDict); break; } @@ -397,9 +399,9 @@ namespace messaging { { QpidList ^ newList = gcnew QpidList(); - NativeToManaged(newList, variant.asList()); + NativeToManaged(variant.asList(), newList); - (*vList).Add(newList); + (*managedList).Add(newList); break; } diff --git a/cpp/bindings/qpid/dotnet/src/TypeTranslator.h b/cpp/bindings/qpid/dotnet/src/TypeTranslator.h index 7ffba69614..df12689cf8 100644 --- a/cpp/bindings/qpid/dotnet/src/TypeTranslator.h +++ b/cpp/bindings/qpid/dotnet/src/TypeTranslator.h @@ -28,43 +28,44 @@ #include "QpidTypeCheck.h" -namespace org { -namespace apache { -namespace qpid { -namespace messaging { +namespace Org { +namespace Apache { +namespace Qpid { +namespace Messaging { /// /// TypeTranslator provides codec between .NET Dictionary/List and /// qpid messaging Map/List. /// - - public ref class TypeTranslator + public ref class TypeTranslator sealed { + private: + TypeTranslator::TypeTranslator() {} public: - // The given object is a Dictionary. + // The given object is a managed Dictionary. // Add its elements to the qpid map. - static void ManagedToNative(::qpid::types::Variant::Map & theMapp, - QpidMap ^ theObjp); + static void ManagedToNative(QpidMap ^ theDictionary, + ::qpid::types::Variant::Map & qpidMap); - // The given object is a List. + // The given object is a managed List. // Add its elements to the qpid list. - static void ManagedToNative(::qpid::types::Variant::List & theListp, - QpidList ^ theObjp); + static void ManagedToNative(QpidList ^ theList, + ::qpid::types::Variant::List & qpidList); - // The given object is a simple native type (not a Dictionary or List) + // The given object is a simple managed type (not a Dictionary or List) // Returns a variant representing simple native type object. - static void ManagedToNativeObject(System::Object ^ theObjp, - ::qpid::types::Variant & targetp); + static void ManagedToNativeObject(System::Object ^ managedValue, + ::qpid::types::Variant & qpidVariant); - // Given a Dictionary, - // Return its values in a Qpid map - static void NativeToManaged(QpidMap ^ dict, - ::qpid::types::Variant::Map & map); + // The given object is a qpid map. + // Add its elements to the managed Dictionary. + static void NativeToManaged(::qpid::types::Variant::Map & qpidMap, + QpidMap ^ dict); - // Given a List, - // Return its values in a Qpid list - static void NativeToManaged(QpidList ^ vList, - ::qpid::types::Variant::List & qpidList); + // The given object is a qpid list. + // Add its elements to the managed List. + static void NativeToManaged(::qpid::types::Variant::List & qpidList, + QpidList ^ managedList); }; }}}} diff --git a/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.rc b/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.rc index 0e47baec7e..71f051c3e4 100644 --- a/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.rc +++ b/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.rc @@ -69,12 +69,12 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "FileDescription", "org" + VALUE "FileDescription", "org.apache.qpid.messaging" VALUE "FileVersion", "1, 3, 0, 1" - VALUE "InternalName", "org" + VALUE "InternalName", "org.apache.qpid.messaging" VALUE "LegalCopyright", "Copyright (C) 2010" VALUE "OriginalFilename", "org.apache.qpid.messaging" - VALUE "ProductName", "org" + VALUE "ProductName", "org.apache.qpid.messaging" VALUE "ProductVersion", "1, 3, 0, 1" END END diff --git a/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.vcproj b/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.vcproj index 7c31781f40..9700b59666 100644 --- a/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.vcproj +++ b/cpp/bindings/qpid/dotnet/src/org.apache.qpid.messaging.vcproj @@ -2,7 +2,7 @@ + + diff --git a/cpp/bindings/qpid/dotnet/src/sessionreceiver/Properties/AssemblyInfo.cs b/cpp/bindings/qpid/dotnet/src/sessionreceiver/Properties/AssemblyInfo.cs index 57f83add20..19c1ea9da1 100644 --- a/cpp/bindings/qpid/dotnet/src/sessionreceiver/Properties/AssemblyInfo.cs +++ b/cpp/bindings/qpid/dotnet/src/sessionreceiver/Properties/AssemblyInfo.cs @@ -24,11 +24,11 @@ using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("org.apache.qpid.messaging.sessionreceiver")] +[assembly: AssemblyTitle("Org.Apache.Qpid.Messaging.SessionReceiver")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("org.apache.qpid.messaging.sessionreceiver")] +[assembly: AssemblyProduct("Org.Apache.Qpid.Messaging.SessionReceiver")] [assembly: AssemblyCopyright("Copyright © 2010")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs b/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs index 73956ecdef..c5a1a7eecc 100644 --- a/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs +++ b/cpp/bindings/qpid/dotnet/src/sessionreceiver/sessionreceiver.cs @@ -23,9 +23,9 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using org.apache.qpid.messaging; +using Org.Apache.Qpid.Messaging; -namespace org.apache.qpid.messaging.sessionreceiver +namespace Org.Apache.Qpid.Messaging.SessionReceiver { /// /// ISessionReceiver interface defines the callback for users to supply. @@ -43,19 +43,19 @@ namespace org.apache.qpid.messaging.sessionreceiver /// - /// eventEngine - wait for messages from the underlying C++ code. + /// EventEngine - wait for messages from the underlying C++ code. /// When available get them and deliver them via callback to our /// client through the ISessionReceiver interface. /// This class consumes the thread that calls the Run() function. /// - internal class eventEngine + internal class EventEngine { private Session session; private ISessionReceiver callback; private bool keepRunning; - public eventEngine(Session theSession, ISessionReceiver thecallback) + public EventEngine(Session theSession, ISessionReceiver thecallback) { this.session = theSession; this.callback = thecallback; @@ -65,35 +65,35 @@ namespace org.apache.qpid.messaging.sessionreceiver /// Function to call Session's nextReceiver, discover messages, /// and to deliver messages through the callback. /// - public void open() + public void Open() { - Receiver rcvr = session.createReceiver(); + Receiver rcvr = session.CreateReceiver(); Message msg; keepRunning = true; while (keepRunning) { - if (session.nextReceiver(rcvr, DurationConstants.SECOND)) + if (session.NextReceiver(rcvr, DurationConstants.SECOND)) { if (keepRunning) { - msg = rcvr.fetch(DurationConstants.SECOND); + msg = rcvr.Fetch(DurationConstants.SECOND); this.callback.SessionReceiver(rcvr, msg); } } //else // receive timed out - // eventEngine exits the nextReceiver() function periodically + // EventEngine exits the nextReceiver() function periodically // in order to test the keepRunning flag } // Private thread is now exiting. } /// - /// Function to stop the eventEngine. Private thread will exit within + /// Function to stop the EventEngine. Private thread will exit within /// one second. /// - public void close() + public void Close() { keepRunning = false; } @@ -104,9 +104,9 @@ namespace org.apache.qpid.messaging.sessionreceiver /// server is the class that users instantiate to connect a SessionReceiver /// callback to the stream of received messages received on a Session. /// - public class server + public class CallbackServer { - private eventEngine ee; + private EventEngine ee; /// /// Constructor for the server. @@ -114,20 +114,20 @@ namespace org.apache.qpid.messaging.sessionreceiver /// The Session whose messages are collected. /// The user function call with each message. /// - public server(Session session, ISessionReceiver callback) + public CallbackServer(Session session, ISessionReceiver callback) { - ee = new eventEngine(session, callback); + ee = new EventEngine(session, callback); new System.Threading.Thread( - new System.Threading.ThreadStart(ee.open)).Start(); + new System.Threading.ThreadStart(ee.Open)).Start(); } /// /// Function to stop the server. /// - public void close() + public void Close() { - ee.close(); + ee.Close(); } } } diff --git a/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.cs b/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.cs index 5d161728e5..923952bff9 100644 --- a/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.cs +++ b/cpp/bindings/qpid/dotnet/test/messaging.test/messaging.test.cs @@ -2,9 +2,9 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using org.apache.qpid.messaging; +using Org.Apache.Qpid.Messaging; -namespace org.apache.qpid.messaging +namespace Org.Apache.Qpid.Messaging { class Program { @@ -64,22 +64,22 @@ namespace org.apache.qpid.messaging Address aType = new Address ("check3", "subj", options, "hot"); - Console.WriteLine("aEmpty : {0}", aEmpty.str()); - Console.WriteLine("aStr : {0}", aStr.str()); - Console.WriteLine("aSubj : {0}", aSubj.str()); - Console.WriteLine("aType : {0}", aType.str()); + Console.WriteLine("aEmpty : {0}", aEmpty.ToStr()); + Console.WriteLine("aStr : {0}", aStr.ToStr()); + Console.WriteLine("aSubj : {0}", aSubj.ToStr()); + Console.WriteLine("aType : {0}", aType.ToStr()); // // Raw message data retrieval // Message m2 = new Message("rarey"); - UInt64 m2Size = m2.getContentSize(); + UInt64 m2Size = m2.GetContentSize(); byte[] myRaw = new byte [m2Size]; - m2.getRaw(myRaw); + m2.GetRaw(myRaw); Console.WriteLine("Got raw array size {0}", m2Size); for (UInt64 i = 0; i < m2Size; i++) Console.Write("{0} ", myRaw[i].ToString()); -- cgit v1.2.1