Skip to content

Commit cb1bc96

Browse files
author
Jason Becker
committed
Merge remote-tracking branch 'origin/dev' into future
2 parents 3154cc6 + b300a3a commit cb1bc96

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/Moryx/Serialization/DefaultSerialization.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public virtual object ConvertValue(Type memberType, ICustomAttributeProvider att
221221
return CollectionBuilder(memberType, currentValue, mappedEntry);
222222
default:
223223
var value = mappedEntry.Value.Current;
224-
if (value is null)
224+
if (value is null)
225225
return null;
226226

227227
try
@@ -251,6 +251,9 @@ public EntryUnitType GetUnitTypeByAttributes(ICustomAttributeProvider property)
251251
{
252252
var unitType = EntryUnitType.None;
253253

254+
if (HasFlagsAttribute(property))
255+
unitType = EntryUnitType.Flags;
256+
254257
var passwordAttr = property.GetCustomAttribute<PasswordAttribute>();
255258
if (passwordAttr != null)
256259
unitType = EntryUnitType.Password;
@@ -318,5 +321,17 @@ protected static object CollectionBuilder(Type collectionType, object currentVal
318321
// Other collections are not supported
319322
return null;
320323
}
324+
325+
/// <summary>
326+
/// Checks if the given property is an enum and has the <see cref="System.FlagsAttribute"/>.
327+
/// </summary>
328+
/// <param name="property">The property to inspect for attributes.</param>
329+
/// <returns>True if the property has the Flags attribute; otherwise, false.</returns>
330+
private bool HasFlagsAttribute(ICustomAttributeProvider property)
331+
{
332+
return property is PropertyInfo propertyInfo &&
333+
propertyInfo.PropertyType.IsEnum &&
334+
propertyInfo.PropertyType.GetCustomAttributes(typeof(System.FlagsAttribute), false).Any();
335+
}
321336
}
322337
}

src/Moryx/Serialization/EntryConvert/EntryUnitType.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public enum EntryUnitType
2323
/// <summary>
2424
/// Unit directory
2525
/// </summary>
26-
Directory
26+
Directory,
27+
/// <summary>
28+
/// Unit with <see cref="System.FlagsAttribute"/>
29+
/// </summary>
30+
Flags,
2731
}
2832
}

0 commit comments

Comments
 (0)