Exemple #1
0
        internal static object?GetImplementation(Type baseType, params object[] args)
        {
            if (!LatestImplementations.ContainsKey(baseType.FullName()))
            {
                return(null);
            }

            var latestImplementationType = LatestImplementations[baseType.FullName()];

            return(Activator.CreateInstance(latestImplementationType, args));
        }
Exemple #2
0
        internal static object?GetImplementation(Type baseType, Type wrapperType, params object[] args)
        {
            if (!LatestImplementations.ContainsKey(baseType.FullName()))
            {
                return(null);
            }

            var latestImplementationType = LatestImplementations[baseType.FullName()];
            var obj = Activator.CreateInstance(latestImplementationType, args);

            return(baseType.IsAssignableFrom(latestImplementationType)
                ? obj
                : Activator.CreateInstance(wrapperType, obj) is IWrapper wrapperObject && wrapperObject.IsCorrect
                    ? wrapperObject
                    : null);
        }