Skip to content

Dataverse Container Adds implementations to Dictionary that already exist #1

@TomWinton

Description

@TomWinton

Line 53 of https://github.com/AetherFlowDev/PluginFramework/blob/v1/develop/AetherFlow.Framework/DataverseContainer.cs

Adds the implementation even if it is already inside the dictionary throwing an error:

 if (type.IsGenericTypeDefinition)
                {
                    var implementations = GetGenericImplementationsOf(assembly, type);
                    if (implementations != null && implementations.Length > 0)
                    {
                        // We have some generic implementations, however, we may need to remove
                        // some duplicates where implementations have been added by default
                        if (_implementations.TryGetValue(type, out var current))
                        {
                            // We have some already added... lets remove duplicates!
                            var newItems = implementations
                                .ToList()
                                .Where(a => !current.Contains(a))
                                .ToArray();

                            // Add to implementations
                            _implementations[type].AddRange(newItems);
                        }
                        _implementations.Add(type, implementations.ToList());
                    }

_implementations.Add should be wrapped in an else

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions