Beispiel #1
0
 public ComponentVersion SwitchSnapshotToRelease(ComponentVersion anotherVersion)
 {
     if (!IsDefined)
     {
         throw new InvalidOperationException("version undefined");
     }
     if (!anotherVersion.IsDefined)
     {
         throw new InvalidOperationException("target version undefined");
     }
     if (anotherVersion.IsSnapshot)
     {
         throw new InvalidOperationException("targer version is SNAPSHOT");
     }
     if (IsSnapshot)
     {
         string v = _value.Substring(0, _value.Length - SnapshotPosfix.Length);
         if (!anotherVersion.Value.StartsWith(v))
         {
             throw new InvalidOperationException($"release version must extend snapshot. {anotherVersion.Value} does not start with {v}");
         }
         return(new ComponentVersion(anotherVersion.Value));
     }
     throw new InvalidOperationException("version already in release");
 }
Beispiel #2
0
        public VersionOperations(ComponentVersion version)
        {
            if (!version.IsDefined)
            {
                throw new InvalidOperationException("version undefined");
            }
            _version = version;

            var value = version.Value;

            _suffix = "";
            int pos = value.IndexOf('-');

            if (pos >= 0)
            {
                _suffix = value.Substring(pos);
                value   = value.Substring(0, pos);
            }

            _parts = ParseVersion(value).ToArray();
        }
Beispiel #3
0
 private static bool VersionEqual(ComponentVersion version1, ComponentVersion version2)
 {
     return(NullableStringEqual(version1.Value, version2.Value));            // TODO: it is questionable, need review logic
 }
Beispiel #4
0
 public bool Equals(ComponentVersion other)
 {
     return(string.Equals(_value, other._value, StringComparison.Ordinal));
 }
Beispiel #5
0
 public static VersionOperations Operations(this ComponentVersion version)
 {
     return(new VersionOperations(version));
 }