summaryrefslogtreecommitdiff
path: root/cpp/bindings/qpid/dotnet/src/Message.h
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2010-06-25 17:55:46 +0000
committerTed Ross <tross@apache.org>2010-06-25 17:55:46 +0000
commitcff7dc046568b207c9a08dea221427c54706c747 (patch)
tree95e7d49125ad4d552a1be163352fd4e04f62152a /cpp/bindings/qpid/dotnet/src/Message.h
parentc3a6e87c3f21009135b5826de6917586477e0589 (diff)
downloadqpid-python-cff7dc046568b207c9a08dea221427c54706c747.tar.gz
QPID-2589 - Patch from Chuck Rolke
* Convert c-style Get() functions to c#-style properties. * Add powershell helloworld example. * Fix message SetContent to accept byte array or byte array slice. * Re-code Session GetReceiver and GetSender not to malloc new objects but to create the objects on the stack. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@958052 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/bindings/qpid/dotnet/src/Message.h')
-rw-r--r--cpp/bindings/qpid/dotnet/src/Message.h254
1 files changed, 225 insertions, 29 deletions
diff --git a/cpp/bindings/qpid/dotnet/src/Message.h b/cpp/bindings/qpid/dotnet/src/Message.h
index 99d0b8667e..d5b4beb406 100644
--- a/cpp/bindings/qpid/dotnet/src/Message.h
+++ b/cpp/bindings/qpid/dotnet/src/Message.h
@@ -26,6 +26,11 @@
#include "qpid/messaging/Message.h"
+#include "QpidMarshal.h"
+#include "Address.h"
+#include "Duration.h"
+#include "TypeTranslator.h"
+
namespace Org {
namespace Apache {
namespace Qpid {
@@ -78,46 +83,227 @@ namespace Messaging {
::qpid::messaging::Message * get () { return messagep; }
}
- void SetReplyTo(Address ^ address);
- Address ^ GetReplyTo();
+ //
+ // ReplyTo
+ //
+ property Address ^ ReplyTo
+ {
+ void set (Address ^ address)
+ {
+ messagep->setReplyTo(*(address->NativeAddress));
+ }
+
+ Address ^ get ()
+ {
+ const ::qpid::messaging::Address & addrp =
+ messagep->::qpid::messaging::Message::getReplyTo();
+
+ return gcnew Address(const_cast<::qpid::messaging::Address *>(&addrp));
+ }
+ }
+
+ //
+ // Subject
+ //
+ property System::String ^ Subject
+ {
+ void set (System::String ^ subject)
+ {
+ messagep->setSubject(QpidMarshal::ToNative(subject));
+ }
+
+
+ System::String ^ get ()
+ {
+ return gcnew String(messagep->getSubject().c_str());
+ }
+ }
- void SetSubject(System::String ^ subject);
- System::String ^ GetSubject();
- void SetContentType(System::String ^ ct);
- System::String ^ GetContentType();
-
- void SetMessageId(System::String ^ messageId);
- System::String ^ GetMessageId();
-
- void SetUserId(System::String ^ uId);
- System::String ^ GetUserId();
+ //
+ // ContentType
+ //
+ property System::String ^ ContentType
+ {
+ void set (System::String ^ ct)
+ {
+ messagep->setContentType(QpidMarshal::ToNative(ct));
+ }
+
+ System::String ^ get ()
+ {
+ return gcnew String(messagep->::qpid::messaging::Message::getContentType().c_str());
+ }
+ }
+
+
+ //
+ // MessageId
+ //
+ property System::String ^ MessageId
+ {
+ void set (System::String ^ messageId)
+ {
+ messagep->setMessageId(QpidMarshal::ToNative(messageId));
+ }
+
+ System::String ^ get ()
+ {
+ return gcnew String(messagep->getMessageId().c_str());
+ }
+ }
+
- void SetCorrelationId(System::String ^ correlationId);
- System::String ^ GetCorrelationId();
+ //
+ // UserId
+ //
+ property System::String ^ UserId
+ {
+ void set (System::String ^ uId)
+ {
+ messagep->setUserId(QpidMarshal::ToNative(uId));
+ }
+
+ System::String ^ get ()
+ {
+ return gcnew String(messagep->getUserId().c_str());
+ }
+ }
- void SetPriority(unsigned char priority);
- unsigned char GetPriority();
+
+ //
+ // CorrelationId
+ //
+ property System::String ^ CorrelationId
+ {
+ void set (System::String ^ correlationId)
+ {
+ messagep->setCorrelationId(QpidMarshal::ToNative(correlationId));
+ }
+
+ System::String ^ get ()
+ {
+ return gcnew String(messagep->getCorrelationId().c_str());
+ }
+ }
- void SetTtl(Duration ^ ttl);
- Duration ^ GetTtl();
- void SetDurable(bool durable);
- bool GetDurable();
+ //
+ // Priority
+ //
+ property unsigned char Priority
+ {
+ void set (unsigned char priority)
+ {
+ messagep->setPriority(priority);
+ }
+
+ unsigned char get ()
+ {
+ return messagep->getPriority();
+ }
+ }
+
+
+ //
+ // Ttl
+ //
+ property Duration ^ Ttl
+ {
+ void set (Duration ^ ttl)
+ {
+ ::qpid::messaging::Duration dur(ttl->Milliseconds);
+
+ messagep->setTtl(dur);
+ }
+
+ Duration ^ get ()
+ {
+ Duration ^ dur = gcnew Duration(messagep->getTtl().getMilliseconds());
+
+ return dur;
+ }
+ }
+
+ //
+ // Durable
+ //
+ property bool Durable
+ {
+ void set (bool durable)
+ {
+ messagep->setDurable(durable);
+ }
+
+ bool get ()
+ {
+ return messagep->getDurable();
+ }
+ }
+
+ //
+ // Redelivered
+ //
+ property bool Redelivered
+ {
+ bool get ()
+ {
+ return messagep->getRedelivered();
+ }
+
+ void set (bool redelivered)
+ {
+ messagep->setRedelivered(redelivered);
+ }
+ }
+
+ //
+ // Property
+ //
+ void Message::SetProperty(System::String ^ name, System::Object ^ value);
+
+ //
+ // Properties
+ //
+ property System::Collections::Generic::Dictionary<
+ System::String^, System::Object^> ^ Properties
+ {
+ System::Collections::Generic::Dictionary<
+ System::String^, System::Object^> ^ get ()
+ {
+ ::qpid::types::Variant::Map map;
- bool GetRedelivered();
- void SetRedelivered(bool redelivered);
+ map = messagep->getProperties();
- System::Collections::Generic::Dictionary<
- System::String^, System::Object^> ^ GetProperties();
+ System::Collections::Generic::Dictionary<
+ System::String^, System::Object^> ^ dict =
+ gcnew System::Collections::Generic::Dictionary<
+ System::String^, System::Object^> ;
- void SetProperty(System::String ^ name, System::Object ^ value);
+ TypeTranslator::NativeToManaged(map, dict);
+
+ return dict;
+ }
+
+
+ void set (System::Collections::Generic::Dictionary<
+ System::String^, System::Object^> ^ properties)
+ {
+ for each (System::Collections::Generic::KeyValuePair
+ <System::String^, System::Object^> kvp in properties)
+ {
+ SetProperty(kvp.Key, kvp.Value);
+ }
+ }
+ }
- void SetProperties(System::Collections::Generic::Dictionary<
- System::String^, System::Object^> ^ properties);
void SetContent(System::String ^ content);
+ void SetContent(cli::array<System::Byte> ^ bytes);
+
+ void SetContent(cli::array<System::Byte> ^ bytes, int offset, int size);
+
//TODO:: void setContent(Bytes{} bytes, offset, length);
// get content as string
@@ -133,9 +319,19 @@ namespace Messaging {
System::Object^> ^);
// get content as bytes
- void GetRaw(cli::array<System::Byte> ^ arr);
+ void GetContent(cli::array<System::Byte> ^ arr);
+
+ //
+ // ContentSize
+ //
+ property System::UInt64 ContentSize
+ {
+ System::UInt64 get ()
+ {
+ return messagep->getContentSize();
+ }
+ }
- System::UInt64 GetContentSize();
// A message has been returned to managed code through GetContent().
// Display the content of that System::Object as a string.