57 lines
No EOL
1.6 KiB
C#
57 lines
No EOL
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace FrostFS.SDK.ClientV2.Extensions;
|
|
|
|
public static class ObjectExtensions
|
|
{
|
|
public static FrostFsObject SetPayloadLength(this FrostFsObject obj, ulong length)
|
|
{
|
|
obj.Header.PayloadLength = length;
|
|
return obj;
|
|
}
|
|
|
|
public static FrostFsObject SetPayload(this FrostFsObject obj, byte[] bytes)
|
|
{
|
|
obj.Payload = bytes;
|
|
return obj;
|
|
}
|
|
|
|
public static FrostFsObject AddAttribute(this FrostFsObject obj, string key, string value)
|
|
{
|
|
obj.AddAttribute(new FrostFsAttribute(key, value));
|
|
return obj;
|
|
}
|
|
|
|
public static FrostFsObject AddAttribute(this FrostFsObject obj, FrostFsAttribute attribute)
|
|
{
|
|
obj.Header.Attributes.Add(attribute);
|
|
return obj;
|
|
}
|
|
|
|
public static FrostFsObject AddAttributes(this FrostFsObject obj, IEnumerable<FrostFsAttribute> attributes)
|
|
{
|
|
obj.Header.Attributes.AddRange(attributes);
|
|
return obj;
|
|
}
|
|
|
|
public static FrostFsObject SetSplit(this FrostFsObject obj, FrostFsSplit? split)
|
|
{
|
|
obj.Header.Split = split;
|
|
return obj;
|
|
}
|
|
|
|
public static FrostFsLinkObject AddChildren(this FrostFsLinkObject linkObject, IEnumerable<FrostFsObjectId> objectIds)
|
|
{
|
|
linkObject.Header.Split!.Children.AddRange(objectIds);
|
|
return linkObject;
|
|
}
|
|
|
|
public static FrostFsObject CalculateObjectId(this FrostFsObject obj)
|
|
{
|
|
if (obj.Header == null)
|
|
throw new MissingFieldException("Header cannot be null");
|
|
|
|
return obj;
|
|
}
|
|
} |