コード例 #1
0
        public bool TryPopulate([NotNull] VIsan vIsan)
        {
            if (!Cache.ContainsKey(vIsan.Number))
            {
                return(false);
            }
            var json = Cache[vIsan.Number];

            json.Populate(vIsan);
            return(true);
        }
コード例 #2
0
        private void PopulateParent(VIsan vIsan)
        {
            if (_token.IsCancelled || vIsan.Parent == null)
            {
                return;
            }

            var dom = GetDom(vIsan.Parent);

            Populate(vIsan.Parent, dom);
        }
コード例 #3
0
        public void Populate([CanBeNull] VIsan vIsan)
        {
            if (vIsan == null || !vIsan.IsSearchable)
            {
                return;
            }

            var dom = GetDom(vIsan);

            Populate(vIsan, dom);
            SetParent(vIsan, dom);
            PopulateParent(vIsan);

            _token.ReportProgress(100.0, "Finished querying isan.org");
        }
コード例 #4
0
        private void SetParent(VIsan vIsan, CQ dom)
        {
            if (_token.IsCancelled || dom == null)
            {
                return;
            }

            var titles = dom["a[href*=\"javascript:publicDisplayWork\"]"];

            titles.ForEach(delegate(IDomObject o)
            {
                var href = (o.GetAttribute("href") ?? "").Trim();
                if (Isan.IsIsan(href))
                {
                    vIsan.Parent = Isan.TryParse(href);
                }
            });
        }
コード例 #5
0
        public void TestPopulateEmptyTitle()
        {
            const string emptyTitleVIsan = "00000000E0AA000000000001";

            var vIsan = VIsan.TryParse(emptyTitleVIsan);

            _provider.Populate(vIsan);

            var parent = vIsan.Parent;

            Assert.IsNull(vIsan.Title);
            Assert.IsNull(vIsan.Year);
            Assert.IsNull(vIsan.LengthMin);
            Assert.IsNotNull(parent);
            Assert.AreEqual("Lord Of War", parent.Title);
            Assert.AreEqual(2004, parent.Year);
            Assert.AreEqual(100, parent.LengthMin);
        }
コード例 #6
0
        private static VIsan GetVISAN(Disc disc)
        {
            var file = disc.FileSystem.Files.MCMF;

            if (file == null)
            {
                return(null);
            }

            var xml = string.Join(" ", File.ReadAllLines(file.FullName));

            if (!ISANContentIdRegex.IsMatch(xml))
            {
                return(null);
            }

            var match     = ISANContentIdRegex.Match(xml);
            var contentId = match.Groups[1].Value;

            return(VIsan.TryParse(contentId));
        }
コード例 #7
0
 public void Store([NotNull] VIsan vIsan)
 {
     Cache[vIsan.Number] = vIsan.ToJson();
 }