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)); }
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()); }
/// <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); }
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 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() { var result = string.Empty; switch (_floatBehavior) { case NuGetVersionFloatBehavior.None: result = MinVersion.ToString(); 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); }
/// <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 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); }
public override string ToString() { return (string.Format("{0},{1},{2}", PluginId, MinVersion != null ? MinVersion.ToString(3) : "", MaxVersion != null ? MaxVersion.ToString(3) : "").TrimEnd(',')); }