configure grpc
This commit is contained in:
41
AZKiServer/RPC/ConversionExtensions.cs
Normal file
41
AZKiServer/RPC/ConversionExtensions.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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()
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user