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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// Copyright (c) ZeroC, Inc. All rights reserved.
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using ZeroC.Test;
namespace ZeroC.Ice.Test.Proxy
{
internal sealed class AsyncMyDerivedClass : IAsyncMyDerivedClass
{
private IReadOnlyDictionary<string, string>? _ctx;
public ValueTask<IObjectPrx?> EchoAsync(IObjectPrx? obj, Current c, CancellationToken cancel) =>
new(obj);
public ValueTask<IEnumerable<string>> GetLocationAsync(Current current, CancellationToken cancel) =>
new(current.Location);
public ValueTask ShutdownAsync(Current current, CancellationToken cancel)
{
current.Communicator.ShutdownAsync();
return default;
}
public ValueTask<IReadOnlyDictionary<string, string>> GetContextAsync(
Current current,
CancellationToken cancel) =>
new(_ctx!);
public ValueTask<bool> IceIsAAsync(string typeId, Current current, CancellationToken cancel)
{
_ctx = current.Context;
return new(typeof(IMyDerivedClass).GetAllIceTypeIds().Contains(typeId));
}
public async ValueTask<IRelativeTestPrx> OpRelativeAsync(
ICallbackPrx callback,
Current current,
CancellationToken cancel)
{
TestHelper.Assert(callback.IsFixed);
IRelativeTestPrx relativeTest =
current.Adapter.AddWithUUID(new RelativeTest(), IRelativeTestPrx.Factory).Clone(relative: true);
TestHelper.Assert(await callback.OpAsync(relativeTest, cancel: cancel) == 1);
return relativeTest;
}
}
internal sealed class RelativeTest : IRelativeTest
{
private int _count;
public int DoIt(Current current, CancellationToken cancel) => ++_count;
}
}
|