You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
829 B
38 lines
829 B
using DotWhat.Contracts;
|
|
using System;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace DotWhat.DuckTyping
|
|
{
|
|
public sealed class CustomAwaiters : What
|
|
{
|
|
public override string Name => "CustomAwaiters";
|
|
|
|
public override async void Run()
|
|
{
|
|
const int i = 123;
|
|
|
|
Console.WriteLine(await (await await 7 + await i));
|
|
}
|
|
}
|
|
|
|
public static class IntExtensions
|
|
{
|
|
public static IntAwaiter GetAwaiter(this int i) => new IntAwaiter(i);
|
|
}
|
|
|
|
public sealed class IntAwaiter : INotifyCompletion
|
|
{
|
|
private readonly int _value;
|
|
public bool IsCompleted => true;
|
|
|
|
public IntAwaiter(int i) => _value = i;
|
|
|
|
public int GetResult() => _value;
|
|
|
|
public void OnCompleted(Action continuation)
|
|
{
|
|
}
|
|
}
|
|
}
|