Rename project, namespaces and class names Signed-off-by: Pavel Gross <p.gross@yadro.com>
55 lines
1.7 KiB
C#
55 lines
1.7 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
|
|
using FrostFS.Object;
|
|
using FrostFS.SDK.Cryptography;
|
|
|
|
namespace FrostFS.SDK.Client.Mappers.GRPC;
|
|
|
|
public static class ObjectHeaderMapper
|
|
{
|
|
public static FrostFsObjectHeader ToModel(this Header header)
|
|
{
|
|
if (header is null)
|
|
{
|
|
throw new ArgumentNullException(nameof(header));
|
|
}
|
|
|
|
var objTypeName = header.ObjectType switch
|
|
{
|
|
ObjectType.Regular => FrostFsObjectType.Regular,
|
|
ObjectType.Lock => FrostFsObjectType.Lock,
|
|
ObjectType.Tombstone => FrostFsObjectType.Tombstone,
|
|
_ => throw new ArgumentException($"Unknown ObjectType. Value: '{header.ObjectType}'.")
|
|
};
|
|
|
|
FrostFsSplit? split = null;
|
|
|
|
if (header.Split != null)
|
|
{
|
|
var children = header.Split.Children.Count != 0 ? new ReadOnlyCollection<FrostFsObjectId>(
|
|
header.Split.Children.Select(x => x.ToModel()).ToList()) : null;
|
|
|
|
split = new FrostFsSplit(new SplitId(header.Split.SplitId.ToUuid()),
|
|
header.Split.Previous?.ToModel(),
|
|
header.Split.Parent?.ToModel(),
|
|
header.Split.ParentHeader?.ToModel(),
|
|
null,
|
|
children);
|
|
}
|
|
|
|
var model = new FrostFsObjectHeader(
|
|
new FrostFsContainerId(Base58.Encode(header.ContainerId.Value.ToByteArray())),
|
|
objTypeName,
|
|
header.Attributes.Select(attribute => attribute.ToModel()).ToArray(),
|
|
split,
|
|
header.OwnerId.ToModel(),
|
|
header.Version.ToModel())
|
|
{
|
|
PayloadLength = header.PayloadLength,
|
|
};
|
|
|
|
return model;
|
|
}
|
|
}
|