Exemple #1
0
 private static async Task ChangeMethodAtRuntime(ILogger logger, DeadLetterObject deadletter)
 {
     Console.WriteLine("Define method at runtime using dynamic object");
     var dynamicObject = new DynamicObject(logger);
     Console.WriteLine("Define method at runtime [1st call - undefined]");
     await deadletter.Send(dynamicObject, new GreetMessage());
     Console.WriteLine("Define method at runtime [2nd call]");
     dynamicObject.AddOrUpdateMethod<GreetMessage>(new Method(async sender => await Task.Run( () => Console.WriteLine("Howdy!"))));
     await deadletter.Send(dynamicObject, new GreetMessage());
     Console.WriteLine();
 }
Exemple #2
0
        private static async Task ChangeMethodAtRuntime(ILogger logger, DeadLetterObject deadletter)
        {
            Console.WriteLine("Define method at runtime using dynamic object");
            var dynamicObject = new DynamicObject(logger);

            Console.WriteLine("Define method at runtime [1st call - undefined]");
            await deadletter.Send(dynamicObject, new GreetMessage());

            Console.WriteLine("Define method at runtime [2nd call]");
            dynamicObject.AddOrUpdateMethod <GreetMessage>(new Method(async sender => await Task.Run(() => Console.WriteLine("Howdy!"))));
            await deadletter.Send(dynamicObject, new GreetMessage());

            Console.WriteLine();
        }