35 lines
741 B
C#
35 lines
741 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace FileService.Domain.ValueObjects
|
|
{
|
|
public class FileName
|
|
{
|
|
public string Value { get; }
|
|
|
|
public FileName(string value)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(value) || value.Length > 255)
|
|
{
|
|
throw new ArgumentException("文件名不能为空且不能超过 255 个字符");
|
|
}
|
|
|
|
Value = value;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return Value;
|
|
}
|
|
|
|
public static implicit operator FileName(string value)
|
|
{
|
|
return new FileName(value);
|
|
}
|
|
|
|
}
|
|
}
|