Table of Contents

EntityInfo Class

Definition

Namespace
Cuemon.Data.Integrity
Assemblies
Cuemon.Data.Integrity.dll
Source
src/Cuemon.Data.Integrity/EntityInfo.cs

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

public class EntityInfo : IEntityInfo, IEntityDataTimestamp, IEntityDataIntegrity, IDataIntegrity
Inheritance
object
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

Name Description
EntityInfo(DateTime)

Initializes a new instance of the EntityInfo class.

EntityInfo(DateTime, DateTime?)

Initializes a new instance of the EntityInfo class.

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

Initializes a new instance of the EntityInfo class.

Properties

Name Description
Checksum

Gets a HashResult 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).

Modified

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

Validation

Gets the validation strength of the integrity of this resource.

See Also