Plan.cs 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  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. namespace System.Reactive.Joins
  6. {
  7. /// <summary>
  8. /// Represents an execution plan for join patterns.
  9. /// </summary>
  10. /// <typeparam name="TResult">The type of the results produced by the plan.</typeparam>
  11. public abstract class Plan<TResult>
  12. {
  13. internal Plan()
  14. {
  15. }
  16. internal abstract ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  17. IObserver<TResult> observer, Action<ActivePlan> deactivate);
  18. internal static JoinObserver<TSource> CreateObserver<TSource>(
  19. Dictionary<object, IJoinObserver> externalSubscriptions, IObservable<TSource> observable, Action<Exception> onError)
  20. {
  21. var observer = default(JoinObserver<TSource>);
  22. if (!externalSubscriptions.TryGetValue(observable, out var nonGeneric))
  23. {
  24. observer = new JoinObserver<TSource>(observable, onError);
  25. externalSubscriptions.Add(observable, observer);
  26. }
  27. else
  28. {
  29. observer = (JoinObserver<TSource>)nonGeneric;
  30. }
  31. return observer;
  32. }
  33. }
  34. internal class Plan<T1, TResult> : Plan<TResult>
  35. {
  36. internal Pattern<T1> Expression { get; }
  37. internal Func<T1, TResult> Selector { get; }
  38. internal Plan(Pattern<T1> expression, Func<T1, TResult> selector)
  39. {
  40. Expression = expression;
  41. Selector = selector;
  42. }
  43. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  44. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  45. {
  46. var onError = new Action<Exception>(observer.OnError);
  47. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  48. var activePlan = default(ActivePlan<T1>);
  49. activePlan = new ActivePlan<T1>(firstJoinObserver,
  50. first =>
  51. {
  52. var result = default(TResult);
  53. try
  54. {
  55. result = Selector(first);
  56. }
  57. catch (Exception exception)
  58. {
  59. observer.OnError(exception);
  60. return;
  61. }
  62. observer.OnNext(result);
  63. },
  64. () =>
  65. {
  66. firstJoinObserver.RemoveActivePlan(activePlan);
  67. deactivate(activePlan);
  68. });
  69. firstJoinObserver.AddActivePlan(activePlan);
  70. return activePlan;
  71. }
  72. }
  73. internal class Plan<T1, T2, TResult> : Plan<TResult>
  74. {
  75. internal Pattern<T1, T2> Expression { get; }
  76. internal Func<T1, T2, TResult> Selector { get; }
  77. internal Plan(Pattern<T1, T2> expression, Func<T1, T2, TResult> selector)
  78. {
  79. Expression = expression;
  80. Selector = selector;
  81. }
  82. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  83. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  84. {
  85. var onError = new Action<Exception>(observer.OnError);
  86. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  87. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  88. var activePlan = default(ActivePlan<T1, T2>);
  89. activePlan = new ActivePlan<T1, T2>(firstJoinObserver, secondJoinObserver,
  90. (first, second) =>
  91. {
  92. var result = default(TResult);
  93. try
  94. {
  95. result = Selector(first, second);
  96. }
  97. catch (Exception exception)
  98. {
  99. observer.OnError(exception);
  100. return;
  101. }
  102. observer.OnNext(result);
  103. },
  104. () =>
  105. {
  106. firstJoinObserver.RemoveActivePlan(activePlan);
  107. secondJoinObserver.RemoveActivePlan(activePlan);
  108. deactivate(activePlan);
  109. });
  110. firstJoinObserver.AddActivePlan(activePlan);
  111. secondJoinObserver.AddActivePlan(activePlan);
  112. return activePlan;
  113. }
  114. }
  115. internal class Plan<T1, T2, T3, TResult> : Plan<TResult>
  116. {
  117. internal Pattern<T1, T2, T3> Expression { get; }
  118. internal Func<T1, T2, T3, TResult> Selector { get; }
  119. internal Plan(Pattern<T1, T2, T3> expression, Func<T1, T2, T3, TResult> selector)
  120. {
  121. Expression = expression;
  122. Selector = selector;
  123. }
  124. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  125. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  126. {
  127. var onError = new Action<Exception>(observer.OnError);
  128. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  129. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  130. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  131. var activePlan = default(ActivePlan<T1, T2, T3>);
  132. activePlan = new ActivePlan<T1, T2, T3>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  133. (first, second, third) =>
  134. {
  135. var result = default(TResult);
  136. try
  137. {
  138. result = Selector(first, second, third);
  139. }
  140. catch (Exception exception)
  141. {
  142. observer.OnError(exception);
  143. return;
  144. }
  145. observer.OnNext(result);
  146. },
  147. () =>
  148. {
  149. firstJoinObserver.RemoveActivePlan(activePlan);
  150. secondJoinObserver.RemoveActivePlan(activePlan);
  151. thirdJoinObserver.RemoveActivePlan(activePlan);
  152. deactivate(activePlan);
  153. });
  154. firstJoinObserver.AddActivePlan(activePlan);
  155. secondJoinObserver.AddActivePlan(activePlan);
  156. thirdJoinObserver.AddActivePlan(activePlan);
  157. return activePlan;
  158. }
  159. }
  160. internal class Plan<T1, T2, T3, T4, TResult> : Plan<TResult>
  161. {
  162. internal Pattern<T1, T2, T3, T4> Expression { get; }
  163. internal Func<T1, T2, T3, T4, TResult> Selector { get; }
  164. internal Plan(Pattern<T1, T2, T3, T4> expression,
  165. Func<T1, T2, T3, T4, TResult> selector)
  166. {
  167. Expression = expression;
  168. Selector = selector;
  169. }
  170. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  171. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  172. {
  173. var onError = new Action<Exception>(observer.OnError);
  174. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  175. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  176. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  177. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  178. var activePlan = default(ActivePlan<T1, T2, T3, T4>);
  179. activePlan = new ActivePlan<T1, T2, T3, T4>(firstJoinObserver, secondJoinObserver, thirdJoinObserver, fourthJoinObserver,
  180. (first, second, third, fourth) =>
  181. {
  182. var result = default(TResult);
  183. try
  184. {
  185. result = Selector(first, second, third, fourth);
  186. }
  187. catch (Exception exception)
  188. {
  189. observer.OnError(exception);
  190. return;
  191. }
  192. observer.OnNext(result);
  193. },
  194. () =>
  195. {
  196. firstJoinObserver.RemoveActivePlan(activePlan);
  197. secondJoinObserver.RemoveActivePlan(activePlan);
  198. thirdJoinObserver.RemoveActivePlan(activePlan);
  199. fourthJoinObserver.RemoveActivePlan(activePlan);
  200. deactivate(activePlan);
  201. });
  202. firstJoinObserver.AddActivePlan(activePlan);
  203. secondJoinObserver.AddActivePlan(activePlan);
  204. thirdJoinObserver.AddActivePlan(activePlan);
  205. fourthJoinObserver.AddActivePlan(activePlan);
  206. return activePlan;
  207. }
  208. }
  209. internal class Plan<T1, T2, T3, T4, T5, TResult> : Plan<TResult>
  210. {
  211. internal Pattern<T1, T2, T3, T4, T5> Expression { get; }
  212. internal Func<T1, T2, T3, T4, T5, TResult> Selector { get; }
  213. internal Plan(Pattern<T1, T2, T3, T4, T5> expression,
  214. Func<T1, T2, T3, T4, T5, TResult> selector)
  215. {
  216. Expression = expression;
  217. Selector = selector;
  218. }
  219. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  220. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  221. {
  222. var onError = new Action<Exception>(observer.OnError);
  223. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  224. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  225. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  226. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  227. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  228. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5>);
  229. activePlan = new ActivePlan<T1, T2, T3, T4, T5>(firstJoinObserver, secondJoinObserver, thirdJoinObserver, fourthJoinObserver, fifthJoinObserver,
  230. (first, second, third, fourth, fifth) =>
  231. {
  232. var result = default(TResult);
  233. try
  234. {
  235. result = Selector(first, second, third, fourth, fifth);
  236. }
  237. catch (Exception exception)
  238. {
  239. observer.OnError(exception);
  240. return;
  241. }
  242. observer.OnNext(result);
  243. },
  244. () =>
  245. {
  246. firstJoinObserver.RemoveActivePlan(activePlan);
  247. secondJoinObserver.RemoveActivePlan(activePlan);
  248. thirdJoinObserver.RemoveActivePlan(activePlan);
  249. fourthJoinObserver.RemoveActivePlan(activePlan);
  250. fifthJoinObserver.RemoveActivePlan(activePlan);
  251. deactivate(activePlan);
  252. });
  253. firstJoinObserver.AddActivePlan(activePlan);
  254. secondJoinObserver.AddActivePlan(activePlan);
  255. thirdJoinObserver.AddActivePlan(activePlan);
  256. fourthJoinObserver.AddActivePlan(activePlan);
  257. fifthJoinObserver.AddActivePlan(activePlan);
  258. return activePlan;
  259. }
  260. }
  261. internal class Plan<T1, T2, T3, T4, T5, T6, TResult> : Plan<TResult>
  262. {
  263. internal Pattern<T1, T2, T3, T4, T5, T6> Expression { get; }
  264. internal Func<T1, T2, T3, T4, T5, T6, TResult> Selector { get; }
  265. internal Plan(Pattern<T1, T2, T3, T4, T5, T6> expression,
  266. Func<T1, T2, T3, T4, T5, T6, TResult> selector)
  267. {
  268. Expression = expression;
  269. Selector = selector;
  270. }
  271. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  272. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  273. {
  274. var onError = new Action<Exception>(observer.OnError);
  275. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  276. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  277. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  278. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  279. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  280. var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
  281. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6>);
  282. activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  283. fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
  284. (first, second, third, fourth, fifth, sixth) =>
  285. {
  286. var result = default(TResult);
  287. try
  288. {
  289. result = Selector(first, second, third, fourth, fifth, sixth);
  290. }
  291. catch (Exception exception)
  292. {
  293. observer.OnError(exception);
  294. return;
  295. }
  296. observer.OnNext(result);
  297. },
  298. () =>
  299. {
  300. firstJoinObserver.RemoveActivePlan(activePlan);
  301. secondJoinObserver.RemoveActivePlan(activePlan);
  302. thirdJoinObserver.RemoveActivePlan(activePlan);
  303. fourthJoinObserver.RemoveActivePlan(activePlan);
  304. fifthJoinObserver.RemoveActivePlan(activePlan);
  305. sixthJoinObserver.RemoveActivePlan(activePlan);
  306. deactivate(activePlan);
  307. });
  308. firstJoinObserver.AddActivePlan(activePlan);
  309. secondJoinObserver.AddActivePlan(activePlan);
  310. thirdJoinObserver.AddActivePlan(activePlan);
  311. fourthJoinObserver.AddActivePlan(activePlan);
  312. fifthJoinObserver.AddActivePlan(activePlan);
  313. sixthJoinObserver.AddActivePlan(activePlan);
  314. return activePlan;
  315. }
  316. }
  317. internal class Plan<T1, T2, T3, T4, T5, T6, T7, TResult> : Plan<TResult>
  318. {
  319. internal Pattern<T1, T2, T3, T4, T5, T6, T7> Expression { get; }
  320. internal Func<T1, T2, T3, T4, T5, T6, T7, TResult> Selector { get; }
  321. internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7> expression,
  322. Func<T1, T2, T3, T4, T5, T6, T7, TResult> selector)
  323. {
  324. Expression = expression;
  325. Selector = selector;
  326. }
  327. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  328. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  329. {
  330. var onError = new Action<Exception>(observer.OnError);
  331. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  332. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  333. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  334. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  335. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  336. var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
  337. var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
  338. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7>);
  339. activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  340. fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver,
  341. (first, second, third, fourth, fifth, sixth, seventh) =>
  342. {
  343. var result = default(TResult);
  344. try
  345. {
  346. result = Selector(first, second, third, fourth, fifth, sixth, seventh);
  347. }
  348. catch (Exception exception)
  349. {
  350. observer.OnError(exception);
  351. return;
  352. }
  353. observer.OnNext(result);
  354. },
  355. () =>
  356. {
  357. firstJoinObserver.RemoveActivePlan(activePlan);
  358. secondJoinObserver.RemoveActivePlan(activePlan);
  359. thirdJoinObserver.RemoveActivePlan(activePlan);
  360. fourthJoinObserver.RemoveActivePlan(activePlan);
  361. fifthJoinObserver.RemoveActivePlan(activePlan);
  362. sixthJoinObserver.RemoveActivePlan(activePlan);
  363. seventhJoinObserver.RemoveActivePlan(activePlan);
  364. deactivate(activePlan);
  365. });
  366. firstJoinObserver.AddActivePlan(activePlan);
  367. secondJoinObserver.AddActivePlan(activePlan);
  368. thirdJoinObserver.AddActivePlan(activePlan);
  369. fourthJoinObserver.AddActivePlan(activePlan);
  370. fifthJoinObserver.AddActivePlan(activePlan);
  371. sixthJoinObserver.AddActivePlan(activePlan);
  372. seventhJoinObserver.AddActivePlan(activePlan);
  373. return activePlan;
  374. }
  375. }
  376. internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, TResult> : Plan<TResult>
  377. {
  378. internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8> Expression { get; }
  379. internal Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> Selector { get; }
  380. internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8> expression,
  381. Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> selector)
  382. {
  383. Expression = expression;
  384. Selector = selector;
  385. }
  386. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  387. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  388. {
  389. var onError = new Action<Exception>(observer.OnError);
  390. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  391. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  392. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  393. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  394. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  395. var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
  396. var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
  397. var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
  398. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8>);
  399. activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  400. fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver,
  401. (first, second, third, fourth, fifth, sixth, seventh, eighth) =>
  402. {
  403. var result = default(TResult);
  404. try
  405. {
  406. result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth);
  407. }
  408. catch (Exception exception)
  409. {
  410. observer.OnError(exception);
  411. return;
  412. }
  413. observer.OnNext(result);
  414. },
  415. () =>
  416. {
  417. firstJoinObserver.RemoveActivePlan(activePlan);
  418. secondJoinObserver.RemoveActivePlan(activePlan);
  419. thirdJoinObserver.RemoveActivePlan(activePlan);
  420. fourthJoinObserver.RemoveActivePlan(activePlan);
  421. fifthJoinObserver.RemoveActivePlan(activePlan);
  422. sixthJoinObserver.RemoveActivePlan(activePlan);
  423. seventhJoinObserver.RemoveActivePlan(activePlan);
  424. eighthJoinObserver.RemoveActivePlan(activePlan);
  425. deactivate(activePlan);
  426. });
  427. firstJoinObserver.AddActivePlan(activePlan);
  428. secondJoinObserver.AddActivePlan(activePlan);
  429. thirdJoinObserver.AddActivePlan(activePlan);
  430. fourthJoinObserver.AddActivePlan(activePlan);
  431. fifthJoinObserver.AddActivePlan(activePlan);
  432. sixthJoinObserver.AddActivePlan(activePlan);
  433. seventhJoinObserver.AddActivePlan(activePlan);
  434. eighthJoinObserver.AddActivePlan(activePlan);
  435. return activePlan;
  436. }
  437. }
  438. internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> : Plan<TResult>
  439. {
  440. internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9> Expression { get; }
  441. internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> Selector { get; }
  442. internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9> expression,
  443. Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> selector)
  444. {
  445. Expression = expression;
  446. Selector = selector;
  447. }
  448. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  449. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  450. {
  451. var onError = new Action<Exception>(observer.OnError);
  452. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  453. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  454. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  455. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  456. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  457. var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
  458. var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
  459. var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
  460. var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
  461. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9>);
  462. activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  463. fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
  464. (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth) =>
  465. {
  466. var result = default(TResult);
  467. try
  468. {
  469. result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth);
  470. }
  471. catch (Exception exception)
  472. {
  473. observer.OnError(exception);
  474. return;
  475. }
  476. observer.OnNext(result);
  477. },
  478. () =>
  479. {
  480. firstJoinObserver.RemoveActivePlan(activePlan);
  481. secondJoinObserver.RemoveActivePlan(activePlan);
  482. thirdJoinObserver.RemoveActivePlan(activePlan);
  483. fourthJoinObserver.RemoveActivePlan(activePlan);
  484. fifthJoinObserver.RemoveActivePlan(activePlan);
  485. sixthJoinObserver.RemoveActivePlan(activePlan);
  486. seventhJoinObserver.RemoveActivePlan(activePlan);
  487. eighthJoinObserver.RemoveActivePlan(activePlan);
  488. ninthJoinObserver.RemoveActivePlan(activePlan);
  489. deactivate(activePlan);
  490. });
  491. firstJoinObserver.AddActivePlan(activePlan);
  492. secondJoinObserver.AddActivePlan(activePlan);
  493. thirdJoinObserver.AddActivePlan(activePlan);
  494. fourthJoinObserver.AddActivePlan(activePlan);
  495. fifthJoinObserver.AddActivePlan(activePlan);
  496. sixthJoinObserver.AddActivePlan(activePlan);
  497. seventhJoinObserver.AddActivePlan(activePlan);
  498. eighthJoinObserver.AddActivePlan(activePlan);
  499. ninthJoinObserver.AddActivePlan(activePlan);
  500. return activePlan;
  501. }
  502. }
  503. internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> : Plan<TResult>
  504. {
  505. internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Expression { get; }
  506. internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> Selector { get; }
  507. internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> expression,
  508. Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> selector)
  509. {
  510. Expression = expression;
  511. Selector = selector;
  512. }
  513. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  514. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  515. {
  516. var onError = new Action<Exception>(observer.OnError);
  517. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  518. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  519. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  520. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  521. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  522. var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
  523. var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
  524. var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
  525. var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
  526. var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
  527. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>);
  528. activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  529. fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver,
  530. (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth) =>
  531. {
  532. var result = default(TResult);
  533. try
  534. {
  535. result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth);
  536. }
  537. catch (Exception exception)
  538. {
  539. observer.OnError(exception);
  540. return;
  541. }
  542. observer.OnNext(result);
  543. },
  544. () =>
  545. {
  546. firstJoinObserver.RemoveActivePlan(activePlan);
  547. secondJoinObserver.RemoveActivePlan(activePlan);
  548. thirdJoinObserver.RemoveActivePlan(activePlan);
  549. fourthJoinObserver.RemoveActivePlan(activePlan);
  550. fifthJoinObserver.RemoveActivePlan(activePlan);
  551. sixthJoinObserver.RemoveActivePlan(activePlan);
  552. seventhJoinObserver.RemoveActivePlan(activePlan);
  553. eighthJoinObserver.RemoveActivePlan(activePlan);
  554. ninthJoinObserver.RemoveActivePlan(activePlan);
  555. tenthJoinObserver.RemoveActivePlan(activePlan);
  556. deactivate(activePlan);
  557. });
  558. firstJoinObserver.AddActivePlan(activePlan);
  559. secondJoinObserver.AddActivePlan(activePlan);
  560. thirdJoinObserver.AddActivePlan(activePlan);
  561. fourthJoinObserver.AddActivePlan(activePlan);
  562. fifthJoinObserver.AddActivePlan(activePlan);
  563. sixthJoinObserver.AddActivePlan(activePlan);
  564. seventhJoinObserver.AddActivePlan(activePlan);
  565. eighthJoinObserver.AddActivePlan(activePlan);
  566. ninthJoinObserver.AddActivePlan(activePlan);
  567. tenthJoinObserver.AddActivePlan(activePlan);
  568. return activePlan;
  569. }
  570. }
  571. internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> : Plan<TResult>
  572. {
  573. internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Expression { get; }
  574. internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> Selector { get; }
  575. internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> expression,
  576. Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> selector)
  577. {
  578. Expression = expression;
  579. Selector = selector;
  580. }
  581. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  582. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  583. {
  584. var onError = new Action<Exception>(observer.OnError);
  585. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  586. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  587. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  588. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  589. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  590. var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
  591. var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
  592. var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
  593. var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
  594. var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
  595. var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
  596. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>);
  597. activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  598. fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver, eleventhJoinObserver,
  599. (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh) =>
  600. {
  601. var result = default(TResult);
  602. try
  603. {
  604. result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh);
  605. }
  606. catch (Exception exception)
  607. {
  608. observer.OnError(exception);
  609. return;
  610. }
  611. observer.OnNext(result);
  612. },
  613. () =>
  614. {
  615. firstJoinObserver.RemoveActivePlan(activePlan);
  616. secondJoinObserver.RemoveActivePlan(activePlan);
  617. thirdJoinObserver.RemoveActivePlan(activePlan);
  618. fourthJoinObserver.RemoveActivePlan(activePlan);
  619. fifthJoinObserver.RemoveActivePlan(activePlan);
  620. sixthJoinObserver.RemoveActivePlan(activePlan);
  621. seventhJoinObserver.RemoveActivePlan(activePlan);
  622. eighthJoinObserver.RemoveActivePlan(activePlan);
  623. ninthJoinObserver.RemoveActivePlan(activePlan);
  624. tenthJoinObserver.RemoveActivePlan(activePlan);
  625. eleventhJoinObserver.RemoveActivePlan(activePlan);
  626. deactivate(activePlan);
  627. });
  628. firstJoinObserver.AddActivePlan(activePlan);
  629. secondJoinObserver.AddActivePlan(activePlan);
  630. thirdJoinObserver.AddActivePlan(activePlan);
  631. fourthJoinObserver.AddActivePlan(activePlan);
  632. fifthJoinObserver.AddActivePlan(activePlan);
  633. sixthJoinObserver.AddActivePlan(activePlan);
  634. seventhJoinObserver.AddActivePlan(activePlan);
  635. eighthJoinObserver.AddActivePlan(activePlan);
  636. ninthJoinObserver.AddActivePlan(activePlan);
  637. tenthJoinObserver.AddActivePlan(activePlan);
  638. eleventhJoinObserver.AddActivePlan(activePlan);
  639. return activePlan;
  640. }
  641. }
  642. internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> : Plan<TResult>
  643. {
  644. internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Expression { get; }
  645. internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> Selector { get; }
  646. internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> expression,
  647. Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> selector)
  648. {
  649. Expression = expression;
  650. Selector = selector;
  651. }
  652. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  653. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  654. {
  655. var onError = new Action<Exception>(observer.OnError);
  656. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  657. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  658. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  659. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  660. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  661. var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
  662. var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
  663. var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
  664. var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
  665. var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
  666. var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
  667. var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
  668. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>);
  669. activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  670. fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver, eleventhJoinObserver,
  671. twelfthJoinObserver,
  672. (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth) =>
  673. {
  674. var result = default(TResult);
  675. try
  676. {
  677. result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth);
  678. }
  679. catch (Exception exception)
  680. {
  681. observer.OnError(exception);
  682. return;
  683. }
  684. observer.OnNext(result);
  685. },
  686. () =>
  687. {
  688. firstJoinObserver.RemoveActivePlan(activePlan);
  689. secondJoinObserver.RemoveActivePlan(activePlan);
  690. thirdJoinObserver.RemoveActivePlan(activePlan);
  691. fourthJoinObserver.RemoveActivePlan(activePlan);
  692. fifthJoinObserver.RemoveActivePlan(activePlan);
  693. sixthJoinObserver.RemoveActivePlan(activePlan);
  694. seventhJoinObserver.RemoveActivePlan(activePlan);
  695. eighthJoinObserver.RemoveActivePlan(activePlan);
  696. ninthJoinObserver.RemoveActivePlan(activePlan);
  697. tenthJoinObserver.RemoveActivePlan(activePlan);
  698. eleventhJoinObserver.RemoveActivePlan(activePlan);
  699. twelfthJoinObserver.RemoveActivePlan(activePlan);
  700. deactivate(activePlan);
  701. });
  702. firstJoinObserver.AddActivePlan(activePlan);
  703. secondJoinObserver.AddActivePlan(activePlan);
  704. thirdJoinObserver.AddActivePlan(activePlan);
  705. fourthJoinObserver.AddActivePlan(activePlan);
  706. fifthJoinObserver.AddActivePlan(activePlan);
  707. sixthJoinObserver.AddActivePlan(activePlan);
  708. seventhJoinObserver.AddActivePlan(activePlan);
  709. eighthJoinObserver.AddActivePlan(activePlan);
  710. ninthJoinObserver.AddActivePlan(activePlan);
  711. tenthJoinObserver.AddActivePlan(activePlan);
  712. eleventhJoinObserver.AddActivePlan(activePlan);
  713. twelfthJoinObserver.AddActivePlan(activePlan);
  714. return activePlan;
  715. }
  716. }
  717. internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> : Plan<TResult>
  718. {
  719. internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Expression { get; }
  720. internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> Selector { get; }
  721. internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> expression,
  722. Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> selector)
  723. {
  724. Expression = expression;
  725. Selector = selector;
  726. }
  727. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  728. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  729. {
  730. var onError = new Action<Exception>(observer.OnError);
  731. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  732. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  733. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  734. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  735. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  736. var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
  737. var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
  738. var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
  739. var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
  740. var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
  741. var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
  742. var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
  743. var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
  744. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>);
  745. activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  746. fourthJoinObserver, fifthJoinObserver, sixthJoinObserver, seventhJoinObserver, eighthJoinObserver, ninthJoinObserver, tenthJoinObserver, eleventhJoinObserver,
  747. twelfthJoinObserver, thirteenthJoinObserver,
  748. (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth) =>
  749. {
  750. var result = default(TResult);
  751. try
  752. {
  753. result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth);
  754. }
  755. catch (Exception exception)
  756. {
  757. observer.OnError(exception);
  758. return;
  759. }
  760. observer.OnNext(result);
  761. },
  762. () =>
  763. {
  764. firstJoinObserver.RemoveActivePlan(activePlan);
  765. secondJoinObserver.RemoveActivePlan(activePlan);
  766. thirdJoinObserver.RemoveActivePlan(activePlan);
  767. fourthJoinObserver.RemoveActivePlan(activePlan);
  768. fifthJoinObserver.RemoveActivePlan(activePlan);
  769. sixthJoinObserver.RemoveActivePlan(activePlan);
  770. seventhJoinObserver.RemoveActivePlan(activePlan);
  771. eighthJoinObserver.RemoveActivePlan(activePlan);
  772. ninthJoinObserver.RemoveActivePlan(activePlan);
  773. tenthJoinObserver.RemoveActivePlan(activePlan);
  774. eleventhJoinObserver.RemoveActivePlan(activePlan);
  775. twelfthJoinObserver.RemoveActivePlan(activePlan);
  776. thirteenthJoinObserver.RemoveActivePlan(activePlan);
  777. deactivate(activePlan);
  778. });
  779. firstJoinObserver.AddActivePlan(activePlan);
  780. secondJoinObserver.AddActivePlan(activePlan);
  781. thirdJoinObserver.AddActivePlan(activePlan);
  782. fourthJoinObserver.AddActivePlan(activePlan);
  783. fifthJoinObserver.AddActivePlan(activePlan);
  784. sixthJoinObserver.AddActivePlan(activePlan);
  785. seventhJoinObserver.AddActivePlan(activePlan);
  786. eighthJoinObserver.AddActivePlan(activePlan);
  787. ninthJoinObserver.AddActivePlan(activePlan);
  788. tenthJoinObserver.AddActivePlan(activePlan);
  789. eleventhJoinObserver.AddActivePlan(activePlan);
  790. twelfthJoinObserver.AddActivePlan(activePlan);
  791. thirteenthJoinObserver.AddActivePlan(activePlan);
  792. return activePlan;
  793. }
  794. }
  795. internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> : Plan<TResult>
  796. {
  797. internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Expression { get; }
  798. internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> Selector { get; }
  799. internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> expression,
  800. Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> selector)
  801. {
  802. Expression = expression;
  803. Selector = selector;
  804. }
  805. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  806. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  807. {
  808. var onError = new Action<Exception>(observer.OnError);
  809. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  810. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  811. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  812. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  813. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  814. var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
  815. var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
  816. var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
  817. var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
  818. var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
  819. var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
  820. var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
  821. var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
  822. var fourteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourteenth, onError);
  823. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>);
  824. activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(
  825. firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  826. fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
  827. seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
  828. tenthJoinObserver, eleventhJoinObserver,
  829. twelfthJoinObserver, thirteenthJoinObserver,
  830. fourteenthJoinObserver,
  831. (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth) =>
  832. {
  833. var result = default(TResult);
  834. try
  835. {
  836. result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth);
  837. }
  838. catch (Exception exception)
  839. {
  840. observer.OnError(exception);
  841. return;
  842. }
  843. observer.OnNext(result);
  844. },
  845. () =>
  846. {
  847. firstJoinObserver.RemoveActivePlan(activePlan);
  848. secondJoinObserver.RemoveActivePlan(activePlan);
  849. thirdJoinObserver.RemoveActivePlan(activePlan);
  850. fourthJoinObserver.RemoveActivePlan(activePlan);
  851. fifthJoinObserver.RemoveActivePlan(activePlan);
  852. sixthJoinObserver.RemoveActivePlan(activePlan);
  853. seventhJoinObserver.RemoveActivePlan(activePlan);
  854. eighthJoinObserver.RemoveActivePlan(activePlan);
  855. ninthJoinObserver.RemoveActivePlan(activePlan);
  856. tenthJoinObserver.RemoveActivePlan(activePlan);
  857. eleventhJoinObserver.RemoveActivePlan(activePlan);
  858. twelfthJoinObserver.RemoveActivePlan(activePlan);
  859. thirteenthJoinObserver.RemoveActivePlan(activePlan);
  860. fourteenthJoinObserver.RemoveActivePlan(activePlan);
  861. deactivate(activePlan);
  862. });
  863. firstJoinObserver.AddActivePlan(activePlan);
  864. secondJoinObserver.AddActivePlan(activePlan);
  865. thirdJoinObserver.AddActivePlan(activePlan);
  866. fourthJoinObserver.AddActivePlan(activePlan);
  867. fifthJoinObserver.AddActivePlan(activePlan);
  868. sixthJoinObserver.AddActivePlan(activePlan);
  869. seventhJoinObserver.AddActivePlan(activePlan);
  870. eighthJoinObserver.AddActivePlan(activePlan);
  871. ninthJoinObserver.AddActivePlan(activePlan);
  872. tenthJoinObserver.AddActivePlan(activePlan);
  873. eleventhJoinObserver.AddActivePlan(activePlan);
  874. twelfthJoinObserver.AddActivePlan(activePlan);
  875. thirteenthJoinObserver.AddActivePlan(activePlan);
  876. fourteenthJoinObserver.AddActivePlan(activePlan);
  877. return activePlan;
  878. }
  879. }
  880. internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> : Plan<TResult>
  881. {
  882. internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> Expression { get; }
  883. internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> Selector { get; }
  884. internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> expression,
  885. Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> selector)
  886. {
  887. Expression = expression;
  888. Selector = selector;
  889. }
  890. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  891. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  892. {
  893. var onError = new Action<Exception>(observer.OnError);
  894. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  895. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  896. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  897. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  898. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  899. var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
  900. var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
  901. var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
  902. var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
  903. var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
  904. var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
  905. var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
  906. var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
  907. var fourteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourteenth, onError);
  908. var fifteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifteenth, onError);
  909. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>);
  910. activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(
  911. firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  912. fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
  913. seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
  914. tenthJoinObserver, eleventhJoinObserver,
  915. twelfthJoinObserver, thirteenthJoinObserver,
  916. fourteenthJoinObserver, fifteenthJoinObserver,
  917. (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth) =>
  918. {
  919. var result = default(TResult);
  920. try
  921. {
  922. result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth);
  923. }
  924. catch (Exception exception)
  925. {
  926. observer.OnError(exception);
  927. return;
  928. }
  929. observer.OnNext(result);
  930. },
  931. () =>
  932. {
  933. firstJoinObserver.RemoveActivePlan(activePlan);
  934. secondJoinObserver.RemoveActivePlan(activePlan);
  935. thirdJoinObserver.RemoveActivePlan(activePlan);
  936. fourthJoinObserver.RemoveActivePlan(activePlan);
  937. fifthJoinObserver.RemoveActivePlan(activePlan);
  938. sixthJoinObserver.RemoveActivePlan(activePlan);
  939. seventhJoinObserver.RemoveActivePlan(activePlan);
  940. eighthJoinObserver.RemoveActivePlan(activePlan);
  941. ninthJoinObserver.RemoveActivePlan(activePlan);
  942. tenthJoinObserver.RemoveActivePlan(activePlan);
  943. eleventhJoinObserver.RemoveActivePlan(activePlan);
  944. twelfthJoinObserver.RemoveActivePlan(activePlan);
  945. thirteenthJoinObserver.RemoveActivePlan(activePlan);
  946. fourteenthJoinObserver.RemoveActivePlan(activePlan);
  947. fifteenthJoinObserver.RemoveActivePlan(activePlan);
  948. deactivate(activePlan);
  949. });
  950. firstJoinObserver.AddActivePlan(activePlan);
  951. secondJoinObserver.AddActivePlan(activePlan);
  952. thirdJoinObserver.AddActivePlan(activePlan);
  953. fourthJoinObserver.AddActivePlan(activePlan);
  954. fifthJoinObserver.AddActivePlan(activePlan);
  955. sixthJoinObserver.AddActivePlan(activePlan);
  956. seventhJoinObserver.AddActivePlan(activePlan);
  957. eighthJoinObserver.AddActivePlan(activePlan);
  958. ninthJoinObserver.AddActivePlan(activePlan);
  959. tenthJoinObserver.AddActivePlan(activePlan);
  960. eleventhJoinObserver.AddActivePlan(activePlan);
  961. twelfthJoinObserver.AddActivePlan(activePlan);
  962. thirteenthJoinObserver.AddActivePlan(activePlan);
  963. fourteenthJoinObserver.AddActivePlan(activePlan);
  964. fifteenthJoinObserver.AddActivePlan(activePlan);
  965. return activePlan;
  966. }
  967. }
  968. internal class Plan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> : Plan<TResult>
  969. {
  970. internal Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> Expression { get; }
  971. internal Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> Selector { get; }
  972. internal Plan(Pattern<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16> expression,
  973. Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, TResult> selector)
  974. {
  975. Expression = expression;
  976. Selector = selector;
  977. }
  978. internal override ActivePlan Activate(Dictionary<object, IJoinObserver> externalSubscriptions,
  979. IObserver<TResult> observer, Action<ActivePlan> deactivate)
  980. {
  981. var onError = new Action<Exception>(observer.OnError);
  982. var firstJoinObserver = CreateObserver(externalSubscriptions, Expression.First, onError);
  983. var secondJoinObserver = CreateObserver(externalSubscriptions, Expression.Second, onError);
  984. var thirdJoinObserver = CreateObserver(externalSubscriptions, Expression.Third, onError);
  985. var fourthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourth, onError);
  986. var fifthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifth, onError);
  987. var sixthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixth, onError);
  988. var seventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Seventh, onError);
  989. var eighthJoinObserver = CreateObserver(externalSubscriptions, Expression.Eighth, onError);
  990. var ninthJoinObserver = CreateObserver(externalSubscriptions, Expression.Ninth, onError);
  991. var tenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Tenth, onError);
  992. var eleventhJoinObserver = CreateObserver(externalSubscriptions, Expression.Eleventh, onError);
  993. var twelfthJoinObserver = CreateObserver(externalSubscriptions, Expression.Twelfth, onError);
  994. var thirteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Thirteenth, onError);
  995. var fourteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fourteenth, onError);
  996. var fifteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Fifteenth, onError);
  997. var sixteenthJoinObserver = CreateObserver(externalSubscriptions, Expression.Sixteenth, onError);
  998. var activePlan = default(ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>);
  999. activePlan = new ActivePlan<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16>(
  1000. firstJoinObserver, secondJoinObserver, thirdJoinObserver,
  1001. fourthJoinObserver, fifthJoinObserver, sixthJoinObserver,
  1002. seventhJoinObserver, eighthJoinObserver, ninthJoinObserver,
  1003. tenthJoinObserver, eleventhJoinObserver,
  1004. twelfthJoinObserver, thirteenthJoinObserver,
  1005. fourteenthJoinObserver, fifteenthJoinObserver,
  1006. sixteenthJoinObserver,
  1007. (first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth) =>
  1008. {
  1009. var result = default(TResult);
  1010. try
  1011. {
  1012. result = Selector(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth);
  1013. }
  1014. catch (Exception exception)
  1015. {
  1016. observer.OnError(exception);
  1017. return;
  1018. }
  1019. observer.OnNext(result);
  1020. },
  1021. () =>
  1022. {
  1023. firstJoinObserver.RemoveActivePlan(activePlan);
  1024. secondJoinObserver.RemoveActivePlan(activePlan);
  1025. thirdJoinObserver.RemoveActivePlan(activePlan);
  1026. fourthJoinObserver.RemoveActivePlan(activePlan);
  1027. fifthJoinObserver.RemoveActivePlan(activePlan);
  1028. sixthJoinObserver.RemoveActivePlan(activePlan);
  1029. seventhJoinObserver.RemoveActivePlan(activePlan);
  1030. eighthJoinObserver.RemoveActivePlan(activePlan);
  1031. ninthJoinObserver.RemoveActivePlan(activePlan);
  1032. tenthJoinObserver.RemoveActivePlan(activePlan);
  1033. eleventhJoinObserver.RemoveActivePlan(activePlan);
  1034. twelfthJoinObserver.RemoveActivePlan(activePlan);
  1035. thirteenthJoinObserver.RemoveActivePlan(activePlan);
  1036. fourteenthJoinObserver.RemoveActivePlan(activePlan);
  1037. fifteenthJoinObserver.RemoveActivePlan(activePlan);
  1038. sixteenthJoinObserver.RemoveActivePlan(activePlan);
  1039. deactivate(activePlan);
  1040. });
  1041. firstJoinObserver.AddActivePlan(activePlan);
  1042. secondJoinObserver.AddActivePlan(activePlan);
  1043. thirdJoinObserver.AddActivePlan(activePlan);
  1044. fourthJoinObserver.AddActivePlan(activePlan);
  1045. fifthJoinObserver.AddActivePlan(activePlan);
  1046. sixthJoinObserver.AddActivePlan(activePlan);
  1047. seventhJoinObserver.AddActivePlan(activePlan);
  1048. eighthJoinObserver.AddActivePlan(activePlan);
  1049. ninthJoinObserver.AddActivePlan(activePlan);
  1050. tenthJoinObserver.AddActivePlan(activePlan);
  1051. eleventhJoinObserver.AddActivePlan(activePlan);
  1052. twelfthJoinObserver.AddActivePlan(activePlan);
  1053. thirteenthJoinObserver.AddActivePlan(activePlan);
  1054. fourteenthJoinObserver.AddActivePlan(activePlan);
  1055. fifteenthJoinObserver.AddActivePlan(activePlan);
  1056. sixteenthJoinObserver.AddActivePlan(activePlan);
  1057. return activePlan;
  1058. }
  1059. }
  1060. }