diff --git a/DynamicEnums/DynamicEnum.cs b/DynamicEnums/DynamicEnum.cs
index c722474..2d6cc04 100644
--- a/DynamicEnums/DynamicEnum.cs
+++ b/DynamicEnums/DynamicEnum.cs
@@ -42,7 +42,8 @@ namespace DynamicEnums {
///
/// The name of the enum value
/// The value
- protected DynamicEnum(string name, BigInteger value) {
+ /// Whether this enum value , and thus, not a combined flag.
+ protected DynamicEnum(string name, BigInteger value, bool defined) {
this.value = value;
this.name = name;
}
@@ -121,7 +122,7 @@ namespace DynamicEnums {
throw new ArgumentException($"Duplicate name {name}", nameof(name));
}
- var ret = DynamicEnum.Construct(typeof(T), name, value);
+ var ret = DynamicEnum.Construct(typeof(T), name, value, true);
storage.Values.Add(value, ret);
return (T) ret;
}
@@ -345,7 +346,7 @@ namespace DynamicEnums {
// otherwise, cache the combined value
if (!storage.FlagCache.TryGetValue(value, out var combined)) {
- combined = DynamicEnum.Construct(type, null, value);
+ combined = DynamicEnum.Construct(type, null, value, false);
storage.FlagCache.Add(value, combined);
}
return combined;
@@ -431,8 +432,8 @@ namespace DynamicEnums {
#if NET6_0_OR_GREATER
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)]
#endif
- Type type, string name, BigInteger value) {
- return (DynamicEnum) Activator.CreateInstance(type, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new object[] {name, value}, CultureInfo.InvariantCulture);
+ Type type, string name, BigInteger value, bool defined) {
+ return (DynamicEnum) Activator.CreateInstance(type, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new object[] {name, value, defined}, CultureInfo.InvariantCulture);
}
private class Storage {
@@ -457,4 +458,4 @@ namespace DynamicEnums {
}
}
-}
+}
\ No newline at end of file
diff --git a/Tests/EnumTests.cs b/Tests/EnumTests.cs
index 8d5ab6f..a789ec8 100644
--- a/Tests/EnumTests.cs
+++ b/Tests/EnumTests.cs
@@ -86,7 +86,7 @@ public class EnumTests {
private class TestDynamicEnum : DynamicEnum {
- public TestDynamicEnum(string name, BigInteger value) : base(name, value) {}
+ public TestDynamicEnum(string name, BigInteger value, bool defined) : base(name, value, defined) {}
}