Table of Contents

Class EntityInfo

Namespace
Cuemon.Data.Integrity
Assembly
Cuemon.Data.Integrity.dll

Represents the metadata information normally associated with an entity/resource. Implements the IEntityInfo

public class EntityInfo : IEntityInfo, IEntityDataTimestamp, IEntityDataIntegrity, IDataIntegrity
Inheritance
EntityInfo
Implements

Examples

The following example demonstrates various ways to construct EntityInfo instances with timestamps and optional checksums for data integrity. It shows creation-only, created-and-modified, validated, and local-time normalization scenarios, printing the resulting values.

using System;
using Cuemon.Data.Integrity;
using Cuemon.Security;

namespace MyApp.Data
{
    public static class EntityInfoExamples
    {
        public static void Demonstrate()
        {
            // Create EntityInfo with only a creation timestamp.
            var entity = new EntityInfo(new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc));
            Console.WriteLine("Created: {0:O}", entity.Created);
            Console.WriteLine("Modified: {0}", entity.Modified.HasValue ? entity.Modified.Value.ToString("O") : "null");
            Console.WriteLine("Has checksum: {0}", entity.Checksum.HasValue);
            Console.WriteLine("Validation: {0}", entity.Validation);

            // Create EntityInfo with creation and modification timestamps.
            var modified = new EntityInfo(
                new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc),
                new DateTime(2025, 6, 15, 12, 30, 0, DateTimeKind.Utc));
            Console.WriteLine("Modified entity: Created={0:O}, LastModified={1:O}",
                modified.Created, modified.Modified);

            // Create EntityInfo with a checksum for data integrity validation.
            // The checksum can be used to detect changes to the underlying data.
            byte[] checksumBytes = { 0x1A, 0x2B, 0x3C, 0x4D };
            var validated = new EntityInfo(
                new DateTime(2025, 1, 1, 0, 0, 0, DateTimeKind.Utc),
                null,
                checksumBytes,
                EntityDataIntegrityValidation.Strong);

            Console.WriteLine("Validated entity: Checksum={0}, Validation={1}",
                validated.Checksum.ToHexadecimalString(),
                validated.Validation);

            // Timestamps are always normalized to UTC.
            var localTime = new EntityInfo(new DateTime(2025, 6, 1, 10, 0, 0, DateTimeKind.Local));
            Console.WriteLine("UTC created: {0:O}", localTime.Created);

}}
}

Constructors

EntityInfo(DateTime)

Initializes a new instance of the EntityInfo class.

public EntityInfo(DateTime created)

Parameters

created DateTime

A DateTime value for when data this instance represents was first created.

EntityInfo(DateTime, DateTime?)

Initializes a new instance of the EntityInfo class.

public EntityInfo(DateTime created, DateTime? modified)

Parameters

created DateTime

A DateTime value for when data this instance represents was first created.

modified DateTime?

A DateTime value for when data this instance represents was last modified.

EntityInfo(DateTime, DateTime?, byte[], EntityDataIntegrityValidation)

Initializes a new instance of the EntityInfo class.

public EntityInfo(DateTime created, DateTime? modified, byte[] checksum, EntityDataIntegrityValidation validation = EntityDataIntegrityValidation.Weak)

Parameters

created DateTime

A DateTime value for when data this instance represents was first created.

modified DateTime?

A DateTime value for when data this instance represents was last modified.

checksum byte[]

A byte[] containing a checksum of the data this instance represents.

validation EntityDataIntegrityValidation

A EntityDataIntegrityValidation enumeration value that indicates the validation strength of the specified checksum. Default is Weak.

Properties

Checksum

Gets a HashResult that represents the integrity of this instance.

public HashResult Checksum { get; }

Property Value

HashResult

The checksum that represents the integrity of this instance.

Created

Gets a DateTime value from when data this resource represents was first created, expressed as the Coordinated Universal Time (UTC).

public DateTime Created { get; }

Property Value

DateTime

The timestamp from when data this resource represents was first created.

Modified

Gets a DateTime value from when data this resource represents was last modified, expressed as the Coordinated Universal Time (UTC).

public DateTime? Modified { get; }

Property Value

DateTime?

The timestamp from when data this resource represents was last modified.

Validation

Gets the validation strength of the integrity of this resource.

public EntityDataIntegrityValidation Validation { get; }

Property Value

EntityDataIntegrityValidation

The validation strength of the integrity of this resource.

See Also