您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

62 行
1.7 KiB

using System;
using System.Collections.Generic;
namespace ChatComponents
{
public class PartialFile
{
/// Media type
public readonly string mimeType;
/// The name of the file
public readonly string name;
/// Size of the file in bytes
public readonly int size;
/// The file source (either a remote URL or a local resource)
public readonly string uri;
/// Creates a partial file message with all variables file can have.
/// Use [FileMessage] to create a full message.
/// You can use [FileMessage.fromPartial] constructor to create a full
/// message from a partial one.
public PartialFile(
string name,
int size,
string uri,
string mimeType = null
)
{
this.name = name;
this.size = size;
this.uri = uri;
this.mimeType = mimeType;
}
/// Creates a partial file message from a map (decoded JSON).
public PartialFile fromJson(Dictionary<string, object> json)
{
return new PartialFile(
mimeType: json["mimeType"] as string,
name: json["name"] as string,
size: Convert.ToInt32(json["size"]),
uri: json["uri"] as string
);
}
/// Converts a partial file message to the map representation, encodable to JSON.
private Dictionary<string, object> toJson()
{
return new Dictionary<string, object>
{
{"mimeType", mimeType},
{"name", name},
{"size", size},
{"uri", uri}
};
}
}
}