Skip to content

Commit

Permalink
improved code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
iamr8 committed Feb 1, 2024
1 parent c715373 commit 2d1616d
Show file tree
Hide file tree
Showing 34 changed files with 1,102 additions and 510 deletions.
6 changes: 3 additions & 3 deletions R8.EntityFrameworkCore.AuditProvider.Abstractions/Audit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ public record struct Audit
/// Gets a flag that represents what happened to entity.
/// </summary>
[JsonPropertyName(JsonNames.Audit.Flag)]
public AuditFlag Flag { get; set; }
public AuditFlag Flag { get; init; }

/// <summary>
/// Gets the changes that made to entity.
/// </summary>
/// <remarks>This property only works when <see cref="Flag"/> is <see cref="AuditFlag.Changed"/></remarks>
[JsonPropertyName(JsonNames.Audit.Changes)]
public AuditChange[]? Changes { get; set; }
public AuditChange[]? Changes { get; init; }

/// <summary>
/// Gets the user that made changes.
/// </summary>
[JsonPropertyName(JsonNames.Audit.User)]
public AuditUser? User { get; set; }
public AuditUser? User { get; init; }

public static Audit Empty = new()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ private AuditCollection(JsonElement element)
return _cachedDeserialized;
}

/// <summary>
/// Parses <see cref="JsonElement"/> to <see cref="AuditCollection"/>.
/// </summary>
public static AuditCollection Parse(JsonElement element)
{
return new AuditCollection(element);
}

public static explicit operator AuditCollection(JsonElement element)
{
return new AuditCollection(element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
public enum AuditFlag : ushort
{
/// <summary>
/// This will be used when <see cref="IAuditable"/> is newly created.
/// This will be used when the entity is created.
/// </summary>
Created = 0,

/// <summary>
/// This will be used when <see cref="IAuditable"/> is changed.
/// This will be used when the entity is updated.
/// </summary>
Changed = 1,

/// <summary>
/// This will be used when <see cref="IAuditable"/> is deleted.
/// This will be used when the entity is soft-deleted.
/// </summary>
Deleted = 2,

/// <summary>
/// This will be used when <see cref="IAuditable"/> is undeleted.
/// This will be used when the entity is restored after soft-deletion.
/// </summary>
UnDeleted = 3
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace R8.EntityFrameworkCore.AuditProvider.Abstractions
/// Ignores the property from being tracked by Audit Interceptor.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public sealed class IgnoreAuditAttribute : Attribute
public sealed class AuditIgnoreAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace R8.EntityFrameworkCore.AuditProvider.Abstractions
{
/// <summary>
/// An <see cref="IAuditActivator"/> interface that enables an entity to be auditable.
/// </summary>
public interface IAuditActivator
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace R8.EntityFrameworkCore.AuditProvider.Abstractions
{
/// <summary>
/// An <see cref="IAuditCreateDate"/> interface that enables an entity to store creation date.
/// </summary>
public interface IAuditCreateDate
{
/// <summary>
/// Gets the creation date of this record.
/// </summary>
DateTime? CreateDate { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace R8.EntityFrameworkCore.AuditProvider.Abstractions
{
/// <summary>
/// An <see cref="IAuditDeleteDate"/> interface that enables an entity to store delete date.
/// </summary>
public interface IAuditDeleteDate
{
/// <summary>
/// Gets the delete date of this record.
/// </summary>
DateTime? DeleteDate { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace R8.EntityFrameworkCore.AuditProvider.Abstractions
{
/// <summary>
/// An <see cref="IAuditSoftDelete"/> interface that enables an entity to be soft-deletable.
/// </summary>
/// <remarks>This interface takes effect only when <see cref="IAuditActivator"/> is implemented.</remarks>
public interface IAuditSoftDelete
{
/// <summary>
/// Gets a value indicating whether current entity is soft-deleted or not.
/// </summary>
bool IsDeleted { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace R8.EntityFrameworkCore.AuditProvider.Abstractions
{
/// <summary>
/// An <see cref="IAuditable"/> interface that represents an entity that is auditable.
/// An <see cref="IAuditStorage"/> interface that represents an a column to store audits.
/// </summary>
public interface IAuditable
public interface IAuditStorage
{
/// <summary>
/// Gets or sets the Audit `JSON` data for this record.
/// Gets the Audit `JSON` data for this record.
/// </summary>
JsonElement? Audits { get; set; }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace R8.EntityFrameworkCore.AuditProvider.Abstractions
{
/// <summary>
/// An <see cref="IAuditCreateDate"/> interface that enables an entity to store update/restore date.
/// </summary>
public interface IAuditUpdateDate
{
/// <summary>
/// Gets the update date of this record.
/// </summary>
DateTime? UpdateDate { get; set; }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<Version>1.0.7</Version>
<Version>1.0.9</Version>
<Authors>iamr8</Authors>
<Description>A .NET package for Entity Framework, providing comprehensive change tracking with deep insights.</Description>
<PackageId>R8.EntityFrameworkCore.AuditProvider.Abstractions</PackageId>
Expand Down
Loading

0 comments on commit 2d1616d

Please sign in to comment.