diff options
| author | Ted Ross <tross@apache.org> | 2010-06-25 17:55:46 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2010-06-25 17:55:46 +0000 |
| commit | cff7dc046568b207c9a08dea221427c54706c747 (patch) | |
| tree | 95e7d49125ad4d552a1be163352fd4e04f62152a /cpp/bindings/qpid/dotnet/examples | |
| parent | c3a6e87c3f21009135b5826de6917586477e0589 (diff) | |
| download | qpid-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/examples')
9 files changed, 50 insertions, 16 deletions
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 af0b398da6..69f7a0d974 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 @@ -58,7 +58,7 @@ namespace CSharpDirect {
connection = new Connection(host);
connection.Open();
- if (!connection.IsOpen()) {
+ if (!connection.IsOpen) {
Console.WriteLine("Failed to open connection to host : {0}", host);
} else {
Session session = connection.CreateSession();
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 b287af2563..2e80e8c47d 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 @@ -59,7 +59,7 @@ namespace csharp.direct.sender connection = new Connection(host);
connection.Open();
- if (!connection.IsOpen()) {
+ if (!connection.IsOpen) {
Console.WriteLine("Failed to open connection to host : {0}", host);
} else {
Session session = connection.CreateSession();
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.example.client/csharp.example.client.cs b/cpp/bindings/qpid/dotnet/examples/csharp.example.client/csharp.example.client.cs index 93459b6684..79b798e540 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.example.client/csharp.example.client.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.example.client/csharp.example.client.cs @@ -50,7 +50,7 @@ namespace Org.Apache.Qpid.Messaging.Examples { };
Message request = new Message("");
- request.SetReplyTo(responseQueue);
+ request.ReplyTo = responseQueue;
for (int i = 0; i < s.Length; i++) {
request.SetContent(s[i]);
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs b/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs index 6740e6a076..2d763a306d 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.example.drain/csharp.example.drain.cs @@ -47,17 +47,17 @@ namespace Org.Apache.Qpid.Messaging.Examples { while (receiver.Fetch(message, timeout))
{
Dictionary<string, object> properties = new Dictionary<string, object>();
- properties = message.GetProperties();
+ properties = message.Properties;
Console.Write("Message(properties={0}, content='",
message.MapAsString(properties));
- if ("amqp/map" == message.GetContentType())
+ if ("amqp/map" == message.ContentType)
{
Dictionary<string, object> content = new Dictionary<string, object>();
message.GetContent(content);
Console.Write(message.MapAsString(content));
}
- else if ("amqp/list" == message.GetContentType())
+ else if ("amqp/list" == message.ContentType)
{
Collection<object> content = new Collection<object>();
message.GetContent(content);
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.example.server/csharp.example.server.cs b/cpp/bindings/qpid/dotnet/examples/csharp.example.server/csharp.example.server.cs index af01e4b0f9..4ec56491ac 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.example.server/csharp.example.server.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.example.server/csharp.example.server.cs @@ -38,7 +38,7 @@ namespace Org.Apache.Qpid.Messaging.Examples { while (true) {
Message request = receiver.Fetch();
- Address address = request.GetReplyTo();
+ Address address = request.ReplyTo;
if (null != address) {
Sender sender = session.CreateSender(address);
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.example.spout/csharp.example.spout.cs b/cpp/bindings/qpid/dotnet/examples/csharp.example.spout/csharp.example.spout.cs index 7eeece3194..59ba35f12b 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.example.spout/csharp.example.spout.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.example.spout/csharp.example.spout.cs @@ -29,8 +29,8 @@ using Org.Apache.Qpid.Messaging; namespace Org.Apache.Qpid.Messaging.Examples {
class Spout {
//
- // Sample invocation: csharp.example.drain.exe --broker localhost:5672 --timeout 30 my-queue
- // This pro
+ // Sample invocation: csharp.example.spout.exe --broker localhost:5672 my-queue
+ //
static bool NameVal(string In, out string nameOut, out string valueOut)
{
int pos = In.IndexOf("=");
@@ -83,7 +83,7 @@ namespace Org.Apache.Qpid.Messaging.Examples { else
{
message = new Message(options.Content);
- message.SetContentType("text/plain");
+ message.ContentType = "text/plain";
}
Address replyToAddr = new Address(options.ReplyTo);
@@ -95,7 +95,7 @@ namespace Org.Apache.Qpid.Messaging.Examples { (0 == options.Timeout || stopwatch.Elapsed <= timespan);
count++)
{
- if ("" != options.ReplyTo) message.SetReplyTo(replyToAddr);
+ if ("" != options.ReplyTo) message.ReplyTo = replyToAddr;
string id = options.Id ;
if ("" == id) {
Guid g = Guid.NewGuid();
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 2ef78545b6..965b494dc7 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 @@ -93,14 +93,14 @@ namespace Org.Apache.Qpid.Messaging.Examples /// <param name="message">The Message</param>
public static void ShowMessage(Message message)
{
- if ("amqp/map" == message.GetContentType())
+ if ("amqp/map" == message.ContentType)
{
Console.WriteLine("Received a Dictionary");
Dictionary<string, object> content = new Dictionary<string, object>();
message.GetContent(content);
ShowDictionary(content, 0);
}
- else if ("amqp/list" == message.GetContentType())
+ else if ("amqp/list" == message.ContentType)
{
Console.WriteLine("Received a List");
Collection<object> content = new Collection<object>();
@@ -148,7 +148,7 @@ namespace Org.Apache.Qpid.Messaging.Examples //
// Acknowledge the receipt of all received messages.
//
- receiver.GetSession().Acknowledge();
+ receiver.Session.Acknowledge();
}
@@ -241,7 +241,7 @@ namespace Org.Apache.Qpid.Messaging.Examples //
// Establish a capacity
//
- receiver.SetCapacity(100);
+ receiver.Capacity = 100;
//
// Wait so many seconds for messages to arrive.
diff --git a/cpp/bindings/qpid/dotnet/examples/powershell.example.helloworld/powershell.example.helloworld.ps1 b/cpp/bindings/qpid/dotnet/examples/powershell.example.helloworld/powershell.example.helloworld.ps1 new file mode 100644 index 0000000000..e8c21bc3f6 --- /dev/null +++ b/cpp/bindings/qpid/dotnet/examples/powershell.example.helloworld/powershell.example.helloworld.ps1 @@ -0,0 +1,34 @@ +#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+#
+# Script for 32-bit powershell
+#
+
+[Reflection.Assembly]::LoadFile('W:\cpp\src\Debug\org.apache.qpid.messagingd.dll')
+$conn = new-object Org.Apache.Qpid.Messaging.Connection("localhost:5672")
+$conn.Open()
+$sess = $conn.CreateSession()
+$rcvr = $sess.CreateReceiver("amq.topic")
+$sender = $sess.CreateSender("amq.topic")
+$msg1 = new-object Org.Apache.Qpid.Messaging.Message("Hello world!")
+$sender.Send($msg1)
+$dur = new-object Org.Apache.Qpid.Messaging.Duration(1000)
+$msg2 = $rcvr.Fetch($dur)
+$msg2.GetContent()
diff --git a/cpp/bindings/qpid/dotnet/examples/visualbasic.example.client/visualbasic.example.client.vb b/cpp/bindings/qpid/dotnet/examples/visualbasic.example.client/visualbasic.example.client.vb index 96300ecf66..ccdc0d673c 100644 --- a/cpp/bindings/qpid/dotnet/examples/visualbasic.example.client/visualbasic.example.client.vb +++ b/cpp/bindings/qpid/dotnet/examples/visualbasic.example.client/visualbasic.example.client.vb @@ -48,7 +48,7 @@ Namespace Org.Apache.Qpid.Messaging.Examples s(3) = "And the mome raths outgrabe."
Dim request As Message = New Message("")
- request.SetReplyTo(responseQueue)
+ request.ReplyTo = responseQueue
Dim i As Integer
For i = 0 To s.Length - 1
|
