Пример #1
0
        public override string ToString()
        {
            StringBuilder __sb = new StringBuilder("MDependency(");

            __sb.Append(", ID: ");
            __sb.Append(ID);
            __sb.Append(", Type: ");
            __sb.Append(Type);
            __sb.Append(", MinVersion: ");
            __sb.Append(MinVersion == null ? "<null>" : MinVersion.ToString());
            __sb.Append(", MaxVersion: ");
            __sb.Append(MaxVersion == null ? "<null>" : MaxVersion.ToString());
            if (ExcludedVersions != null && __isset.ExcludedVersions)
            {
                __sb.Append(", ExcludedVersions: ");
                __sb.Append(ExcludedVersions);
            }
            if (Name != null && __isset.Name)
            {
                __sb.Append(", Name: ");
                __sb.Append(Name);
            }
            __sb.Append(")");
            return(__sb.ToString());
        }
Пример #2
0
        IEnumerable <VersionVertex> CreateVersionVertices()
        {
            if (Version != null)
            {
                foreach (var vertice in NuSpecConverter.ConvertNuGetVersionRange(Version).DefaultIfEmpty(new AnyVersionVertex()))
                {
                    yield return(vertice);
                }
                yield break;
            }
            Version version = null;

            if (!string.IsNullOrEmpty(ExactVersion) && (version = ExactVersion.ToVersion()) != null)
            {
                yield return(new EqualVersionVertex(version));
            }
            if (!string.IsNullOrEmpty(MinVersion) && (version = MinVersion.ToVersion()) != null)
            {
                yield return(new GreaterThanOrEqualVersionVertex(version));
            }
            if (!string.IsNullOrEmpty(MaxVersion) && (version = MaxVersion.ToVersion()) != null)
            {
                yield return(new LessThanVersionVertex(version));
            }
        }
Пример #3
0
 private void ThrowIfMaxVersionLessThenMinVersion()
 {
     if (MaxVersion.CompareTo(MinVersion) < 0)
     {
         throw new Exception("MaxVersion < MinVersion !");
     }
 }
        /// <summary>
        /// Save this VersionRequirement as an XmlNode that can later be
        /// re-instantiated by it's constructor.
        /// </summary>
        /// <param name="doc">The XML Document that this node will be a part of.</param>
        /// <param name="isExport">Specifies if this Save operation is for export of a final package.</param>
        /// <returns>A new XmlNode instance which defines this object.</returns>
        public XmlNode Save(XmlDocument doc, Boolean isExport)
        {
            XmlNode      node = doc.CreateElement(NodeName);
            XmlAttribute attrib;


            if (MinVersion != null)
            {
                attrib       = doc.CreateAttribute("MinVersion");
                attrib.Value = MinVersion.ToString();
                node.Attributes.Append(attrib);
            }

            if (MaxVersion != null)
            {
                attrib       = doc.CreateAttribute("MaxVersion");
                attrib.Value = MaxVersion.ToString();
                node.Attributes.Append(attrib);
            }

            if (Version != null)
            {
                attrib       = doc.CreateAttribute("Version");
                attrib.Value = Version.ToString();
                node.Attributes.Append(attrib);
            }

            return(node);
        }
Пример #5
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);
        }
Пример #6
0
 public override string ToString()
 {
     if (!string.IsNullOrEmpty(_versionString))
     {
         return(_versionString);
     }
     if ((MaxVersion == null) && (MinVersion == null))
     {
         return("[0.0.0, Maximum Version)");
     }
     return("MinVersion:" + MinVersion.ToString() + " MaxVersion:" + MaxVersion.ToString());
 }
Пример #7
0
 /// <inheritdoc/>
 public bool Equals(PackageVersionRange other)
 {
     if (ReferenceEquals(other, null))
     {
         return(false);
     }
     if (ReferenceEquals(other, this))
     {
         return(true);
     }
     return(MinVersion.Equals(other.MinVersion) &&
            MaxVersion.Equals(other.MaxVersion) &&
            IsMinInclusive == other.IsMinInclusive &&
            IsMaxInclusive == other.IsMaxInclusive);
 }
Пример #8
0
        public override int GetHashCode()
        {
            int hashCode = MinVersion.GetHashCode();

            hashCode = CombineHashCode(hashCode, VersionFloatBehavior.GetHashCode());

            if (MaxVersion != null)
            {
                hashCode = CombineHashCode(hashCode, MaxVersion.GetHashCode());
            }

            hashCode = CombineHashCode(hashCode, IsMaxInclusive.GetHashCode());

            return(hashCode);
        }
Пример #9
0
        IEnumerable <ICommandOutput> ValidateInputs()
        {
            var gotVersion                = Version != null;
            var gotMinVersion             = MinVersion != null;
            var gotMaxVersion             = MaxVersion != null;
            var numberOfVersionInputTypes = (new[] { gotVersion, (gotMinVersion || gotMaxVersion) }).Count(v => v);

            if (numberOfVersionInputTypes > 1)
            {
                yield return(new Error("Arguments for 'version' and 'version boundaries' cannot be combined."));

                yield break;
            }

            if (gotVersion && Version.ToVersion() == null)
            {
                yield return(new Error("Could not parse version: " + Version));

                yield break;
            }

            if (gotMinVersion && MinVersion.ToVersion() == null)
            {
                yield return(new Error("Could not parse minversion: " + MinVersion));

                yield break;
            }

            if (gotMaxVersion && MaxVersion.ToVersion() == null)
            {
                yield return(new Error("Could not parse maxversion: " + MaxVersion));

                yield break;
            }

            if (Project && HostEnvironment.ProjectRepository == null)
            {
                yield return(new Error("Project repository doesn't exist but -project has been specified."));

                yield break;
            }
            if (!string.IsNullOrEmpty(Scope) && !Project)
            {
                yield return(new Error("Cannot specify a scope when adding to a system package."));

                yield break;
            }
        }
Пример #10
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = (LicenseKey != null ? LicenseKey.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Application != null ? Application.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (MinVersion != null ? MinVersion.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (MaxVersion != null ? MaxVersion.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (LicensedUserName != null ? LicensedUserName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (LicensedUserEmail != null ? LicensedUserEmail.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ StartDate.GetHashCode();
         hashCode = (hashCode * 397) ^ EndDate.GetHashCode();
         hashCode = (hashCode * 397) ^ (CustomValues != null ? CustomValues.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #11
0
        public override bool IsSupportedByCurrentVersion(string currentVersion)
        {
            var curVersion = new Version(currentVersion);
            var supported  = true;

            if (MinVersion.StringIsNotEmpty())
            {
                supported = new Version(MinVersion).CompareTo(curVersion) <= 0;
            }

            if (MaxVersion.StringIsNotEmpty())
            {
                supported = supported && curVersion.CompareTo(new Version(MaxVersion)) <= 0;
            }

            return(supported);
        }
Пример #12
0
        IEnumerable <ICommandOutput> ValidateInputs()
        {
            _dependency = FindDependencyByName();
            if (_dependency == null)
            {
                yield return(new Error("Dependency not found: " + Name));

                yield break;
            }

            var gotVersion                = Version != null;
            var gotMinVersion             = MinVersion != null;
            var gotMaxVersion             = MaxVersion != null;
            var numberOfVersionInputTypes = (new[] { gotVersion, (gotMinVersion || gotMaxVersion), AnyVersion }).Count(v => v);

            if (numberOfVersionInputTypes > 1)
            {
                yield return(new Error("Arguments for 'version', 'version boundaries' and 'anyVersion' cannot be combined."));

                yield break;
            }

            if (gotVersion && Version.ToVersion() == null)
            {
                yield return(new Error("Could not parse version: " + Version));

                yield break;
            }

            if (gotMinVersion && MinVersion.ToVersion() == null)
            {
                yield return(new Error("Could not parse minversion: " + MinVersion));

                yield break;
            }

            if (gotMaxVersion && MaxVersion.ToVersion() == null)
            {
                yield return(new Error("Could not parse maxversion: " + MaxVersion));

                yield break;
            }
        }
 /// <summary>
 /// Perform a validation against the specified PackageVersion. If
 /// the validation fails an exception is thrown using the prefix
 /// string as the first part of the message (e.g. the package name).
 /// </summary>
 /// <exception cref="PackageDependencyException">
 /// Version does not meet the requirements. Message includes a
 /// user-friendly description of why.
 /// </exception>
 /// <param name="version">The package version number to compare against.</param>
 /// <param name="prefix">The prefix applied to the error message.</param>
 public void ValidateVersion(PackageVersion version, String prefix)
 {
     if (MinVersion != null && MinVersion.CompareTo(version) > 0)
     {
         throw new PackageDependencyException(String.Format(
                                                  "{0} version {1} does not meet minimum version requirement of {2}",
                                                  prefix, version.ToString(), MinVersion.ToString()));
     }
     else if (MaxVersion != null && MaxVersion.CompareTo(version) < 0)
     {
         throw new PackageDependencyException(String.Format(
                                                  "{0} version {1} exceeds maximum version requirement of {2}",
                                                  prefix, version.ToString(), MaxVersion.ToString()));
     }
     else if (Version != null && Version.CompareTo(version) != 0)
     {
         throw new PackageDependencyException(String.Format(
                                                  "{0} version {1} does not meet exact version requirement of {2}",
                                                  prefix, version.ToString(), Version.ToString()));
     }
 }
Пример #14
0
 public void Write(TProtocol oprot)
 {
     oprot.IncrementRecursionDepth();
     try
     {
         TStruct struc = new TStruct("MDependency");
         oprot.WriteStructBegin(struc);
         TField field = new TField();
         if (ID == null)
         {
             throw new TProtocolException(TProtocolException.INVALID_DATA, "required field ID not set");
         }
         field.Name = "ID";
         field.Type = TType.String;
         field.ID   = 1;
         oprot.WriteFieldBegin(field);
         oprot.WriteString(ID);
         oprot.WriteFieldEnd();
         field.Name = "Type";
         field.Type = TType.I32;
         field.ID   = 2;
         oprot.WriteFieldBegin(field);
         oprot.WriteI32((int)Type);
         oprot.WriteFieldEnd();
         if (MinVersion == null)
         {
             throw new TProtocolException(TProtocolException.INVALID_DATA, "required field MinVersion not set");
         }
         field.Name = "MinVersion";
         field.Type = TType.Struct;
         field.ID   = 3;
         oprot.WriteFieldBegin(field);
         MinVersion.Write(oprot);
         oprot.WriteFieldEnd();
         if (MaxVersion == null)
         {
             throw new TProtocolException(TProtocolException.INVALID_DATA, "required field MaxVersion not set");
         }
         field.Name = "MaxVersion";
         field.Type = TType.Struct;
         field.ID   = 4;
         oprot.WriteFieldBegin(field);
         MaxVersion.Write(oprot);
         oprot.WriteFieldEnd();
         if (ExcludedVersions != null && __isset.ExcludedVersions)
         {
             field.Name = "ExcludedVersions";
             field.Type = TType.List;
             field.ID   = 5;
             oprot.WriteFieldBegin(field);
             {
                 oprot.WriteListBegin(new TList(TType.Struct, ExcludedVersions.Count));
                 foreach (MVersion _iter40 in ExcludedVersions)
                 {
                     _iter40.Write(oprot);
                 }
                 oprot.WriteListEnd();
             }
             oprot.WriteFieldEnd();
         }
         if (Name != null && __isset.Name)
         {
             field.Name = "Name";
             field.Type = TType.String;
             field.ID   = 6;
             oprot.WriteFieldBegin(field);
             oprot.WriteString(Name);
             oprot.WriteFieldEnd();
         }
         oprot.WriteFieldStop();
         oprot.WriteStructEnd();
     }
     finally
     {
         oprot.DecrementRecursionDepth();
     }
 }
Пример #15
0
 public override string ToString()
 {
     return
         (string.Format("{0},{1},{2}", PluginId, MinVersion != null ? MinVersion.ToString(3) : "",
                        MaxVersion != null ? MaxVersion.ToString(3) : "").TrimEnd(','));
 }