1 // **********************************************************************
3 // Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
5 // This copy of Ice is licensed to you under the terms described in the
6 // ICE_LICENSE file included in this distribution.
8 // **********************************************************************
11 using System
.Diagnostics
;
12 using System
.Reflection
;
14 [assembly
: CLSCompliant(true)]
16 [assembly
: AssemblyTitle("IceTest")]
17 [assembly
: AssemblyDescription("Ice test")]
18 [assembly
: AssemblyCompany("ZeroC, Inc.")]
22 private class MyObjectFactory
: Ice
.ObjectFactory
24 public Ice
.Object
create(string type
)
26 if(type
.Equals("::Test::I"))
30 else if(type
.Equals("::Test::J"))
34 else if(type
.Equals("::Test::H"))
38 Debug
.Assert(false); // Should never be reached
49 private static int run(string[] args
, Ice
.Communicator communicator
)
51 Ice
.ObjectFactory factory
= new MyObjectFactory();
52 communicator
.addObjectFactory(factory
, "::Test::I");
53 communicator
.addObjectFactory(factory
, "::Test::J");
54 communicator
.addObjectFactory(factory
, "::Test::H");
56 communicator
.getProperties().setProperty("TestAdapter.Endpoints", "default -p 12010");
57 Ice
.ObjectAdapter adapter
= communicator
.createObjectAdapter("TestAdapter");
58 Ice
.Object
@object = new InitialI(adapter
);
59 adapter
.add(@object, communicator
.stringToIdentity("initial"));
60 @object = new UnexpectedObjectExceptionTestI();
61 adapter
.add(@object, communicator
.stringToIdentity("uoet"));
63 communicator
.waitForShutdown();
67 public static int Main(string[] args
)
70 Ice
.Communicator communicator
= null;
73 Debug
.Listeners
.Add(new ConsoleTraceListener());
78 communicator
= Ice
.Util
.initialize(ref args
);
79 status
= run(args
, communicator
);
81 catch(System
.Exception ex
)
83 System
.Console
.Error
.WriteLine(ex
);
87 if(communicator
!= null)
91 communicator
.destroy();
93 catch(Ice
.LocalException ex
)
95 System
.Console
.Error
.WriteLine(ex
);