diff options
| author | Ted Ross <tross@apache.org> | 2010-06-09 11:59:38 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2010-06-09 11:59:38 +0000 |
| commit | 077b8b25ab7fac22daf8494feb125cd5c73b95ac (patch) | |
| tree | f0f2d8b17c7ef912d16d3110bc18790006bbd87a /cpp/bindings/qpid/dotnet/examples | |
| parent | b6b344dccb18ed44500232e492573244b8a6bdf3 (diff) | |
| download | qpid-python-077b8b25ab7fac22daf8494feb125cd5c73b95ac.tar.gz | |
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
Diffstat (limited to 'cpp/bindings/qpid/dotnet/examples')
6 files changed, 68 insertions, 66 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 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
{
/// <summary>
/// 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<object>)kvp.Value, level + 1);
+ ShowList((Collection<object>)kvp.Value, level + 1);
}
else
Console.WriteLine("Key: {0}, Value: {1}, Type: {2}",
@@ -63,7 +64,7 @@ namespace org.apache.qpid.messaging.examples /// </summary>
/// <param name="list">The AMQP list</param>
/// <param name="level">Nested depth</param>
- public static void ShowList(List<object> list, int level)
+ public static void ShowList(Collection<object> 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<object>)obj, level + 1);
+ ShowList((Collection<object>)obj, level + 1);
}
else
Console.WriteLine("Value: {0}, Type: {1}",
@@ -92,24 +93,24 @@ 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.GetContentType())
{
Console.WriteLine("Received a Dictionary");
Dictionary<string, object> content = new Dictionary<string, object>();
- 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<object> content = new List<object>();
- message.getContent(content);
+ Collection<object> content = new Collection<object>();
+ 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<string, object> content = new Dictionary<string, object>();
Dictionary<string, object> subMap = new Dictionary<string, object>();
- List<object> colors = new List<object>();
+ Collection<object> colors = new Collection<object>();
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<count; i++)
- sender.send(message, true);
+ sender.Send(message, true);
//
// Close the connection.
//
- connection.close();
+ connection.Close();
}
}
diff --git a/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs index 9a425c03b7..41ed9f30b5 100644 --- a/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs +++ b/cpp/bindings/qpid/dotnet/examples/csharp.map.receiver/csharp.map.recevier.cs @@ -21,16 +21,15 @@ using System;
using System.Collections.Generic;
-using org.apache.qpid.messaging;
+using Org.Apache.Qpid.Messaging;
-namespace org.apache.qpid.messaging.examples
+namespace Org.Apache.Qpid.Messaging.examples
{
class MapReceiver
{
static void Main(string[] args)
{
string url = "amqp:tcp:localhost:5672";
-// string url = "10.16.18.254:5672";
if (args.Length > 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<string, object> content = new Dictionary<string, object>();
- 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<string, object> content = new Dictionary<string, object>();
Dictionary<string, object> subMap = new Dictionary<string, object>();
- List<object> colors = new List<object>();
+ Collection<object> colors = new Collection<object>();
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();
}
}
}
|
