forked from sergeyt/Owin.Routing
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed async methods invocation for internal api classes
- Loading branch information
Ilya Izhovkin
committed
May 21, 2015
1 parent
ac5ad3e
commit 94c5c06
Showing
1 changed file
with
10 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,7 @@ public static IAppBuilder UseApi<T>(this IAppBuilder app, Func<IOwinContext, T> | |
{ | ||
if (hasResult) | ||
{ | ||
result = await (dynamic) result; | ||
result = await ToTaskOfObject((Task) result); | ||
} | ||
else | ||
{ | ||
|
@@ -94,6 +94,15 @@ public static IAppBuilder UseApi<T>(this IAppBuilder app, Func<IOwinContext, T> | |
return app; | ||
} | ||
|
||
private static Task<object> ToTaskOfObject(Task task) | ||
{ | ||
return task.ContinueWith(t => | ||
{ | ||
var resultProp = task.GetType().GetProperty("Result", BindingFlags.Public | BindingFlags.Instance); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
izhovkin
Owner
|
||
return resultProp.GetValue(t); | ||
}); | ||
} | ||
|
||
private static object[] MapParameters(IOwinContext ctx, Func<IOwinContext, object[]> mapper, out string error) | ||
{ | ||
error = null; | ||
|
using of "dynamic" could reduce code and maybe improve performance a bit for successive calls