Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update minimal C# demo #195

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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