summaryrefslogtreecommitdiff
path: root/csharp/test/IceBox/admin/TestServiceI.cs
blob: fcc87a3a90806c04ed6ec446b0f3bb96d4dbc552 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) ZeroC, Inc. All rights reserved.

using System.Threading;
using System.Threading.Tasks;

using ZeroC.Ice;

namespace ZeroC.IceBox.Test.Admin
{
    public class TestService : IService
    {
        public TestService(Communicator serviceManagerCommunicator)
        {
            var facet = new TestFacet();

            // Install a custom admin facet.
            serviceManagerCommunicator.AddAdminFacet("TestFacet", facet);

            // The TestFacetI servant also implements PropertiesAdminUpdateCallback. Set the callback on the admin facet.
            IObject? propFacet = serviceManagerCommunicator.FindAdminFacet("IceBox.Service.TestService.Properties");
            if (propFacet is IAsyncPropertiesAdmin admin)
            {
                admin.Updated += (_, updates) => facet.Updated(updates);
            }
        }

        public Task StartAsync(string name, Communicator communicator, string[] args, CancellationToken cancel) =>
            Task.CompletedTask;

        public Task StopAsync() => Task.CompletedTask;
    }
}