internal void AddPackageFiles(Package package, PackagePart rootFile) { if (package == null) { throw new ArgumentNullException(nameof(package)); } // get all supplementary files related to the root file var relations = rootFile.GetRelationships(); // get all parts var parts = package.GetParts(); // add all supplementary files foreach (var relation in relations) { DocumentFileType type; if (!relation.TryParseDocumentFileType(out type)) { continue; } var part = parts.FirstOrDefault(p => PackUriHelper.ComparePartUri(p.Uri, relation.TargetUri) == 0); if (part != null) { _files.Add(new PackageDocumentFile(part) { Type = type }); } } }
public void PartUriCompareTest() { Assert.AreEqual(0, PackUriHelper.ComparePartUri(null, null), "#1"); Assert.IsTrue(PackUriHelper.ComparePartUri(part1, null) > 0, "#2"); Assert.IsTrue(PackUriHelper.ComparePartUri(part1, part2) < 0, "#3"); }
public void InvalidPartUriCompareTest() { PackUriHelper.ComparePartUri(a, b); }