//--------------------// #region Normalize /// <summary> /// Sets missing default values and handles legacy elements. /// </summary> /// <param name="feedUri">The feed the data was originally loaded from; can be <see langword="null"/>.</param> /// <remarks>This method should be called to prepare a <see cref="Feed"/> for solver processing. Do not call it if you plan on serializing the feed again since it may loose some of its structure.</remarks> public override void Normalize(FeedUri feedUri = null) { base.Normalize(feedUri); // Merge the version modifier into the normal version attribute if (!string.IsNullOrEmpty(VersionModifier)) { Version = new ImplementationVersion(Version + VersionModifier); VersionModifier = null; } // Default stability rating to testing if (Stability == Stability.Unset) { Stability = Stability.Testing; } // Make local paths absolute if (!string.IsNullOrEmpty(LocalPath)) { LocalPath = ModelUtils.GetAbsolutePath(LocalPath, feedUri); } else if (!string.IsNullOrEmpty(ID) && ID.StartsWith(".")) // Get local path from ID { LocalPath = ID = ModelUtils.GetAbsolutePath(ID, feedUri); } // Parse manifest digest from ID if missing if (!string.IsNullOrEmpty(ID)) { _manifestDigest.ParseID(ID); } }
public void TestParseID() { new ManifestDigest("sha1=test").Sha1.Should().Be("test"); new ManifestDigest("sha1new=test").Sha1New.Should().Be("test"); new ManifestDigest("sha256=test").Sha256.Should().Be("test"); new ManifestDigest("sha256new_test").Sha256New.Should().Be("test"); // Once a digest value has been set, ID values shall not be able to overwrite it var digest = new ManifestDigest("sha1=test"); digest.ParseID("sha1=test2"); digest.Sha1.Should().Be("test"); }
public void TestParseID() { Assert.AreEqual("test", new ManifestDigest("sha1=test").Sha1); Assert.AreEqual("test", new ManifestDigest("sha1new=test").Sha1New); Assert.AreEqual("test", new ManifestDigest("sha256=test").Sha256); Assert.AreEqual("test", new ManifestDigest("sha256new_test").Sha256New); // Once a digest value has been set, ID values shall not be able to overwrite it var digest = new ManifestDigest("sha1=test"); digest.ParseID("sha1=test2"); Assert.AreEqual("test", digest.Sha1); }
/// <summary> /// Sets missing default values and handles legacy elements. /// </summary> /// <param name="feedUri">The feed the data was originally loaded from.</param> /// <remarks>This method should be called to prepare a <see cref="Feed"/> for solver processing. Do not call it if you plan on serializing the feed again since it may loose some of its structure.</remarks> public override void Normalize(FeedUri feedUri) { #region Sanity checks if (feedUri == null) { throw new ArgumentNullException(nameof(feedUri)); } #endregion base.Normalize(feedUri); // Merge the version modifier into the normal version attribute if (!string.IsNullOrEmpty(VersionModifier)) { Version = new ImplementationVersion(Version + VersionModifier); VersionModifier = null; } // Default stability rating to testing if (Stability == Stability.Unset) { Stability = Stability.Testing; } // Make local paths absolute try { if (!string.IsNullOrEmpty(LocalPath)) { LocalPath = ModelUtils.GetAbsolutePath(LocalPath, feedUri); } else if (!string.IsNullOrEmpty(ID) && ID.StartsWith(".")) // Get local path from ID { LocalPath = ID = ModelUtils.GetAbsolutePath(ID, feedUri); } } #region Error handling catch (UriFormatException ex) { Log.Error(ex); LocalPath = null; } #endregion // Parse manifest digest from ID if missing if (!string.IsNullOrEmpty(ID)) { _manifestDigest.ParseID(ID); } }