You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
865 B
35 lines
865 B
3 months ago
|
namespace Kean.Domain.Task.Models
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 规格
|
||
|
/// </summary>
|
||
|
public class Spec
|
||
|
{
|
||
|
private int? _spec; // 规格值
|
||
|
|
||
|
/// <summary>
|
||
|
/// 从整型隐式转换
|
||
|
/// </summary>
|
||
|
public static implicit operator Spec(int? spec) => new() { _spec = spec };
|
||
|
|
||
|
/// <summary>
|
||
|
/// 隐式转换为整型
|
||
|
/// </summary>
|
||
|
public static implicit operator int?(Spec spec) => spec?._spec;
|
||
|
|
||
|
/// <summary>
|
||
|
/// 是否适配目标规格
|
||
|
/// </summary>
|
||
|
/// <param name="spec">目标规格</param>
|
||
|
/// <returns>适配结果</returns>
|
||
|
public bool? Adaptive(int? spec)
|
||
|
{
|
||
|
if (!_spec.HasValue || !spec.HasValue)
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
return _spec >= spec;
|
||
|
}
|
||
|
}
|
||
|
}
|