Skip to content

Commit

Permalink
fix exception when using Microsoft.Owin.AppBuilderUseExtensions.Use
Browse files Browse the repository at this point in the history
because of constructor type mismatch
  • Loading branch information
Yusuke Ito committed Jan 7, 2015
1 parent 9adec3e commit 77d1061
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Fos/Middleware/OwinMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ void BuildHandler()
ConstructorInfo ctor;
try
{
ctor = MiddlewareType.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(c => c.GetParameters().Length >= 1 && c.GetParameters().Length - 1 <= Args.Length).OrderByDescending(c => c.GetParameters().Length).First();
// filtered by matching all with Args type(except null Args)
ctor = MiddlewareType.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(c => c.GetParameters().Length >= 1 && c.GetParameters().Length - 1 <= Args.Length).OrderByDescending(c => c.GetParameters().Length)
.Where((ct)=>{
return ct.GetParameters().Zip(Args,(pinfo,arg)=>(arg==null)||(pinfo.ParameterType == arg.GetType()))
.All(b=>b);
}).First();
}
catch
{
Expand Down

0 comments on commit 77d1061

Please sign in to comment.