2 using System.Threading.Tasks;
6 protected void InvokeAction (Action action)
19 var implementor = ServiceLocator.GetImplementor<IInterface1> ();
20 string message = null;
21 bool result = await implementor.Foo ((s) => message = s);
23 InvokeAction (() => Bar ());
29 Task<bool> Foo(Action<string> action);
32 class CIInterface1 : IInterface1
34 public Task<bool> Foo (Action<string> action)
37 return Task.FromResult (false);
41 static class ServiceLocator
43 public static TService GetImplementor<TService>() where TService : class
45 return (TService) (object) new CIInterface1 ();
49 public static void Main ()
51 new Class1 ().Test ().Wait ();