mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-04 13:08:23 +08:00
61a653579f
* fix #1987 IsPicture bug * Optimize image judgment method * Optimize picture type Judgment method * Optimize imagetypes comparison method
50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Text.Json;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public class UploadFileItem
|
|
{
|
|
public string Id { get; set; }
|
|
|
|
public string FileName { get; set; }
|
|
|
|
public int Percent { get; set; }
|
|
|
|
public string ObjectURL { get; set; }
|
|
|
|
public string Url { get; set; }
|
|
|
|
public string Response { get; set; }
|
|
|
|
public UploadState State { get; set; }
|
|
|
|
public long Size { get; set; }
|
|
|
|
public string Ext { get; set; }
|
|
|
|
public string Type { get; set; }
|
|
|
|
public TResponseModel GetResponse<TResponseModel>(JsonSerializerOptions options = null)
|
|
{
|
|
if (options == null)
|
|
{
|
|
//Provide default configuration: ignore case
|
|
options = new JsonSerializerOptions
|
|
{
|
|
PropertyNameCaseInsensitive = true,
|
|
};
|
|
}
|
|
return JsonSerializer.Deserialize<TResponseModel>(this.Response, options);
|
|
}
|
|
|
|
public bool IsPicture()
|
|
{
|
|
string[] imageTypes = new[] { ".jpg", ".png", ".gif", ".ico" };
|
|
Ext = FileName.Substring(FileName.LastIndexOf('.'));
|
|
return imageTypes.Any(imageType => imageType.Equals(Ext, StringComparison.InvariantCultureIgnoreCase));
|
|
}
|
|
}
|
|
}
|