josephwoodward / GlobalExceptionHandlerDotNet

Exception handling as a convention in the ASP.NET Core request pipeline
MIT License
272 stars 32 forks source link

Is it possible to add a non-generic method of Map<T>() ? #40

Open eukaryoteoops opened 4 years ago

eukaryoteoops commented 4 years ago

I would like to scan the Implement classes of the interface IException that I defined to custom StatusCode in GlobalExceptionHandler, but with generic version of Map<T>(), I had to use reflection to achieve that, it's a bit of annoying... is it possible to add a non-generic version of Map<T>(), such as Map(Type t)? or add a property of StatusCode to ExceptionHandlerConfiguration?

var exceptionList = Assembly.GetExecutingAssembly().GetTypes().Where(t => t != typeof(IException) && typeof(IException).IsAssignableFrom(t)).ToList();

 foreach (var item in exceptionList)
{
/// can not use o.Map<T>() here directly.
}