Ejemplo n.º 1
0
        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.ToSemVer()));
                }
                if (maxversion != null)
                {
                    dep.VersionVertex(new LessThanVersionVertex(maxversion.Value.ToSemVer()));
                }
            }
            else
            {
                dep.SetVersionVertices(ConvertNuGetVersionRange(version != null ? version.Value : null).DefaultIfEmpty(new AnyVersionVertex()));
            }
            return(dep);
        }
Ejemplo n.º 2
0
        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.ToVersion()));
            }
            if (MinVersion != null)
            {
                builder = builder.VersionVertex(new GreaterThanOrEqualVersionVertex(MinVersion.ToVersion()));
            }
            if (MaxVersion != null)
            {
                builder = builder.VersionVertex(new LessThanVersionVertex(MaxVersion.ToVersion()));
            }
            return(builder);
        }