PackageDependency UpdatedDependency(PackageDependency dependency) { var builder = new PackageDependencyBuilder(dependency); if (_content.HasValue) { builder = builder.Content(_content.Value); } if (_anchored.HasValue) { builder = builder.Anchored(_anchored.Value); } if (SomeVersionInputGiven) { builder = builder.SetVersionVertices(Enumerable.Empty<VersionVertex>()); } if (AnyVersion) { builder = builder.VersionVertex(new AnyVersionVertex()); } if (Version != null) { builder = builder.VersionVertex(new EqualVersionVertex(Version.ToSemVer())); } if (MinVersion != null) { builder = builder.VersionVertex(new GreaterThanOrEqualVersionVertex(MinVersion.ToSemVer())); } if (MaxVersion != null) { builder = builder.VersionVertex(new LessThanVersionVertex(MaxVersion.ToSemVer())); } return builder; }
static PackageDependency CreateDependency(XmlNode xmlNode) { var dep = new PackageDependencyBuilder((xmlNode.Attributes["id"] ?? xmlNode.Attributes["id", NuGetConverter.NuSpecSchema]).Value); var version = xmlNode.Attributes["version"] ?? xmlNode.Attributes["version", NuGetConverter.NuSpecSchema]; var minversion = xmlNode.Attributes["minversion"] ?? xmlNode.Attributes["minversion", NuGetConverter.NuSpecSchema]; var maxversion = xmlNode.Attributes["maxversion"] ?? xmlNode.Attributes["maxversion", NuGetConverter.NuSpecSchema]; if (minversion != null || maxversion != null) { if (minversion != null) dep.VersionVertex(new GreaterThanOrEqualVersionVertex(minversion.Value.ToVersion())); if (maxversion != null) dep.VersionVertex(new LessThanVersionVertex(maxversion.Value.ToVersion())); } else { dep.SetVersionVertices(ConvertNuGetVersionRange(version != null ? version.Value : null).DefaultIfEmpty(new AnyVersionVertex())); } return dep; }