Skip to content

Commit

Permalink
Updating C# Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
metadings committed Feb 20, 2015
1 parent 1e6c991 commit 1a634ca
Show file tree
Hide file tree
Showing 52 changed files with 75 additions and 56 deletions.
2 changes: 1 addition & 1 deletion examples/C#/Beispiel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Examples
{
public partial class Program
{
public static void Beispiel(IDictionary<string, string> dict, string[] args)
public static void Beispiel(string[] args)
{
//
// Simple REQ-REP
Expand Down
27 changes: 23 additions & 4 deletions examples/C#/ProgramRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,35 @@ static int Main(string[] args)
if (method != null)
{

ParameterInfo[] methodParameters = method.GetParameters();

object[] parameters;

if (methodParameters.Length == 2)
{
parameters = new object[] {
dict,
args.Skip(1 + leaveOut).ToArray() /* string[] args */
};
}
else if (methodParameters.Length == 1)
{
parameters = new object[] {
args.Skip(1 + leaveOut).ToArray() /* string[] args */
};
}
else
{
throw new InvalidOperationException();
}

// INFO: Invoking the Sample by "the Delegate.Invoke" makes it hard to debug!
// Using DebugInvoke
object result
= DebugStackTrace<TargetInvocationException>.Invoke(
method,
null,
new object[] {
dict,
args.Skip(1 + leaveOut).ToArray() /* string[] args */
});
parameters);

if (method.ReturnType == typeof(bool) && true == (bool)result)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/C#/Z85Encode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Examples
{
public partial class Program
{
public static void Z85Encode(IDictionary<string, string> dict, string[] args)
public static void Z85Encode(string[] args)
{
//
// Author: metadings
Expand All @@ -24,7 +24,7 @@ public static void Z85Encode(IDictionary<string, string> dict, string[] args)
Console.WriteLine("{0}: {1}", txt, encoded);
}

public static void Z85Decode(IDictionary<string, string> dict, string[] args)
public static void Z85Decode(string[] args)
{
//
// Author: metadings
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/asyncsrv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void AsyncSrv_ServerWorker(ZContext context, int i)
}
}

public static void AsyncSrv(IDictionary<string, string> dict, string[] args)
public static void AsyncSrv(string[] args)
{
// The main thread simply starts several clients and a server, and then
// waits for the server to finish.
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/eagain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void EAgain(IDictionary<string, string> dict, string[] args)
public static void EAgain(string[] args)
{
//
// Shows how to provoke EAGAIN when reaching HWM
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/espresso.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Examples
{
static partial class Program
{
public static void Espresso(IDictionary<string, string> dict, string[] args)
public static void Espresso(string[] args)
{
//
// Espresso Pattern
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/flclient1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static partial class Program

static int FLClient1_MAX_RETRIES = 3; // Before we abandon

public static void FLClient1(IDictionary<string, string> dict, string[] args)
public static void FLClient1(string[] args)
{
//
// Freelance client - Model 1
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/flclient2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public ZMessage Request(ZMessage request)

static partial class Program
{
public static void FLClient2(IDictionary<string, string> dict, string[] args)
public static void FLClient2(string[] args)
{
if (args == null || args.Length < 1)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/flclient3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Examples
static partial class Program
{

public static void FLClient3(IDictionary<string, string> dict, string[] args)
public static void FLClient3(string[] args)
{
//
// Freelance client - Model 3
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/flserver1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void FLServer1(IDictionary<string, string> dict, string[] args)
public static void FLServer1(string[] args)
{
//
// Freelance server - Model 1
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/flserver2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void FLServer2(IDictionary<string, string> dict, string[] args)
public static void FLServer2(string[] args)
{
//
// Freelance server - Model 2
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/flserver3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void FLServer3(IDictionary<string, string> dict, string[] args)
public static void FLServer3(string[] args)
{
//
// Freelance server - Model 3
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/hwclient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void HWClient(IDictionary<string, string> dict, string[] args)
public static void HWClient(string[] args)
{
//
// Hello World client
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/hwserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void HWServer(IDictionary<string, string> dict, string[] args)
public static void HWServer(string[] args)
{
//
// Hello World server
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/identity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void Identity(IDictionary<string, string> dict, string[] args)
public static void Identity(string[] args)
{
//
// Demonstrate request-reply identities
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/interrupt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void Interrupt(IDictionary<string, string> dict, string[] args)
public static void Interrupt(string[] args)
{
//
// Interrupt
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/lbbroker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static void LBBroker_Worker(ZContext context, int i)
}
}

public static void LBBroker(IDictionary<string, string> dict, string[] args)
public static void LBBroker(string[] args)
{
// This is the main task. It starts the clients and workers, and then
// routes requests between the two layers. Workers signal READY when
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/lpclient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static ZSocket LPClient_CreateZSocket(ZContext context, string name, out ZError
return requester;
}

public static void LPClient(IDictionary<string, string> dict, string[] args)
public static void LPClient(string[] args)
{
if (args == null || args.Length < 1)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/lpserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static partial class Program
// Author: metadings
//

public static void LPServer(IDictionary<string, string> dict, string[] args)
public static void LPServer(string[] args)
{
using (var context = new ZContext())
using (var responder = new ZSocket(context, ZSocketType.REP))
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/lvcache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void LVCache(IDictionary<string, string> dict, string[] args)
public static void LVCache(string[] args)
{
//
// Last value cache
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/msgqueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void MsgQueue(IDictionary<string, string> dict, string[] args)
public static void MsgQueue(string[] args)
{
//
// Simple message queuing broker
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/mspoller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void MSPoller(IDictionary<string, string> dict, string[] args)
public static void MSPoller(string[] args)
{
//
// Reading from multiple sockets
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/msreader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void MSReader(IDictionary<string, string> dict, string[] args)
public static void MSReader(string[] args)
{
//
// Reading from multiple sockets
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/mtrelay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void MTRelay(IDictionary<string, string> dict, string[] args)
public static void MTRelay(string[] args)
{
//
// Multithreaded relay
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/mtserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void MTServer(IDictionary<string, string> dict, string[] args)
public static void MTServer(string[] args)
{
//
// Multithreaded Hello World server
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/pathopub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void PathoPub(IDictionary<string, string> dict, string[] args)
public static void PathoPub(string[] args)
{
//
// Pathological publisher
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/pathosub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void PathoSub(IDictionary<string, string> dict, string[] args)
public static void PathoSub(string[] args)
{
//
// Pathological subscriber
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/peering1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static partial class Program
// Author: metadings
//

public static void Peering1(IDictionary<string, string> dict, string[] args)
public static void Peering1(string[] args)
{
// First argument is this broker's name
// Other arguments are our peers' names
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/peering2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static void Peering2_WorkerTask(ZContext context, int i, string name)

// The main task begins by setting-up its frontend and backend sockets
// and then starting its client and worker tasks:
public static void Peering2(IDictionary<string, string> dict, string[] args)
public static void Peering2(string[] args)
{
// First argument is this broker's name
// Other arguments are our peers' names
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/ppqueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static void Purge(this IList<Worker> workers)

static partial class Program
{
public static void PPQueue(IDictionary<string, string> dict, string[] args)
public static void PPQueue(string[] args)
{
using (var context = new ZContext())
using (var backend = new ZSocket(context, ZSocketType.ROUTER))
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/ppworker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static ZSocket PPWorker_CreateZSocket(ZContext context, string name, out ZError
return worker;
}

public static void PPWorker(IDictionary<string, string> dict, string[] args)
public static void PPWorker(string[] args)
{
if (args == null || args.Length == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/psenvpub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void PSEnvPub(IDictionary<string, string> dict, string[] args)
public static void PSEnvPub(string[] args)
{
//
// Pubsub envelope publisher
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/psenvsub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void PSEnvSub(IDictionary<string, string> dict, string[] args)
public static void PSEnvSub(string[] args)
{
//
// Pubsub envelope subscriber
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/rrbroker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void RRBroker(IDictionary<string, string> dict, string[] args)
public static void RRBroker(string[] args)
{
//
// Simple request-reply broker
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/rrclient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void RRClient(IDictionary<string, string> dict, string[] args)
public static void RRClient(string[] args)
{
//
// Hello World client
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/rrworker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void RRWorker(IDictionary<string, string> dict, string[] args)
public static void RRWorker(string[] args)
{
//
// Hello World worker
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/rtdealer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static partial class Program
{
static int RTDealer_Workers = 10;

public static void RTDealer(IDictionary<string, string> dict, string[] args)
public static void RTDealer(string[] args)
{
//
// ROUTER-to-DEALER example
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/rtreq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ static partial class Program
{
static int RTReq_Workers = 10;

public static void RTReq(IDictionary<string, string> dict, string[] args)
public static void RTReq(string[] args)
{
//
// ROUTER-to-REQ example
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/spqueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void SPQueue(IDictionary<string, string> dict, string[] args)
public static void SPQueue(string[] args)
{
//
// Simple Pirate broker
Expand Down
2 changes: 1 addition & 1 deletion examples/C#/spworker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Examples
{
static partial class Program
{
public static void SPWorker(IDictionary<string, string> dict, string[] args)
public static void SPWorker(string[] args)
{
//
// Simple Pirate worker
Expand Down
Loading

0 comments on commit 1a634ca

Please sign in to comment.