-
-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support read-only collection interfaces #236
Comments
@aaubry - I was interested in this feature and was thinking about coming up with a PR. Would you be able to offer any hints as to what changes might be required? I thought it might just be a case of adding these extra interfaces to Edit: ah, it seems like |
In the meantime, hooking the below in via public sealed class ReadOnlyCollectionNodeTypeResolver : INodeTypeResolver
{
public bool Resolve(NodeEvent nodeEvent, ref Type type)
{
if (type.IsInterface && type.IsGenericType && CustomGenericInterfaceImplementations.TryGetValue(type.GetGenericTypeDefinition(), out var concreteType))
{
type = concreteType.MakeGenericType(type.GetGenericArguments());
return true;
}
return false;
}
private static readonly IReadOnlyDictionary<Type, Type> CustomGenericInterfaceImplementations = new Dictionary<Type, Type>
{
{typeof(IReadOnlyCollection<>), typeof(List<>)},
{typeof(IReadOnlyList<>), typeof(List<>)},
{typeof(IReadOnlyDictionary<,>), typeof(Dictionary<,>)}
};
} |
@mparry But what is the simplest way to serialize |
It would be great if the library could deserialize into properties of the following interfaces:
IReadOnlyCollection<T>
IReadOnlyList<T>
IReadOnlyDictionary<TKey, TValue>
The text was updated successfully, but these errors were encountered: