AsyncQueryableEx.Generated.cs 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Collections.Generic;
  5. using System.Linq.Expressions;
  6. using System.Reflection;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. namespace System.Linq
  10. {
  11. public static partial class AsyncQueryableEx
  12. {
  13. public static IAsyncQueryable<IList<TSource>> Buffer<TSource>(this IAsyncQueryable<TSource> source, int count)
  14. {
  15. if (source == null)
  16. throw new ArgumentNullException(nameof(source));
  17. #if CRIPPLED_REFLECTION
  18. return source.Provider.CreateQuery<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.Buffer<TSource>(default(IAsyncQueryable<TSource>), default(int))), source.Expression, Expression.Constant(count, typeof(int))));
  19. #else
  20. return source.Provider.CreateQuery<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int))));
  21. #endif
  22. }
  23. public static IAsyncQueryable<IList<TSource>> Buffer<TSource>(this IAsyncQueryable<TSource> source, int count, int skip)
  24. {
  25. if (source == null)
  26. throw new ArgumentNullException(nameof(source));
  27. #if CRIPPLED_REFLECTION
  28. return source.Provider.CreateQuery<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.Buffer<TSource>(default(IAsyncQueryable<TSource>), default(int), default(int))), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int))));
  29. #else
  30. return source.Provider.CreateQuery<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int)), Expression.Constant(skip, typeof(int))));
  31. #endif
  32. }
  33. public static IAsyncQueryable<TSource> Catch<TSource, TException>(this IAsyncQueryable<TSource> source, Expression<Func<TException, IAsyncEnumerable<TSource>>> handler)
  34. {
  35. if (source == null)
  36. throw new ArgumentNullException(nameof(source));
  37. if (handler == null)
  38. throw new ArgumentNullException(nameof(handler));
  39. #if CRIPPLED_REFLECTION
  40. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch<TSource, TException>(default(IAsyncQueryable<TSource>), default(Expression<Func<TException, IAsyncEnumerable<TSource>>>))), source.Expression, handler));
  41. #else
  42. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler));
  43. #endif
  44. }
  45. public static IAsyncQueryable<TSource> Catch<TSource, TException>(this IAsyncQueryable<TSource> source, Expression<Func<TException, Task<IAsyncEnumerable<TSource>>>> handler)
  46. {
  47. if (source == null)
  48. throw new ArgumentNullException(nameof(source));
  49. if (handler == null)
  50. throw new ArgumentNullException(nameof(handler));
  51. #if CRIPPLED_REFLECTION
  52. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch<TSource, TException>(default(IAsyncQueryable<TSource>), default(Expression<Func<TException, Task<IAsyncEnumerable<TSource>>>>))), source.Expression, handler));
  53. #else
  54. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)), source.Expression, handler));
  55. #endif
  56. }
  57. public static IAsyncQueryable<TSource> Catch<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second)
  58. {
  59. if (first == null)
  60. throw new ArgumentNullException(nameof(first));
  61. if (second == null)
  62. throw new ArgumentNullException(nameof(second));
  63. #if CRIPPLED_REFLECTION
  64. return first.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Catch<TSource>(default(IAsyncQueryable<TSource>), default(IAsyncEnumerable<TSource>))), first.Expression, GetSourceExpression(second)));
  65. #else
  66. return first.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)));
  67. #endif
  68. }
  69. public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  70. {
  71. if (source == null)
  72. throw new ArgumentNullException(nameof(source));
  73. if (keySelector == null)
  74. throw new ArgumentNullException(nameof(keySelector));
  75. #if CRIPPLED_REFLECTION
  76. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>))), source.Expression, keySelector));
  77. #else
  78. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector));
  79. #endif
  80. }
  81. public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector)
  82. {
  83. if (source == null)
  84. throw new ArgumentNullException(nameof(source));
  85. if (keySelector == null)
  86. throw new ArgumentNullException(nameof(keySelector));
  87. #if CRIPPLED_REFLECTION
  88. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>))), source.Expression, keySelector));
  89. #else
  90. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector));
  91. #endif
  92. }
  93. public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  94. {
  95. if (source == null)
  96. throw new ArgumentNullException(nameof(source));
  97. if (keySelector == null)
  98. throw new ArgumentNullException(nameof(keySelector));
  99. if (comparer == null)
  100. throw new ArgumentNullException(nameof(comparer));
  101. #if CRIPPLED_REFLECTION
  102. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  103. #else
  104. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  105. #endif
  106. }
  107. public static IAsyncQueryable<TSource> Distinct<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector, IEqualityComparer<TKey> comparer)
  108. {
  109. if (source == null)
  110. throw new ArgumentNullException(nameof(source));
  111. if (keySelector == null)
  112. throw new ArgumentNullException(nameof(keySelector));
  113. if (comparer == null)
  114. throw new ArgumentNullException(nameof(comparer));
  115. #if CRIPPLED_REFLECTION
  116. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Distinct<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>), default(IEqualityComparer<TKey>))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  117. #else
  118. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  119. #endif
  120. }
  121. public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource>(this IAsyncQueryable<TSource> source)
  122. {
  123. if (source == null)
  124. throw new ArgumentNullException(nameof(source));
  125. #if CRIPPLED_REFLECTION
  126. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged<TSource>(default(IAsyncQueryable<TSource>))), source.Expression));
  127. #else
  128. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression));
  129. #endif
  130. }
  131. public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource>(this IAsyncQueryable<TSource> source, IEqualityComparer<TSource> comparer)
  132. {
  133. if (source == null)
  134. throw new ArgumentNullException(nameof(source));
  135. if (comparer == null)
  136. throw new ArgumentNullException(nameof(comparer));
  137. #if CRIPPLED_REFLECTION
  138. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged<TSource>(default(IAsyncQueryable<TSource>), default(IEqualityComparer<TSource>))), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))));
  139. #else
  140. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))));
  141. #endif
  142. }
  143. public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  144. {
  145. if (source == null)
  146. throw new ArgumentNullException(nameof(source));
  147. if (keySelector == null)
  148. throw new ArgumentNullException(nameof(keySelector));
  149. #if CRIPPLED_REFLECTION
  150. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>))), source.Expression, keySelector));
  151. #else
  152. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector));
  153. #endif
  154. }
  155. public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector)
  156. {
  157. if (source == null)
  158. throw new ArgumentNullException(nameof(source));
  159. if (keySelector == null)
  160. throw new ArgumentNullException(nameof(keySelector));
  161. #if CRIPPLED_REFLECTION
  162. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>))), source.Expression, keySelector));
  163. #else
  164. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector));
  165. #endif
  166. }
  167. public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  168. {
  169. if (source == null)
  170. throw new ArgumentNullException(nameof(source));
  171. if (keySelector == null)
  172. throw new ArgumentNullException(nameof(keySelector));
  173. if (comparer == null)
  174. throw new ArgumentNullException(nameof(comparer));
  175. #if CRIPPLED_REFLECTION
  176. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  177. #else
  178. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  179. #endif
  180. }
  181. public static IAsyncQueryable<TSource> DistinctUntilChanged<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector, IEqualityComparer<TKey> comparer)
  182. {
  183. if (source == null)
  184. throw new ArgumentNullException(nameof(source));
  185. if (keySelector == null)
  186. throw new ArgumentNullException(nameof(keySelector));
  187. if (comparer == null)
  188. throw new ArgumentNullException(nameof(comparer));
  189. #if CRIPPLED_REFLECTION
  190. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.DistinctUntilChanged<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>), default(IEqualityComparer<TKey>))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  191. #else
  192. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))));
  193. #endif
  194. }
  195. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Action<TSource>> onNext)
  196. {
  197. if (source == null)
  198. throw new ArgumentNullException(nameof(source));
  199. if (onNext == null)
  200. throw new ArgumentNullException(nameof(onNext));
  201. #if CRIPPLED_REFLECTION
  202. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Do<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Action<TSource>>))), source.Expression, onNext));
  203. #else
  204. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext));
  205. #endif
  206. }
  207. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task>> onNext)
  208. {
  209. if (source == null)
  210. throw new ArgumentNullException(nameof(source));
  211. if (onNext == null)
  212. throw new ArgumentNullException(nameof(onNext));
  213. #if CRIPPLED_REFLECTION
  214. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Do<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task>>))), source.Expression, onNext));
  215. #else
  216. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext));
  217. #endif
  218. }
  219. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, IObserver<TSource> observer)
  220. {
  221. if (source == null)
  222. throw new ArgumentNullException(nameof(source));
  223. if (observer == null)
  224. throw new ArgumentNullException(nameof(observer));
  225. #if CRIPPLED_REFLECTION
  226. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Do<TSource>(default(IAsyncQueryable<TSource>), default(IObserver<TSource>))), source.Expression, Expression.Constant(observer, typeof(IObserver<TSource>))));
  227. #else
  228. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(observer, typeof(IObserver<TSource>))));
  229. #endif
  230. }
  231. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Action<TSource>> onNext, Action onCompleted)
  232. {
  233. if (source == null)
  234. throw new ArgumentNullException(nameof(source));
  235. if (onNext == null)
  236. throw new ArgumentNullException(nameof(onNext));
  237. if (onCompleted == null)
  238. throw new ArgumentNullException(nameof(onCompleted));
  239. #if CRIPPLED_REFLECTION
  240. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Do<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Action<TSource>>), default(Action))), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action))));
  241. #else
  242. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, Expression.Constant(onCompleted, typeof(Action))));
  243. #endif
  244. }
  245. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError)
  246. {
  247. if (source == null)
  248. throw new ArgumentNullException(nameof(source));
  249. if (onNext == null)
  250. throw new ArgumentNullException(nameof(onNext));
  251. if (onError == null)
  252. throw new ArgumentNullException(nameof(onError));
  253. #if CRIPPLED_REFLECTION
  254. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Do<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>))), source.Expression, onNext, onError));
  255. #else
  256. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError));
  257. #endif
  258. }
  259. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task>> onNext, Expression<Func<Task>> onCompleted)
  260. {
  261. if (source == null)
  262. throw new ArgumentNullException(nameof(source));
  263. if (onNext == null)
  264. throw new ArgumentNullException(nameof(onNext));
  265. if (onCompleted == null)
  266. throw new ArgumentNullException(nameof(onCompleted));
  267. #if CRIPPLED_REFLECTION
  268. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Do<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task>>), default(Expression<Func<Task>>))), source.Expression, onNext, onCompleted));
  269. #else
  270. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onCompleted));
  271. #endif
  272. }
  273. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task>> onNext, Expression<Func<Exception, Task>> onError)
  274. {
  275. if (source == null)
  276. throw new ArgumentNullException(nameof(source));
  277. if (onNext == null)
  278. throw new ArgumentNullException(nameof(onNext));
  279. if (onError == null)
  280. throw new ArgumentNullException(nameof(onError));
  281. #if CRIPPLED_REFLECTION
  282. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Do<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task>>), default(Expression<Func<Exception, Task>>))), source.Expression, onNext, onError));
  283. #else
  284. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError));
  285. #endif
  286. }
  287. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError, Action onCompleted)
  288. {
  289. if (source == null)
  290. throw new ArgumentNullException(nameof(source));
  291. if (onNext == null)
  292. throw new ArgumentNullException(nameof(onNext));
  293. if (onError == null)
  294. throw new ArgumentNullException(nameof(onError));
  295. if (onCompleted == null)
  296. throw new ArgumentNullException(nameof(onCompleted));
  297. #if CRIPPLED_REFLECTION
  298. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Do<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>), default(Action))), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action))));
  299. #else
  300. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, Expression.Constant(onCompleted, typeof(Action))));
  301. #endif
  302. }
  303. public static IAsyncQueryable<TSource> Do<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task>> onNext, Expression<Func<Exception, Task>> onError, Expression<Func<Task>> onCompleted)
  304. {
  305. if (source == null)
  306. throw new ArgumentNullException(nameof(source));
  307. if (onNext == null)
  308. throw new ArgumentNullException(nameof(onNext));
  309. if (onError == null)
  310. throw new ArgumentNullException(nameof(onError));
  311. if (onCompleted == null)
  312. throw new ArgumentNullException(nameof(onCompleted));
  313. #if CRIPPLED_REFLECTION
  314. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Do<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task>>), default(Expression<Func<Exception, Task>>), default(Expression<Func<Task>>))), source.Expression, onNext, onError, onCompleted));
  315. #else
  316. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, onNext, onError, onCompleted));
  317. #endif
  318. }
  319. public static IAsyncQueryable<TSource> Expand<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, IAsyncEnumerable<TSource>>> selector)
  320. {
  321. if (source == null)
  322. throw new ArgumentNullException(nameof(source));
  323. if (selector == null)
  324. throw new ArgumentNullException(nameof(selector));
  325. #if CRIPPLED_REFLECTION
  326. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Expand<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, IAsyncEnumerable<TSource>>>))), source.Expression, selector));
  327. #else
  328. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector));
  329. #endif
  330. }
  331. public static IAsyncQueryable<TSource> Expand<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<IAsyncEnumerable<TSource>>>> selector)
  332. {
  333. if (source == null)
  334. throw new ArgumentNullException(nameof(source));
  335. if (selector == null)
  336. throw new ArgumentNullException(nameof(selector));
  337. #if CRIPPLED_REFLECTION
  338. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Expand<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<IAsyncEnumerable<TSource>>>>))), source.Expression, selector));
  339. #else
  340. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, selector));
  341. #endif
  342. }
  343. public static IAsyncQueryable<TSource> Finally<TSource>(this IAsyncQueryable<TSource> source, Action finallyAction)
  344. {
  345. if (source == null)
  346. throw new ArgumentNullException(nameof(source));
  347. if (finallyAction == null)
  348. throw new ArgumentNullException(nameof(finallyAction));
  349. #if CRIPPLED_REFLECTION
  350. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Finally<TSource>(default(IAsyncQueryable<TSource>), default(Action))), source.Expression, Expression.Constant(finallyAction, typeof(Action))));
  351. #else
  352. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(finallyAction, typeof(Action))));
  353. #endif
  354. }
  355. public static IAsyncQueryable<TSource> Finally<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<Task>> finallyAction)
  356. {
  357. if (source == null)
  358. throw new ArgumentNullException(nameof(source));
  359. if (finallyAction == null)
  360. throw new ArgumentNullException(nameof(finallyAction));
  361. #if CRIPPLED_REFLECTION
  362. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Finally<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Func<Task>>))), source.Expression, finallyAction));
  363. #else
  364. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, finallyAction));
  365. #endif
  366. }
  367. public static IAsyncQueryable<TSource> IgnoreElements<TSource>(this IAsyncQueryable<TSource> source)
  368. {
  369. if (source == null)
  370. throw new ArgumentNullException(nameof(source));
  371. #if CRIPPLED_REFLECTION
  372. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.IgnoreElements<TSource>(default(IAsyncQueryable<TSource>))), source.Expression));
  373. #else
  374. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression));
  375. #endif
  376. }
  377. public static Task<bool> IsEmpty<TSource>(this IAsyncQueryable<TSource> source)
  378. {
  379. if (source == null)
  380. throw new ArgumentNullException(nameof(source));
  381. #if CRIPPLED_REFLECTION
  382. return source.Provider.ExecuteAsync<bool>(Expression.Call(InfoOf(() => AsyncQueryableEx.IsEmpty<TSource>(default(IAsyncQueryable<TSource>))), source.Expression), CancellationToken.None);
  383. #else
  384. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression), CancellationToken.None);
  385. #endif
  386. }
  387. public static Task<bool> IsEmpty<TSource>(this IAsyncQueryable<TSource> source, CancellationToken cancellationToken)
  388. {
  389. if (source == null)
  390. throw new ArgumentNullException(nameof(source));
  391. #if CRIPPLED_REFLECTION
  392. return source.Provider.ExecuteAsync<bool>(Expression.Call(InfoOf(() => AsyncQueryableEx.IsEmpty<TSource>(default(IAsyncQueryable<TSource>), default(CancellationToken))), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  393. #else
  394. return source.Provider.ExecuteAsync<bool>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  395. #endif
  396. }
  397. public static Task<TSource> Max<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource> comparer)
  398. {
  399. if (source == null)
  400. throw new ArgumentNullException(nameof(source));
  401. if (comparer == null)
  402. throw new ArgumentNullException(nameof(comparer));
  403. #if CRIPPLED_REFLECTION
  404. return source.Provider.ExecuteAsync<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Max<TSource>(default(IAsyncQueryable<TSource>), default(IComparer<TSource>))), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>))), CancellationToken.None);
  405. #else
  406. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>))), CancellationToken.None);
  407. #endif
  408. }
  409. public static Task<TSource> Max<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
  410. {
  411. if (source == null)
  412. throw new ArgumentNullException(nameof(source));
  413. if (comparer == null)
  414. throw new ArgumentNullException(nameof(comparer));
  415. #if CRIPPLED_REFLECTION
  416. return source.Provider.ExecuteAsync<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Max<TSource>(default(IAsyncQueryable<TSource>), default(IComparer<TSource>), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  417. #else
  418. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  419. #endif
  420. }
  421. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  422. {
  423. if (source == null)
  424. throw new ArgumentNullException(nameof(source));
  425. if (keySelector == null)
  426. throw new ArgumentNullException(nameof(keySelector));
  427. #if CRIPPLED_REFLECTION
  428. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>))), source.Expression, keySelector), CancellationToken.None);
  429. #else
  430. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None);
  431. #endif
  432. }
  433. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector)
  434. {
  435. if (source == null)
  436. throw new ArgumentNullException(nameof(source));
  437. if (keySelector == null)
  438. throw new ArgumentNullException(nameof(keySelector));
  439. #if CRIPPLED_REFLECTION
  440. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>))), source.Expression, keySelector), CancellationToken.None);
  441. #else
  442. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None);
  443. #endif
  444. }
  445. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector, CancellationToken cancellationToken)
  446. {
  447. if (source == null)
  448. throw new ArgumentNullException(nameof(source));
  449. if (keySelector == null)
  450. throw new ArgumentNullException(nameof(keySelector));
  451. #if CRIPPLED_REFLECTION
  452. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  453. #else
  454. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  455. #endif
  456. }
  457. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector, IComparer<TKey> comparer)
  458. {
  459. if (source == null)
  460. throw new ArgumentNullException(nameof(source));
  461. if (keySelector == null)
  462. throw new ArgumentNullException(nameof(keySelector));
  463. if (comparer == null)
  464. throw new ArgumentNullException(nameof(comparer));
  465. #if CRIPPLED_REFLECTION
  466. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>), default(IComparer<TKey>))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))), CancellationToken.None);
  467. #else
  468. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))), CancellationToken.None);
  469. #endif
  470. }
  471. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, CancellationToken cancellationToken)
  472. {
  473. if (source == null)
  474. throw new ArgumentNullException(nameof(source));
  475. if (keySelector == null)
  476. throw new ArgumentNullException(nameof(keySelector));
  477. #if CRIPPLED_REFLECTION
  478. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  479. #else
  480. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  481. #endif
  482. }
  483. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  484. {
  485. if (source == null)
  486. throw new ArgumentNullException(nameof(source));
  487. if (keySelector == null)
  488. throw new ArgumentNullException(nameof(keySelector));
  489. if (comparer == null)
  490. throw new ArgumentNullException(nameof(comparer));
  491. #if CRIPPLED_REFLECTION
  492. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))), CancellationToken.None);
  493. #else
  494. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))), CancellationToken.None);
  495. #endif
  496. }
  497. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
  498. {
  499. if (source == null)
  500. throw new ArgumentNullException(nameof(source));
  501. if (keySelector == null)
  502. throw new ArgumentNullException(nameof(keySelector));
  503. if (comparer == null)
  504. throw new ArgumentNullException(nameof(comparer));
  505. #if CRIPPLED_REFLECTION
  506. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>), default(IComparer<TKey>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  507. #else
  508. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  509. #endif
  510. }
  511. public static Task<IList<TSource>> MaxBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
  512. {
  513. if (source == null)
  514. throw new ArgumentNullException(nameof(source));
  515. if (keySelector == null)
  516. throw new ArgumentNullException(nameof(keySelector));
  517. if (comparer == null)
  518. throw new ArgumentNullException(nameof(comparer));
  519. #if CRIPPLED_REFLECTION
  520. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MaxBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  521. #else
  522. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  523. #endif
  524. }
  525. public static Task<TSource> Min<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource> comparer)
  526. {
  527. if (source == null)
  528. throw new ArgumentNullException(nameof(source));
  529. if (comparer == null)
  530. throw new ArgumentNullException(nameof(comparer));
  531. #if CRIPPLED_REFLECTION
  532. return source.Provider.ExecuteAsync<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Min<TSource>(default(IAsyncQueryable<TSource>), default(IComparer<TSource>))), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>))), CancellationToken.None);
  533. #else
  534. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>))), CancellationToken.None);
  535. #endif
  536. }
  537. public static Task<TSource> Min<TSource>(this IAsyncQueryable<TSource> source, IComparer<TSource> comparer, CancellationToken cancellationToken)
  538. {
  539. if (source == null)
  540. throw new ArgumentNullException(nameof(source));
  541. if (comparer == null)
  542. throw new ArgumentNullException(nameof(comparer));
  543. #if CRIPPLED_REFLECTION
  544. return source.Provider.ExecuteAsync<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Min<TSource>(default(IAsyncQueryable<TSource>), default(IComparer<TSource>), default(CancellationToken))), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  545. #else
  546. return source.Provider.ExecuteAsync<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(comparer, typeof(IComparer<TSource>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  547. #endif
  548. }
  549. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  550. {
  551. if (source == null)
  552. throw new ArgumentNullException(nameof(source));
  553. if (keySelector == null)
  554. throw new ArgumentNullException(nameof(keySelector));
  555. #if CRIPPLED_REFLECTION
  556. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>))), source.Expression, keySelector), CancellationToken.None);
  557. #else
  558. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None);
  559. #endif
  560. }
  561. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector)
  562. {
  563. if (source == null)
  564. throw new ArgumentNullException(nameof(source));
  565. if (keySelector == null)
  566. throw new ArgumentNullException(nameof(keySelector));
  567. #if CRIPPLED_REFLECTION
  568. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>))), source.Expression, keySelector), CancellationToken.None);
  569. #else
  570. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector), CancellationToken.None);
  571. #endif
  572. }
  573. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, CancellationToken cancellationToken)
  574. {
  575. if (source == null)
  576. throw new ArgumentNullException(nameof(source));
  577. if (keySelector == null)
  578. throw new ArgumentNullException(nameof(keySelector));
  579. #if CRIPPLED_REFLECTION
  580. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  581. #else
  582. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  583. #endif
  584. }
  585. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  586. {
  587. if (source == null)
  588. throw new ArgumentNullException(nameof(source));
  589. if (keySelector == null)
  590. throw new ArgumentNullException(nameof(keySelector));
  591. if (comparer == null)
  592. throw new ArgumentNullException(nameof(comparer));
  593. #if CRIPPLED_REFLECTION
  594. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))), CancellationToken.None);
  595. #else
  596. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))), CancellationToken.None);
  597. #endif
  598. }
  599. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector, CancellationToken cancellationToken)
  600. {
  601. if (source == null)
  602. throw new ArgumentNullException(nameof(source));
  603. if (keySelector == null)
  604. throw new ArgumentNullException(nameof(keySelector));
  605. #if CRIPPLED_REFLECTION
  606. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  607. #else
  608. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  609. #endif
  610. }
  611. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector, IComparer<TKey> comparer)
  612. {
  613. if (source == null)
  614. throw new ArgumentNullException(nameof(source));
  615. if (keySelector == null)
  616. throw new ArgumentNullException(nameof(keySelector));
  617. if (comparer == null)
  618. throw new ArgumentNullException(nameof(comparer));
  619. #if CRIPPLED_REFLECTION
  620. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>), default(IComparer<TKey>))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))), CancellationToken.None);
  621. #else
  622. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>))), CancellationToken.None);
  623. #endif
  624. }
  625. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
  626. {
  627. if (source == null)
  628. throw new ArgumentNullException(nameof(source));
  629. if (keySelector == null)
  630. throw new ArgumentNullException(nameof(keySelector));
  631. if (comparer == null)
  632. throw new ArgumentNullException(nameof(comparer));
  633. #if CRIPPLED_REFLECTION
  634. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  635. #else
  636. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  637. #endif
  638. }
  639. public static Task<IList<TSource>> MinBy<TSource, TKey>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, Task<TKey>>> keySelector, IComparer<TKey> comparer, CancellationToken cancellationToken)
  640. {
  641. if (source == null)
  642. throw new ArgumentNullException(nameof(source));
  643. if (keySelector == null)
  644. throw new ArgumentNullException(nameof(keySelector));
  645. if (comparer == null)
  646. throw new ArgumentNullException(nameof(comparer));
  647. #if CRIPPLED_REFLECTION
  648. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(InfoOf(() => AsyncQueryableEx.MinBy<TSource, TKey>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, Task<TKey>>>), default(IComparer<TKey>), default(CancellationToken))), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  649. #else
  650. return source.Provider.ExecuteAsync<IList<TSource>>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)), source.Expression, keySelector, Expression.Constant(comparer, typeof(IComparer<TKey>)), Expression.Constant(cancellationToken, typeof(CancellationToken))), cancellationToken);
  651. #endif
  652. }
  653. public static IAsyncQueryable<TSource> OnErrorResumeNext<TSource>(this IAsyncQueryable<TSource> first, IAsyncEnumerable<TSource> second)
  654. {
  655. if (first == null)
  656. throw new ArgumentNullException(nameof(first));
  657. if (second == null)
  658. throw new ArgumentNullException(nameof(second));
  659. #if CRIPPLED_REFLECTION
  660. return first.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.OnErrorResumeNext<TSource>(default(IAsyncQueryable<TSource>), default(IAsyncEnumerable<TSource>))), first.Expression, GetSourceExpression(second)));
  661. #else
  662. return first.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), first.Expression, GetSourceExpression(second)));
  663. #endif
  664. }
  665. public static IAsyncQueryable<TSource> Repeat<TSource>(this IAsyncQueryable<TSource> source)
  666. {
  667. if (source == null)
  668. throw new ArgumentNullException(nameof(source));
  669. #if CRIPPLED_REFLECTION
  670. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Repeat<TSource>(default(IAsyncQueryable<TSource>))), source.Expression));
  671. #else
  672. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression));
  673. #endif
  674. }
  675. public static IAsyncQueryable<TSource> Repeat<TSource>(this IAsyncQueryable<TSource> source, int count)
  676. {
  677. if (source == null)
  678. throw new ArgumentNullException(nameof(source));
  679. #if CRIPPLED_REFLECTION
  680. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Repeat<TSource>(default(IAsyncQueryable<TSource>), default(int))), source.Expression, Expression.Constant(count, typeof(int))));
  681. #else
  682. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(count, typeof(int))));
  683. #endif
  684. }
  685. public static IAsyncQueryable<TSource> Retry<TSource>(this IAsyncQueryable<TSource> source)
  686. {
  687. if (source == null)
  688. throw new ArgumentNullException(nameof(source));
  689. #if CRIPPLED_REFLECTION
  690. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Retry<TSource>(default(IAsyncQueryable<TSource>))), source.Expression));
  691. #else
  692. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression));
  693. #endif
  694. }
  695. public static IAsyncQueryable<TSource> Retry<TSource>(this IAsyncQueryable<TSource> source, int retryCount)
  696. {
  697. if (source == null)
  698. throw new ArgumentNullException(nameof(source));
  699. #if CRIPPLED_REFLECTION
  700. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Retry<TSource>(default(IAsyncQueryable<TSource>), default(int))), source.Expression, Expression.Constant(retryCount, typeof(int))));
  701. #else
  702. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(retryCount, typeof(int))));
  703. #endif
  704. }
  705. public static IAsyncQueryable<TSource> Scan<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  706. {
  707. if (source == null)
  708. throw new ArgumentNullException(nameof(source));
  709. if (accumulator == null)
  710. throw new ArgumentNullException(nameof(accumulator));
  711. #if CRIPPLED_REFLECTION
  712. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))), source.Expression, accumulator));
  713. #else
  714. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator));
  715. #endif
  716. }
  717. public static IAsyncQueryable<TSource> Scan<TSource>(this IAsyncQueryable<TSource> source, Expression<Func<TSource, TSource, Task<TSource>>> accumulator)
  718. {
  719. if (source == null)
  720. throw new ArgumentNullException(nameof(source));
  721. if (accumulator == null)
  722. throw new ArgumentNullException(nameof(accumulator));
  723. #if CRIPPLED_REFLECTION
  724. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan<TSource>(default(IAsyncQueryable<TSource>), default(Expression<Func<TSource, TSource, Task<TSource>>>))), source.Expression, accumulator));
  725. #else
  726. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, accumulator));
  727. #endif
  728. }
  729. public static IAsyncQueryable<TAccumulate> Scan<TSource, TAccumulate>(this IAsyncQueryable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  730. {
  731. if (source == null)
  732. throw new ArgumentNullException(nameof(source));
  733. if (accumulator == null)
  734. throw new ArgumentNullException(nameof(accumulator));
  735. #if CRIPPLED_REFLECTION
  736. return source.Provider.CreateQuery<TAccumulate>(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan<TSource, TAccumulate>(default(IAsyncQueryable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator));
  737. #else
  738. return source.Provider.CreateQuery<TAccumulate>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator));
  739. #endif
  740. }
  741. public static IAsyncQueryable<TAccumulate> Scan<TSource, TAccumulate>(this IAsyncQueryable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, Task<TAccumulate>>> accumulator)
  742. {
  743. if (source == null)
  744. throw new ArgumentNullException(nameof(source));
  745. if (accumulator == null)
  746. throw new ArgumentNullException(nameof(accumulator));
  747. #if CRIPPLED_REFLECTION
  748. return source.Provider.CreateQuery<TAccumulate>(Expression.Call(InfoOf(() => AsyncQueryableEx.Scan<TSource, TAccumulate>(default(IAsyncQueryable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, Task<TAccumulate>>>))), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator));
  749. #else
  750. return source.Provider.CreateQuery<TAccumulate>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)), source.Expression, Expression.Constant(seed, typeof(TAccumulate)), accumulator));
  751. #endif
  752. }
  753. public static IAsyncQueryable<TOther> SelectMany<TSource, TOther>(this IAsyncQueryable<TSource> source, IAsyncEnumerable<TOther> other)
  754. {
  755. if (source == null)
  756. throw new ArgumentNullException(nameof(source));
  757. if (other == null)
  758. throw new ArgumentNullException(nameof(other));
  759. #if CRIPPLED_REFLECTION
  760. return source.Provider.CreateQuery<TOther>(Expression.Call(InfoOf(() => AsyncQueryableEx.SelectMany<TSource, TOther>(default(IAsyncQueryable<TSource>), default(IAsyncEnumerable<TOther>))), source.Expression, GetSourceExpression(other)));
  761. #else
  762. return source.Provider.CreateQuery<TOther>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)), source.Expression, GetSourceExpression(other)));
  763. #endif
  764. }
  765. public static IAsyncQueryable<TSource> StartWith<TSource>(this IAsyncQueryable<TSource> source, params TSource[] values)
  766. {
  767. if (source == null)
  768. throw new ArgumentNullException(nameof(source));
  769. if (values == null)
  770. throw new ArgumentNullException(nameof(values));
  771. #if CRIPPLED_REFLECTION
  772. return source.Provider.CreateQuery<TSource>(Expression.Call(InfoOf(() => AsyncQueryableEx.StartWith<TSource>(default(IAsyncQueryable<TSource>), default(TSource[]))), source.Expression, Expression.Constant(values, typeof(TSource[]))));
  773. #else
  774. return source.Provider.CreateQuery<TSource>(Expression.Call(((MethodInfo)MethodBase.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)), source.Expression, Expression.Constant(values, typeof(TSource[]))));
  775. #endif
  776. }
  777. }
  778. }