An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Reflection
PharmaSoft
1
Reputation point
Hello, I try to inject this service in serviceprovider with two parameters. At the end, it will be generic but for this exemple, I put the parameters. Could you help me ?
List<ConstructorInfo> ctors;
Type[] genericArguments = interfaceType.GetGenericArguments();
int expectedArgumentsCount = genericArguments.Length;
if (expectedArgumentsCount > 2)
{
ctors = pipeline.Select(
x => {
if (x.IsGenericType)
{
Type[] genericArguments;
if (x == typeof(RemoveEntityGenericHandler<,>))
{
Type entityType = typeof(Assurance); // ou déterminez dynamiquement
Type queryType = typeof(AssuranceRepository);
genericArguments = new Type[] { entityType, queryType };
}
else
{
genericArguments = interfaceType.GetGenericArguments();
}
Type specificType = x.MakeGenericType(genericArguments);
return specificType.GetConstructors().Single();
}
else
{
return x.GetConstructors().Single();
}
})
.ToList();
}
Developer technologies | C#
Developer technologies | C#
Sign in to answer