Skip to content

Register the same mappings more then one time #73

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

Open
HrBozhidarov opened this issue Feb 28, 2022 · 0 comments
Open

Register the same mappings more then one time #73

HrBozhidarov opened this issue Feb 28, 2022 · 0 comments

Comments

@HrBozhidarov
Copy link

We register custom mappings more then one time in GetCustomMappings.
When we use from i in t.GetTypeInfo().GetInterfaces() we get all interfaces IMapFrom, IMapTo and IHaveCustomMappings => we will register 3 times our mappings if they exist in our model.

var customMaps = from t in types
                             from i in t.GetTypeInfo().GetInterfaces()
                             where typeof(IHaveCustomMappings).GetTypeInfo().IsAssignableFrom(t) &&
                                   !t.GetTypeInfo().IsAbstract &&
                                   !t.GetTypeInfo().IsInterface
                             select (IHaveCustomMappings)Activator.CreateInstance(t);

Fix

var customMaps = from t in types
                             where typeof(IHaveCustomMappings).GetTypeInfo().IsAssignableFrom(t) &&
                                   !t.GetTypeInfo().IsAbstract &&
                                   !t.GetTypeInfo().IsInterface
                             select (IHaveCustomMappings)Activator.CreateInstance(t);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant