42 lines
1.0 KiB
C#
42 lines
1.0 KiB
C#
namespace AZKiServer.RPC;
|
|
|
|
public static class ConversionExtensions
|
|
{
|
|
public static Models.MediaType FromRpc(this MediaType type)
|
|
{
|
|
return type switch
|
|
{
|
|
MediaType.None => Models.MediaType.None,
|
|
MediaType.Image => Models.MediaType.Image,
|
|
MediaType.Video => Models.MediaType.Video,
|
|
MediaType.All => Models.MediaType.All,
|
|
_ => throw new NotSupportedException()
|
|
};
|
|
}
|
|
|
|
public static MediaType ToRpc(this Models.MediaType type)
|
|
{
|
|
return type switch
|
|
{
|
|
Models.MediaType.None => MediaType.None,
|
|
Models.MediaType.Image => MediaType.Image,
|
|
Models.MediaType.Video => MediaType.Video,
|
|
Models.MediaType.All => MediaType.All,
|
|
_ => throw new NotSupportedException()
|
|
};
|
|
}
|
|
|
|
public static MediaEntry ToRpc(this Models.MediaEntry entry)
|
|
{
|
|
return new MediaEntry
|
|
{
|
|
Version = entry.Version,
|
|
CameraId = entry.CameraId,
|
|
Date = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(entry.Date),
|
|
FilePath = entry.Filepath,
|
|
Id = entry.Id.ToString(),
|
|
Type = entry.Type.ToRpc()
|
|
};
|
|
}
|
|
}
|