bitwarden-android/src/App/Models/Attachment.cs

47 lines
1.2 KiB
C#
Raw Normal View History

2017-07-12 22:16:36 +03:00
using Bit.App.Models.Api;
using Bit.App.Models.Data;
namespace Bit.App.Models
{
public class Attachment
{
public Attachment()
{ }
public Attachment(AttachmentData data)
{
Id = data.Id;
Url = data.Url;
FileName = data.FileName != null ? new CipherString(data.FileName) : null;
2017-07-13 16:01:00 +03:00
SetSize(data.Size);
2017-07-12 22:16:36 +03:00
SizeName = data.SizeName;
}
public Attachment(AttachmentResponse response)
{
Id = response.Id;
Url = response.Url;
FileName = response.FileName != null ? new CipherString(response.FileName) : null;
2017-07-13 16:01:00 +03:00
SetSize(response.Size);
2017-07-12 22:16:36 +03:00
SizeName = response.SizeName;
}
public string Id { get; set; }
public string Url { get; set; }
public CipherString FileName { get; set; }
2017-07-13 16:01:00 +03:00
public long Size { get; set; }
2017-07-12 22:16:36 +03:00
public string SizeName { get; set; }
2017-07-13 16:01:00 +03:00
private void SetSize(string sizeString)
{
long size;
if(!long.TryParse(sizeString, out size))
{
size = 0;
}
Size = size;
}
2017-07-12 22:16:36 +03:00
}
}