예제 #1
0
        /// <summary>
        /// Checks whether this link is available.
        /// </summary>
        public void CheckLink()
        {
            if (string.IsNullOrWhiteSpace(FileURL))
            {
                return;
            }

            var checker = Extensibility.GetNewInstances <LinkCheckerEngine>().FirstOrDefault(x => x.CanCheck(FileURL));

            if (checker == null)
            {
                return;
            }

            var inf = Infos;

            if (!string.IsNullOrWhiteSpace(inf))
            {
                inf += ", ";
            }

            Infos = inf + "Checking...";
            MainWindow.Active.Run(() => { try { PropertyChanged(this, new PropertyChangedEventArgs("Infos")); } catch { } });

            try
            {
                var result = checker.Check(FileURL.Split('\0').First());

                if (!result)
                {
                    Color = "#50FFFFFF";
                }

                Infos = inf + "Link is " + (result ? "online" : "broken");
                MainWindow.Active.Run(() =>
                {
                    try
                    {
                        PropertyChanged(this, new PropertyChangedEventArgs("Infos"));
                        PropertyChanged(this, new PropertyChangedEventArgs("Color"));
                    } catch { }
                });
            }
            catch
            {
                Infos = inf + "Check error";
                MainWindow.Active.Run(() => { try { PropertyChanged(this, new PropertyChangedEventArgs("Infos")); } catch { } });
            }
        }