Rename project, namespaces and class names Signed-off-by: Pavel Gross <p.gross@yadro.com>
62 lines
1 KiB
C#
62 lines
1 KiB
C#
using System;
|
|
|
|
using FrostFS.SDK.Cryptography;
|
|
|
|
using Google.Protobuf;
|
|
|
|
namespace FrostFS.SDK;
|
|
|
|
public class SplitId
|
|
{
|
|
private readonly Guid id;
|
|
|
|
private ByteString? message;
|
|
|
|
public SplitId()
|
|
{
|
|
this.id = Guid.NewGuid();
|
|
}
|
|
|
|
public SplitId(Guid id)
|
|
{
|
|
this.id = id;
|
|
}
|
|
|
|
private SplitId(byte[] binary)
|
|
{
|
|
this.id = new Guid(binary);
|
|
}
|
|
|
|
private SplitId(string str)
|
|
{
|
|
this.id = new Guid(str);
|
|
}
|
|
|
|
public static SplitId CreateFromBinary(byte[] binaryData)
|
|
{
|
|
return new SplitId(binaryData);
|
|
}
|
|
|
|
public static SplitId CreateFromString(string stringData)
|
|
{
|
|
return new SplitId(stringData);
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return this.id.ToString();
|
|
}
|
|
|
|
public byte[]? ToBinary()
|
|
{
|
|
if (this.id == Guid.Empty)
|
|
return null;
|
|
|
|
return this.id.ToBytes();
|
|
}
|
|
|
|
public ByteString? GetSplitId()
|
|
{
|
|
return this.message ??= ByteString.CopyFrom(ToBinary());
|
|
}
|
|
}
|