[#28] Clients: Make immutable parameters
Signed-off-by: Pavel Gross <p.gross@yadro.com>
This commit is contained in:
parent
749000a090
commit
9bb7b5eff8
62 changed files with 2742 additions and 963 deletions
|
@ -2,23 +2,70 @@
|
|||
|
||||
namespace FrostFS.SDK.Client;
|
||||
|
||||
public sealed class PrmObjectPatch(FrostFsAddress address, CallContext? ctx = null) : PrmBase(ctx), ISessionToken
|
||||
public readonly struct PrmObjectPatch(
|
||||
FrostFsAddress address,
|
||||
FrostFsRange range,
|
||||
Stream? payload,
|
||||
int maxChunkLength,
|
||||
FrostFsSessionToken? sessionToken = null,
|
||||
bool replaceAttributes = false,
|
||||
FrostFsAttributePair[]? newAttributes = null,
|
||||
string[]? xheaders = null) : ISessionToken, System.IEquatable<PrmObjectPatch>
|
||||
{
|
||||
public FrostFsAddress Address { get; } = address;
|
||||
|
||||
public FrostFsRange Range { get; set; }
|
||||
public FrostFsRange Range { get; } = range;
|
||||
|
||||
/// <summary>
|
||||
/// A stream with source data
|
||||
/// </summary>
|
||||
public Stream? Payload { get; set; }
|
||||
public Stream? Payload { get; } = payload;
|
||||
|
||||
public FrostFsAttributePair[]? NewAttributes { get; set; }
|
||||
public FrostFsAttributePair[]? NewAttributes { get; } = newAttributes;
|
||||
|
||||
public bool ReplaceAttributes { get; set; }
|
||||
public bool ReplaceAttributes { get; } = replaceAttributes;
|
||||
|
||||
public int MaxPayloadPatchChunkLength { get; set; }
|
||||
public int MaxChunkLength { get; } = maxChunkLength;
|
||||
|
||||
/// <inheritdoc />
|
||||
public FrostFsSessionToken? SessionToken { get; set; }
|
||||
public FrostFsSessionToken? SessionToken { get; } = sessionToken;
|
||||
|
||||
/// <summary>
|
||||
/// FrostFS request X-Headers
|
||||
/// </summary>
|
||||
public string[] XHeaders { get; } = xheaders ?? [];
|
||||
|
||||
public override readonly bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || obj is not PrmObjectPatch)
|
||||
return false;
|
||||
|
||||
return Equals((PrmObjectPatch)obj);
|
||||
}
|
||||
|
||||
public readonly bool Equals(PrmObjectPatch other)
|
||||
{
|
||||
return GetHashCode() == other.GetHashCode();
|
||||
}
|
||||
|
||||
public override readonly int GetHashCode()
|
||||
{
|
||||
return Address.GetHashCode()
|
||||
^ Range.GetHashCode()
|
||||
^ (Payload == null ? 0 : Payload.GetHashCode())
|
||||
^ (NewAttributes == null ? 0 : NewAttributes.GetHashCode())
|
||||
^ (SessionToken == null ? 0 : SessionToken.GetHashCode())
|
||||
^ (ReplaceAttributes ? 1 : 0)
|
||||
^ MaxChunkLength;
|
||||
}
|
||||
|
||||
public static bool operator ==(PrmObjectPatch left, PrmObjectPatch right)
|
||||
{
|
||||
return left.Equals(right);
|
||||
}
|
||||
|
||||
public static bool operator !=(PrmObjectPatch left, PrmObjectPatch right)
|
||||
{
|
||||
return !(left == right);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue