Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.2.0
8.3.0
17 changes: 16 additions & 1 deletion src/Moryx/Serialization/DefaultSerialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public virtual object ConvertValue(Type memberType, ICustomAttributeProvider att
return CollectionBuilder(memberType, currentValue, mappedEntry);
default:
var value = mappedEntry.Value.Current;
if (value is null)
if (value is null)
return null;

try
Expand Down Expand Up @@ -251,6 +251,9 @@ public EntryUnitType GetUnitTypeByAttributes(ICustomAttributeProvider property)
{
var unitType = EntryUnitType.None;

if (HasFlagsAttribute(property))
unitType = EntryUnitType.Flags;

var passwordAttr = property.GetCustomAttribute<PasswordAttribute>();
if (passwordAttr != null)
unitType = EntryUnitType.Password;
Expand Down Expand Up @@ -318,5 +321,17 @@ protected static object CollectionBuilder(Type collectionType, object currentVal
// Other collections are not supported
return null;
}

/// <summary>
/// Checks if the given property is an enum and has the <see cref="System.FlagsAttribute"/>.
/// </summary>
/// <param name="property">The property to inspect for attributes.</param>
/// <returns>True if the property has the Flags attribute; otherwise, false.</returns>
private bool HasFlagsAttribute(ICustomAttributeProvider property)
{
return property is PropertyInfo propertyInfo &&
propertyInfo.PropertyType.IsEnum &&
propertyInfo.PropertyType.GetCustomAttributes(typeof(System.FlagsAttribute), false).Any();
}
}
}
6 changes: 5 additions & 1 deletion src/Moryx/Serialization/EntryConvert/EntryUnitType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public enum EntryUnitType
/// <summary>
/// Unit directory
/// </summary>
Directory
Directory,
/// <summary>
/// Unit with <see cref="System.FlagsAttribute"/>
/// </summary>
Flags,
}
}
Loading