public static int Main(string[] args) { try { using (Ice.Communicator ic = Ice.Util.initialize(ref args)) { // // Create a proxy for the root directory // var obj = ic.stringToProxy("RootDir:default -h localhost -p 10000"); // // Down-cast the proxy to a Directory proxy // var rootDir = DirectoryPrxHelper.checkedCast(obj); 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) { Console.Error.WriteLine(e); return(1); } return(0); }
// Recursively print the contents of directory "dir" in tree fashion. // For files, show the contents of each file. The "depth" // parameter is the current nesting level (for indentation). static void listRecursive(DirectoryPrx dir, int depth) { var indent = new string('\t', ++depth); NodePrx[] contents = dir.list(); foreach (var node in contents) { var subdir = DirectoryPrxHelper.checkedCast(node); var file = FilePrxHelper.uncheckedCast(node); Console.WriteLine(indent + node.name() + (subdir != null ? " (directory):" : " (file):")); if (subdir != null) { listRecursive(subdir, depth); } else { var text = file.read(); for (int j = 0; j < text.Length; ++j) { Console.WriteLine(indent + "\t" + text[j]); } } } }
public static int Main(string[] args) { try { // // The new communicator is automatically destroyed (disposed) at the end of the // using statement // using (var communicator = Ice.Util.initialize(ref args)) { // // Create a proxy for the root directory // var @base = communicator.stringToProxy("RootDir:default -h localhost -p 10000"); // // Down-cast the proxy to a Directory proxy. // var rootDir = DirectoryPrxHelper.checkedCast(@base); if (rootDir == null) { throw new Error("Invalid proxy"); } var p = new Parser(rootDir); return(p.parse()); } } catch (Exception ex) { Console.Error.WriteLine(ex); return(1); } }
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 -h localhost -p 10000"); // // Down-cast the proxy to a Directory proxy. // DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(@base); if (rootDir == null) { throw new Error("Invalid proxy"); } Parser p = new Parser(rootDir); return(p.parse()); }
public static int Main(string[] args) { int status = 0; Ice.Communicator ic = null; try { Ice.InitializationData data = new Ice.InitializationData(); // // Create a communicator // ic = Ice.Util.initialize(ref args, data); // // Create a proxy for the root directory // Ice.ObjectPrx obj = ic.stringToProxy("RootDir:default -h localhost -p 10000"); // // Down-cast the proxy to a Directory proxy // DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(obj); 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) { Console.Error.WriteLine(e); status = 1; } if (ic != null) { try { ic.destroy(); } catch (Exception e) { Console.Error.WriteLine(e); status = 1; } } return(status); }
public static int Main(string[] args) { int status = 0; Ice.Communicator ic = null; try { Ice.InitializationData data = new Ice.InitializationData(); #if COMPACT // // When using Ice for .NET Compact Framework, we need to specify // the assembly so that Ice can locate classes and exceptions. // data.properties = Ice.Util.createProperties(); data.properties.setProperty("Ice.FactoryAssemblies", "client,version=1.0.0.0"); #endif // // Create a communicator // ic = Ice.Util.initialize(ref args, data); // // Create a proxy for the root directory // Ice.ObjectPrx obj = ic.stringToProxy("RootDir:default -h localhost -p 10000"); // // Down-cast the proxy to a Directory proxy // DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(obj); 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) { Console.Error.WriteLine(e); status = 1; } if (ic != null) { try { ic.destroy(); } catch (Exception e) { Console.Error.WriteLine(e); status = 1; } } return(status); }