示例#1
0
文件: Program.cs 项目: lemmit/RealOOP
 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();
 }
示例#2
0
文件: Program.cs 项目: lemmit/RealOOP
        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();
        }