summaryrefslogtreecommitdiff
path: root/cs
diff options
context:
space:
mode:
Diffstat (limited to 'cs')
-rw-r--r--cs/demo/book/lifecycle/Client.cs7
-rw-r--r--cs/demo/book/lifecycle/Server.cs7
-rw-r--r--cs/demo/book/printer/Client.cs26
-rw-r--r--cs/demo/book/printer/Server.cs27
-rw-r--r--cs/demo/book/simple_filesystem/Client.cs41
-rw-r--r--cs/demo/book/simple_filesystem/DirectoryI.cs1
-rw-r--r--cs/demo/book/simple_filesystem/FileI.cs1
-rw-r--r--cs/demo/book/simple_filesystem/Server.cs30
8 files changed, 93 insertions, 47 deletions
diff --git a/cs/demo/book/lifecycle/Client.cs b/cs/demo/book/lifecycle/Client.cs
index 2921a4c347a..8310f8c8d3d 100644
--- a/cs/demo/book/lifecycle/Client.cs
+++ b/cs/demo/book/lifecycle/Client.cs
@@ -23,18 +23,17 @@ public class Client
{
public override int run(String[] args)
{
+ //
// Terminate cleanly on receipt of a signal.
//
shutdownOnInterrupt();
+ //
// Create a proxy for the root directory
//
Ice.ObjectPrx @base = communicator().stringToProxy("RootDir:default -p 10000");
- if(@base == null)
- {
- throw new Error("Could not create proxy");
- }
+ //
// Down-cast the proxy to a Directory proxy.
//
DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(@base);
diff --git a/cs/demo/book/lifecycle/Server.cs b/cs/demo/book/lifecycle/Server.cs
index b9f2c5b157d..2a5627b95c4 100644
--- a/cs/demo/book/lifecycle/Server.cs
+++ b/cs/demo/book/lifecycle/Server.cs
@@ -23,15 +23,18 @@ public class Server
{
public override int run(string[] args)
{
+ //
// Terminate cleanly on receipt of a signal.
//
shutdownOnInterrupt();
+ //
// Create an object adapter
//
Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints(
- "LifecycleFilesystem", "default -h 127.0.0.1 -p 10000");
+ "LifecycleFilesystem", "default -h 127.0.0.1 -p 10000");
+ //
// Create the root directory.
//
DirectoryI root = new DirectoryI();
@@ -39,12 +42,14 @@ public class Server
id.name = "RootDir";
adapter.add(root, id);
+ //
// All objects are created, allow client requests now.
//
adapter.activate();
//
// Wait until we are done.
+ //
communicator().waitForShutdown();
if(interrupted())
{
diff --git a/cs/demo/book/printer/Client.cs b/cs/demo/book/printer/Client.cs
index af3cf8e820d..faf7d16b1c9 100644
--- a/cs/demo/book/printer/Client.cs
+++ b/cs/demo/book/printer/Client.cs
@@ -23,25 +23,31 @@ public class Client
{
int status = 0;
Ice.Communicator ic = null;
- try {
+ try
+ {
ic = Ice.Util.initialize(ref args);
- Ice.ObjectPrx obj = ic.stringToProxy(
- "SimplePrinter:default -p 10000");
+ Ice.ObjectPrx obj = ic.stringToProxy("SimplePrinter:default -p 10000");
PrinterPrx printer = PrinterPrxHelper.checkedCast(obj);
- if (printer == null)
+ if(printer == null)
+ {
throw new ApplicationException("Invalid proxy");
+ }
printer.printString("Hello World!");
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
- if (ic != null) {
- // Clean up
- //
- try {
+ if(ic != null)
+ {
+ try
+ {
ic.destroy();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
diff --git a/cs/demo/book/printer/Server.cs b/cs/demo/book/printer/Server.cs
index 42e3c16e591..21561874570 100644
--- a/cs/demo/book/printer/Server.cs
+++ b/cs/demo/book/printer/Server.cs
@@ -30,28 +30,29 @@ public class Server
{
int status = 0;
Ice.Communicator ic = null;
- try {
+ try
+ {
ic = Ice.Util.initialize(ref args);
- Ice.ObjectAdapter adapter
- = ic.createObjectAdapterWithEndpoints(
- "SimplePrinterAdapter", "default -p 10000");
+ Ice.ObjectAdapter adapter =
+ ic.createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
Ice.Object obj = new PrinterI();
- adapter.add(
- obj,
- ic.stringToIdentity("SimplePrinter"));
+ adapter.add(obj, ic.stringToIdentity("SimplePrinter"));
adapter.activate();
ic.waitForShutdown();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
- if (ic != null)
+ if(ic != null)
{
- // Clean up
- //
- try {
+ try
+ {
ic.destroy();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
diff --git a/cs/demo/book/simple_filesystem/Client.cs b/cs/demo/book/simple_filesystem/Client.cs
index c3e7777665a..fe6e0a8fa28 100644
--- a/cs/demo/book/simple_filesystem/Client.cs
+++ b/cs/demo/book/simple_filesystem/Client.cs
@@ -29,16 +29,22 @@ public class Client
NodePrx[] contents = dir.list();
- foreach (NodePrx node in contents) {
+ foreach(NodePrx node in contents)
+ {
DirectoryPrx subdir = DirectoryPrxHelper.checkedCast(node);
FilePrx file = FilePrxHelper.uncheckedCast(node);
Console.WriteLine(indent + node.name() + (subdir != null ? " (directory):" : " (file):"));
- if (subdir != null) {
+ if(subdir != null)
+ {
listRecursive(subdir, depth);
- } else {
+ }
+ else
+ {
string[] text = file.read();
- for (int j = 0; j < text.Length; ++j)
+ for(int j = 0; j < text.Length; ++j)
+ {
Console.WriteLine(indent + "\t" + text[j]);
+ }
}
}
}
@@ -47,35 +53,46 @@ public class Client
{
int status = 0;
Ice.Communicator ic = null;
- try {
+ try
+ {
+ //
// Create a communicator
//
ic = Ice.Util.initialize(ref args);
+ //
// Create a proxy for the root directory
//
Ice.ObjectPrx obj = ic.stringToProxy("RootDir:default -p 10000");
+ //
// Down-cast the proxy to a Directory proxy
//
DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(obj);
- if (rootDir == null)
+ if(rootDir == null)
+ {
throw new ApplicationException("Invalid proxy");
+ }
+ //
// Recursively list the contents of the root directory
//
Console.WriteLine("Contents of root directory:");
listRecursive(rootDir, 0);
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
- if (ic != null) {
- // Clean up
- //
- try {
+ if(ic != null)
+ {
+ try
+ {
ic.destroy();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
diff --git a/cs/demo/book/simple_filesystem/DirectoryI.cs b/cs/demo/book/simple_filesystem/DirectoryI.cs
index 236fe62db2b..d7e47e4023d 100644
--- a/cs/demo/book/simple_filesystem/DirectoryI.cs
+++ b/cs/demo/book/simple_filesystem/DirectoryI.cs
@@ -19,6 +19,7 @@ public class DirectoryI : DirectoryDisp_
_name = name;
_parent = parent;
+ //
// Create an identity. The root directory has the fixed identity "RootDir"
//
_id = new Ice.Identity();
diff --git a/cs/demo/book/simple_filesystem/FileI.cs b/cs/demo/book/simple_filesystem/FileI.cs
index 717f47b182f..25a84eab096 100644
--- a/cs/demo/book/simple_filesystem/FileI.cs
+++ b/cs/demo/book/simple_filesystem/FileI.cs
@@ -21,6 +21,7 @@ public class FileI : FileDisp_
Debug.Assert(_parent != null);
+ //
// Create an identity
//
_id = new Ice.Identity();
diff --git a/cs/demo/book/simple_filesystem/Server.cs b/cs/demo/book/simple_filesystem/Server.cs
index 9a324b2e97a..55e972732cc 100644
--- a/cs/demo/book/simple_filesystem/Server.cs
+++ b/cs/demo/book/simple_filesystem/Server.cs
@@ -23,37 +23,46 @@ public class Server
{
public override int run(string[] args)
{
+ //
// Terminate cleanly on receipt of a signal
//
shutdownOnInterrupt();
+ //
// Create an object adapter.
//
- Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints(
- "SimpleFilesystem", "default -h 127.0.0.1 -p 10000");
+ Ice.ObjectAdapter adapter =
+ communicator().createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h 127.0.0.1 -p 10000");
+ //
// Create the root directory (with name "/" and no parent)
//
DirectoryI root = new DirectoryI(communicator(), "/", null);
root.activate(adapter);
+ //
// Create a file called "README" in the root directory
//
FileI file = new FileI(communicator(), "README", root);
string[] text;
text = new string[]{ "This file system contains a collection of poetry." };
- try {
+ try
+ {
file.write(text);
- } catch (GenericError e) {
+ }
+ catch(GenericError e)
+ {
Console.Error.WriteLine(e.reason);
}
file.activate(adapter);
+ //
// Create a directory called "Coleridge" in the root directory
//
DirectoryI coleridge = new DirectoryI(communicator(), "Coleridge", root);
coleridge.activate(adapter);
+ //
// Create a file called "Kubla_Khan" in the Coleridge directory
//
file = new FileI(communicator(), "Kubla_Khan", coleridge);
@@ -62,23 +71,30 @@ public class Server
"Where Alph, the sacred river, ran",
"Through caverns measureless to man",
"Down to a sunless sea." };
- try {
+ try
+ {
file.write(text);
- } catch (GenericError e) {
+ }
+ catch(GenericError e)
+ {
Console.Error.WriteLine(e.reason);
}
file.activate(adapter);
+ //
// All objects are created, allow client requests now
//
adapter.activate();
+ //
// Wait until we are done
//
communicator().waitForShutdown();
- if (interrupted())
+ if(interrupted())
+ {
Console.Error.WriteLine(appName() + ": terminating");
+ }
return 0;
}