Skip to content

Commit

Permalink
Update minimal C# demo (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Oct 6, 2023
1 parent b328f9f commit 4c4f4e4
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
14 changes: 0 additions & 14 deletions csharp/Ice/minimal/HelloI.cs

This file was deleted.

16 changes: 16 additions & 0 deletions csharp/Ice/minimal/Printer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

using System;
using Demo;

/// <summary>Implements Slice interface `Hello` by printing messages.</summary>
public class Printer : HelloDisp_
{
/// <summary>Prints a message to the standard output.</summary>
public override void sayHello(Ice.Current current)
{
Console.WriteLine("Hello World!");
}
}
13 changes: 8 additions & 5 deletions csharp/Ice/minimal/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ public static int Main(string[] args)
{
using(var communicator = Ice.Util.initialize(ref args))
{
//
// Destroy the communicator on Ctrl+C or Ctrl+Break
//
Console.CancelKeyPress += (sender, eventArgs) => communicator.destroy();
// Shut down the communicator on Ctrl+C or Ctrl+Break.
Console.CancelKeyPress += (sender, eventArgs) =>
{
eventArgs.Cancel = true;
communicator.shutdown();
};

var adapter = communicator.createObjectAdapterWithEndpoints("Hello", "default -h localhost -p 10000");
adapter.add(new HelloI(), Ice.Util.stringToIdentity("hello"));
adapter.add(new Printer(), Ice.Util.stringToIdentity("hello"));
adapter.activate();
communicator.waitForShutdown();
}
Expand Down
4 changes: 2 additions & 2 deletions csharp/Ice/minimal/msbuild/server/net45/server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
<Compile Include="generated\Hello.cs">
<SliceCompileSource>..\..\..\Hello.ice</SliceCompileSource>
</Compile>
<Compile Include="..\..\..\HelloI.cs">
<Link>HelloI.cs</Link>
<Compile Include="..\..\..\Printer.cs">
<Link>Printer.cs</Link>
</Compile>
<Compile Include="..\..\..\Server.cs">
<Link>Server.cs</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<ExternalConsole>true</ExternalConsole>
</PropertyGroup>
<ItemGroup>
<Compile Include="../../../HelloI.cs" />
<Compile Include="../../../Printer.cs" />
<Compile Include="../../../Server.cs" />
<SliceCompile Include="../../../Hello.ice" />
<PackageReference Include="zeroc.ice.net" Version="3.7.9" />
Expand Down

0 comments on commit 4c4f4e4

Please sign in to comment.