easier access to Document filename

This commit is contained in:
Wizou 2022-02-24 17:12:52 +01:00
parent f282d270ae
commit a178d4be6f

View file

@ -355,6 +355,8 @@ namespace TL
partial class Document partial class Document
{ {
public override long ID => id; public override long ID => id;
public override string ToString() => Filename is string filename ? base.ToString() + ": " + filename : base.ToString();
public string Filename => attributes.OfType<DocumentAttributeFilename>().FirstOrDefault()?.file_name;
protected override InputDocument ToInputDocument() => new() { id = id, access_hash = access_hash, file_reference = file_reference }; protected override InputDocument ToInputDocument() => new() { id = id, access_hash = access_hash, file_reference = file_reference };
public InputDocumentFileLocation ToFileLocation(PhotoSizeBase thumbSize = null) => new() { id = id, access_hash = access_hash, file_reference = file_reference, thumb_size = thumbSize?.Type }; public InputDocumentFileLocation ToFileLocation(PhotoSizeBase thumbSize = null) => new() { id = id, access_hash = access_hash, file_reference = file_reference, thumb_size = thumbSize?.Type };
public PhotoSizeBase LargestThumbSize => thumbs?.Aggregate((agg, next) => (long)next.Width * next.Height > (long)agg.Width * agg.Height ? next : agg); public PhotoSizeBase LargestThumbSize => thumbs?.Aggregate((agg, next) => (long)next.Width * next.Height > (long)agg.Width * agg.Height ? next : agg);