public ActivityExecutionResult Execute(IExecuteContext context)
        {
            if (context.IsContinue)
            {
                return(ActivityExecutionResult.Complete);
            }
            var chat = Guid.Parse(context.Resolve(ChatId));
            var msgs = GetMessages().Select(msg =>
            {
                var m = new StorableOutgoingMessage();
                m.Restore(msg, null);
                m.Resolve(context);
                return(new SendMessageMessage(m)
                {
                    BotEngine = BotEngine,
                    BotKey = BotKey,
                    ChatId = chat
                } as Infrastructure.IMessage);
            }).ToList();

            if (Sync)
            {
                var book = context.SetBookmark();
                var rmsg = new ResumeBookmarkMessage(book, new DynamicObject());
                msgs.Add(rmsg);
                context.SendMessagesSequence(msgs.ToArray());
                return(ActivityExecutionResult.Idle);
            }
            else
            {
                context.SendMessagesSequence(msgs.ToArray());
                return(ActivityExecutionResult.Complete);
            }
        }
        public override void Restore(IDynamicObject store, IResourceWrapper wrapper)
        {
            BotEngine = store.Get <BotEngine>("botEngine");
            BotKey    = store.Get <String>("botKey");
            ChatId    = store.Get <Guid>("chatId");
            var m = new StorableOutgoingMessage();

            m.Restore(store.GetDynamicObject("message"), wrapper);
            Message = m;
        }
 public SendMessageMessage(StorableOutgoingMessage message) : base(Guid.NewGuid())
 {
     Message = message;
 }