Esempio n. 1
0
        public void AreSame()
        {
            var rl  = new RestUrl("http://someserver.org/Patient/4?oauth=xxxx");
            var rl2 = new RestUrl("https://someserver.org/Patient/4");

            Assert.IsTrue(rl.IsSameUrl(rl2));
            Assert.IsTrue(rl2.IsSameUrl(rl));

            rl2 = new RestUrl("http://someserver.org/Patient/4");
            Assert.IsTrue(rl.IsSameUrl(rl2));
            Assert.IsTrue(rl2.IsSameUrl(rl));

            rl2 = new RestUrl("https://someserver.org:81/Patient/4");
            Assert.IsFalse(rl.IsSameUrl(rl2));
            Assert.IsFalse(rl2.IsSameUrl(rl));
        }
Esempio n. 2
0
        public static bool IsTargetOf(this Bundle.BundleEntryComponent entry, string reference)
        {
            // From the spec: If the reference is version specific (either relative or absolute), then remove the version from the URL
            // before matching fullUrl, and then match the version based on Resource.meta.versionId.

            if (reference == null)
            {
                throw Error.ArgumentNull("reference");
            }
            if (!new Uri(reference, UriKind.RelativeOrAbsolute).IsAbsoluteUri)
            {
                throw Error.Argument("reference", "uri should be absolute");
            }

            string referencedVersion = ResourceIdentity.IsRestResourceIdentity(reference) ? (new ResourceIdentity(reference).VersionId) : null;

            reference = referencedVersion != null ? (new ResourceIdentity(reference).WithoutVersion().ToString()) : reference;
            var refRestUrl = new RestUrl(reference);

            return(refRestUrl.IsSameUrl(new RestUrl(entry.FullUrl)) &&
                   (referencedVersion == null || (entry.HasResource() && entry.Resource.VersionId == referencedVersion)));
        }