示例#1
0
        public async Task SetText(string text)
        {
            Facade facade = new Facade();
            Dispatcher dispatcher = Application.Current.Dispatcher;

            LinkTask task = new LinkTask
            {
                OnStatus = (link, status) =>
                {
                    dispatcher.Handle(() =>
                    {
                        this.model.SetStatus(link, status);
                    });
                },
                OnCompleted = (link, resource) =>
                {
                    dispatcher.Handle(() =>
                    {
                        this.model.Complete(link, resource);
                    });
                },
                OnLog = entry =>
                {
                    dispatcher.Handle(() =>
                    {
                        this.OnLog.Invoke(entry);
                    });
                }
            };

            this.model.ClearLinks();
            this.model.SetLinks(await facade.ParseTextToLinks(text));

            task.Links = this.model.GetAnalyzableLinks();
            await facade.Analyze(task);
        }