mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-06-13 14:38:43 +00:00
64 lines
1.6 KiB
C#
64 lines
1.6 KiB
C#
using Esiur.Core;
|
|
using Esiur.Data;
|
|
using Esiur.Protocol;
|
|
using Esiur.Resource;
|
|
using Google.Protobuf;
|
|
using System;
|
|
namespace Esiur.Tests.RPC.EsiurServer
|
|
{
|
|
[Remote("Esiur.Tests.RPC.EsiurServer.Attachment", "")]
|
|
[Export]
|
|
public class Attachment : IRecord
|
|
{
|
|
[Annotation("", "Byte[]")]
|
|
public byte[] Data { get; set; }
|
|
|
|
[Annotation("", "String")]
|
|
public string MimeType { get; set; }
|
|
|
|
[Annotation("", "String")]
|
|
public string Name { get; set; }
|
|
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
var other = obj as Attachment;
|
|
if (Name != other.Name) return false;
|
|
if (MimeType != other.MimeType) return false;
|
|
if (!(Data.SequenceEqual(other.Data))) return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
public Client.SharedModel.Attachment ToShared()
|
|
{
|
|
return new Client.SharedModel.Attachment()
|
|
{
|
|
Data = Data,
|
|
MimeType = MimeType,
|
|
Name = Name,
|
|
};
|
|
}
|
|
|
|
public Esiur.Tests.RPC.Client.Grpc.Attachment ToGrpc()
|
|
{
|
|
return new Esiur.Tests.RPC.Client.Grpc.Attachment()
|
|
{
|
|
Data = ByteString.CopyFrom(Data),
|
|
MimeType = MimeType,
|
|
Name = Name,
|
|
};
|
|
}
|
|
|
|
public Echo.ThriftModel.Attachment ToThrift()
|
|
{
|
|
return new Echo.ThriftModel.Attachment()
|
|
{
|
|
Data = Data,
|
|
MimeType = MimeType,
|
|
Name = Name,
|
|
};
|
|
}
|
|
}
|
|
}
|