Skip to main content

StoredAttributeValueComparer

Namespace: Meshmakers.Octo.Runtime.Contracts.Secrets

Compares two in-memory attribute values the way the conditional rewrite (IRuntimeRepository.RewriteAttributeValueIfUnchangedForMigrationAsync(IOctoSession, RtCkId<CkTypeId>, OctoObjectId, String, Object, Object), AB#5532) needs it: "is the stored value still the one that was read?". The comparison is about the stored content, not about the CLR shape a read happens to produce, so a repository can compare the value it reads back now with the value a caller read earlier.

public static class StoredAttributeValueComparer

Inheritance Object → StoredAttributeValueComparer

Remarks:

Secret values compare by their stored form: a protected value by its envelope, a legacy value (RtSecretValueState.LegacyPlaintext or a plain String) by its text. LegacyPlaintext("x") equals "x"; a protected value never equals a string, even when the string holds the same envelope (sub-document vs. string slot).

Records compare by record id and member values (a missing member equals null).

Arrays compare element by element, whatever the collection type.

Numbers compare by value across CLR types (a BSON int32 read as int vs. an int64).

Never logs or exposes a value.

Methods​

AreEqual(Object, Object)​

True when stored and expected describe the same stored attribute value.

public static bool AreEqual(object stored, object expected)

Parameters​

stored Object
The value as currently stored (read back by the repository)

expected Object
The value the caller read earlier

Returns​

Boolean