[#1] Add object Get operation + code quality
Signed-off-by: Ivan Pchelintsev <i.pchelintsev@yadro.com>
This commit is contained in:
parent
9aa93d123d
commit
b307c2c899
17 changed files with 182 additions and 99 deletions
|
@ -52,20 +52,27 @@ public static class ObjectHeadMapper
|
|||
throw new ArgumentException($"Unknown ObjectType. Value: '{header.ObjectType}'.");
|
||||
}
|
||||
|
||||
var attributes = new List<ObjectAttribute>();
|
||||
foreach (var attribute in header.Attributes)
|
||||
{
|
||||
attributes.Add(attribute.ToModel());
|
||||
}
|
||||
|
||||
return new ObjectHeader(
|
||||
ContainerId.FromHash(header.ContainerId.Value.ToByteArray()),
|
||||
Enum.Parse<ModelsV2.Enums.ObjectType>(objTypeName),
|
||||
attributes.ToArray()
|
||||
header.Attributes.Select(attribute => attribute.ToModel()).ToArray()
|
||||
)
|
||||
{
|
||||
Size = (long)header.PayloadLength,
|
||||
Version = header.Version.ToModel()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static class ObjectMapper
|
||||
{
|
||||
public static ModelsV2.Object ToModel(this Object.Object obj)
|
||||
{
|
||||
return new ModelsV2.Object
|
||||
{
|
||||
Header = obj.Header.ToModel(),
|
||||
ObjectId = ObjectId.FromHash(obj.ObjectId.Value.ToByteArray()),
|
||||
Payload = obj.Payload.ToByteArray()
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue