具有通配符符号的简单版本号检查器

时间:2019-07-09 00:35:58

标签: c#

c#中是否有任何允许通配符的内置版本检查器类?如果没有,那么有没有更简单的方法可以做到这一点? 示例:

bool IsVersionValid(string version, string allowedVersions)
{
    // compares the string and returns if the version is valid.
}

如果我打电话:

IsVersionValid("1.0", "(1.0,)") --> it should return false.
IsVersionValid("1.0.1", "(1.0,)") --> it should return true.
IsVersionValid("1.0", "[1.0]") --> it should return true.
IsVersionValid("1.0.1", "[1.0]") --> it should return false.

以下是通配符列表。

Notation: 1.0
Applied rule: x ≥ 1.0   
Description: Minimum version, inclusive

Notation: (1.0,)    
Applied rule: x > 1.0   
Description: Minimum version, exclusive

Notation: [1.0] 
Applied rule: x == 1.0  
Description: Exact version match

Notation: (,1.0]    
Applied rule: x ≤ 1.0   
Description: Maximum version, inclusive

Notation: (,1.0)    
Applied rule: x < 1.0   
Description: Maximum version, exclusive

Notation: [1.0,2.0] 
Applied rule: 1.0 ≤ x ≤ 2.0 
Description: Exact range, inclusive

Notation: (1.0,2.0) 
Applied rule: 1.0 < x < 2.0 
Description: Exact range, exclusive

Notation: [1.0,2.0) 
Applied rule: 1.0 ≤ x < 2.0 
Description: inclusive minimum and exclusive maximum version

Notation: (1.0) 
Applied rule: invalid
Description: invalid

0 个答案:

没有答案