diff options
author | crupest <crupest@outlook.com> | 2021-04-30 16:52:55 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-04-30 16:52:55 +0800 |
commit | 88002173a1155883d1fb46683a9a7ad1f521eb56 (patch) | |
tree | 742cce92b6e424d7bcd4a51a8da63dd10e18c4c7 /BackEnd/Timeline/Services/EntityException.cs | |
parent | bf4c48980f81e566065c07f3fe534ce7551ebdcc (diff) | |
download | timeline-88002173a1155883d1fb46683a9a7ad1f521eb56.tar.gz timeline-88002173a1155883d1fb46683a9a7ad1f521eb56.tar.bz2 timeline-88002173a1155883d1fb46683a9a7ad1f521eb56.zip |
refactor: ...
Diffstat (limited to 'BackEnd/Timeline/Services/EntityException.cs')
-rw-r--r-- | BackEnd/Timeline/Services/EntityException.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/BackEnd/Timeline/Services/EntityException.cs b/BackEnd/Timeline/Services/EntityException.cs new file mode 100644 index 00000000..7a302e5a --- /dev/null +++ b/BackEnd/Timeline/Services/EntityException.cs @@ -0,0 +1,31 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Timeline.Services
+{
+ [Serializable]
+ public class EntityException : Exception
+ {
+ public EntityException() { }
+ public EntityException(string? message) : base(message) { }
+ public EntityException(string? message, Exception? inner) : base(message, inner) { }
+ public EntityException(EntityType entityType, IDictionary<string, object> constraints, string? message = null, Exception? inner = null)
+ : base(message, inner)
+ {
+ EntityType = entityType;
+ Constraints = constraints;
+ }
+ protected EntityException(
+ System.Runtime.Serialization.SerializationInfo info,
+ System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
+
+ public EntityType EntityType { get; } = EntityTypes.Default;
+ public IDictionary<string, object> Constraints { get; } = new Dictionary<string, object>();
+
+ public string GenerateConstraintString()
+ {
+ return string.Join(' ', Constraints.Select(c => $"[{c.Key} = {c.Value}]"));
+ }
+ }
+}
|