| | | 1 | | namespace ProjectTemplate.Infrastructure.Data.Auditing; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Defines supported audit storage mode names for application data access. |
| | | 5 | | /// </summary> |
| | | 6 | | public static class AuditStorageModes |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Stores audit records in the application database through the local EF Core audit record table. |
| | | 10 | | /// </summary> |
| | | 11 | | public const string Local = "Local"; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Indicates that a consuming application intends to route audit records through an outbox-style store. |
| | | 15 | | /// </summary> |
| | | 16 | | public const string Outbox = "Outbox"; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Indicates that a consuming application intends to route audit records through a custom external sink. |
| | | 20 | | /// </summary> |
| | | 21 | | public const string ExternalSink = "ExternalSink"; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Determines whether the supplied storage mode is one of the supported mode names. |
| | | 25 | | /// </summary> |
| | | 26 | | public static bool IsSupported(string? storageMode) |
| | | 27 | | { |
| | 494 | 28 | | string normalizedStorageMode = Normalize(storageMode); |
| | | 29 | | |
| | 494 | 30 | | return normalizedStorageMode.Equals(Local, StringComparison.OrdinalIgnoreCase) |
| | 494 | 31 | | || normalizedStorageMode.Equals(Outbox, StringComparison.OrdinalIgnoreCase) |
| | 494 | 32 | | || normalizedStorageMode.Equals(ExternalSink, StringComparison.OrdinalIgnoreCase); |
| | | 33 | | } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// Determines whether the supplied storage mode uses the default local audit record table. |
| | | 37 | | /// </summary> |
| | | 38 | | public static bool IsLocal(string? storageMode) |
| | | 39 | | { |
| | 250 | 40 | | return Normalize(storageMode).Equals(Local, StringComparison.OrdinalIgnoreCase); |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Normalizes a configured storage mode value for comparison and logging. |
| | | 45 | | /// </summary> |
| | | 46 | | public static string Normalize(string? storageMode) |
| | | 47 | | { |
| | 956 | 48 | | return storageMode?.Trim() ?? string.Empty; |
| | | 49 | | } |
| | | 50 | | } |