示例#1
0
 protected internal override void Define()
 {
     On((HasBeenReminded x) => reminded);
     On((SetReminder x) => Reminders.Register("test", TimeSpan.Zero, x.Period));
     On((GetInstanceHashcode x) => RuntimeHelpers.GetHashCode(this));
     On((Deactivate x) => Activation.DeactivateOnIdle());
 }
示例#2
0
文件: Topic.cs 项目: pkese/Orleankka
        public async Task Handle(CreateTopic cmd)
        {
            query = cmd.Query;

            foreach (var entry in cmd.Schedule)
            {
                await Reminders.Register(entry.Key.Path.Id, TimeSpan.Zero, entry.Value);
            }
        }
示例#3
0
        async Task <object> On(object message)
        {
            switch (message)
            {
            case Reminder _:
                Console.WriteLine("Reminded");
                return(Done);

            case Activate _:
                await NotifyLightsOn();

                return("");

            case Deactivate _:
                await CleanupOn();

                return("");

            case PressSwitch _:
                await behavior.Become(Off);

                return("Turning off");

            case Touch _:
                return("Hot!");

            default:
                return(Unhandled);
            }

            async Task NotifyLightsOn()
            {
                await Reminders.Register("123", TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(60));

                Timers.Register("123", TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1), () =>
                {
                    Console.WriteLine("Lights, on!!!");
                    return(Task.CompletedTask);
                });
            }

            async Task CleanupOn()
            {
                Timers.Unregister("123");

                await Reminders.Unregister("123");
            }
        }
示例#4
0
 void On(SetReminder x) => Reminders.Register("test", TimeSpan.Zero, x.Period);
 Task On(RegisterReminder x) => Reminders.Register(x.Name, TimeSpan.FromHours(10), TimeSpan.FromHours(10));