using System; using System.Collections.Generic; using FrostFS.SDK.ModelsV2; 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 ObjectAttribute(key, value)); return obj; } public static FrostFsObject AddAttribute(this FrostFsObject obj, ObjectAttribute attribute) { obj.Header.Attributes.Add(attribute); return obj; } public static FrostFsObject AddAttributes(this FrostFsObject obj, IEnumerable attributes) { obj.Header.Attributes.AddRange(attributes); return obj; } public static FrostFsObject SetSplit(this FrostFsObject obj, Split split) { obj.Header.Split = split; return obj; } public static LinkObject AddChildren(this LinkObject linkObject, IEnumerable 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; } }