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()); }
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); }
public override string ToString() { // Returns nothing if no min or max if (MinVersion == null && MaxVersion == null) { return(null); } // If we have min and minInclusive but no max, then return min string if (MinVersion != null && IsMinInclusive && MaxVersion == null && !IsMaxInclusive) { return(MinVersion.ToString()); } // MinVersion and MaxVersion is the same and both inclusives then return the value if (MinVersion == MaxVersion && IsMinInclusive && IsMaxInclusive) { return(String.Format(CultureInfo.InvariantCulture, "[{0}]", MinVersion)); } char lhs = IsMinInclusive ? '[' : '('; char rhs = IsMaxInclusive ? ']' : ')'; return(String.Format(CultureInfo.InvariantCulture, "{0}{1}, {2}{3}", lhs, MinVersion, MaxVersion, rhs)); }
public bool NeedsUpdate() { if (MinVersion == null) { return(true); } if (MaxVersion == null) { return(true); } var field = GetVersionField(); var minVersionType = MinVersion.GetType(); var maxVersionType = MaxVersion.GetType(); if (field.Type == "byte[]" && minVersionType == typeof(byte[]) && maxVersionType == typeof(byte[])) { var beginBytes = (byte[])MinVersion; var endBytes = (byte[])MaxVersion; return(!beginBytes.SequenceEqual(endBytes)); } if (minVersionType != maxVersionType) { MinVersion = field.Convert(MinVersion.ToString()); MaxVersion = field.Convert(MaxVersion.ToString()); } return(!MinVersion.Equals(MaxVersion)); }
/// <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); }
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)); } }
public override int GetHashCode() { unchecked { var hashCode = (int)ApiKey; hashCode = (hashCode * 397) ^ MinVersion.GetHashCode(); hashCode = (hashCode * 397) ^ MaxVersion.GetHashCode(); return(hashCode); } }
public override string ToString() { if (MinVersion == MaxVersion && VersionFloatBehavior == SemanticVersionFloatBehavior.None) { return(MinVersion.ToString()); } var sb = new StringBuilder(); sb.Append(">= "); switch (VersionFloatBehavior) { case SemanticVersionFloatBehavior.None: sb.Append(MinVersion); break; case SemanticVersionFloatBehavior.Prerelease: sb.AppendFormat("{0}-*", MinVersion); break; case SemanticVersionFloatBehavior.Revision: sb.AppendFormat("{0}.{1}.{2}.*", MinVersion.Version.Major, MinVersion.Version.Minor, MinVersion.Version.Build); break; case SemanticVersionFloatBehavior.Build: sb.AppendFormat("{0}.{1}.*", MinVersion.Version.Major, MinVersion.Version.Minor); break; case SemanticVersionFloatBehavior.Minor: sb.AppendFormat("{0}.{1}.*", MinVersion.Version.Major); break; case SemanticVersionFloatBehavior.Major: sb.AppendFormat("*"); break; default: break; } if (MaxVersion != null) { sb.Append(IsMaxInclusive ? " <= " : " < "); sb.Append(MaxVersion); } return(sb.ToString()); }
/// <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); }
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); }
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; } }
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); } }
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); }
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; } }
/// <inheritdoc/> public override string ToString() { if (MinVersion != null && IsMinInclusive && MaxVersion == null && !IsMaxInclusive) { return(MinVersion.ToString()); } if (MinVersion != null && MaxVersion != null && MinVersion == MaxVersion && IsMinInclusive && IsMaxInclusive) { return("[" + MinVersion + "]"); } var versionBuilder = new StringBuilder(); versionBuilder.Append(IsMinInclusive ? '[' : '('); versionBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}, {1}", MinVersion, MaxVersion); versionBuilder.Append(IsMaxInclusive ? ']' : ')'); return(versionBuilder.ToString()); }
/// <summary> /// Create a floating version string in the format: 1.0.0-alpha-* /// </summary> public override string ToString() { string result = string.Empty; switch (_floatBehavior) { case NuGetVersionFloatBehavior.None: result = MinVersion.ToNormalizedString(); break; case NuGetVersionFloatBehavior.Prerelease: result = String.Format(new VersionFormatter(), "{0:V}-{1}*", MinVersion, _releasePrefix); break; case NuGetVersionFloatBehavior.Revision: result = String.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}.*", MinVersion.Major, MinVersion.Minor, MinVersion.Patch); break; case NuGetVersionFloatBehavior.Patch: result = String.Format(CultureInfo.InvariantCulture, "{0}.{1}.*", MinVersion.Major, MinVersion.Minor); break; case NuGetVersionFloatBehavior.Minor: result = String.Format(CultureInfo.InvariantCulture, "{0}.*", MinVersion.Major); break; case NuGetVersionFloatBehavior.Major: result = "*"; break; case NuGetVersionFloatBehavior.AbsoluteLatest: // TODO: how should this be denoted? result = string.Empty; break; default: break; } return(result); }
/// <summary> /// 返回格式为:<paramref name="format"/> 的版本范围字符串,如果最大和最小版本都为null则返回空字符串,如果最大或者最小版本只有一个为null则返回单个版本字符串。 /// </summary> /// <param name="format">格式。</param> /// <returns>指定格式的版本字符串信息。</returns> /// <exception cref="ArgumentNullException"><paramref name="format"/> 为空。</exception> public string ToString(string format) { if (string.IsNullOrWhiteSpace(format)) { throw new ArgumentNullException("format"); } if (MinVersion != null && MaxVersion != null) { return(string.Format(format, MinVersion, MaxVersion)); } if (MinVersion == null && MaxVersion != null) { return(MaxVersion.ToString()); } if (MaxVersion == null && MinVersion != null) { return(MinVersion.ToString()); } return(string.Empty); }
public bool NeedsUpdate() { if (MinVersion == null) { return(true); } if (MaxVersion == null) { return(true); } var field = GetVersionField(); if (field.Type == "byte[]") { var beginBytes = (byte[])MinVersion; var endBytes = (byte[])MaxVersion; return(!beginBytes.SequenceEqual(endBytes)); } return(!MinVersion.Equals(MaxVersion)); }
/// <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())); } }
public override string ToString() { return (string.Format("{0},{1},{2}", PluginId, MinVersion != null ? MinVersion.ToString(3) : "", MaxVersion != null ? MaxVersion.ToString(3) : "").TrimEnd(',')); }
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(); } }
public ColumnFamilySchema ToPbSchema() { var schema = new ColumnFamilySchema { Name = ByteString.CopyFrom(Name) }; schema.Attributes.Add(new BytesBytesPair { First = ByteString.CopyFromUtf8("VERSIONS"), Second = ByteString.CopyFromUtf8(MaxVersions.ToString()) }); schema.Attributes.Add(new BytesBytesPair { First = ByteString.CopyFromUtf8("TTl"), Second = ByteString.CopyFromUtf8(TTL.ToString()) }); schema.Attributes.Add(new BytesBytesPair { First = ByteString.CopyFromUtf8("MIN_VERSIONS"), Second = ByteString.CopyFromUtf8(MinVersion.ToString()) }); schema.Attributes.Add(new BytesBytesPair { First = ByteString.CopyFromUtf8("KEEP_DELETED_CELLS"), Second = ByteString.CopyFromUtf8(KeepDeletedCells.ToString()) }); schema.Attributes.Add(new BytesBytesPair { First = ByteString.CopyFromUtf8("BLOCKSIZE"), Second = ByteString.CopyFromUtf8(BlockSize.ToString()) }); schema.Attributes.Add(new BytesBytesPair { First = ByteString.CopyFromUtf8("COMPRESSION"), Second = ByteString.CopyFromUtf8(Compression.ToString()) }); schema.Attributes.Add(new BytesBytesPair { First = ByteString.CopyFromUtf8("BLOCKCACHE"), Second = ByteString.CopyFromUtf8(IsBlockCache.ToString()) }); schema.Attributes.Add(new BytesBytesPair { First = ByteString.CopyFromUtf8("BLOOMFILTER"), Second = ByteString.CopyFromUtf8(BloomFilter.ToString()) }); schema.Attributes.Add(new BytesBytesPair { First = ByteString.CopyFromUtf8("REPLICATION_SCOPE"), Second = ByteString.CopyFromUtf8(ReplicationScope.ToString()) }); schema.Attributes.Add(new BytesBytesPair { First = ByteString.CopyFromUtf8("DATA_BLOCK_ENCODING"), Second = ByteString.CopyFromUtf8(DataBlockEncoding.ToString()) }); return(schema); }