Skip to content

Commit 7e9cd56

Browse files
committed
fix: GetExchangeApi generic resolves T
1 parent df39e23 commit 7e9cd56

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ExchangeSharp/API/Exchanges/_Base/ExchangeAPI.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,19 +605,20 @@ public static Task<IExchangeAPI> GetExchangeAPIAsync(string exchangeName)
605605
/// <typeparam name="T">Type of exchange to get</typeparam>
606606
/// <returns>Exchange API or null if not found</returns>
607607
[Obsolete("Use the async version")]
608-
public static IExchangeAPI GetExchangeAPI<T>()
608+
public static T GetExchangeAPI<T>()
609609
where T : ExchangeAPI
610610
{
611611
return GetExchangeAPIAsync<T>().Result;
612612
}
613613

614-
public static Task<IExchangeAPI> GetExchangeAPIAsync<T>()
614+
public static async Task<T> GetExchangeAPIAsync<T>()
615615
where T : ExchangeAPI
616616
{
617617
// note: this method will be slightly slow (milliseconds) the first time it is called due to cache miss and initialization
618618
// subsequent calls with cache hits will be nanoseconds
619619
Type type = typeof(T)!;
620-
return GetExchangeAPIAsync(type);
620+
621+
return (T)await GetExchangeAPIAsync(type);
621622
}
622623

623624
/// <summary>

0 commit comments

Comments
 (0)