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 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 toJson() { return new Dictionary { {"mimeType", mimeType}, {"name", name}, {"size", size}, {"uri", uri} }; } } }