1
0

CombineLatest.Generated.cs 726 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT License.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Reactive.Disposables;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. namespace System.Reactive.Linq
  8. {
  9. public partial class AsyncObservable
  10. {
  11. public static IAsyncObservable<(T1, T2)> CombineLatest<T1, T2>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2)
  12. {
  13. if (source1 == null)
  14. throw new ArgumentNullException(nameof(source1));
  15. if (source2 == null)
  16. throw new ArgumentNullException(nameof(source2));
  17. return Create<(T1, T2)>(async observer =>
  18. {
  19. var d = new CompositeAsyncDisposable();
  20. var (observer1, observer2) = AsyncObserver.CombineLatest(observer);
  21. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  22. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  23. await Task.WhenAll(sub1, sub2).ConfigureAwait(false);
  24. return d;
  25. });
  26. }
  27. public static IAsyncObservable<TResult> CombineLatest<T1, T2, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, Func<T1, T2, TResult> selector)
  28. {
  29. if (source1 == null)
  30. throw new ArgumentNullException(nameof(source1));
  31. if (source2 == null)
  32. throw new ArgumentNullException(nameof(source2));
  33. if (selector == null)
  34. throw new ArgumentNullException(nameof(selector));
  35. return Create<TResult>(async observer =>
  36. {
  37. var d = new CompositeAsyncDisposable();
  38. var (observer1, observer2) = AsyncObserver.CombineLatest(observer, selector);
  39. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  40. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  41. await Task.WhenAll(sub1, sub2).ConfigureAwait(false);
  42. return d;
  43. });
  44. }
  45. public static IAsyncObservable<TResult> CombineLatest<T1, T2, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, Func<T1, T2, ValueTask<TResult>> selector)
  46. {
  47. if (source1 == null)
  48. throw new ArgumentNullException(nameof(source1));
  49. if (source2 == null)
  50. throw new ArgumentNullException(nameof(source2));
  51. if (selector == null)
  52. throw new ArgumentNullException(nameof(selector));
  53. return Create<TResult>(async observer =>
  54. {
  55. var d = new CompositeAsyncDisposable();
  56. var (observer1, observer2) = AsyncObserver.CombineLatest(observer, selector);
  57. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  58. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  59. await Task.WhenAll(sub1, sub2).ConfigureAwait(false);
  60. return d;
  61. });
  62. }
  63. public static IAsyncObservable<(T1, T2, T3)> CombineLatest<T1, T2, T3>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3)
  64. {
  65. if (source1 == null)
  66. throw new ArgumentNullException(nameof(source1));
  67. if (source2 == null)
  68. throw new ArgumentNullException(nameof(source2));
  69. if (source3 == null)
  70. throw new ArgumentNullException(nameof(source3));
  71. return Create<(T1, T2, T3)>(async observer =>
  72. {
  73. var d = new CompositeAsyncDisposable();
  74. var (observer1, observer2, observer3) = AsyncObserver.CombineLatest(observer);
  75. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  76. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  77. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  78. await Task.WhenAll(sub1, sub2, sub3).ConfigureAwait(false);
  79. return d;
  80. });
  81. }
  82. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, Func<T1, T2, T3, TResult> selector)
  83. {
  84. if (source1 == null)
  85. throw new ArgumentNullException(nameof(source1));
  86. if (source2 == null)
  87. throw new ArgumentNullException(nameof(source2));
  88. if (source3 == null)
  89. throw new ArgumentNullException(nameof(source3));
  90. if (selector == null)
  91. throw new ArgumentNullException(nameof(selector));
  92. return Create<TResult>(async observer =>
  93. {
  94. var d = new CompositeAsyncDisposable();
  95. var (observer1, observer2, observer3) = AsyncObserver.CombineLatest(observer, selector);
  96. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  97. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  98. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  99. await Task.WhenAll(sub1, sub2, sub3).ConfigureAwait(false);
  100. return d;
  101. });
  102. }
  103. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, Func<T1, T2, T3, ValueTask<TResult>> selector)
  104. {
  105. if (source1 == null)
  106. throw new ArgumentNullException(nameof(source1));
  107. if (source2 == null)
  108. throw new ArgumentNullException(nameof(source2));
  109. if (source3 == null)
  110. throw new ArgumentNullException(nameof(source3));
  111. if (selector == null)
  112. throw new ArgumentNullException(nameof(selector));
  113. return Create<TResult>(async observer =>
  114. {
  115. var d = new CompositeAsyncDisposable();
  116. var (observer1, observer2, observer3) = AsyncObserver.CombineLatest(observer, selector);
  117. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  118. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  119. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  120. await Task.WhenAll(sub1, sub2, sub3).ConfigureAwait(false);
  121. return d;
  122. });
  123. }
  124. public static IAsyncObservable<(T1, T2, T3, T4)> CombineLatest<T1, T2, T3, T4>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4)
  125. {
  126. if (source1 == null)
  127. throw new ArgumentNullException(nameof(source1));
  128. if (source2 == null)
  129. throw new ArgumentNullException(nameof(source2));
  130. if (source3 == null)
  131. throw new ArgumentNullException(nameof(source3));
  132. if (source4 == null)
  133. throw new ArgumentNullException(nameof(source4));
  134. return Create<(T1, T2, T3, T4)>(async observer =>
  135. {
  136. var d = new CompositeAsyncDisposable();
  137. var (observer1, observer2, observer3, observer4) = AsyncObserver.CombineLatest(observer);
  138. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  139. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  140. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  141. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  142. await Task.WhenAll(sub1, sub2, sub3, sub4).ConfigureAwait(false);
  143. return d;
  144. });
  145. }
  146. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, Func<T1, T2, T3, T4, TResult> selector)
  147. {
  148. if (source1 == null)
  149. throw new ArgumentNullException(nameof(source1));
  150. if (source2 == null)
  151. throw new ArgumentNullException(nameof(source2));
  152. if (source3 == null)
  153. throw new ArgumentNullException(nameof(source3));
  154. if (source4 == null)
  155. throw new ArgumentNullException(nameof(source4));
  156. if (selector == null)
  157. throw new ArgumentNullException(nameof(selector));
  158. return Create<TResult>(async observer =>
  159. {
  160. var d = new CompositeAsyncDisposable();
  161. var (observer1, observer2, observer3, observer4) = AsyncObserver.CombineLatest(observer, selector);
  162. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  163. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  164. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  165. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  166. await Task.WhenAll(sub1, sub2, sub3, sub4).ConfigureAwait(false);
  167. return d;
  168. });
  169. }
  170. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, Func<T1, T2, T3, T4, ValueTask<TResult>> selector)
  171. {
  172. if (source1 == null)
  173. throw new ArgumentNullException(nameof(source1));
  174. if (source2 == null)
  175. throw new ArgumentNullException(nameof(source2));
  176. if (source3 == null)
  177. throw new ArgumentNullException(nameof(source3));
  178. if (source4 == null)
  179. throw new ArgumentNullException(nameof(source4));
  180. if (selector == null)
  181. throw new ArgumentNullException(nameof(selector));
  182. return Create<TResult>(async observer =>
  183. {
  184. var d = new CompositeAsyncDisposable();
  185. var (observer1, observer2, observer3, observer4) = AsyncObserver.CombineLatest(observer, selector);
  186. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  187. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  188. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  189. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  190. await Task.WhenAll(sub1, sub2, sub3, sub4).ConfigureAwait(false);
  191. return d;
  192. });
  193. }
  194. public static IAsyncObservable<(T1, T2, T3, T4, T5)> CombineLatest<T1, T2, T3, T4, T5>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5)
  195. {
  196. if (source1 == null)
  197. throw new ArgumentNullException(nameof(source1));
  198. if (source2 == null)
  199. throw new ArgumentNullException(nameof(source2));
  200. if (source3 == null)
  201. throw new ArgumentNullException(nameof(source3));
  202. if (source4 == null)
  203. throw new ArgumentNullException(nameof(source4));
  204. if (source5 == null)
  205. throw new ArgumentNullException(nameof(source5));
  206. return Create<(T1, T2, T3, T4, T5)>(async observer =>
  207. {
  208. var d = new CompositeAsyncDisposable();
  209. var (observer1, observer2, observer3, observer4, observer5) = AsyncObserver.CombineLatest(observer);
  210. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  211. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  212. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  213. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  214. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  215. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5).ConfigureAwait(false);
  216. return d;
  217. });
  218. }
  219. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, Func<T1, T2, T3, T4, T5, TResult> selector)
  220. {
  221. if (source1 == null)
  222. throw new ArgumentNullException(nameof(source1));
  223. if (source2 == null)
  224. throw new ArgumentNullException(nameof(source2));
  225. if (source3 == null)
  226. throw new ArgumentNullException(nameof(source3));
  227. if (source4 == null)
  228. throw new ArgumentNullException(nameof(source4));
  229. if (source5 == null)
  230. throw new ArgumentNullException(nameof(source5));
  231. if (selector == null)
  232. throw new ArgumentNullException(nameof(selector));
  233. return Create<TResult>(async observer =>
  234. {
  235. var d = new CompositeAsyncDisposable();
  236. var (observer1, observer2, observer3, observer4, observer5) = AsyncObserver.CombineLatest(observer, selector);
  237. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  238. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  239. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  240. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  241. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  242. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5).ConfigureAwait(false);
  243. return d;
  244. });
  245. }
  246. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, Func<T1, T2, T3, T4, T5, ValueTask<TResult>> selector)
  247. {
  248. if (source1 == null)
  249. throw new ArgumentNullException(nameof(source1));
  250. if (source2 == null)
  251. throw new ArgumentNullException(nameof(source2));
  252. if (source3 == null)
  253. throw new ArgumentNullException(nameof(source3));
  254. if (source4 == null)
  255. throw new ArgumentNullException(nameof(source4));
  256. if (source5 == null)
  257. throw new ArgumentNullException(nameof(source5));
  258. if (selector == null)
  259. throw new ArgumentNullException(nameof(selector));
  260. return Create<TResult>(async observer =>
  261. {
  262. var d = new CompositeAsyncDisposable();
  263. var (observer1, observer2, observer3, observer4, observer5) = AsyncObserver.CombineLatest(observer, selector);
  264. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  265. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  266. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  267. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  268. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  269. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5).ConfigureAwait(false);
  270. return d;
  271. });
  272. }
  273. public static IAsyncObservable<(T1, T2, T3, T4, T5, T6)> CombineLatest<T1, T2, T3, T4, T5, T6>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6)
  274. {
  275. if (source1 == null)
  276. throw new ArgumentNullException(nameof(source1));
  277. if (source2 == null)
  278. throw new ArgumentNullException(nameof(source2));
  279. if (source3 == null)
  280. throw new ArgumentNullException(nameof(source3));
  281. if (source4 == null)
  282. throw new ArgumentNullException(nameof(source4));
  283. if (source5 == null)
  284. throw new ArgumentNullException(nameof(source5));
  285. if (source6 == null)
  286. throw new ArgumentNullException(nameof(source6));
  287. return Create<(T1, T2, T3, T4, T5, T6)>(async observer =>
  288. {
  289. var d = new CompositeAsyncDisposable();
  290. var (observer1, observer2, observer3, observer4, observer5, observer6) = AsyncObserver.CombineLatest(observer);
  291. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  292. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  293. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  294. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  295. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  296. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  297. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6).ConfigureAwait(false);
  298. return d;
  299. });
  300. }
  301. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, Func<T1, T2, T3, T4, T5, T6, TResult> selector)
  302. {
  303. if (source1 == null)
  304. throw new ArgumentNullException(nameof(source1));
  305. if (source2 == null)
  306. throw new ArgumentNullException(nameof(source2));
  307. if (source3 == null)
  308. throw new ArgumentNullException(nameof(source3));
  309. if (source4 == null)
  310. throw new ArgumentNullException(nameof(source4));
  311. if (source5 == null)
  312. throw new ArgumentNullException(nameof(source5));
  313. if (source6 == null)
  314. throw new ArgumentNullException(nameof(source6));
  315. if (selector == null)
  316. throw new ArgumentNullException(nameof(selector));
  317. return Create<TResult>(async observer =>
  318. {
  319. var d = new CompositeAsyncDisposable();
  320. var (observer1, observer2, observer3, observer4, observer5, observer6) = AsyncObserver.CombineLatest(observer, selector);
  321. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  322. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  323. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  324. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  325. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  326. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  327. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6).ConfigureAwait(false);
  328. return d;
  329. });
  330. }
  331. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, Func<T1, T2, T3, T4, T5, T6, ValueTask<TResult>> selector)
  332. {
  333. if (source1 == null)
  334. throw new ArgumentNullException(nameof(source1));
  335. if (source2 == null)
  336. throw new ArgumentNullException(nameof(source2));
  337. if (source3 == null)
  338. throw new ArgumentNullException(nameof(source3));
  339. if (source4 == null)
  340. throw new ArgumentNullException(nameof(source4));
  341. if (source5 == null)
  342. throw new ArgumentNullException(nameof(source5));
  343. if (source6 == null)
  344. throw new ArgumentNullException(nameof(source6));
  345. if (selector == null)
  346. throw new ArgumentNullException(nameof(selector));
  347. return Create<TResult>(async observer =>
  348. {
  349. var d = new CompositeAsyncDisposable();
  350. var (observer1, observer2, observer3, observer4, observer5, observer6) = AsyncObserver.CombineLatest(observer, selector);
  351. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  352. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  353. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  354. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  355. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  356. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  357. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6).ConfigureAwait(false);
  358. return d;
  359. });
  360. }
  361. public static IAsyncObservable<(T1, T2, T3, T4, T5, T6, T7)> CombineLatest<T1, T2, T3, T4, T5, T6, T7>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7)
  362. {
  363. if (source1 == null)
  364. throw new ArgumentNullException(nameof(source1));
  365. if (source2 == null)
  366. throw new ArgumentNullException(nameof(source2));
  367. if (source3 == null)
  368. throw new ArgumentNullException(nameof(source3));
  369. if (source4 == null)
  370. throw new ArgumentNullException(nameof(source4));
  371. if (source5 == null)
  372. throw new ArgumentNullException(nameof(source5));
  373. if (source6 == null)
  374. throw new ArgumentNullException(nameof(source6));
  375. if (source7 == null)
  376. throw new ArgumentNullException(nameof(source7));
  377. return Create<(T1, T2, T3, T4, T5, T6, T7)>(async observer =>
  378. {
  379. var d = new CompositeAsyncDisposable();
  380. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7) = AsyncObserver.CombineLatest(observer);
  381. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  382. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  383. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  384. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  385. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  386. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  387. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  388. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7).ConfigureAwait(false);
  389. return d;
  390. });
  391. }
  392. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, Func<T1, T2, T3, T4, T5, T6, T7, TResult> selector)
  393. {
  394. if (source1 == null)
  395. throw new ArgumentNullException(nameof(source1));
  396. if (source2 == null)
  397. throw new ArgumentNullException(nameof(source2));
  398. if (source3 == null)
  399. throw new ArgumentNullException(nameof(source3));
  400. if (source4 == null)
  401. throw new ArgumentNullException(nameof(source4));
  402. if (source5 == null)
  403. throw new ArgumentNullException(nameof(source5));
  404. if (source6 == null)
  405. throw new ArgumentNullException(nameof(source6));
  406. if (source7 == null)
  407. throw new ArgumentNullException(nameof(source7));
  408. if (selector == null)
  409. throw new ArgumentNullException(nameof(selector));
  410. return Create<TResult>(async observer =>
  411. {
  412. var d = new CompositeAsyncDisposable();
  413. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7) = AsyncObserver.CombineLatest(observer, selector);
  414. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  415. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  416. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  417. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  418. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  419. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  420. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  421. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7).ConfigureAwait(false);
  422. return d;
  423. });
  424. }
  425. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, Func<T1, T2, T3, T4, T5, T6, T7, ValueTask<TResult>> selector)
  426. {
  427. if (source1 == null)
  428. throw new ArgumentNullException(nameof(source1));
  429. if (source2 == null)
  430. throw new ArgumentNullException(nameof(source2));
  431. if (source3 == null)
  432. throw new ArgumentNullException(nameof(source3));
  433. if (source4 == null)
  434. throw new ArgumentNullException(nameof(source4));
  435. if (source5 == null)
  436. throw new ArgumentNullException(nameof(source5));
  437. if (source6 == null)
  438. throw new ArgumentNullException(nameof(source6));
  439. if (source7 == null)
  440. throw new ArgumentNullException(nameof(source7));
  441. if (selector == null)
  442. throw new ArgumentNullException(nameof(selector));
  443. return Create<TResult>(async observer =>
  444. {
  445. var d = new CompositeAsyncDisposable();
  446. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7) = AsyncObserver.CombineLatest(observer, selector);
  447. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  448. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  449. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  450. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  451. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  452. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  453. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  454. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7).ConfigureAwait(false);
  455. return d;
  456. });
  457. }
  458. public static IAsyncObservable<(T1, T2, T3, T4, T5, T6, T7, T8)> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8)
  459. {
  460. if (source1 == null)
  461. throw new ArgumentNullException(nameof(source1));
  462. if (source2 == null)
  463. throw new ArgumentNullException(nameof(source2));
  464. if (source3 == null)
  465. throw new ArgumentNullException(nameof(source3));
  466. if (source4 == null)
  467. throw new ArgumentNullException(nameof(source4));
  468. if (source5 == null)
  469. throw new ArgumentNullException(nameof(source5));
  470. if (source6 == null)
  471. throw new ArgumentNullException(nameof(source6));
  472. if (source7 == null)
  473. throw new ArgumentNullException(nameof(source7));
  474. if (source8 == null)
  475. throw new ArgumentNullException(nameof(source8));
  476. return Create<(T1, T2, T3, T4, T5, T6, T7, T8)>(async observer =>
  477. {
  478. var d = new CompositeAsyncDisposable();
  479. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8) = AsyncObserver.CombineLatest(observer);
  480. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  481. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  482. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  483. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  484. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  485. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  486. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  487. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  488. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8).ConfigureAwait(false);
  489. return d;
  490. });
  491. }
  492. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> selector)
  493. {
  494. if (source1 == null)
  495. throw new ArgumentNullException(nameof(source1));
  496. if (source2 == null)
  497. throw new ArgumentNullException(nameof(source2));
  498. if (source3 == null)
  499. throw new ArgumentNullException(nameof(source3));
  500. if (source4 == null)
  501. throw new ArgumentNullException(nameof(source4));
  502. if (source5 == null)
  503. throw new ArgumentNullException(nameof(source5));
  504. if (source6 == null)
  505. throw new ArgumentNullException(nameof(source6));
  506. if (source7 == null)
  507. throw new ArgumentNullException(nameof(source7));
  508. if (source8 == null)
  509. throw new ArgumentNullException(nameof(source8));
  510. if (selector == null)
  511. throw new ArgumentNullException(nameof(selector));
  512. return Create<TResult>(async observer =>
  513. {
  514. var d = new CompositeAsyncDisposable();
  515. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8) = AsyncObserver.CombineLatest(observer, selector);
  516. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  517. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  518. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  519. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  520. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  521. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  522. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  523. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  524. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8).ConfigureAwait(false);
  525. return d;
  526. });
  527. }
  528. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, Func<T1, T2, T3, T4, T5, T6, T7, T8, ValueTask<TResult>> selector)
  529. {
  530. if (source1 == null)
  531. throw new ArgumentNullException(nameof(source1));
  532. if (source2 == null)
  533. throw new ArgumentNullException(nameof(source2));
  534. if (source3 == null)
  535. throw new ArgumentNullException(nameof(source3));
  536. if (source4 == null)
  537. throw new ArgumentNullException(nameof(source4));
  538. if (source5 == null)
  539. throw new ArgumentNullException(nameof(source5));
  540. if (source6 == null)
  541. throw new ArgumentNullException(nameof(source6));
  542. if (source7 == null)
  543. throw new ArgumentNullException(nameof(source7));
  544. if (source8 == null)
  545. throw new ArgumentNullException(nameof(source8));
  546. if (selector == null)
  547. throw new ArgumentNullException(nameof(selector));
  548. return Create<TResult>(async observer =>
  549. {
  550. var d = new CompositeAsyncDisposable();
  551. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8) = AsyncObserver.CombineLatest(observer, selector);
  552. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  553. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  554. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  555. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  556. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  557. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  558. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  559. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  560. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8).ConfigureAwait(false);
  561. return d;
  562. });
  563. }
  564. public static IAsyncObservable<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9)
  565. {
  566. if (source1 == null)
  567. throw new ArgumentNullException(nameof(source1));
  568. if (source2 == null)
  569. throw new ArgumentNullException(nameof(source2));
  570. if (source3 == null)
  571. throw new ArgumentNullException(nameof(source3));
  572. if (source4 == null)
  573. throw new ArgumentNullException(nameof(source4));
  574. if (source5 == null)
  575. throw new ArgumentNullException(nameof(source5));
  576. if (source6 == null)
  577. throw new ArgumentNullException(nameof(source6));
  578. if (source7 == null)
  579. throw new ArgumentNullException(nameof(source7));
  580. if (source8 == null)
  581. throw new ArgumentNullException(nameof(source8));
  582. if (source9 == null)
  583. throw new ArgumentNullException(nameof(source9));
  584. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9)>(async observer =>
  585. {
  586. var d = new CompositeAsyncDisposable();
  587. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9) = AsyncObserver.CombineLatest(observer);
  588. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  589. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  590. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  591. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  592. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  593. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  594. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  595. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  596. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  597. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9).ConfigureAwait(false);
  598. return d;
  599. });
  600. }
  601. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> selector)
  602. {
  603. if (source1 == null)
  604. throw new ArgumentNullException(nameof(source1));
  605. if (source2 == null)
  606. throw new ArgumentNullException(nameof(source2));
  607. if (source3 == null)
  608. throw new ArgumentNullException(nameof(source3));
  609. if (source4 == null)
  610. throw new ArgumentNullException(nameof(source4));
  611. if (source5 == null)
  612. throw new ArgumentNullException(nameof(source5));
  613. if (source6 == null)
  614. throw new ArgumentNullException(nameof(source6));
  615. if (source7 == null)
  616. throw new ArgumentNullException(nameof(source7));
  617. if (source8 == null)
  618. throw new ArgumentNullException(nameof(source8));
  619. if (source9 == null)
  620. throw new ArgumentNullException(nameof(source9));
  621. if (selector == null)
  622. throw new ArgumentNullException(nameof(selector));
  623. return Create<TResult>(async observer =>
  624. {
  625. var d = new CompositeAsyncDisposable();
  626. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9) = AsyncObserver.CombineLatest(observer, selector);
  627. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  628. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  629. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  630. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  631. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  632. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  633. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  634. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  635. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  636. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9).ConfigureAwait(false);
  637. return d;
  638. });
  639. }
  640. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, ValueTask<TResult>> selector)
  641. {
  642. if (source1 == null)
  643. throw new ArgumentNullException(nameof(source1));
  644. if (source2 == null)
  645. throw new ArgumentNullException(nameof(source2));
  646. if (source3 == null)
  647. throw new ArgumentNullException(nameof(source3));
  648. if (source4 == null)
  649. throw new ArgumentNullException(nameof(source4));
  650. if (source5 == null)
  651. throw new ArgumentNullException(nameof(source5));
  652. if (source6 == null)
  653. throw new ArgumentNullException(nameof(source6));
  654. if (source7 == null)
  655. throw new ArgumentNullException(nameof(source7));
  656. if (source8 == null)
  657. throw new ArgumentNullException(nameof(source8));
  658. if (source9 == null)
  659. throw new ArgumentNullException(nameof(source9));
  660. if (selector == null)
  661. throw new ArgumentNullException(nameof(selector));
  662. return Create<TResult>(async observer =>
  663. {
  664. var d = new CompositeAsyncDisposable();
  665. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9) = AsyncObserver.CombineLatest(observer, selector);
  666. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  667. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  668. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  669. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  670. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  671. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  672. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  673. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  674. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  675. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9).ConfigureAwait(false);
  676. return d;
  677. });
  678. }
  679. public static IAsyncObservable<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10)
  680. {
  681. if (source1 == null)
  682. throw new ArgumentNullException(nameof(source1));
  683. if (source2 == null)
  684. throw new ArgumentNullException(nameof(source2));
  685. if (source3 == null)
  686. throw new ArgumentNullException(nameof(source3));
  687. if (source4 == null)
  688. throw new ArgumentNullException(nameof(source4));
  689. if (source5 == null)
  690. throw new ArgumentNullException(nameof(source5));
  691. if (source6 == null)
  692. throw new ArgumentNullException(nameof(source6));
  693. if (source7 == null)
  694. throw new ArgumentNullException(nameof(source7));
  695. if (source8 == null)
  696. throw new ArgumentNullException(nameof(source8));
  697. if (source9 == null)
  698. throw new ArgumentNullException(nameof(source9));
  699. if (source10 == null)
  700. throw new ArgumentNullException(nameof(source10));
  701. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>(async observer =>
  702. {
  703. var d = new CompositeAsyncDisposable();
  704. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10) = AsyncObserver.CombineLatest(observer);
  705. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  706. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  707. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  708. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  709. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  710. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  711. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  712. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  713. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  714. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  715. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10).ConfigureAwait(false);
  716. return d;
  717. });
  718. }
  719. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> selector)
  720. {
  721. if (source1 == null)
  722. throw new ArgumentNullException(nameof(source1));
  723. if (source2 == null)
  724. throw new ArgumentNullException(nameof(source2));
  725. if (source3 == null)
  726. throw new ArgumentNullException(nameof(source3));
  727. if (source4 == null)
  728. throw new ArgumentNullException(nameof(source4));
  729. if (source5 == null)
  730. throw new ArgumentNullException(nameof(source5));
  731. if (source6 == null)
  732. throw new ArgumentNullException(nameof(source6));
  733. if (source7 == null)
  734. throw new ArgumentNullException(nameof(source7));
  735. if (source8 == null)
  736. throw new ArgumentNullException(nameof(source8));
  737. if (source9 == null)
  738. throw new ArgumentNullException(nameof(source9));
  739. if (source10 == null)
  740. throw new ArgumentNullException(nameof(source10));
  741. if (selector == null)
  742. throw new ArgumentNullException(nameof(selector));
  743. return Create<TResult>(async observer =>
  744. {
  745. var d = new CompositeAsyncDisposable();
  746. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10) = AsyncObserver.CombineLatest(observer, selector);
  747. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  748. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  749. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  750. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  751. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  752. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  753. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  754. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  755. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  756. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  757. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10).ConfigureAwait(false);
  758. return d;
  759. });
  760. }
  761. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, ValueTask<TResult>> selector)
  762. {
  763. if (source1 == null)
  764. throw new ArgumentNullException(nameof(source1));
  765. if (source2 == null)
  766. throw new ArgumentNullException(nameof(source2));
  767. if (source3 == null)
  768. throw new ArgumentNullException(nameof(source3));
  769. if (source4 == null)
  770. throw new ArgumentNullException(nameof(source4));
  771. if (source5 == null)
  772. throw new ArgumentNullException(nameof(source5));
  773. if (source6 == null)
  774. throw new ArgumentNullException(nameof(source6));
  775. if (source7 == null)
  776. throw new ArgumentNullException(nameof(source7));
  777. if (source8 == null)
  778. throw new ArgumentNullException(nameof(source8));
  779. if (source9 == null)
  780. throw new ArgumentNullException(nameof(source9));
  781. if (source10 == null)
  782. throw new ArgumentNullException(nameof(source10));
  783. if (selector == null)
  784. throw new ArgumentNullException(nameof(selector));
  785. return Create<TResult>(async observer =>
  786. {
  787. var d = new CompositeAsyncDisposable();
  788. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10) = AsyncObserver.CombineLatest(observer, selector);
  789. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  790. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  791. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  792. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  793. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  794. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  795. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  796. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  797. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  798. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  799. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10).ConfigureAwait(false);
  800. return d;
  801. });
  802. }
  803. public static IAsyncObservable<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11)
  804. {
  805. if (source1 == null)
  806. throw new ArgumentNullException(nameof(source1));
  807. if (source2 == null)
  808. throw new ArgumentNullException(nameof(source2));
  809. if (source3 == null)
  810. throw new ArgumentNullException(nameof(source3));
  811. if (source4 == null)
  812. throw new ArgumentNullException(nameof(source4));
  813. if (source5 == null)
  814. throw new ArgumentNullException(nameof(source5));
  815. if (source6 == null)
  816. throw new ArgumentNullException(nameof(source6));
  817. if (source7 == null)
  818. throw new ArgumentNullException(nameof(source7));
  819. if (source8 == null)
  820. throw new ArgumentNullException(nameof(source8));
  821. if (source9 == null)
  822. throw new ArgumentNullException(nameof(source9));
  823. if (source10 == null)
  824. throw new ArgumentNullException(nameof(source10));
  825. if (source11 == null)
  826. throw new ArgumentNullException(nameof(source11));
  827. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>(async observer =>
  828. {
  829. var d = new CompositeAsyncDisposable();
  830. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11) = AsyncObserver.CombineLatest(observer);
  831. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  832. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  833. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  834. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  835. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  836. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  837. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  838. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  839. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  840. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  841. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  842. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11).ConfigureAwait(false);
  843. return d;
  844. });
  845. }
  846. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> selector)
  847. {
  848. if (source1 == null)
  849. throw new ArgumentNullException(nameof(source1));
  850. if (source2 == null)
  851. throw new ArgumentNullException(nameof(source2));
  852. if (source3 == null)
  853. throw new ArgumentNullException(nameof(source3));
  854. if (source4 == null)
  855. throw new ArgumentNullException(nameof(source4));
  856. if (source5 == null)
  857. throw new ArgumentNullException(nameof(source5));
  858. if (source6 == null)
  859. throw new ArgumentNullException(nameof(source6));
  860. if (source7 == null)
  861. throw new ArgumentNullException(nameof(source7));
  862. if (source8 == null)
  863. throw new ArgumentNullException(nameof(source8));
  864. if (source9 == null)
  865. throw new ArgumentNullException(nameof(source9));
  866. if (source10 == null)
  867. throw new ArgumentNullException(nameof(source10));
  868. if (source11 == null)
  869. throw new ArgumentNullException(nameof(source11));
  870. if (selector == null)
  871. throw new ArgumentNullException(nameof(selector));
  872. return Create<TResult>(async observer =>
  873. {
  874. var d = new CompositeAsyncDisposable();
  875. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11) = AsyncObserver.CombineLatest(observer, selector);
  876. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  877. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  878. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  879. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  880. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  881. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  882. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  883. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  884. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  885. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  886. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  887. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11).ConfigureAwait(false);
  888. return d;
  889. });
  890. }
  891. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ValueTask<TResult>> selector)
  892. {
  893. if (source1 == null)
  894. throw new ArgumentNullException(nameof(source1));
  895. if (source2 == null)
  896. throw new ArgumentNullException(nameof(source2));
  897. if (source3 == null)
  898. throw new ArgumentNullException(nameof(source3));
  899. if (source4 == null)
  900. throw new ArgumentNullException(nameof(source4));
  901. if (source5 == null)
  902. throw new ArgumentNullException(nameof(source5));
  903. if (source6 == null)
  904. throw new ArgumentNullException(nameof(source6));
  905. if (source7 == null)
  906. throw new ArgumentNullException(nameof(source7));
  907. if (source8 == null)
  908. throw new ArgumentNullException(nameof(source8));
  909. if (source9 == null)
  910. throw new ArgumentNullException(nameof(source9));
  911. if (source10 == null)
  912. throw new ArgumentNullException(nameof(source10));
  913. if (source11 == null)
  914. throw new ArgumentNullException(nameof(source11));
  915. if (selector == null)
  916. throw new ArgumentNullException(nameof(selector));
  917. return Create<TResult>(async observer =>
  918. {
  919. var d = new CompositeAsyncDisposable();
  920. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11) = AsyncObserver.CombineLatest(observer, selector);
  921. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  922. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  923. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  924. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  925. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  926. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  927. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  928. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  929. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  930. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  931. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  932. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11).ConfigureAwait(false);
  933. return d;
  934. });
  935. }
  936. public static IAsyncObservable<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12)
  937. {
  938. if (source1 == null)
  939. throw new ArgumentNullException(nameof(source1));
  940. if (source2 == null)
  941. throw new ArgumentNullException(nameof(source2));
  942. if (source3 == null)
  943. throw new ArgumentNullException(nameof(source3));
  944. if (source4 == null)
  945. throw new ArgumentNullException(nameof(source4));
  946. if (source5 == null)
  947. throw new ArgumentNullException(nameof(source5));
  948. if (source6 == null)
  949. throw new ArgumentNullException(nameof(source6));
  950. if (source7 == null)
  951. throw new ArgumentNullException(nameof(source7));
  952. if (source8 == null)
  953. throw new ArgumentNullException(nameof(source8));
  954. if (source9 == null)
  955. throw new ArgumentNullException(nameof(source9));
  956. if (source10 == null)
  957. throw new ArgumentNullException(nameof(source10));
  958. if (source11 == null)
  959. throw new ArgumentNullException(nameof(source11));
  960. if (source12 == null)
  961. throw new ArgumentNullException(nameof(source12));
  962. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)>(async observer =>
  963. {
  964. var d = new CompositeAsyncDisposable();
  965. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12) = AsyncObserver.CombineLatest(observer);
  966. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  967. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  968. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  969. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  970. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  971. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  972. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  973. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  974. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  975. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  976. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  977. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  978. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12).ConfigureAwait(false);
  979. return d;
  980. });
  981. }
  982. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> selector)
  983. {
  984. if (source1 == null)
  985. throw new ArgumentNullException(nameof(source1));
  986. if (source2 == null)
  987. throw new ArgumentNullException(nameof(source2));
  988. if (source3 == null)
  989. throw new ArgumentNullException(nameof(source3));
  990. if (source4 == null)
  991. throw new ArgumentNullException(nameof(source4));
  992. if (source5 == null)
  993. throw new ArgumentNullException(nameof(source5));
  994. if (source6 == null)
  995. throw new ArgumentNullException(nameof(source6));
  996. if (source7 == null)
  997. throw new ArgumentNullException(nameof(source7));
  998. if (source8 == null)
  999. throw new ArgumentNullException(nameof(source8));
  1000. if (source9 == null)
  1001. throw new ArgumentNullException(nameof(source9));
  1002. if (source10 == null)
  1003. throw new ArgumentNullException(nameof(source10));
  1004. if (source11 == null)
  1005. throw new ArgumentNullException(nameof(source11));
  1006. if (source12 == null)
  1007. throw new ArgumentNullException(nameof(source12));
  1008. if (selector == null)
  1009. throw new ArgumentNullException(nameof(selector));
  1010. return Create<TResult>(async observer =>
  1011. {
  1012. var d = new CompositeAsyncDisposable();
  1013. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12) = AsyncObserver.CombineLatest(observer, selector);
  1014. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1015. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1016. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1017. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1018. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1019. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1020. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1021. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1022. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1023. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1024. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1025. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1026. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12).ConfigureAwait(false);
  1027. return d;
  1028. });
  1029. }
  1030. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ValueTask<TResult>> selector)
  1031. {
  1032. if (source1 == null)
  1033. throw new ArgumentNullException(nameof(source1));
  1034. if (source2 == null)
  1035. throw new ArgumentNullException(nameof(source2));
  1036. if (source3 == null)
  1037. throw new ArgumentNullException(nameof(source3));
  1038. if (source4 == null)
  1039. throw new ArgumentNullException(nameof(source4));
  1040. if (source5 == null)
  1041. throw new ArgumentNullException(nameof(source5));
  1042. if (source6 == null)
  1043. throw new ArgumentNullException(nameof(source6));
  1044. if (source7 == null)
  1045. throw new ArgumentNullException(nameof(source7));
  1046. if (source8 == null)
  1047. throw new ArgumentNullException(nameof(source8));
  1048. if (source9 == null)
  1049. throw new ArgumentNullException(nameof(source9));
  1050. if (source10 == null)
  1051. throw new ArgumentNullException(nameof(source10));
  1052. if (source11 == null)
  1053. throw new ArgumentNullException(nameof(source11));
  1054. if (source12 == null)
  1055. throw new ArgumentNullException(nameof(source12));
  1056. if (selector == null)
  1057. throw new ArgumentNullException(nameof(selector));
  1058. return Create<TResult>(async observer =>
  1059. {
  1060. var d = new CompositeAsyncDisposable();
  1061. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12) = AsyncObserver.CombineLatest(observer, selector);
  1062. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1063. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1064. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1065. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1066. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1067. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1068. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1069. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1070. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1071. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1072. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1073. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1074. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12).ConfigureAwait(false);
  1075. return d;
  1076. });
  1077. }
  1078. public static IAsyncObservable<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12, IAsyncObservable<T13> source13)
  1079. {
  1080. if (source1 == null)
  1081. throw new ArgumentNullException(nameof(source1));
  1082. if (source2 == null)
  1083. throw new ArgumentNullException(nameof(source2));
  1084. if (source3 == null)
  1085. throw new ArgumentNullException(nameof(source3));
  1086. if (source4 == null)
  1087. throw new ArgumentNullException(nameof(source4));
  1088. if (source5 == null)
  1089. throw new ArgumentNullException(nameof(source5));
  1090. if (source6 == null)
  1091. throw new ArgumentNullException(nameof(source6));
  1092. if (source7 == null)
  1093. throw new ArgumentNullException(nameof(source7));
  1094. if (source8 == null)
  1095. throw new ArgumentNullException(nameof(source8));
  1096. if (source9 == null)
  1097. throw new ArgumentNullException(nameof(source9));
  1098. if (source10 == null)
  1099. throw new ArgumentNullException(nameof(source10));
  1100. if (source11 == null)
  1101. throw new ArgumentNullException(nameof(source11));
  1102. if (source12 == null)
  1103. throw new ArgumentNullException(nameof(source12));
  1104. if (source13 == null)
  1105. throw new ArgumentNullException(nameof(source13));
  1106. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)>(async observer =>
  1107. {
  1108. var d = new CompositeAsyncDisposable();
  1109. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13) = AsyncObserver.CombineLatest(observer);
  1110. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1111. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1112. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1113. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1114. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1115. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1116. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1117. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1118. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1119. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1120. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1121. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1122. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1123. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13).ConfigureAwait(false);
  1124. return d;
  1125. });
  1126. }
  1127. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12, IAsyncObservable<T13> source13, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> selector)
  1128. {
  1129. if (source1 == null)
  1130. throw new ArgumentNullException(nameof(source1));
  1131. if (source2 == null)
  1132. throw new ArgumentNullException(nameof(source2));
  1133. if (source3 == null)
  1134. throw new ArgumentNullException(nameof(source3));
  1135. if (source4 == null)
  1136. throw new ArgumentNullException(nameof(source4));
  1137. if (source5 == null)
  1138. throw new ArgumentNullException(nameof(source5));
  1139. if (source6 == null)
  1140. throw new ArgumentNullException(nameof(source6));
  1141. if (source7 == null)
  1142. throw new ArgumentNullException(nameof(source7));
  1143. if (source8 == null)
  1144. throw new ArgumentNullException(nameof(source8));
  1145. if (source9 == null)
  1146. throw new ArgumentNullException(nameof(source9));
  1147. if (source10 == null)
  1148. throw new ArgumentNullException(nameof(source10));
  1149. if (source11 == null)
  1150. throw new ArgumentNullException(nameof(source11));
  1151. if (source12 == null)
  1152. throw new ArgumentNullException(nameof(source12));
  1153. if (source13 == null)
  1154. throw new ArgumentNullException(nameof(source13));
  1155. if (selector == null)
  1156. throw new ArgumentNullException(nameof(selector));
  1157. return Create<TResult>(async observer =>
  1158. {
  1159. var d = new CompositeAsyncDisposable();
  1160. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13) = AsyncObserver.CombineLatest(observer, selector);
  1161. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1162. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1163. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1164. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1165. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1166. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1167. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1168. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1169. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1170. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1171. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1172. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1173. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1174. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13).ConfigureAwait(false);
  1175. return d;
  1176. });
  1177. }
  1178. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12, IAsyncObservable<T13> source13, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ValueTask<TResult>> selector)
  1179. {
  1180. if (source1 == null)
  1181. throw new ArgumentNullException(nameof(source1));
  1182. if (source2 == null)
  1183. throw new ArgumentNullException(nameof(source2));
  1184. if (source3 == null)
  1185. throw new ArgumentNullException(nameof(source3));
  1186. if (source4 == null)
  1187. throw new ArgumentNullException(nameof(source4));
  1188. if (source5 == null)
  1189. throw new ArgumentNullException(nameof(source5));
  1190. if (source6 == null)
  1191. throw new ArgumentNullException(nameof(source6));
  1192. if (source7 == null)
  1193. throw new ArgumentNullException(nameof(source7));
  1194. if (source8 == null)
  1195. throw new ArgumentNullException(nameof(source8));
  1196. if (source9 == null)
  1197. throw new ArgumentNullException(nameof(source9));
  1198. if (source10 == null)
  1199. throw new ArgumentNullException(nameof(source10));
  1200. if (source11 == null)
  1201. throw new ArgumentNullException(nameof(source11));
  1202. if (source12 == null)
  1203. throw new ArgumentNullException(nameof(source12));
  1204. if (source13 == null)
  1205. throw new ArgumentNullException(nameof(source13));
  1206. if (selector == null)
  1207. throw new ArgumentNullException(nameof(selector));
  1208. return Create<TResult>(async observer =>
  1209. {
  1210. var d = new CompositeAsyncDisposable();
  1211. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13) = AsyncObserver.CombineLatest(observer, selector);
  1212. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1213. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1214. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1215. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1216. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1217. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1218. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1219. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1220. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1221. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1222. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1223. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1224. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1225. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13).ConfigureAwait(false);
  1226. return d;
  1227. });
  1228. }
  1229. public static IAsyncObservable<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12, IAsyncObservable<T13> source13, IAsyncObservable<T14> source14)
  1230. {
  1231. if (source1 == null)
  1232. throw new ArgumentNullException(nameof(source1));
  1233. if (source2 == null)
  1234. throw new ArgumentNullException(nameof(source2));
  1235. if (source3 == null)
  1236. throw new ArgumentNullException(nameof(source3));
  1237. if (source4 == null)
  1238. throw new ArgumentNullException(nameof(source4));
  1239. if (source5 == null)
  1240. throw new ArgumentNullException(nameof(source5));
  1241. if (source6 == null)
  1242. throw new ArgumentNullException(nameof(source6));
  1243. if (source7 == null)
  1244. throw new ArgumentNullException(nameof(source7));
  1245. if (source8 == null)
  1246. throw new ArgumentNullException(nameof(source8));
  1247. if (source9 == null)
  1248. throw new ArgumentNullException(nameof(source9));
  1249. if (source10 == null)
  1250. throw new ArgumentNullException(nameof(source10));
  1251. if (source11 == null)
  1252. throw new ArgumentNullException(nameof(source11));
  1253. if (source12 == null)
  1254. throw new ArgumentNullException(nameof(source12));
  1255. if (source13 == null)
  1256. throw new ArgumentNullException(nameof(source13));
  1257. if (source14 == null)
  1258. throw new ArgumentNullException(nameof(source14));
  1259. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)>(async observer =>
  1260. {
  1261. var d = new CompositeAsyncDisposable();
  1262. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14) = AsyncObserver.CombineLatest(observer);
  1263. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1264. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1265. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1266. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1267. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1268. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1269. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1270. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1271. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1272. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1273. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1274. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1275. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1276. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1277. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14).ConfigureAwait(false);
  1278. return d;
  1279. });
  1280. }
  1281. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12, IAsyncObservable<T13> source13, IAsyncObservable<T14> source14, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> selector)
  1282. {
  1283. if (source1 == null)
  1284. throw new ArgumentNullException(nameof(source1));
  1285. if (source2 == null)
  1286. throw new ArgumentNullException(nameof(source2));
  1287. if (source3 == null)
  1288. throw new ArgumentNullException(nameof(source3));
  1289. if (source4 == null)
  1290. throw new ArgumentNullException(nameof(source4));
  1291. if (source5 == null)
  1292. throw new ArgumentNullException(nameof(source5));
  1293. if (source6 == null)
  1294. throw new ArgumentNullException(nameof(source6));
  1295. if (source7 == null)
  1296. throw new ArgumentNullException(nameof(source7));
  1297. if (source8 == null)
  1298. throw new ArgumentNullException(nameof(source8));
  1299. if (source9 == null)
  1300. throw new ArgumentNullException(nameof(source9));
  1301. if (source10 == null)
  1302. throw new ArgumentNullException(nameof(source10));
  1303. if (source11 == null)
  1304. throw new ArgumentNullException(nameof(source11));
  1305. if (source12 == null)
  1306. throw new ArgumentNullException(nameof(source12));
  1307. if (source13 == null)
  1308. throw new ArgumentNullException(nameof(source13));
  1309. if (source14 == null)
  1310. throw new ArgumentNullException(nameof(source14));
  1311. if (selector == null)
  1312. throw new ArgumentNullException(nameof(selector));
  1313. return Create<TResult>(async observer =>
  1314. {
  1315. var d = new CompositeAsyncDisposable();
  1316. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14) = AsyncObserver.CombineLatest(observer, selector);
  1317. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1318. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1319. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1320. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1321. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1322. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1323. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1324. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1325. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1326. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1327. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1328. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1329. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1330. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1331. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14).ConfigureAwait(false);
  1332. return d;
  1333. });
  1334. }
  1335. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12, IAsyncObservable<T13> source13, IAsyncObservable<T14> source14, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ValueTask<TResult>> selector)
  1336. {
  1337. if (source1 == null)
  1338. throw new ArgumentNullException(nameof(source1));
  1339. if (source2 == null)
  1340. throw new ArgumentNullException(nameof(source2));
  1341. if (source3 == null)
  1342. throw new ArgumentNullException(nameof(source3));
  1343. if (source4 == null)
  1344. throw new ArgumentNullException(nameof(source4));
  1345. if (source5 == null)
  1346. throw new ArgumentNullException(nameof(source5));
  1347. if (source6 == null)
  1348. throw new ArgumentNullException(nameof(source6));
  1349. if (source7 == null)
  1350. throw new ArgumentNullException(nameof(source7));
  1351. if (source8 == null)
  1352. throw new ArgumentNullException(nameof(source8));
  1353. if (source9 == null)
  1354. throw new ArgumentNullException(nameof(source9));
  1355. if (source10 == null)
  1356. throw new ArgumentNullException(nameof(source10));
  1357. if (source11 == null)
  1358. throw new ArgumentNullException(nameof(source11));
  1359. if (source12 == null)
  1360. throw new ArgumentNullException(nameof(source12));
  1361. if (source13 == null)
  1362. throw new ArgumentNullException(nameof(source13));
  1363. if (source14 == null)
  1364. throw new ArgumentNullException(nameof(source14));
  1365. if (selector == null)
  1366. throw new ArgumentNullException(nameof(selector));
  1367. return Create<TResult>(async observer =>
  1368. {
  1369. var d = new CompositeAsyncDisposable();
  1370. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14) = AsyncObserver.CombineLatest(observer, selector);
  1371. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1372. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1373. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1374. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1375. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1376. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1377. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1378. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1379. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1380. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1381. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1382. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1383. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1384. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1385. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14).ConfigureAwait(false);
  1386. return d;
  1387. });
  1388. }
  1389. public static IAsyncObservable<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12, IAsyncObservable<T13> source13, IAsyncObservable<T14> source14, IAsyncObservable<T15> source15)
  1390. {
  1391. if (source1 == null)
  1392. throw new ArgumentNullException(nameof(source1));
  1393. if (source2 == null)
  1394. throw new ArgumentNullException(nameof(source2));
  1395. if (source3 == null)
  1396. throw new ArgumentNullException(nameof(source3));
  1397. if (source4 == null)
  1398. throw new ArgumentNullException(nameof(source4));
  1399. if (source5 == null)
  1400. throw new ArgumentNullException(nameof(source5));
  1401. if (source6 == null)
  1402. throw new ArgumentNullException(nameof(source6));
  1403. if (source7 == null)
  1404. throw new ArgumentNullException(nameof(source7));
  1405. if (source8 == null)
  1406. throw new ArgumentNullException(nameof(source8));
  1407. if (source9 == null)
  1408. throw new ArgumentNullException(nameof(source9));
  1409. if (source10 == null)
  1410. throw new ArgumentNullException(nameof(source10));
  1411. if (source11 == null)
  1412. throw new ArgumentNullException(nameof(source11));
  1413. if (source12 == null)
  1414. throw new ArgumentNullException(nameof(source12));
  1415. if (source13 == null)
  1416. throw new ArgumentNullException(nameof(source13));
  1417. if (source14 == null)
  1418. throw new ArgumentNullException(nameof(source14));
  1419. if (source15 == null)
  1420. throw new ArgumentNullException(nameof(source15));
  1421. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)>(async observer =>
  1422. {
  1423. var d = new CompositeAsyncDisposable();
  1424. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14, observer15) = AsyncObserver.CombineLatest(observer);
  1425. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1426. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1427. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1428. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1429. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1430. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1431. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1432. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1433. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1434. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1435. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1436. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1437. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1438. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1439. var sub15 = source15.SubscribeSafeAsync(observer15).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1440. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14, sub15).ConfigureAwait(false);
  1441. return d;
  1442. });
  1443. }
  1444. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12, IAsyncObservable<T13> source13, IAsyncObservable<T14> source14, IAsyncObservable<T15> source15, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> selector)
  1445. {
  1446. if (source1 == null)
  1447. throw new ArgumentNullException(nameof(source1));
  1448. if (source2 == null)
  1449. throw new ArgumentNullException(nameof(source2));
  1450. if (source3 == null)
  1451. throw new ArgumentNullException(nameof(source3));
  1452. if (source4 == null)
  1453. throw new ArgumentNullException(nameof(source4));
  1454. if (source5 == null)
  1455. throw new ArgumentNullException(nameof(source5));
  1456. if (source6 == null)
  1457. throw new ArgumentNullException(nameof(source6));
  1458. if (source7 == null)
  1459. throw new ArgumentNullException(nameof(source7));
  1460. if (source8 == null)
  1461. throw new ArgumentNullException(nameof(source8));
  1462. if (source9 == null)
  1463. throw new ArgumentNullException(nameof(source9));
  1464. if (source10 == null)
  1465. throw new ArgumentNullException(nameof(source10));
  1466. if (source11 == null)
  1467. throw new ArgumentNullException(nameof(source11));
  1468. if (source12 == null)
  1469. throw new ArgumentNullException(nameof(source12));
  1470. if (source13 == null)
  1471. throw new ArgumentNullException(nameof(source13));
  1472. if (source14 == null)
  1473. throw new ArgumentNullException(nameof(source14));
  1474. if (source15 == null)
  1475. throw new ArgumentNullException(nameof(source15));
  1476. if (selector == null)
  1477. throw new ArgumentNullException(nameof(selector));
  1478. return Create<TResult>(async observer =>
  1479. {
  1480. var d = new CompositeAsyncDisposable();
  1481. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14, observer15) = AsyncObserver.CombineLatest(observer, selector);
  1482. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1483. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1484. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1485. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1486. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1487. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1488. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1489. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1490. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1491. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1492. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1493. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1494. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1495. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1496. var sub15 = source15.SubscribeSafeAsync(observer15).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1497. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14, sub15).ConfigureAwait(false);
  1498. return d;
  1499. });
  1500. }
  1501. public static IAsyncObservable<TResult> CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3, IAsyncObservable<T4> source4, IAsyncObservable<T5> source5, IAsyncObservable<T6> source6, IAsyncObservable<T7> source7, IAsyncObservable<T8> source8, IAsyncObservable<T9> source9, IAsyncObservable<T10> source10, IAsyncObservable<T11> source11, IAsyncObservable<T12> source12, IAsyncObservable<T13> source13, IAsyncObservable<T14> source14, IAsyncObservable<T15> source15, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ValueTask<TResult>> selector)
  1502. {
  1503. if (source1 == null)
  1504. throw new ArgumentNullException(nameof(source1));
  1505. if (source2 == null)
  1506. throw new ArgumentNullException(nameof(source2));
  1507. if (source3 == null)
  1508. throw new ArgumentNullException(nameof(source3));
  1509. if (source4 == null)
  1510. throw new ArgumentNullException(nameof(source4));
  1511. if (source5 == null)
  1512. throw new ArgumentNullException(nameof(source5));
  1513. if (source6 == null)
  1514. throw new ArgumentNullException(nameof(source6));
  1515. if (source7 == null)
  1516. throw new ArgumentNullException(nameof(source7));
  1517. if (source8 == null)
  1518. throw new ArgumentNullException(nameof(source8));
  1519. if (source9 == null)
  1520. throw new ArgumentNullException(nameof(source9));
  1521. if (source10 == null)
  1522. throw new ArgumentNullException(nameof(source10));
  1523. if (source11 == null)
  1524. throw new ArgumentNullException(nameof(source11));
  1525. if (source12 == null)
  1526. throw new ArgumentNullException(nameof(source12));
  1527. if (source13 == null)
  1528. throw new ArgumentNullException(nameof(source13));
  1529. if (source14 == null)
  1530. throw new ArgumentNullException(nameof(source14));
  1531. if (source15 == null)
  1532. throw new ArgumentNullException(nameof(source15));
  1533. if (selector == null)
  1534. throw new ArgumentNullException(nameof(selector));
  1535. return Create<TResult>(async observer =>
  1536. {
  1537. var d = new CompositeAsyncDisposable();
  1538. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14, observer15) = AsyncObserver.CombineLatest(observer, selector);
  1539. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1540. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1541. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1542. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1543. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1544. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1545. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1546. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1547. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1548. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1549. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1550. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1551. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1552. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1553. var sub15 = source15.SubscribeSafeAsync(observer15).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1554. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14, sub15).ConfigureAwait(false);
  1555. return d;
  1556. });
  1557. }
  1558. }
  1559. public partial class AsyncObserver
  1560. {
  1561. public static (IAsyncObserver<T1>, IAsyncObserver<T2>) CombineLatest<T1, T2>(IAsyncObserver<(T1, T2)> observer)
  1562. {
  1563. if (observer == null)
  1564. throw new ArgumentNullException(nameof(observer));
  1565. bool allHasValue = false;
  1566. bool hasValue1 = false;
  1567. bool isDone1 = false;
  1568. T1 latestValue1 = default(T1);
  1569. bool hasValue2 = false;
  1570. bool isDone2 = false;
  1571. T2 latestValue2 = default(T2);
  1572. var gate = new AsyncGate();
  1573. return
  1574. (
  1575. Create<T1>(
  1576. async x =>
  1577. {
  1578. using (await gate.LockAsync().ConfigureAwait(false))
  1579. {
  1580. if (!hasValue1)
  1581. {
  1582. hasValue1 = true;
  1583. allHasValue = hasValue1 && hasValue2;
  1584. }
  1585. latestValue1 = x;
  1586. if (allHasValue)
  1587. {
  1588. await observer.OnNextAsync((latestValue1, latestValue2)).ConfigureAwait(false);
  1589. }
  1590. else if (isDone2)
  1591. {
  1592. await observer.OnCompletedAsync().ConfigureAwait(false);
  1593. }
  1594. }
  1595. },
  1596. async ex =>
  1597. {
  1598. using (await gate.LockAsync().ConfigureAwait(false))
  1599. {
  1600. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1601. }
  1602. },
  1603. async () =>
  1604. {
  1605. using (await gate.LockAsync().ConfigureAwait(false))
  1606. {
  1607. isDone1 = true;
  1608. if (isDone1 && isDone2)
  1609. {
  1610. await observer.OnCompletedAsync().ConfigureAwait(false);
  1611. }
  1612. }
  1613. }
  1614. ),
  1615. Create<T2>(
  1616. async x =>
  1617. {
  1618. using (await gate.LockAsync().ConfigureAwait(false))
  1619. {
  1620. if (!hasValue2)
  1621. {
  1622. hasValue2 = true;
  1623. allHasValue = hasValue1 && hasValue2;
  1624. }
  1625. latestValue2 = x;
  1626. if (allHasValue)
  1627. {
  1628. await observer.OnNextAsync((latestValue1, latestValue2)).ConfigureAwait(false);
  1629. }
  1630. else if (isDone1)
  1631. {
  1632. await observer.OnCompletedAsync().ConfigureAwait(false);
  1633. }
  1634. }
  1635. },
  1636. async ex =>
  1637. {
  1638. using (await gate.LockAsync().ConfigureAwait(false))
  1639. {
  1640. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1641. }
  1642. },
  1643. async () =>
  1644. {
  1645. using (await gate.LockAsync().ConfigureAwait(false))
  1646. {
  1647. isDone2 = true;
  1648. if (isDone1 && isDone2)
  1649. {
  1650. await observer.OnCompletedAsync().ConfigureAwait(false);
  1651. }
  1652. }
  1653. }
  1654. )
  1655. );
  1656. }
  1657. public static (IAsyncObserver<T1>, IAsyncObserver<T2>) CombineLatest<T1, T2, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, TResult> selector)
  1658. {
  1659. if (observer == null)
  1660. throw new ArgumentNullException(nameof(observer));
  1661. if (selector == null)
  1662. throw new ArgumentNullException(nameof(selector));
  1663. return CombineLatest<T1, T2, TResult>(observer, (x1, x2) => new ValueTask<TResult>(selector(x1, x2)));
  1664. }
  1665. public static (IAsyncObserver<T1>, IAsyncObserver<T2>) CombineLatest<T1, T2, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, ValueTask<TResult>> selector)
  1666. {
  1667. if (observer == null)
  1668. throw new ArgumentNullException(nameof(observer));
  1669. if (selector == null)
  1670. throw new ArgumentNullException(nameof(selector));
  1671. bool allHasValue = false;
  1672. bool hasValue1 = false;
  1673. bool isDone1 = false;
  1674. T1 latestValue1 = default(T1);
  1675. bool hasValue2 = false;
  1676. bool isDone2 = false;
  1677. T2 latestValue2 = default(T2);
  1678. var gate = new AsyncGate();
  1679. return
  1680. (
  1681. Create<T1>(
  1682. async x =>
  1683. {
  1684. using (await gate.LockAsync().ConfigureAwait(false))
  1685. {
  1686. if (!hasValue1)
  1687. {
  1688. hasValue1 = true;
  1689. allHasValue = hasValue1 && hasValue2;
  1690. }
  1691. latestValue1 = x;
  1692. if (allHasValue)
  1693. {
  1694. TResult res;
  1695. try
  1696. {
  1697. res = await selector(latestValue1, latestValue2).ConfigureAwait(false);
  1698. }
  1699. catch (Exception ex)
  1700. {
  1701. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1702. return;
  1703. }
  1704. await observer.OnNextAsync(res).ConfigureAwait(false);
  1705. }
  1706. else if (isDone2)
  1707. {
  1708. await observer.OnCompletedAsync().ConfigureAwait(false);
  1709. }
  1710. }
  1711. },
  1712. async ex =>
  1713. {
  1714. using (await gate.LockAsync().ConfigureAwait(false))
  1715. {
  1716. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1717. }
  1718. },
  1719. async () =>
  1720. {
  1721. using (await gate.LockAsync().ConfigureAwait(false))
  1722. {
  1723. isDone1 = true;
  1724. if (isDone1 && isDone2)
  1725. {
  1726. await observer.OnCompletedAsync().ConfigureAwait(false);
  1727. }
  1728. }
  1729. }
  1730. ),
  1731. Create<T2>(
  1732. async x =>
  1733. {
  1734. using (await gate.LockAsync().ConfigureAwait(false))
  1735. {
  1736. if (!hasValue2)
  1737. {
  1738. hasValue2 = true;
  1739. allHasValue = hasValue1 && hasValue2;
  1740. }
  1741. latestValue2 = x;
  1742. if (allHasValue)
  1743. {
  1744. TResult res;
  1745. try
  1746. {
  1747. res = await selector(latestValue1, latestValue2).ConfigureAwait(false);
  1748. }
  1749. catch (Exception ex)
  1750. {
  1751. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1752. return;
  1753. }
  1754. await observer.OnNextAsync(res).ConfigureAwait(false);
  1755. }
  1756. else if (isDone1)
  1757. {
  1758. await observer.OnCompletedAsync().ConfigureAwait(false);
  1759. }
  1760. }
  1761. },
  1762. async ex =>
  1763. {
  1764. using (await gate.LockAsync().ConfigureAwait(false))
  1765. {
  1766. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1767. }
  1768. },
  1769. async () =>
  1770. {
  1771. using (await gate.LockAsync().ConfigureAwait(false))
  1772. {
  1773. isDone2 = true;
  1774. if (isDone1 && isDone2)
  1775. {
  1776. await observer.OnCompletedAsync().ConfigureAwait(false);
  1777. }
  1778. }
  1779. }
  1780. )
  1781. );
  1782. }
  1783. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>) CombineLatest<T1, T2, T3>(IAsyncObserver<(T1, T2, T3)> observer)
  1784. {
  1785. if (observer == null)
  1786. throw new ArgumentNullException(nameof(observer));
  1787. bool allHasValue = false;
  1788. bool hasValue1 = false;
  1789. bool isDone1 = false;
  1790. T1 latestValue1 = default(T1);
  1791. bool hasValue2 = false;
  1792. bool isDone2 = false;
  1793. T2 latestValue2 = default(T2);
  1794. bool hasValue3 = false;
  1795. bool isDone3 = false;
  1796. T3 latestValue3 = default(T3);
  1797. var gate = new AsyncGate();
  1798. return
  1799. (
  1800. Create<T1>(
  1801. async x =>
  1802. {
  1803. using (await gate.LockAsync().ConfigureAwait(false))
  1804. {
  1805. if (!hasValue1)
  1806. {
  1807. hasValue1 = true;
  1808. allHasValue = hasValue1 && hasValue2 && hasValue3;
  1809. }
  1810. latestValue1 = x;
  1811. if (allHasValue)
  1812. {
  1813. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3)).ConfigureAwait(false);
  1814. }
  1815. else if (isDone2 && isDone3)
  1816. {
  1817. await observer.OnCompletedAsync().ConfigureAwait(false);
  1818. }
  1819. }
  1820. },
  1821. async ex =>
  1822. {
  1823. using (await gate.LockAsync().ConfigureAwait(false))
  1824. {
  1825. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1826. }
  1827. },
  1828. async () =>
  1829. {
  1830. using (await gate.LockAsync().ConfigureAwait(false))
  1831. {
  1832. isDone1 = true;
  1833. if (isDone1 && isDone2 && isDone3)
  1834. {
  1835. await observer.OnCompletedAsync().ConfigureAwait(false);
  1836. }
  1837. }
  1838. }
  1839. ),
  1840. Create<T2>(
  1841. async x =>
  1842. {
  1843. using (await gate.LockAsync().ConfigureAwait(false))
  1844. {
  1845. if (!hasValue2)
  1846. {
  1847. hasValue2 = true;
  1848. allHasValue = hasValue1 && hasValue2 && hasValue3;
  1849. }
  1850. latestValue2 = x;
  1851. if (allHasValue)
  1852. {
  1853. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3)).ConfigureAwait(false);
  1854. }
  1855. else if (isDone1 && isDone3)
  1856. {
  1857. await observer.OnCompletedAsync().ConfigureAwait(false);
  1858. }
  1859. }
  1860. },
  1861. async ex =>
  1862. {
  1863. using (await gate.LockAsync().ConfigureAwait(false))
  1864. {
  1865. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1866. }
  1867. },
  1868. async () =>
  1869. {
  1870. using (await gate.LockAsync().ConfigureAwait(false))
  1871. {
  1872. isDone2 = true;
  1873. if (isDone1 && isDone2 && isDone3)
  1874. {
  1875. await observer.OnCompletedAsync().ConfigureAwait(false);
  1876. }
  1877. }
  1878. }
  1879. ),
  1880. Create<T3>(
  1881. async x =>
  1882. {
  1883. using (await gate.LockAsync().ConfigureAwait(false))
  1884. {
  1885. if (!hasValue3)
  1886. {
  1887. hasValue3 = true;
  1888. allHasValue = hasValue1 && hasValue2 && hasValue3;
  1889. }
  1890. latestValue3 = x;
  1891. if (allHasValue)
  1892. {
  1893. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3)).ConfigureAwait(false);
  1894. }
  1895. else if (isDone1 && isDone2)
  1896. {
  1897. await observer.OnCompletedAsync().ConfigureAwait(false);
  1898. }
  1899. }
  1900. },
  1901. async ex =>
  1902. {
  1903. using (await gate.LockAsync().ConfigureAwait(false))
  1904. {
  1905. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1906. }
  1907. },
  1908. async () =>
  1909. {
  1910. using (await gate.LockAsync().ConfigureAwait(false))
  1911. {
  1912. isDone3 = true;
  1913. if (isDone1 && isDone2 && isDone3)
  1914. {
  1915. await observer.OnCompletedAsync().ConfigureAwait(false);
  1916. }
  1917. }
  1918. }
  1919. )
  1920. );
  1921. }
  1922. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>) CombineLatest<T1, T2, T3, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, TResult> selector)
  1923. {
  1924. if (observer == null)
  1925. throw new ArgumentNullException(nameof(observer));
  1926. if (selector == null)
  1927. throw new ArgumentNullException(nameof(selector));
  1928. return CombineLatest<T1, T2, T3, TResult>(observer, (x1, x2, x3) => new ValueTask<TResult>(selector(x1, x2, x3)));
  1929. }
  1930. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>) CombineLatest<T1, T2, T3, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, ValueTask<TResult>> selector)
  1931. {
  1932. if (observer == null)
  1933. throw new ArgumentNullException(nameof(observer));
  1934. if (selector == null)
  1935. throw new ArgumentNullException(nameof(selector));
  1936. bool allHasValue = false;
  1937. bool hasValue1 = false;
  1938. bool isDone1 = false;
  1939. T1 latestValue1 = default(T1);
  1940. bool hasValue2 = false;
  1941. bool isDone2 = false;
  1942. T2 latestValue2 = default(T2);
  1943. bool hasValue3 = false;
  1944. bool isDone3 = false;
  1945. T3 latestValue3 = default(T3);
  1946. var gate = new AsyncGate();
  1947. return
  1948. (
  1949. Create<T1>(
  1950. async x =>
  1951. {
  1952. using (await gate.LockAsync().ConfigureAwait(false))
  1953. {
  1954. if (!hasValue1)
  1955. {
  1956. hasValue1 = true;
  1957. allHasValue = hasValue1 && hasValue2 && hasValue3;
  1958. }
  1959. latestValue1 = x;
  1960. if (allHasValue)
  1961. {
  1962. TResult res;
  1963. try
  1964. {
  1965. res = await selector(latestValue1, latestValue2, latestValue3).ConfigureAwait(false);
  1966. }
  1967. catch (Exception ex)
  1968. {
  1969. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1970. return;
  1971. }
  1972. await observer.OnNextAsync(res).ConfigureAwait(false);
  1973. }
  1974. else if (isDone2 && isDone3)
  1975. {
  1976. await observer.OnCompletedAsync().ConfigureAwait(false);
  1977. }
  1978. }
  1979. },
  1980. async ex =>
  1981. {
  1982. using (await gate.LockAsync().ConfigureAwait(false))
  1983. {
  1984. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1985. }
  1986. },
  1987. async () =>
  1988. {
  1989. using (await gate.LockAsync().ConfigureAwait(false))
  1990. {
  1991. isDone1 = true;
  1992. if (isDone1 && isDone2 && isDone3)
  1993. {
  1994. await observer.OnCompletedAsync().ConfigureAwait(false);
  1995. }
  1996. }
  1997. }
  1998. ),
  1999. Create<T2>(
  2000. async x =>
  2001. {
  2002. using (await gate.LockAsync().ConfigureAwait(false))
  2003. {
  2004. if (!hasValue2)
  2005. {
  2006. hasValue2 = true;
  2007. allHasValue = hasValue1 && hasValue2 && hasValue3;
  2008. }
  2009. latestValue2 = x;
  2010. if (allHasValue)
  2011. {
  2012. TResult res;
  2013. try
  2014. {
  2015. res = await selector(latestValue1, latestValue2, latestValue3).ConfigureAwait(false);
  2016. }
  2017. catch (Exception ex)
  2018. {
  2019. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2020. return;
  2021. }
  2022. await observer.OnNextAsync(res).ConfigureAwait(false);
  2023. }
  2024. else if (isDone1 && isDone3)
  2025. {
  2026. await observer.OnCompletedAsync().ConfigureAwait(false);
  2027. }
  2028. }
  2029. },
  2030. async ex =>
  2031. {
  2032. using (await gate.LockAsync().ConfigureAwait(false))
  2033. {
  2034. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2035. }
  2036. },
  2037. async () =>
  2038. {
  2039. using (await gate.LockAsync().ConfigureAwait(false))
  2040. {
  2041. isDone2 = true;
  2042. if (isDone1 && isDone2 && isDone3)
  2043. {
  2044. await observer.OnCompletedAsync().ConfigureAwait(false);
  2045. }
  2046. }
  2047. }
  2048. ),
  2049. Create<T3>(
  2050. async x =>
  2051. {
  2052. using (await gate.LockAsync().ConfigureAwait(false))
  2053. {
  2054. if (!hasValue3)
  2055. {
  2056. hasValue3 = true;
  2057. allHasValue = hasValue1 && hasValue2 && hasValue3;
  2058. }
  2059. latestValue3 = x;
  2060. if (allHasValue)
  2061. {
  2062. TResult res;
  2063. try
  2064. {
  2065. res = await selector(latestValue1, latestValue2, latestValue3).ConfigureAwait(false);
  2066. }
  2067. catch (Exception ex)
  2068. {
  2069. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2070. return;
  2071. }
  2072. await observer.OnNextAsync(res).ConfigureAwait(false);
  2073. }
  2074. else if (isDone1 && isDone2)
  2075. {
  2076. await observer.OnCompletedAsync().ConfigureAwait(false);
  2077. }
  2078. }
  2079. },
  2080. async ex =>
  2081. {
  2082. using (await gate.LockAsync().ConfigureAwait(false))
  2083. {
  2084. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2085. }
  2086. },
  2087. async () =>
  2088. {
  2089. using (await gate.LockAsync().ConfigureAwait(false))
  2090. {
  2091. isDone3 = true;
  2092. if (isDone1 && isDone2 && isDone3)
  2093. {
  2094. await observer.OnCompletedAsync().ConfigureAwait(false);
  2095. }
  2096. }
  2097. }
  2098. )
  2099. );
  2100. }
  2101. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>) CombineLatest<T1, T2, T3, T4>(IAsyncObserver<(T1, T2, T3, T4)> observer)
  2102. {
  2103. if (observer == null)
  2104. throw new ArgumentNullException(nameof(observer));
  2105. bool allHasValue = false;
  2106. bool hasValue1 = false;
  2107. bool isDone1 = false;
  2108. T1 latestValue1 = default(T1);
  2109. bool hasValue2 = false;
  2110. bool isDone2 = false;
  2111. T2 latestValue2 = default(T2);
  2112. bool hasValue3 = false;
  2113. bool isDone3 = false;
  2114. T3 latestValue3 = default(T3);
  2115. bool hasValue4 = false;
  2116. bool isDone4 = false;
  2117. T4 latestValue4 = default(T4);
  2118. var gate = new AsyncGate();
  2119. return
  2120. (
  2121. Create<T1>(
  2122. async x =>
  2123. {
  2124. using (await gate.LockAsync().ConfigureAwait(false))
  2125. {
  2126. if (!hasValue1)
  2127. {
  2128. hasValue1 = true;
  2129. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2130. }
  2131. latestValue1 = x;
  2132. if (allHasValue)
  2133. {
  2134. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4)).ConfigureAwait(false);
  2135. }
  2136. else if (isDone2 && isDone3 && isDone4)
  2137. {
  2138. await observer.OnCompletedAsync().ConfigureAwait(false);
  2139. }
  2140. }
  2141. },
  2142. async ex =>
  2143. {
  2144. using (await gate.LockAsync().ConfigureAwait(false))
  2145. {
  2146. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2147. }
  2148. },
  2149. async () =>
  2150. {
  2151. using (await gate.LockAsync().ConfigureAwait(false))
  2152. {
  2153. isDone1 = true;
  2154. if (isDone1 && isDone2 && isDone3 && isDone4)
  2155. {
  2156. await observer.OnCompletedAsync().ConfigureAwait(false);
  2157. }
  2158. }
  2159. }
  2160. ),
  2161. Create<T2>(
  2162. async x =>
  2163. {
  2164. using (await gate.LockAsync().ConfigureAwait(false))
  2165. {
  2166. if (!hasValue2)
  2167. {
  2168. hasValue2 = true;
  2169. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2170. }
  2171. latestValue2 = x;
  2172. if (allHasValue)
  2173. {
  2174. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4)).ConfigureAwait(false);
  2175. }
  2176. else if (isDone1 && isDone3 && isDone4)
  2177. {
  2178. await observer.OnCompletedAsync().ConfigureAwait(false);
  2179. }
  2180. }
  2181. },
  2182. async ex =>
  2183. {
  2184. using (await gate.LockAsync().ConfigureAwait(false))
  2185. {
  2186. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2187. }
  2188. },
  2189. async () =>
  2190. {
  2191. using (await gate.LockAsync().ConfigureAwait(false))
  2192. {
  2193. isDone2 = true;
  2194. if (isDone1 && isDone2 && isDone3 && isDone4)
  2195. {
  2196. await observer.OnCompletedAsync().ConfigureAwait(false);
  2197. }
  2198. }
  2199. }
  2200. ),
  2201. Create<T3>(
  2202. async x =>
  2203. {
  2204. using (await gate.LockAsync().ConfigureAwait(false))
  2205. {
  2206. if (!hasValue3)
  2207. {
  2208. hasValue3 = true;
  2209. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2210. }
  2211. latestValue3 = x;
  2212. if (allHasValue)
  2213. {
  2214. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4)).ConfigureAwait(false);
  2215. }
  2216. else if (isDone1 && isDone2 && isDone4)
  2217. {
  2218. await observer.OnCompletedAsync().ConfigureAwait(false);
  2219. }
  2220. }
  2221. },
  2222. async ex =>
  2223. {
  2224. using (await gate.LockAsync().ConfigureAwait(false))
  2225. {
  2226. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2227. }
  2228. },
  2229. async () =>
  2230. {
  2231. using (await gate.LockAsync().ConfigureAwait(false))
  2232. {
  2233. isDone3 = true;
  2234. if (isDone1 && isDone2 && isDone3 && isDone4)
  2235. {
  2236. await observer.OnCompletedAsync().ConfigureAwait(false);
  2237. }
  2238. }
  2239. }
  2240. ),
  2241. Create<T4>(
  2242. async x =>
  2243. {
  2244. using (await gate.LockAsync().ConfigureAwait(false))
  2245. {
  2246. if (!hasValue4)
  2247. {
  2248. hasValue4 = true;
  2249. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2250. }
  2251. latestValue4 = x;
  2252. if (allHasValue)
  2253. {
  2254. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4)).ConfigureAwait(false);
  2255. }
  2256. else if (isDone1 && isDone2 && isDone3)
  2257. {
  2258. await observer.OnCompletedAsync().ConfigureAwait(false);
  2259. }
  2260. }
  2261. },
  2262. async ex =>
  2263. {
  2264. using (await gate.LockAsync().ConfigureAwait(false))
  2265. {
  2266. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2267. }
  2268. },
  2269. async () =>
  2270. {
  2271. using (await gate.LockAsync().ConfigureAwait(false))
  2272. {
  2273. isDone4 = true;
  2274. if (isDone1 && isDone2 && isDone3 && isDone4)
  2275. {
  2276. await observer.OnCompletedAsync().ConfigureAwait(false);
  2277. }
  2278. }
  2279. }
  2280. )
  2281. );
  2282. }
  2283. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>) CombineLatest<T1, T2, T3, T4, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, TResult> selector)
  2284. {
  2285. if (observer == null)
  2286. throw new ArgumentNullException(nameof(observer));
  2287. if (selector == null)
  2288. throw new ArgumentNullException(nameof(selector));
  2289. return CombineLatest<T1, T2, T3, T4, TResult>(observer, (x1, x2, x3, x4) => new ValueTask<TResult>(selector(x1, x2, x3, x4)));
  2290. }
  2291. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>) CombineLatest<T1, T2, T3, T4, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, ValueTask<TResult>> selector)
  2292. {
  2293. if (observer == null)
  2294. throw new ArgumentNullException(nameof(observer));
  2295. if (selector == null)
  2296. throw new ArgumentNullException(nameof(selector));
  2297. bool allHasValue = false;
  2298. bool hasValue1 = false;
  2299. bool isDone1 = false;
  2300. T1 latestValue1 = default(T1);
  2301. bool hasValue2 = false;
  2302. bool isDone2 = false;
  2303. T2 latestValue2 = default(T2);
  2304. bool hasValue3 = false;
  2305. bool isDone3 = false;
  2306. T3 latestValue3 = default(T3);
  2307. bool hasValue4 = false;
  2308. bool isDone4 = false;
  2309. T4 latestValue4 = default(T4);
  2310. var gate = new AsyncGate();
  2311. return
  2312. (
  2313. Create<T1>(
  2314. async x =>
  2315. {
  2316. using (await gate.LockAsync().ConfigureAwait(false))
  2317. {
  2318. if (!hasValue1)
  2319. {
  2320. hasValue1 = true;
  2321. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2322. }
  2323. latestValue1 = x;
  2324. if (allHasValue)
  2325. {
  2326. TResult res;
  2327. try
  2328. {
  2329. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4).ConfigureAwait(false);
  2330. }
  2331. catch (Exception ex)
  2332. {
  2333. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2334. return;
  2335. }
  2336. await observer.OnNextAsync(res).ConfigureAwait(false);
  2337. }
  2338. else if (isDone2 && isDone3 && isDone4)
  2339. {
  2340. await observer.OnCompletedAsync().ConfigureAwait(false);
  2341. }
  2342. }
  2343. },
  2344. async ex =>
  2345. {
  2346. using (await gate.LockAsync().ConfigureAwait(false))
  2347. {
  2348. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2349. }
  2350. },
  2351. async () =>
  2352. {
  2353. using (await gate.LockAsync().ConfigureAwait(false))
  2354. {
  2355. isDone1 = true;
  2356. if (isDone1 && isDone2 && isDone3 && isDone4)
  2357. {
  2358. await observer.OnCompletedAsync().ConfigureAwait(false);
  2359. }
  2360. }
  2361. }
  2362. ),
  2363. Create<T2>(
  2364. async x =>
  2365. {
  2366. using (await gate.LockAsync().ConfigureAwait(false))
  2367. {
  2368. if (!hasValue2)
  2369. {
  2370. hasValue2 = true;
  2371. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2372. }
  2373. latestValue2 = x;
  2374. if (allHasValue)
  2375. {
  2376. TResult res;
  2377. try
  2378. {
  2379. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4).ConfigureAwait(false);
  2380. }
  2381. catch (Exception ex)
  2382. {
  2383. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2384. return;
  2385. }
  2386. await observer.OnNextAsync(res).ConfigureAwait(false);
  2387. }
  2388. else if (isDone1 && isDone3 && isDone4)
  2389. {
  2390. await observer.OnCompletedAsync().ConfigureAwait(false);
  2391. }
  2392. }
  2393. },
  2394. async ex =>
  2395. {
  2396. using (await gate.LockAsync().ConfigureAwait(false))
  2397. {
  2398. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2399. }
  2400. },
  2401. async () =>
  2402. {
  2403. using (await gate.LockAsync().ConfigureAwait(false))
  2404. {
  2405. isDone2 = true;
  2406. if (isDone1 && isDone2 && isDone3 && isDone4)
  2407. {
  2408. await observer.OnCompletedAsync().ConfigureAwait(false);
  2409. }
  2410. }
  2411. }
  2412. ),
  2413. Create<T3>(
  2414. async x =>
  2415. {
  2416. using (await gate.LockAsync().ConfigureAwait(false))
  2417. {
  2418. if (!hasValue3)
  2419. {
  2420. hasValue3 = true;
  2421. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2422. }
  2423. latestValue3 = x;
  2424. if (allHasValue)
  2425. {
  2426. TResult res;
  2427. try
  2428. {
  2429. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4).ConfigureAwait(false);
  2430. }
  2431. catch (Exception ex)
  2432. {
  2433. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2434. return;
  2435. }
  2436. await observer.OnNextAsync(res).ConfigureAwait(false);
  2437. }
  2438. else if (isDone1 && isDone2 && isDone4)
  2439. {
  2440. await observer.OnCompletedAsync().ConfigureAwait(false);
  2441. }
  2442. }
  2443. },
  2444. async ex =>
  2445. {
  2446. using (await gate.LockAsync().ConfigureAwait(false))
  2447. {
  2448. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2449. }
  2450. },
  2451. async () =>
  2452. {
  2453. using (await gate.LockAsync().ConfigureAwait(false))
  2454. {
  2455. isDone3 = true;
  2456. if (isDone1 && isDone2 && isDone3 && isDone4)
  2457. {
  2458. await observer.OnCompletedAsync().ConfigureAwait(false);
  2459. }
  2460. }
  2461. }
  2462. ),
  2463. Create<T4>(
  2464. async x =>
  2465. {
  2466. using (await gate.LockAsync().ConfigureAwait(false))
  2467. {
  2468. if (!hasValue4)
  2469. {
  2470. hasValue4 = true;
  2471. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2472. }
  2473. latestValue4 = x;
  2474. if (allHasValue)
  2475. {
  2476. TResult res;
  2477. try
  2478. {
  2479. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4).ConfigureAwait(false);
  2480. }
  2481. catch (Exception ex)
  2482. {
  2483. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2484. return;
  2485. }
  2486. await observer.OnNextAsync(res).ConfigureAwait(false);
  2487. }
  2488. else if (isDone1 && isDone2 && isDone3)
  2489. {
  2490. await observer.OnCompletedAsync().ConfigureAwait(false);
  2491. }
  2492. }
  2493. },
  2494. async ex =>
  2495. {
  2496. using (await gate.LockAsync().ConfigureAwait(false))
  2497. {
  2498. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2499. }
  2500. },
  2501. async () =>
  2502. {
  2503. using (await gate.LockAsync().ConfigureAwait(false))
  2504. {
  2505. isDone4 = true;
  2506. if (isDone1 && isDone2 && isDone3 && isDone4)
  2507. {
  2508. await observer.OnCompletedAsync().ConfigureAwait(false);
  2509. }
  2510. }
  2511. }
  2512. )
  2513. );
  2514. }
  2515. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>) CombineLatest<T1, T2, T3, T4, T5>(IAsyncObserver<(T1, T2, T3, T4, T5)> observer)
  2516. {
  2517. if (observer == null)
  2518. throw new ArgumentNullException(nameof(observer));
  2519. bool allHasValue = false;
  2520. bool hasValue1 = false;
  2521. bool isDone1 = false;
  2522. T1 latestValue1 = default(T1);
  2523. bool hasValue2 = false;
  2524. bool isDone2 = false;
  2525. T2 latestValue2 = default(T2);
  2526. bool hasValue3 = false;
  2527. bool isDone3 = false;
  2528. T3 latestValue3 = default(T3);
  2529. bool hasValue4 = false;
  2530. bool isDone4 = false;
  2531. T4 latestValue4 = default(T4);
  2532. bool hasValue5 = false;
  2533. bool isDone5 = false;
  2534. T5 latestValue5 = default(T5);
  2535. var gate = new AsyncGate();
  2536. return
  2537. (
  2538. Create<T1>(
  2539. async x =>
  2540. {
  2541. using (await gate.LockAsync().ConfigureAwait(false))
  2542. {
  2543. if (!hasValue1)
  2544. {
  2545. hasValue1 = true;
  2546. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2547. }
  2548. latestValue1 = x;
  2549. if (allHasValue)
  2550. {
  2551. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5)).ConfigureAwait(false);
  2552. }
  2553. else if (isDone2 && isDone3 && isDone4 && isDone5)
  2554. {
  2555. await observer.OnCompletedAsync().ConfigureAwait(false);
  2556. }
  2557. }
  2558. },
  2559. async ex =>
  2560. {
  2561. using (await gate.LockAsync().ConfigureAwait(false))
  2562. {
  2563. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2564. }
  2565. },
  2566. async () =>
  2567. {
  2568. using (await gate.LockAsync().ConfigureAwait(false))
  2569. {
  2570. isDone1 = true;
  2571. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2572. {
  2573. await observer.OnCompletedAsync().ConfigureAwait(false);
  2574. }
  2575. }
  2576. }
  2577. ),
  2578. Create<T2>(
  2579. async x =>
  2580. {
  2581. using (await gate.LockAsync().ConfigureAwait(false))
  2582. {
  2583. if (!hasValue2)
  2584. {
  2585. hasValue2 = true;
  2586. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2587. }
  2588. latestValue2 = x;
  2589. if (allHasValue)
  2590. {
  2591. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5)).ConfigureAwait(false);
  2592. }
  2593. else if (isDone1 && isDone3 && isDone4 && isDone5)
  2594. {
  2595. await observer.OnCompletedAsync().ConfigureAwait(false);
  2596. }
  2597. }
  2598. },
  2599. async ex =>
  2600. {
  2601. using (await gate.LockAsync().ConfigureAwait(false))
  2602. {
  2603. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2604. }
  2605. },
  2606. async () =>
  2607. {
  2608. using (await gate.LockAsync().ConfigureAwait(false))
  2609. {
  2610. isDone2 = true;
  2611. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2612. {
  2613. await observer.OnCompletedAsync().ConfigureAwait(false);
  2614. }
  2615. }
  2616. }
  2617. ),
  2618. Create<T3>(
  2619. async x =>
  2620. {
  2621. using (await gate.LockAsync().ConfigureAwait(false))
  2622. {
  2623. if (!hasValue3)
  2624. {
  2625. hasValue3 = true;
  2626. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2627. }
  2628. latestValue3 = x;
  2629. if (allHasValue)
  2630. {
  2631. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5)).ConfigureAwait(false);
  2632. }
  2633. else if (isDone1 && isDone2 && isDone4 && isDone5)
  2634. {
  2635. await observer.OnCompletedAsync().ConfigureAwait(false);
  2636. }
  2637. }
  2638. },
  2639. async ex =>
  2640. {
  2641. using (await gate.LockAsync().ConfigureAwait(false))
  2642. {
  2643. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2644. }
  2645. },
  2646. async () =>
  2647. {
  2648. using (await gate.LockAsync().ConfigureAwait(false))
  2649. {
  2650. isDone3 = true;
  2651. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2652. {
  2653. await observer.OnCompletedAsync().ConfigureAwait(false);
  2654. }
  2655. }
  2656. }
  2657. ),
  2658. Create<T4>(
  2659. async x =>
  2660. {
  2661. using (await gate.LockAsync().ConfigureAwait(false))
  2662. {
  2663. if (!hasValue4)
  2664. {
  2665. hasValue4 = true;
  2666. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2667. }
  2668. latestValue4 = x;
  2669. if (allHasValue)
  2670. {
  2671. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5)).ConfigureAwait(false);
  2672. }
  2673. else if (isDone1 && isDone2 && isDone3 && isDone5)
  2674. {
  2675. await observer.OnCompletedAsync().ConfigureAwait(false);
  2676. }
  2677. }
  2678. },
  2679. async ex =>
  2680. {
  2681. using (await gate.LockAsync().ConfigureAwait(false))
  2682. {
  2683. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2684. }
  2685. },
  2686. async () =>
  2687. {
  2688. using (await gate.LockAsync().ConfigureAwait(false))
  2689. {
  2690. isDone4 = true;
  2691. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2692. {
  2693. await observer.OnCompletedAsync().ConfigureAwait(false);
  2694. }
  2695. }
  2696. }
  2697. ),
  2698. Create<T5>(
  2699. async x =>
  2700. {
  2701. using (await gate.LockAsync().ConfigureAwait(false))
  2702. {
  2703. if (!hasValue5)
  2704. {
  2705. hasValue5 = true;
  2706. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2707. }
  2708. latestValue5 = x;
  2709. if (allHasValue)
  2710. {
  2711. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5)).ConfigureAwait(false);
  2712. }
  2713. else if (isDone1 && isDone2 && isDone3 && isDone4)
  2714. {
  2715. await observer.OnCompletedAsync().ConfigureAwait(false);
  2716. }
  2717. }
  2718. },
  2719. async ex =>
  2720. {
  2721. using (await gate.LockAsync().ConfigureAwait(false))
  2722. {
  2723. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2724. }
  2725. },
  2726. async () =>
  2727. {
  2728. using (await gate.LockAsync().ConfigureAwait(false))
  2729. {
  2730. isDone5 = true;
  2731. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2732. {
  2733. await observer.OnCompletedAsync().ConfigureAwait(false);
  2734. }
  2735. }
  2736. }
  2737. )
  2738. );
  2739. }
  2740. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>) CombineLatest<T1, T2, T3, T4, T5, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, TResult> selector)
  2741. {
  2742. if (observer == null)
  2743. throw new ArgumentNullException(nameof(observer));
  2744. if (selector == null)
  2745. throw new ArgumentNullException(nameof(selector));
  2746. return CombineLatest<T1, T2, T3, T4, T5, TResult>(observer, (x1, x2, x3, x4, x5) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5)));
  2747. }
  2748. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>) CombineLatest<T1, T2, T3, T4, T5, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, ValueTask<TResult>> selector)
  2749. {
  2750. if (observer == null)
  2751. throw new ArgumentNullException(nameof(observer));
  2752. if (selector == null)
  2753. throw new ArgumentNullException(nameof(selector));
  2754. bool allHasValue = false;
  2755. bool hasValue1 = false;
  2756. bool isDone1 = false;
  2757. T1 latestValue1 = default(T1);
  2758. bool hasValue2 = false;
  2759. bool isDone2 = false;
  2760. T2 latestValue2 = default(T2);
  2761. bool hasValue3 = false;
  2762. bool isDone3 = false;
  2763. T3 latestValue3 = default(T3);
  2764. bool hasValue4 = false;
  2765. bool isDone4 = false;
  2766. T4 latestValue4 = default(T4);
  2767. bool hasValue5 = false;
  2768. bool isDone5 = false;
  2769. T5 latestValue5 = default(T5);
  2770. var gate = new AsyncGate();
  2771. return
  2772. (
  2773. Create<T1>(
  2774. async x =>
  2775. {
  2776. using (await gate.LockAsync().ConfigureAwait(false))
  2777. {
  2778. if (!hasValue1)
  2779. {
  2780. hasValue1 = true;
  2781. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2782. }
  2783. latestValue1 = x;
  2784. if (allHasValue)
  2785. {
  2786. TResult res;
  2787. try
  2788. {
  2789. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5).ConfigureAwait(false);
  2790. }
  2791. catch (Exception ex)
  2792. {
  2793. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2794. return;
  2795. }
  2796. await observer.OnNextAsync(res).ConfigureAwait(false);
  2797. }
  2798. else if (isDone2 && isDone3 && isDone4 && isDone5)
  2799. {
  2800. await observer.OnCompletedAsync().ConfigureAwait(false);
  2801. }
  2802. }
  2803. },
  2804. async ex =>
  2805. {
  2806. using (await gate.LockAsync().ConfigureAwait(false))
  2807. {
  2808. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2809. }
  2810. },
  2811. async () =>
  2812. {
  2813. using (await gate.LockAsync().ConfigureAwait(false))
  2814. {
  2815. isDone1 = true;
  2816. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2817. {
  2818. await observer.OnCompletedAsync().ConfigureAwait(false);
  2819. }
  2820. }
  2821. }
  2822. ),
  2823. Create<T2>(
  2824. async x =>
  2825. {
  2826. using (await gate.LockAsync().ConfigureAwait(false))
  2827. {
  2828. if (!hasValue2)
  2829. {
  2830. hasValue2 = true;
  2831. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2832. }
  2833. latestValue2 = x;
  2834. if (allHasValue)
  2835. {
  2836. TResult res;
  2837. try
  2838. {
  2839. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5).ConfigureAwait(false);
  2840. }
  2841. catch (Exception ex)
  2842. {
  2843. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2844. return;
  2845. }
  2846. await observer.OnNextAsync(res).ConfigureAwait(false);
  2847. }
  2848. else if (isDone1 && isDone3 && isDone4 && isDone5)
  2849. {
  2850. await observer.OnCompletedAsync().ConfigureAwait(false);
  2851. }
  2852. }
  2853. },
  2854. async ex =>
  2855. {
  2856. using (await gate.LockAsync().ConfigureAwait(false))
  2857. {
  2858. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2859. }
  2860. },
  2861. async () =>
  2862. {
  2863. using (await gate.LockAsync().ConfigureAwait(false))
  2864. {
  2865. isDone2 = true;
  2866. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2867. {
  2868. await observer.OnCompletedAsync().ConfigureAwait(false);
  2869. }
  2870. }
  2871. }
  2872. ),
  2873. Create<T3>(
  2874. async x =>
  2875. {
  2876. using (await gate.LockAsync().ConfigureAwait(false))
  2877. {
  2878. if (!hasValue3)
  2879. {
  2880. hasValue3 = true;
  2881. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2882. }
  2883. latestValue3 = x;
  2884. if (allHasValue)
  2885. {
  2886. TResult res;
  2887. try
  2888. {
  2889. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5).ConfigureAwait(false);
  2890. }
  2891. catch (Exception ex)
  2892. {
  2893. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2894. return;
  2895. }
  2896. await observer.OnNextAsync(res).ConfigureAwait(false);
  2897. }
  2898. else if (isDone1 && isDone2 && isDone4 && isDone5)
  2899. {
  2900. await observer.OnCompletedAsync().ConfigureAwait(false);
  2901. }
  2902. }
  2903. },
  2904. async ex =>
  2905. {
  2906. using (await gate.LockAsync().ConfigureAwait(false))
  2907. {
  2908. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2909. }
  2910. },
  2911. async () =>
  2912. {
  2913. using (await gate.LockAsync().ConfigureAwait(false))
  2914. {
  2915. isDone3 = true;
  2916. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2917. {
  2918. await observer.OnCompletedAsync().ConfigureAwait(false);
  2919. }
  2920. }
  2921. }
  2922. ),
  2923. Create<T4>(
  2924. async x =>
  2925. {
  2926. using (await gate.LockAsync().ConfigureAwait(false))
  2927. {
  2928. if (!hasValue4)
  2929. {
  2930. hasValue4 = true;
  2931. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2932. }
  2933. latestValue4 = x;
  2934. if (allHasValue)
  2935. {
  2936. TResult res;
  2937. try
  2938. {
  2939. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5).ConfigureAwait(false);
  2940. }
  2941. catch (Exception ex)
  2942. {
  2943. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2944. return;
  2945. }
  2946. await observer.OnNextAsync(res).ConfigureAwait(false);
  2947. }
  2948. else if (isDone1 && isDone2 && isDone3 && isDone5)
  2949. {
  2950. await observer.OnCompletedAsync().ConfigureAwait(false);
  2951. }
  2952. }
  2953. },
  2954. async ex =>
  2955. {
  2956. using (await gate.LockAsync().ConfigureAwait(false))
  2957. {
  2958. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2959. }
  2960. },
  2961. async () =>
  2962. {
  2963. using (await gate.LockAsync().ConfigureAwait(false))
  2964. {
  2965. isDone4 = true;
  2966. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2967. {
  2968. await observer.OnCompletedAsync().ConfigureAwait(false);
  2969. }
  2970. }
  2971. }
  2972. ),
  2973. Create<T5>(
  2974. async x =>
  2975. {
  2976. using (await gate.LockAsync().ConfigureAwait(false))
  2977. {
  2978. if (!hasValue5)
  2979. {
  2980. hasValue5 = true;
  2981. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2982. }
  2983. latestValue5 = x;
  2984. if (allHasValue)
  2985. {
  2986. TResult res;
  2987. try
  2988. {
  2989. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5).ConfigureAwait(false);
  2990. }
  2991. catch (Exception ex)
  2992. {
  2993. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2994. return;
  2995. }
  2996. await observer.OnNextAsync(res).ConfigureAwait(false);
  2997. }
  2998. else if (isDone1 && isDone2 && isDone3 && isDone4)
  2999. {
  3000. await observer.OnCompletedAsync().ConfigureAwait(false);
  3001. }
  3002. }
  3003. },
  3004. async ex =>
  3005. {
  3006. using (await gate.LockAsync().ConfigureAwait(false))
  3007. {
  3008. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3009. }
  3010. },
  3011. async () =>
  3012. {
  3013. using (await gate.LockAsync().ConfigureAwait(false))
  3014. {
  3015. isDone5 = true;
  3016. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  3017. {
  3018. await observer.OnCompletedAsync().ConfigureAwait(false);
  3019. }
  3020. }
  3021. }
  3022. )
  3023. );
  3024. }
  3025. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>) CombineLatest<T1, T2, T3, T4, T5, T6>(IAsyncObserver<(T1, T2, T3, T4, T5, T6)> observer)
  3026. {
  3027. if (observer == null)
  3028. throw new ArgumentNullException(nameof(observer));
  3029. bool allHasValue = false;
  3030. bool hasValue1 = false;
  3031. bool isDone1 = false;
  3032. T1 latestValue1 = default(T1);
  3033. bool hasValue2 = false;
  3034. bool isDone2 = false;
  3035. T2 latestValue2 = default(T2);
  3036. bool hasValue3 = false;
  3037. bool isDone3 = false;
  3038. T3 latestValue3 = default(T3);
  3039. bool hasValue4 = false;
  3040. bool isDone4 = false;
  3041. T4 latestValue4 = default(T4);
  3042. bool hasValue5 = false;
  3043. bool isDone5 = false;
  3044. T5 latestValue5 = default(T5);
  3045. bool hasValue6 = false;
  3046. bool isDone6 = false;
  3047. T6 latestValue6 = default(T6);
  3048. var gate = new AsyncGate();
  3049. return
  3050. (
  3051. Create<T1>(
  3052. async x =>
  3053. {
  3054. using (await gate.LockAsync().ConfigureAwait(false))
  3055. {
  3056. if (!hasValue1)
  3057. {
  3058. hasValue1 = true;
  3059. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3060. }
  3061. latestValue1 = x;
  3062. if (allHasValue)
  3063. {
  3064. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3065. }
  3066. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3067. {
  3068. await observer.OnCompletedAsync().ConfigureAwait(false);
  3069. }
  3070. }
  3071. },
  3072. async ex =>
  3073. {
  3074. using (await gate.LockAsync().ConfigureAwait(false))
  3075. {
  3076. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3077. }
  3078. },
  3079. async () =>
  3080. {
  3081. using (await gate.LockAsync().ConfigureAwait(false))
  3082. {
  3083. isDone1 = true;
  3084. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3085. {
  3086. await observer.OnCompletedAsync().ConfigureAwait(false);
  3087. }
  3088. }
  3089. }
  3090. ),
  3091. Create<T2>(
  3092. async x =>
  3093. {
  3094. using (await gate.LockAsync().ConfigureAwait(false))
  3095. {
  3096. if (!hasValue2)
  3097. {
  3098. hasValue2 = true;
  3099. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3100. }
  3101. latestValue2 = x;
  3102. if (allHasValue)
  3103. {
  3104. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3105. }
  3106. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6)
  3107. {
  3108. await observer.OnCompletedAsync().ConfigureAwait(false);
  3109. }
  3110. }
  3111. },
  3112. async ex =>
  3113. {
  3114. using (await gate.LockAsync().ConfigureAwait(false))
  3115. {
  3116. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3117. }
  3118. },
  3119. async () =>
  3120. {
  3121. using (await gate.LockAsync().ConfigureAwait(false))
  3122. {
  3123. isDone2 = true;
  3124. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3125. {
  3126. await observer.OnCompletedAsync().ConfigureAwait(false);
  3127. }
  3128. }
  3129. }
  3130. ),
  3131. Create<T3>(
  3132. async x =>
  3133. {
  3134. using (await gate.LockAsync().ConfigureAwait(false))
  3135. {
  3136. if (!hasValue3)
  3137. {
  3138. hasValue3 = true;
  3139. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3140. }
  3141. latestValue3 = x;
  3142. if (allHasValue)
  3143. {
  3144. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3145. }
  3146. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6)
  3147. {
  3148. await observer.OnCompletedAsync().ConfigureAwait(false);
  3149. }
  3150. }
  3151. },
  3152. async ex =>
  3153. {
  3154. using (await gate.LockAsync().ConfigureAwait(false))
  3155. {
  3156. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3157. }
  3158. },
  3159. async () =>
  3160. {
  3161. using (await gate.LockAsync().ConfigureAwait(false))
  3162. {
  3163. isDone3 = true;
  3164. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3165. {
  3166. await observer.OnCompletedAsync().ConfigureAwait(false);
  3167. }
  3168. }
  3169. }
  3170. ),
  3171. Create<T4>(
  3172. async x =>
  3173. {
  3174. using (await gate.LockAsync().ConfigureAwait(false))
  3175. {
  3176. if (!hasValue4)
  3177. {
  3178. hasValue4 = true;
  3179. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3180. }
  3181. latestValue4 = x;
  3182. if (allHasValue)
  3183. {
  3184. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3185. }
  3186. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6)
  3187. {
  3188. await observer.OnCompletedAsync().ConfigureAwait(false);
  3189. }
  3190. }
  3191. },
  3192. async ex =>
  3193. {
  3194. using (await gate.LockAsync().ConfigureAwait(false))
  3195. {
  3196. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3197. }
  3198. },
  3199. async () =>
  3200. {
  3201. using (await gate.LockAsync().ConfigureAwait(false))
  3202. {
  3203. isDone4 = true;
  3204. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3205. {
  3206. await observer.OnCompletedAsync().ConfigureAwait(false);
  3207. }
  3208. }
  3209. }
  3210. ),
  3211. Create<T5>(
  3212. async x =>
  3213. {
  3214. using (await gate.LockAsync().ConfigureAwait(false))
  3215. {
  3216. if (!hasValue5)
  3217. {
  3218. hasValue5 = true;
  3219. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3220. }
  3221. latestValue5 = x;
  3222. if (allHasValue)
  3223. {
  3224. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3225. }
  3226. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6)
  3227. {
  3228. await observer.OnCompletedAsync().ConfigureAwait(false);
  3229. }
  3230. }
  3231. },
  3232. async ex =>
  3233. {
  3234. using (await gate.LockAsync().ConfigureAwait(false))
  3235. {
  3236. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3237. }
  3238. },
  3239. async () =>
  3240. {
  3241. using (await gate.LockAsync().ConfigureAwait(false))
  3242. {
  3243. isDone5 = true;
  3244. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3245. {
  3246. await observer.OnCompletedAsync().ConfigureAwait(false);
  3247. }
  3248. }
  3249. }
  3250. ),
  3251. Create<T6>(
  3252. async x =>
  3253. {
  3254. using (await gate.LockAsync().ConfigureAwait(false))
  3255. {
  3256. if (!hasValue6)
  3257. {
  3258. hasValue6 = true;
  3259. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3260. }
  3261. latestValue6 = x;
  3262. if (allHasValue)
  3263. {
  3264. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3265. }
  3266. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  3267. {
  3268. await observer.OnCompletedAsync().ConfigureAwait(false);
  3269. }
  3270. }
  3271. },
  3272. async ex =>
  3273. {
  3274. using (await gate.LockAsync().ConfigureAwait(false))
  3275. {
  3276. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3277. }
  3278. },
  3279. async () =>
  3280. {
  3281. using (await gate.LockAsync().ConfigureAwait(false))
  3282. {
  3283. isDone6 = true;
  3284. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3285. {
  3286. await observer.OnCompletedAsync().ConfigureAwait(false);
  3287. }
  3288. }
  3289. }
  3290. )
  3291. );
  3292. }
  3293. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>) CombineLatest<T1, T2, T3, T4, T5, T6, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, TResult> selector)
  3294. {
  3295. if (observer == null)
  3296. throw new ArgumentNullException(nameof(observer));
  3297. if (selector == null)
  3298. throw new ArgumentNullException(nameof(selector));
  3299. return CombineLatest<T1, T2, T3, T4, T5, T6, TResult>(observer, (x1, x2, x3, x4, x5, x6) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5, x6)));
  3300. }
  3301. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>) CombineLatest<T1, T2, T3, T4, T5, T6, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, ValueTask<TResult>> selector)
  3302. {
  3303. if (observer == null)
  3304. throw new ArgumentNullException(nameof(observer));
  3305. if (selector == null)
  3306. throw new ArgumentNullException(nameof(selector));
  3307. bool allHasValue = false;
  3308. bool hasValue1 = false;
  3309. bool isDone1 = false;
  3310. T1 latestValue1 = default(T1);
  3311. bool hasValue2 = false;
  3312. bool isDone2 = false;
  3313. T2 latestValue2 = default(T2);
  3314. bool hasValue3 = false;
  3315. bool isDone3 = false;
  3316. T3 latestValue3 = default(T3);
  3317. bool hasValue4 = false;
  3318. bool isDone4 = false;
  3319. T4 latestValue4 = default(T4);
  3320. bool hasValue5 = false;
  3321. bool isDone5 = false;
  3322. T5 latestValue5 = default(T5);
  3323. bool hasValue6 = false;
  3324. bool isDone6 = false;
  3325. T6 latestValue6 = default(T6);
  3326. var gate = new AsyncGate();
  3327. return
  3328. (
  3329. Create<T1>(
  3330. async x =>
  3331. {
  3332. using (await gate.LockAsync().ConfigureAwait(false))
  3333. {
  3334. if (!hasValue1)
  3335. {
  3336. hasValue1 = true;
  3337. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3338. }
  3339. latestValue1 = x;
  3340. if (allHasValue)
  3341. {
  3342. TResult res;
  3343. try
  3344. {
  3345. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3346. }
  3347. catch (Exception ex)
  3348. {
  3349. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3350. return;
  3351. }
  3352. await observer.OnNextAsync(res).ConfigureAwait(false);
  3353. }
  3354. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3355. {
  3356. await observer.OnCompletedAsync().ConfigureAwait(false);
  3357. }
  3358. }
  3359. },
  3360. async ex =>
  3361. {
  3362. using (await gate.LockAsync().ConfigureAwait(false))
  3363. {
  3364. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3365. }
  3366. },
  3367. async () =>
  3368. {
  3369. using (await gate.LockAsync().ConfigureAwait(false))
  3370. {
  3371. isDone1 = true;
  3372. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3373. {
  3374. await observer.OnCompletedAsync().ConfigureAwait(false);
  3375. }
  3376. }
  3377. }
  3378. ),
  3379. Create<T2>(
  3380. async x =>
  3381. {
  3382. using (await gate.LockAsync().ConfigureAwait(false))
  3383. {
  3384. if (!hasValue2)
  3385. {
  3386. hasValue2 = true;
  3387. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3388. }
  3389. latestValue2 = x;
  3390. if (allHasValue)
  3391. {
  3392. TResult res;
  3393. try
  3394. {
  3395. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3396. }
  3397. catch (Exception ex)
  3398. {
  3399. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3400. return;
  3401. }
  3402. await observer.OnNextAsync(res).ConfigureAwait(false);
  3403. }
  3404. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6)
  3405. {
  3406. await observer.OnCompletedAsync().ConfigureAwait(false);
  3407. }
  3408. }
  3409. },
  3410. async ex =>
  3411. {
  3412. using (await gate.LockAsync().ConfigureAwait(false))
  3413. {
  3414. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3415. }
  3416. },
  3417. async () =>
  3418. {
  3419. using (await gate.LockAsync().ConfigureAwait(false))
  3420. {
  3421. isDone2 = true;
  3422. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3423. {
  3424. await observer.OnCompletedAsync().ConfigureAwait(false);
  3425. }
  3426. }
  3427. }
  3428. ),
  3429. Create<T3>(
  3430. async x =>
  3431. {
  3432. using (await gate.LockAsync().ConfigureAwait(false))
  3433. {
  3434. if (!hasValue3)
  3435. {
  3436. hasValue3 = true;
  3437. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3438. }
  3439. latestValue3 = x;
  3440. if (allHasValue)
  3441. {
  3442. TResult res;
  3443. try
  3444. {
  3445. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3446. }
  3447. catch (Exception ex)
  3448. {
  3449. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3450. return;
  3451. }
  3452. await observer.OnNextAsync(res).ConfigureAwait(false);
  3453. }
  3454. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6)
  3455. {
  3456. await observer.OnCompletedAsync().ConfigureAwait(false);
  3457. }
  3458. }
  3459. },
  3460. async ex =>
  3461. {
  3462. using (await gate.LockAsync().ConfigureAwait(false))
  3463. {
  3464. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3465. }
  3466. },
  3467. async () =>
  3468. {
  3469. using (await gate.LockAsync().ConfigureAwait(false))
  3470. {
  3471. isDone3 = true;
  3472. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3473. {
  3474. await observer.OnCompletedAsync().ConfigureAwait(false);
  3475. }
  3476. }
  3477. }
  3478. ),
  3479. Create<T4>(
  3480. async x =>
  3481. {
  3482. using (await gate.LockAsync().ConfigureAwait(false))
  3483. {
  3484. if (!hasValue4)
  3485. {
  3486. hasValue4 = true;
  3487. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3488. }
  3489. latestValue4 = x;
  3490. if (allHasValue)
  3491. {
  3492. TResult res;
  3493. try
  3494. {
  3495. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3496. }
  3497. catch (Exception ex)
  3498. {
  3499. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3500. return;
  3501. }
  3502. await observer.OnNextAsync(res).ConfigureAwait(false);
  3503. }
  3504. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6)
  3505. {
  3506. await observer.OnCompletedAsync().ConfigureAwait(false);
  3507. }
  3508. }
  3509. },
  3510. async ex =>
  3511. {
  3512. using (await gate.LockAsync().ConfigureAwait(false))
  3513. {
  3514. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3515. }
  3516. },
  3517. async () =>
  3518. {
  3519. using (await gate.LockAsync().ConfigureAwait(false))
  3520. {
  3521. isDone4 = true;
  3522. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3523. {
  3524. await observer.OnCompletedAsync().ConfigureAwait(false);
  3525. }
  3526. }
  3527. }
  3528. ),
  3529. Create<T5>(
  3530. async x =>
  3531. {
  3532. using (await gate.LockAsync().ConfigureAwait(false))
  3533. {
  3534. if (!hasValue5)
  3535. {
  3536. hasValue5 = true;
  3537. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3538. }
  3539. latestValue5 = x;
  3540. if (allHasValue)
  3541. {
  3542. TResult res;
  3543. try
  3544. {
  3545. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3546. }
  3547. catch (Exception ex)
  3548. {
  3549. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3550. return;
  3551. }
  3552. await observer.OnNextAsync(res).ConfigureAwait(false);
  3553. }
  3554. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6)
  3555. {
  3556. await observer.OnCompletedAsync().ConfigureAwait(false);
  3557. }
  3558. }
  3559. },
  3560. async ex =>
  3561. {
  3562. using (await gate.LockAsync().ConfigureAwait(false))
  3563. {
  3564. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3565. }
  3566. },
  3567. async () =>
  3568. {
  3569. using (await gate.LockAsync().ConfigureAwait(false))
  3570. {
  3571. isDone5 = true;
  3572. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3573. {
  3574. await observer.OnCompletedAsync().ConfigureAwait(false);
  3575. }
  3576. }
  3577. }
  3578. ),
  3579. Create<T6>(
  3580. async x =>
  3581. {
  3582. using (await gate.LockAsync().ConfigureAwait(false))
  3583. {
  3584. if (!hasValue6)
  3585. {
  3586. hasValue6 = true;
  3587. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3588. }
  3589. latestValue6 = x;
  3590. if (allHasValue)
  3591. {
  3592. TResult res;
  3593. try
  3594. {
  3595. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3596. }
  3597. catch (Exception ex)
  3598. {
  3599. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3600. return;
  3601. }
  3602. await observer.OnNextAsync(res).ConfigureAwait(false);
  3603. }
  3604. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  3605. {
  3606. await observer.OnCompletedAsync().ConfigureAwait(false);
  3607. }
  3608. }
  3609. },
  3610. async ex =>
  3611. {
  3612. using (await gate.LockAsync().ConfigureAwait(false))
  3613. {
  3614. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3615. }
  3616. },
  3617. async () =>
  3618. {
  3619. using (await gate.LockAsync().ConfigureAwait(false))
  3620. {
  3621. isDone6 = true;
  3622. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3623. {
  3624. await observer.OnCompletedAsync().ConfigureAwait(false);
  3625. }
  3626. }
  3627. }
  3628. )
  3629. );
  3630. }
  3631. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>) CombineLatest<T1, T2, T3, T4, T5, T6, T7>(IAsyncObserver<(T1, T2, T3, T4, T5, T6, T7)> observer)
  3632. {
  3633. if (observer == null)
  3634. throw new ArgumentNullException(nameof(observer));
  3635. bool allHasValue = false;
  3636. bool hasValue1 = false;
  3637. bool isDone1 = false;
  3638. T1 latestValue1 = default(T1);
  3639. bool hasValue2 = false;
  3640. bool isDone2 = false;
  3641. T2 latestValue2 = default(T2);
  3642. bool hasValue3 = false;
  3643. bool isDone3 = false;
  3644. T3 latestValue3 = default(T3);
  3645. bool hasValue4 = false;
  3646. bool isDone4 = false;
  3647. T4 latestValue4 = default(T4);
  3648. bool hasValue5 = false;
  3649. bool isDone5 = false;
  3650. T5 latestValue5 = default(T5);
  3651. bool hasValue6 = false;
  3652. bool isDone6 = false;
  3653. T6 latestValue6 = default(T6);
  3654. bool hasValue7 = false;
  3655. bool isDone7 = false;
  3656. T7 latestValue7 = default(T7);
  3657. var gate = new AsyncGate();
  3658. return
  3659. (
  3660. Create<T1>(
  3661. async x =>
  3662. {
  3663. using (await gate.LockAsync().ConfigureAwait(false))
  3664. {
  3665. if (!hasValue1)
  3666. {
  3667. hasValue1 = true;
  3668. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3669. }
  3670. latestValue1 = x;
  3671. if (allHasValue)
  3672. {
  3673. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3674. }
  3675. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3676. {
  3677. await observer.OnCompletedAsync().ConfigureAwait(false);
  3678. }
  3679. }
  3680. },
  3681. async ex =>
  3682. {
  3683. using (await gate.LockAsync().ConfigureAwait(false))
  3684. {
  3685. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3686. }
  3687. },
  3688. async () =>
  3689. {
  3690. using (await gate.LockAsync().ConfigureAwait(false))
  3691. {
  3692. isDone1 = true;
  3693. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3694. {
  3695. await observer.OnCompletedAsync().ConfigureAwait(false);
  3696. }
  3697. }
  3698. }
  3699. ),
  3700. Create<T2>(
  3701. async x =>
  3702. {
  3703. using (await gate.LockAsync().ConfigureAwait(false))
  3704. {
  3705. if (!hasValue2)
  3706. {
  3707. hasValue2 = true;
  3708. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3709. }
  3710. latestValue2 = x;
  3711. if (allHasValue)
  3712. {
  3713. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3714. }
  3715. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3716. {
  3717. await observer.OnCompletedAsync().ConfigureAwait(false);
  3718. }
  3719. }
  3720. },
  3721. async ex =>
  3722. {
  3723. using (await gate.LockAsync().ConfigureAwait(false))
  3724. {
  3725. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3726. }
  3727. },
  3728. async () =>
  3729. {
  3730. using (await gate.LockAsync().ConfigureAwait(false))
  3731. {
  3732. isDone2 = true;
  3733. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3734. {
  3735. await observer.OnCompletedAsync().ConfigureAwait(false);
  3736. }
  3737. }
  3738. }
  3739. ),
  3740. Create<T3>(
  3741. async x =>
  3742. {
  3743. using (await gate.LockAsync().ConfigureAwait(false))
  3744. {
  3745. if (!hasValue3)
  3746. {
  3747. hasValue3 = true;
  3748. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3749. }
  3750. latestValue3 = x;
  3751. if (allHasValue)
  3752. {
  3753. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3754. }
  3755. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7)
  3756. {
  3757. await observer.OnCompletedAsync().ConfigureAwait(false);
  3758. }
  3759. }
  3760. },
  3761. async ex =>
  3762. {
  3763. using (await gate.LockAsync().ConfigureAwait(false))
  3764. {
  3765. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3766. }
  3767. },
  3768. async () =>
  3769. {
  3770. using (await gate.LockAsync().ConfigureAwait(false))
  3771. {
  3772. isDone3 = true;
  3773. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3774. {
  3775. await observer.OnCompletedAsync().ConfigureAwait(false);
  3776. }
  3777. }
  3778. }
  3779. ),
  3780. Create<T4>(
  3781. async x =>
  3782. {
  3783. using (await gate.LockAsync().ConfigureAwait(false))
  3784. {
  3785. if (!hasValue4)
  3786. {
  3787. hasValue4 = true;
  3788. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3789. }
  3790. latestValue4 = x;
  3791. if (allHasValue)
  3792. {
  3793. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3794. }
  3795. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7)
  3796. {
  3797. await observer.OnCompletedAsync().ConfigureAwait(false);
  3798. }
  3799. }
  3800. },
  3801. async ex =>
  3802. {
  3803. using (await gate.LockAsync().ConfigureAwait(false))
  3804. {
  3805. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3806. }
  3807. },
  3808. async () =>
  3809. {
  3810. using (await gate.LockAsync().ConfigureAwait(false))
  3811. {
  3812. isDone4 = true;
  3813. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3814. {
  3815. await observer.OnCompletedAsync().ConfigureAwait(false);
  3816. }
  3817. }
  3818. }
  3819. ),
  3820. Create<T5>(
  3821. async x =>
  3822. {
  3823. using (await gate.LockAsync().ConfigureAwait(false))
  3824. {
  3825. if (!hasValue5)
  3826. {
  3827. hasValue5 = true;
  3828. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3829. }
  3830. latestValue5 = x;
  3831. if (allHasValue)
  3832. {
  3833. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3834. }
  3835. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7)
  3836. {
  3837. await observer.OnCompletedAsync().ConfigureAwait(false);
  3838. }
  3839. }
  3840. },
  3841. async ex =>
  3842. {
  3843. using (await gate.LockAsync().ConfigureAwait(false))
  3844. {
  3845. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3846. }
  3847. },
  3848. async () =>
  3849. {
  3850. using (await gate.LockAsync().ConfigureAwait(false))
  3851. {
  3852. isDone5 = true;
  3853. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3854. {
  3855. await observer.OnCompletedAsync().ConfigureAwait(false);
  3856. }
  3857. }
  3858. }
  3859. ),
  3860. Create<T6>(
  3861. async x =>
  3862. {
  3863. using (await gate.LockAsync().ConfigureAwait(false))
  3864. {
  3865. if (!hasValue6)
  3866. {
  3867. hasValue6 = true;
  3868. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3869. }
  3870. latestValue6 = x;
  3871. if (allHasValue)
  3872. {
  3873. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3874. }
  3875. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7)
  3876. {
  3877. await observer.OnCompletedAsync().ConfigureAwait(false);
  3878. }
  3879. }
  3880. },
  3881. async ex =>
  3882. {
  3883. using (await gate.LockAsync().ConfigureAwait(false))
  3884. {
  3885. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3886. }
  3887. },
  3888. async () =>
  3889. {
  3890. using (await gate.LockAsync().ConfigureAwait(false))
  3891. {
  3892. isDone6 = true;
  3893. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3894. {
  3895. await observer.OnCompletedAsync().ConfigureAwait(false);
  3896. }
  3897. }
  3898. }
  3899. ),
  3900. Create<T7>(
  3901. async x =>
  3902. {
  3903. using (await gate.LockAsync().ConfigureAwait(false))
  3904. {
  3905. if (!hasValue7)
  3906. {
  3907. hasValue7 = true;
  3908. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3909. }
  3910. latestValue7 = x;
  3911. if (allHasValue)
  3912. {
  3913. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3914. }
  3915. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3916. {
  3917. await observer.OnCompletedAsync().ConfigureAwait(false);
  3918. }
  3919. }
  3920. },
  3921. async ex =>
  3922. {
  3923. using (await gate.LockAsync().ConfigureAwait(false))
  3924. {
  3925. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3926. }
  3927. },
  3928. async () =>
  3929. {
  3930. using (await gate.LockAsync().ConfigureAwait(false))
  3931. {
  3932. isDone7 = true;
  3933. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3934. {
  3935. await observer.OnCompletedAsync().ConfigureAwait(false);
  3936. }
  3937. }
  3938. }
  3939. )
  3940. );
  3941. }
  3942. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, TResult> selector)
  3943. {
  3944. if (observer == null)
  3945. throw new ArgumentNullException(nameof(observer));
  3946. if (selector == null)
  3947. throw new ArgumentNullException(nameof(selector));
  3948. return CombineLatest<T1, T2, T3, T4, T5, T6, T7, TResult>(observer, (x1, x2, x3, x4, x5, x6, x7) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5, x6, x7)));
  3949. }
  3950. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, ValueTask<TResult>> selector)
  3951. {
  3952. if (observer == null)
  3953. throw new ArgumentNullException(nameof(observer));
  3954. if (selector == null)
  3955. throw new ArgumentNullException(nameof(selector));
  3956. bool allHasValue = false;
  3957. bool hasValue1 = false;
  3958. bool isDone1 = false;
  3959. T1 latestValue1 = default(T1);
  3960. bool hasValue2 = false;
  3961. bool isDone2 = false;
  3962. T2 latestValue2 = default(T2);
  3963. bool hasValue3 = false;
  3964. bool isDone3 = false;
  3965. T3 latestValue3 = default(T3);
  3966. bool hasValue4 = false;
  3967. bool isDone4 = false;
  3968. T4 latestValue4 = default(T4);
  3969. bool hasValue5 = false;
  3970. bool isDone5 = false;
  3971. T5 latestValue5 = default(T5);
  3972. bool hasValue6 = false;
  3973. bool isDone6 = false;
  3974. T6 latestValue6 = default(T6);
  3975. bool hasValue7 = false;
  3976. bool isDone7 = false;
  3977. T7 latestValue7 = default(T7);
  3978. var gate = new AsyncGate();
  3979. return
  3980. (
  3981. Create<T1>(
  3982. async x =>
  3983. {
  3984. using (await gate.LockAsync().ConfigureAwait(false))
  3985. {
  3986. if (!hasValue1)
  3987. {
  3988. hasValue1 = true;
  3989. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3990. }
  3991. latestValue1 = x;
  3992. if (allHasValue)
  3993. {
  3994. TResult res;
  3995. try
  3996. {
  3997. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  3998. }
  3999. catch (Exception ex)
  4000. {
  4001. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4002. return;
  4003. }
  4004. await observer.OnNextAsync(res).ConfigureAwait(false);
  4005. }
  4006. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4007. {
  4008. await observer.OnCompletedAsync().ConfigureAwait(false);
  4009. }
  4010. }
  4011. },
  4012. async ex =>
  4013. {
  4014. using (await gate.LockAsync().ConfigureAwait(false))
  4015. {
  4016. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4017. }
  4018. },
  4019. async () =>
  4020. {
  4021. using (await gate.LockAsync().ConfigureAwait(false))
  4022. {
  4023. isDone1 = true;
  4024. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4025. {
  4026. await observer.OnCompletedAsync().ConfigureAwait(false);
  4027. }
  4028. }
  4029. }
  4030. ),
  4031. Create<T2>(
  4032. async x =>
  4033. {
  4034. using (await gate.LockAsync().ConfigureAwait(false))
  4035. {
  4036. if (!hasValue2)
  4037. {
  4038. hasValue2 = true;
  4039. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4040. }
  4041. latestValue2 = x;
  4042. if (allHasValue)
  4043. {
  4044. TResult res;
  4045. try
  4046. {
  4047. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4048. }
  4049. catch (Exception ex)
  4050. {
  4051. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4052. return;
  4053. }
  4054. await observer.OnNextAsync(res).ConfigureAwait(false);
  4055. }
  4056. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4057. {
  4058. await observer.OnCompletedAsync().ConfigureAwait(false);
  4059. }
  4060. }
  4061. },
  4062. async ex =>
  4063. {
  4064. using (await gate.LockAsync().ConfigureAwait(false))
  4065. {
  4066. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4067. }
  4068. },
  4069. async () =>
  4070. {
  4071. using (await gate.LockAsync().ConfigureAwait(false))
  4072. {
  4073. isDone2 = true;
  4074. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4075. {
  4076. await observer.OnCompletedAsync().ConfigureAwait(false);
  4077. }
  4078. }
  4079. }
  4080. ),
  4081. Create<T3>(
  4082. async x =>
  4083. {
  4084. using (await gate.LockAsync().ConfigureAwait(false))
  4085. {
  4086. if (!hasValue3)
  4087. {
  4088. hasValue3 = true;
  4089. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4090. }
  4091. latestValue3 = x;
  4092. if (allHasValue)
  4093. {
  4094. TResult res;
  4095. try
  4096. {
  4097. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4098. }
  4099. catch (Exception ex)
  4100. {
  4101. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4102. return;
  4103. }
  4104. await observer.OnNextAsync(res).ConfigureAwait(false);
  4105. }
  4106. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7)
  4107. {
  4108. await observer.OnCompletedAsync().ConfigureAwait(false);
  4109. }
  4110. }
  4111. },
  4112. async ex =>
  4113. {
  4114. using (await gate.LockAsync().ConfigureAwait(false))
  4115. {
  4116. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4117. }
  4118. },
  4119. async () =>
  4120. {
  4121. using (await gate.LockAsync().ConfigureAwait(false))
  4122. {
  4123. isDone3 = true;
  4124. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4125. {
  4126. await observer.OnCompletedAsync().ConfigureAwait(false);
  4127. }
  4128. }
  4129. }
  4130. ),
  4131. Create<T4>(
  4132. async x =>
  4133. {
  4134. using (await gate.LockAsync().ConfigureAwait(false))
  4135. {
  4136. if (!hasValue4)
  4137. {
  4138. hasValue4 = true;
  4139. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4140. }
  4141. latestValue4 = x;
  4142. if (allHasValue)
  4143. {
  4144. TResult res;
  4145. try
  4146. {
  4147. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4148. }
  4149. catch (Exception ex)
  4150. {
  4151. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4152. return;
  4153. }
  4154. await observer.OnNextAsync(res).ConfigureAwait(false);
  4155. }
  4156. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7)
  4157. {
  4158. await observer.OnCompletedAsync().ConfigureAwait(false);
  4159. }
  4160. }
  4161. },
  4162. async ex =>
  4163. {
  4164. using (await gate.LockAsync().ConfigureAwait(false))
  4165. {
  4166. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4167. }
  4168. },
  4169. async () =>
  4170. {
  4171. using (await gate.LockAsync().ConfigureAwait(false))
  4172. {
  4173. isDone4 = true;
  4174. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4175. {
  4176. await observer.OnCompletedAsync().ConfigureAwait(false);
  4177. }
  4178. }
  4179. }
  4180. ),
  4181. Create<T5>(
  4182. async x =>
  4183. {
  4184. using (await gate.LockAsync().ConfigureAwait(false))
  4185. {
  4186. if (!hasValue5)
  4187. {
  4188. hasValue5 = true;
  4189. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4190. }
  4191. latestValue5 = x;
  4192. if (allHasValue)
  4193. {
  4194. TResult res;
  4195. try
  4196. {
  4197. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4198. }
  4199. catch (Exception ex)
  4200. {
  4201. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4202. return;
  4203. }
  4204. await observer.OnNextAsync(res).ConfigureAwait(false);
  4205. }
  4206. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7)
  4207. {
  4208. await observer.OnCompletedAsync().ConfigureAwait(false);
  4209. }
  4210. }
  4211. },
  4212. async ex =>
  4213. {
  4214. using (await gate.LockAsync().ConfigureAwait(false))
  4215. {
  4216. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4217. }
  4218. },
  4219. async () =>
  4220. {
  4221. using (await gate.LockAsync().ConfigureAwait(false))
  4222. {
  4223. isDone5 = true;
  4224. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4225. {
  4226. await observer.OnCompletedAsync().ConfigureAwait(false);
  4227. }
  4228. }
  4229. }
  4230. ),
  4231. Create<T6>(
  4232. async x =>
  4233. {
  4234. using (await gate.LockAsync().ConfigureAwait(false))
  4235. {
  4236. if (!hasValue6)
  4237. {
  4238. hasValue6 = true;
  4239. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4240. }
  4241. latestValue6 = x;
  4242. if (allHasValue)
  4243. {
  4244. TResult res;
  4245. try
  4246. {
  4247. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4248. }
  4249. catch (Exception ex)
  4250. {
  4251. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4252. return;
  4253. }
  4254. await observer.OnNextAsync(res).ConfigureAwait(false);
  4255. }
  4256. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7)
  4257. {
  4258. await observer.OnCompletedAsync().ConfigureAwait(false);
  4259. }
  4260. }
  4261. },
  4262. async ex =>
  4263. {
  4264. using (await gate.LockAsync().ConfigureAwait(false))
  4265. {
  4266. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4267. }
  4268. },
  4269. async () =>
  4270. {
  4271. using (await gate.LockAsync().ConfigureAwait(false))
  4272. {
  4273. isDone6 = true;
  4274. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4275. {
  4276. await observer.OnCompletedAsync().ConfigureAwait(false);
  4277. }
  4278. }
  4279. }
  4280. ),
  4281. Create<T7>(
  4282. async x =>
  4283. {
  4284. using (await gate.LockAsync().ConfigureAwait(false))
  4285. {
  4286. if (!hasValue7)
  4287. {
  4288. hasValue7 = true;
  4289. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4290. }
  4291. latestValue7 = x;
  4292. if (allHasValue)
  4293. {
  4294. TResult res;
  4295. try
  4296. {
  4297. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4298. }
  4299. catch (Exception ex)
  4300. {
  4301. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4302. return;
  4303. }
  4304. await observer.OnNextAsync(res).ConfigureAwait(false);
  4305. }
  4306. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  4307. {
  4308. await observer.OnCompletedAsync().ConfigureAwait(false);
  4309. }
  4310. }
  4311. },
  4312. async ex =>
  4313. {
  4314. using (await gate.LockAsync().ConfigureAwait(false))
  4315. {
  4316. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4317. }
  4318. },
  4319. async () =>
  4320. {
  4321. using (await gate.LockAsync().ConfigureAwait(false))
  4322. {
  4323. isDone7 = true;
  4324. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4325. {
  4326. await observer.OnCompletedAsync().ConfigureAwait(false);
  4327. }
  4328. }
  4329. }
  4330. )
  4331. );
  4332. }
  4333. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8>(IAsyncObserver<(T1, T2, T3, T4, T5, T6, T7, T8)> observer)
  4334. {
  4335. if (observer == null)
  4336. throw new ArgumentNullException(nameof(observer));
  4337. bool allHasValue = false;
  4338. bool hasValue1 = false;
  4339. bool isDone1 = false;
  4340. T1 latestValue1 = default(T1);
  4341. bool hasValue2 = false;
  4342. bool isDone2 = false;
  4343. T2 latestValue2 = default(T2);
  4344. bool hasValue3 = false;
  4345. bool isDone3 = false;
  4346. T3 latestValue3 = default(T3);
  4347. bool hasValue4 = false;
  4348. bool isDone4 = false;
  4349. T4 latestValue4 = default(T4);
  4350. bool hasValue5 = false;
  4351. bool isDone5 = false;
  4352. T5 latestValue5 = default(T5);
  4353. bool hasValue6 = false;
  4354. bool isDone6 = false;
  4355. T6 latestValue6 = default(T6);
  4356. bool hasValue7 = false;
  4357. bool isDone7 = false;
  4358. T7 latestValue7 = default(T7);
  4359. bool hasValue8 = false;
  4360. bool isDone8 = false;
  4361. T8 latestValue8 = default(T8);
  4362. var gate = new AsyncGate();
  4363. return
  4364. (
  4365. Create<T1>(
  4366. async x =>
  4367. {
  4368. using (await gate.LockAsync().ConfigureAwait(false))
  4369. {
  4370. if (!hasValue1)
  4371. {
  4372. hasValue1 = true;
  4373. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4374. }
  4375. latestValue1 = x;
  4376. if (allHasValue)
  4377. {
  4378. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4379. }
  4380. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4381. {
  4382. await observer.OnCompletedAsync().ConfigureAwait(false);
  4383. }
  4384. }
  4385. },
  4386. async ex =>
  4387. {
  4388. using (await gate.LockAsync().ConfigureAwait(false))
  4389. {
  4390. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4391. }
  4392. },
  4393. async () =>
  4394. {
  4395. using (await gate.LockAsync().ConfigureAwait(false))
  4396. {
  4397. isDone1 = true;
  4398. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4399. {
  4400. await observer.OnCompletedAsync().ConfigureAwait(false);
  4401. }
  4402. }
  4403. }
  4404. ),
  4405. Create<T2>(
  4406. async x =>
  4407. {
  4408. using (await gate.LockAsync().ConfigureAwait(false))
  4409. {
  4410. if (!hasValue2)
  4411. {
  4412. hasValue2 = true;
  4413. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4414. }
  4415. latestValue2 = x;
  4416. if (allHasValue)
  4417. {
  4418. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4419. }
  4420. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4421. {
  4422. await observer.OnCompletedAsync().ConfigureAwait(false);
  4423. }
  4424. }
  4425. },
  4426. async ex =>
  4427. {
  4428. using (await gate.LockAsync().ConfigureAwait(false))
  4429. {
  4430. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4431. }
  4432. },
  4433. async () =>
  4434. {
  4435. using (await gate.LockAsync().ConfigureAwait(false))
  4436. {
  4437. isDone2 = true;
  4438. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4439. {
  4440. await observer.OnCompletedAsync().ConfigureAwait(false);
  4441. }
  4442. }
  4443. }
  4444. ),
  4445. Create<T3>(
  4446. async x =>
  4447. {
  4448. using (await gate.LockAsync().ConfigureAwait(false))
  4449. {
  4450. if (!hasValue3)
  4451. {
  4452. hasValue3 = true;
  4453. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4454. }
  4455. latestValue3 = x;
  4456. if (allHasValue)
  4457. {
  4458. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4459. }
  4460. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4461. {
  4462. await observer.OnCompletedAsync().ConfigureAwait(false);
  4463. }
  4464. }
  4465. },
  4466. async ex =>
  4467. {
  4468. using (await gate.LockAsync().ConfigureAwait(false))
  4469. {
  4470. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4471. }
  4472. },
  4473. async () =>
  4474. {
  4475. using (await gate.LockAsync().ConfigureAwait(false))
  4476. {
  4477. isDone3 = true;
  4478. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4479. {
  4480. await observer.OnCompletedAsync().ConfigureAwait(false);
  4481. }
  4482. }
  4483. }
  4484. ),
  4485. Create<T4>(
  4486. async x =>
  4487. {
  4488. using (await gate.LockAsync().ConfigureAwait(false))
  4489. {
  4490. if (!hasValue4)
  4491. {
  4492. hasValue4 = true;
  4493. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4494. }
  4495. latestValue4 = x;
  4496. if (allHasValue)
  4497. {
  4498. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4499. }
  4500. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8)
  4501. {
  4502. await observer.OnCompletedAsync().ConfigureAwait(false);
  4503. }
  4504. }
  4505. },
  4506. async ex =>
  4507. {
  4508. using (await gate.LockAsync().ConfigureAwait(false))
  4509. {
  4510. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4511. }
  4512. },
  4513. async () =>
  4514. {
  4515. using (await gate.LockAsync().ConfigureAwait(false))
  4516. {
  4517. isDone4 = true;
  4518. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4519. {
  4520. await observer.OnCompletedAsync().ConfigureAwait(false);
  4521. }
  4522. }
  4523. }
  4524. ),
  4525. Create<T5>(
  4526. async x =>
  4527. {
  4528. using (await gate.LockAsync().ConfigureAwait(false))
  4529. {
  4530. if (!hasValue5)
  4531. {
  4532. hasValue5 = true;
  4533. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4534. }
  4535. latestValue5 = x;
  4536. if (allHasValue)
  4537. {
  4538. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4539. }
  4540. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8)
  4541. {
  4542. await observer.OnCompletedAsync().ConfigureAwait(false);
  4543. }
  4544. }
  4545. },
  4546. async ex =>
  4547. {
  4548. using (await gate.LockAsync().ConfigureAwait(false))
  4549. {
  4550. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4551. }
  4552. },
  4553. async () =>
  4554. {
  4555. using (await gate.LockAsync().ConfigureAwait(false))
  4556. {
  4557. isDone5 = true;
  4558. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4559. {
  4560. await observer.OnCompletedAsync().ConfigureAwait(false);
  4561. }
  4562. }
  4563. }
  4564. ),
  4565. Create<T6>(
  4566. async x =>
  4567. {
  4568. using (await gate.LockAsync().ConfigureAwait(false))
  4569. {
  4570. if (!hasValue6)
  4571. {
  4572. hasValue6 = true;
  4573. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4574. }
  4575. latestValue6 = x;
  4576. if (allHasValue)
  4577. {
  4578. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4579. }
  4580. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8)
  4581. {
  4582. await observer.OnCompletedAsync().ConfigureAwait(false);
  4583. }
  4584. }
  4585. },
  4586. async ex =>
  4587. {
  4588. using (await gate.LockAsync().ConfigureAwait(false))
  4589. {
  4590. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4591. }
  4592. },
  4593. async () =>
  4594. {
  4595. using (await gate.LockAsync().ConfigureAwait(false))
  4596. {
  4597. isDone6 = true;
  4598. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4599. {
  4600. await observer.OnCompletedAsync().ConfigureAwait(false);
  4601. }
  4602. }
  4603. }
  4604. ),
  4605. Create<T7>(
  4606. async x =>
  4607. {
  4608. using (await gate.LockAsync().ConfigureAwait(false))
  4609. {
  4610. if (!hasValue7)
  4611. {
  4612. hasValue7 = true;
  4613. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4614. }
  4615. latestValue7 = x;
  4616. if (allHasValue)
  4617. {
  4618. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4619. }
  4620. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8)
  4621. {
  4622. await observer.OnCompletedAsync().ConfigureAwait(false);
  4623. }
  4624. }
  4625. },
  4626. async ex =>
  4627. {
  4628. using (await gate.LockAsync().ConfigureAwait(false))
  4629. {
  4630. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4631. }
  4632. },
  4633. async () =>
  4634. {
  4635. using (await gate.LockAsync().ConfigureAwait(false))
  4636. {
  4637. isDone7 = true;
  4638. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4639. {
  4640. await observer.OnCompletedAsync().ConfigureAwait(false);
  4641. }
  4642. }
  4643. }
  4644. ),
  4645. Create<T8>(
  4646. async x =>
  4647. {
  4648. using (await gate.LockAsync().ConfigureAwait(false))
  4649. {
  4650. if (!hasValue8)
  4651. {
  4652. hasValue8 = true;
  4653. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4654. }
  4655. latestValue8 = x;
  4656. if (allHasValue)
  4657. {
  4658. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4659. }
  4660. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4661. {
  4662. await observer.OnCompletedAsync().ConfigureAwait(false);
  4663. }
  4664. }
  4665. },
  4666. async ex =>
  4667. {
  4668. using (await gate.LockAsync().ConfigureAwait(false))
  4669. {
  4670. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4671. }
  4672. },
  4673. async () =>
  4674. {
  4675. using (await gate.LockAsync().ConfigureAwait(false))
  4676. {
  4677. isDone8 = true;
  4678. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4679. {
  4680. await observer.OnCompletedAsync().ConfigureAwait(false);
  4681. }
  4682. }
  4683. }
  4684. )
  4685. );
  4686. }
  4687. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, TResult> selector)
  4688. {
  4689. if (observer == null)
  4690. throw new ArgumentNullException(nameof(observer));
  4691. if (selector == null)
  4692. throw new ArgumentNullException(nameof(selector));
  4693. return CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(observer, (x1, x2, x3, x4, x5, x6, x7, x8) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5, x6, x7, x8)));
  4694. }
  4695. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, ValueTask<TResult>> selector)
  4696. {
  4697. if (observer == null)
  4698. throw new ArgumentNullException(nameof(observer));
  4699. if (selector == null)
  4700. throw new ArgumentNullException(nameof(selector));
  4701. bool allHasValue = false;
  4702. bool hasValue1 = false;
  4703. bool isDone1 = false;
  4704. T1 latestValue1 = default(T1);
  4705. bool hasValue2 = false;
  4706. bool isDone2 = false;
  4707. T2 latestValue2 = default(T2);
  4708. bool hasValue3 = false;
  4709. bool isDone3 = false;
  4710. T3 latestValue3 = default(T3);
  4711. bool hasValue4 = false;
  4712. bool isDone4 = false;
  4713. T4 latestValue4 = default(T4);
  4714. bool hasValue5 = false;
  4715. bool isDone5 = false;
  4716. T5 latestValue5 = default(T5);
  4717. bool hasValue6 = false;
  4718. bool isDone6 = false;
  4719. T6 latestValue6 = default(T6);
  4720. bool hasValue7 = false;
  4721. bool isDone7 = false;
  4722. T7 latestValue7 = default(T7);
  4723. bool hasValue8 = false;
  4724. bool isDone8 = false;
  4725. T8 latestValue8 = default(T8);
  4726. var gate = new AsyncGate();
  4727. return
  4728. (
  4729. Create<T1>(
  4730. async x =>
  4731. {
  4732. using (await gate.LockAsync().ConfigureAwait(false))
  4733. {
  4734. if (!hasValue1)
  4735. {
  4736. hasValue1 = true;
  4737. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4738. }
  4739. latestValue1 = x;
  4740. if (allHasValue)
  4741. {
  4742. TResult res;
  4743. try
  4744. {
  4745. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4746. }
  4747. catch (Exception ex)
  4748. {
  4749. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4750. return;
  4751. }
  4752. await observer.OnNextAsync(res).ConfigureAwait(false);
  4753. }
  4754. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4755. {
  4756. await observer.OnCompletedAsync().ConfigureAwait(false);
  4757. }
  4758. }
  4759. },
  4760. async ex =>
  4761. {
  4762. using (await gate.LockAsync().ConfigureAwait(false))
  4763. {
  4764. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4765. }
  4766. },
  4767. async () =>
  4768. {
  4769. using (await gate.LockAsync().ConfigureAwait(false))
  4770. {
  4771. isDone1 = true;
  4772. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4773. {
  4774. await observer.OnCompletedAsync().ConfigureAwait(false);
  4775. }
  4776. }
  4777. }
  4778. ),
  4779. Create<T2>(
  4780. async x =>
  4781. {
  4782. using (await gate.LockAsync().ConfigureAwait(false))
  4783. {
  4784. if (!hasValue2)
  4785. {
  4786. hasValue2 = true;
  4787. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4788. }
  4789. latestValue2 = x;
  4790. if (allHasValue)
  4791. {
  4792. TResult res;
  4793. try
  4794. {
  4795. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4796. }
  4797. catch (Exception ex)
  4798. {
  4799. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4800. return;
  4801. }
  4802. await observer.OnNextAsync(res).ConfigureAwait(false);
  4803. }
  4804. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4805. {
  4806. await observer.OnCompletedAsync().ConfigureAwait(false);
  4807. }
  4808. }
  4809. },
  4810. async ex =>
  4811. {
  4812. using (await gate.LockAsync().ConfigureAwait(false))
  4813. {
  4814. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4815. }
  4816. },
  4817. async () =>
  4818. {
  4819. using (await gate.LockAsync().ConfigureAwait(false))
  4820. {
  4821. isDone2 = true;
  4822. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4823. {
  4824. await observer.OnCompletedAsync().ConfigureAwait(false);
  4825. }
  4826. }
  4827. }
  4828. ),
  4829. Create<T3>(
  4830. async x =>
  4831. {
  4832. using (await gate.LockAsync().ConfigureAwait(false))
  4833. {
  4834. if (!hasValue3)
  4835. {
  4836. hasValue3 = true;
  4837. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4838. }
  4839. latestValue3 = x;
  4840. if (allHasValue)
  4841. {
  4842. TResult res;
  4843. try
  4844. {
  4845. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4846. }
  4847. catch (Exception ex)
  4848. {
  4849. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4850. return;
  4851. }
  4852. await observer.OnNextAsync(res).ConfigureAwait(false);
  4853. }
  4854. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4855. {
  4856. await observer.OnCompletedAsync().ConfigureAwait(false);
  4857. }
  4858. }
  4859. },
  4860. async ex =>
  4861. {
  4862. using (await gate.LockAsync().ConfigureAwait(false))
  4863. {
  4864. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4865. }
  4866. },
  4867. async () =>
  4868. {
  4869. using (await gate.LockAsync().ConfigureAwait(false))
  4870. {
  4871. isDone3 = true;
  4872. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4873. {
  4874. await observer.OnCompletedAsync().ConfigureAwait(false);
  4875. }
  4876. }
  4877. }
  4878. ),
  4879. Create<T4>(
  4880. async x =>
  4881. {
  4882. using (await gate.LockAsync().ConfigureAwait(false))
  4883. {
  4884. if (!hasValue4)
  4885. {
  4886. hasValue4 = true;
  4887. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4888. }
  4889. latestValue4 = x;
  4890. if (allHasValue)
  4891. {
  4892. TResult res;
  4893. try
  4894. {
  4895. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4896. }
  4897. catch (Exception ex)
  4898. {
  4899. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4900. return;
  4901. }
  4902. await observer.OnNextAsync(res).ConfigureAwait(false);
  4903. }
  4904. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8)
  4905. {
  4906. await observer.OnCompletedAsync().ConfigureAwait(false);
  4907. }
  4908. }
  4909. },
  4910. async ex =>
  4911. {
  4912. using (await gate.LockAsync().ConfigureAwait(false))
  4913. {
  4914. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4915. }
  4916. },
  4917. async () =>
  4918. {
  4919. using (await gate.LockAsync().ConfigureAwait(false))
  4920. {
  4921. isDone4 = true;
  4922. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4923. {
  4924. await observer.OnCompletedAsync().ConfigureAwait(false);
  4925. }
  4926. }
  4927. }
  4928. ),
  4929. Create<T5>(
  4930. async x =>
  4931. {
  4932. using (await gate.LockAsync().ConfigureAwait(false))
  4933. {
  4934. if (!hasValue5)
  4935. {
  4936. hasValue5 = true;
  4937. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4938. }
  4939. latestValue5 = x;
  4940. if (allHasValue)
  4941. {
  4942. TResult res;
  4943. try
  4944. {
  4945. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4946. }
  4947. catch (Exception ex)
  4948. {
  4949. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4950. return;
  4951. }
  4952. await observer.OnNextAsync(res).ConfigureAwait(false);
  4953. }
  4954. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8)
  4955. {
  4956. await observer.OnCompletedAsync().ConfigureAwait(false);
  4957. }
  4958. }
  4959. },
  4960. async ex =>
  4961. {
  4962. using (await gate.LockAsync().ConfigureAwait(false))
  4963. {
  4964. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4965. }
  4966. },
  4967. async () =>
  4968. {
  4969. using (await gate.LockAsync().ConfigureAwait(false))
  4970. {
  4971. isDone5 = true;
  4972. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4973. {
  4974. await observer.OnCompletedAsync().ConfigureAwait(false);
  4975. }
  4976. }
  4977. }
  4978. ),
  4979. Create<T6>(
  4980. async x =>
  4981. {
  4982. using (await gate.LockAsync().ConfigureAwait(false))
  4983. {
  4984. if (!hasValue6)
  4985. {
  4986. hasValue6 = true;
  4987. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4988. }
  4989. latestValue6 = x;
  4990. if (allHasValue)
  4991. {
  4992. TResult res;
  4993. try
  4994. {
  4995. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4996. }
  4997. catch (Exception ex)
  4998. {
  4999. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5000. return;
  5001. }
  5002. await observer.OnNextAsync(res).ConfigureAwait(false);
  5003. }
  5004. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8)
  5005. {
  5006. await observer.OnCompletedAsync().ConfigureAwait(false);
  5007. }
  5008. }
  5009. },
  5010. async ex =>
  5011. {
  5012. using (await gate.LockAsync().ConfigureAwait(false))
  5013. {
  5014. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5015. }
  5016. },
  5017. async () =>
  5018. {
  5019. using (await gate.LockAsync().ConfigureAwait(false))
  5020. {
  5021. isDone6 = true;
  5022. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  5023. {
  5024. await observer.OnCompletedAsync().ConfigureAwait(false);
  5025. }
  5026. }
  5027. }
  5028. ),
  5029. Create<T7>(
  5030. async x =>
  5031. {
  5032. using (await gate.LockAsync().ConfigureAwait(false))
  5033. {
  5034. if (!hasValue7)
  5035. {
  5036. hasValue7 = true;
  5037. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  5038. }
  5039. latestValue7 = x;
  5040. if (allHasValue)
  5041. {
  5042. TResult res;
  5043. try
  5044. {
  5045. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  5046. }
  5047. catch (Exception ex)
  5048. {
  5049. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5050. return;
  5051. }
  5052. await observer.OnNextAsync(res).ConfigureAwait(false);
  5053. }
  5054. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8)
  5055. {
  5056. await observer.OnCompletedAsync().ConfigureAwait(false);
  5057. }
  5058. }
  5059. },
  5060. async ex =>
  5061. {
  5062. using (await gate.LockAsync().ConfigureAwait(false))
  5063. {
  5064. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5065. }
  5066. },
  5067. async () =>
  5068. {
  5069. using (await gate.LockAsync().ConfigureAwait(false))
  5070. {
  5071. isDone7 = true;
  5072. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  5073. {
  5074. await observer.OnCompletedAsync().ConfigureAwait(false);
  5075. }
  5076. }
  5077. }
  5078. ),
  5079. Create<T8>(
  5080. async x =>
  5081. {
  5082. using (await gate.LockAsync().ConfigureAwait(false))
  5083. {
  5084. if (!hasValue8)
  5085. {
  5086. hasValue8 = true;
  5087. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  5088. }
  5089. latestValue8 = x;
  5090. if (allHasValue)
  5091. {
  5092. TResult res;
  5093. try
  5094. {
  5095. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  5096. }
  5097. catch (Exception ex)
  5098. {
  5099. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5100. return;
  5101. }
  5102. await observer.OnNextAsync(res).ConfigureAwait(false);
  5103. }
  5104. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  5105. {
  5106. await observer.OnCompletedAsync().ConfigureAwait(false);
  5107. }
  5108. }
  5109. },
  5110. async ex =>
  5111. {
  5112. using (await gate.LockAsync().ConfigureAwait(false))
  5113. {
  5114. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5115. }
  5116. },
  5117. async () =>
  5118. {
  5119. using (await gate.LockAsync().ConfigureAwait(false))
  5120. {
  5121. isDone8 = true;
  5122. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  5123. {
  5124. await observer.OnCompletedAsync().ConfigureAwait(false);
  5125. }
  5126. }
  5127. }
  5128. )
  5129. );
  5130. }
  5131. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9>(IAsyncObserver<(T1, T2, T3, T4, T5, T6, T7, T8, T9)> observer)
  5132. {
  5133. if (observer == null)
  5134. throw new ArgumentNullException(nameof(observer));
  5135. bool allHasValue = false;
  5136. bool hasValue1 = false;
  5137. bool isDone1 = false;
  5138. T1 latestValue1 = default(T1);
  5139. bool hasValue2 = false;
  5140. bool isDone2 = false;
  5141. T2 latestValue2 = default(T2);
  5142. bool hasValue3 = false;
  5143. bool isDone3 = false;
  5144. T3 latestValue3 = default(T3);
  5145. bool hasValue4 = false;
  5146. bool isDone4 = false;
  5147. T4 latestValue4 = default(T4);
  5148. bool hasValue5 = false;
  5149. bool isDone5 = false;
  5150. T5 latestValue5 = default(T5);
  5151. bool hasValue6 = false;
  5152. bool isDone6 = false;
  5153. T6 latestValue6 = default(T6);
  5154. bool hasValue7 = false;
  5155. bool isDone7 = false;
  5156. T7 latestValue7 = default(T7);
  5157. bool hasValue8 = false;
  5158. bool isDone8 = false;
  5159. T8 latestValue8 = default(T8);
  5160. bool hasValue9 = false;
  5161. bool isDone9 = false;
  5162. T9 latestValue9 = default(T9);
  5163. var gate = new AsyncGate();
  5164. return
  5165. (
  5166. Create<T1>(
  5167. async x =>
  5168. {
  5169. using (await gate.LockAsync().ConfigureAwait(false))
  5170. {
  5171. if (!hasValue1)
  5172. {
  5173. hasValue1 = true;
  5174. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5175. }
  5176. latestValue1 = x;
  5177. if (allHasValue)
  5178. {
  5179. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5180. }
  5181. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5182. {
  5183. await observer.OnCompletedAsync().ConfigureAwait(false);
  5184. }
  5185. }
  5186. },
  5187. async ex =>
  5188. {
  5189. using (await gate.LockAsync().ConfigureAwait(false))
  5190. {
  5191. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5192. }
  5193. },
  5194. async () =>
  5195. {
  5196. using (await gate.LockAsync().ConfigureAwait(false))
  5197. {
  5198. isDone1 = true;
  5199. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5200. {
  5201. await observer.OnCompletedAsync().ConfigureAwait(false);
  5202. }
  5203. }
  5204. }
  5205. ),
  5206. Create<T2>(
  5207. async x =>
  5208. {
  5209. using (await gate.LockAsync().ConfigureAwait(false))
  5210. {
  5211. if (!hasValue2)
  5212. {
  5213. hasValue2 = true;
  5214. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5215. }
  5216. latestValue2 = x;
  5217. if (allHasValue)
  5218. {
  5219. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5220. }
  5221. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5222. {
  5223. await observer.OnCompletedAsync().ConfigureAwait(false);
  5224. }
  5225. }
  5226. },
  5227. async ex =>
  5228. {
  5229. using (await gate.LockAsync().ConfigureAwait(false))
  5230. {
  5231. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5232. }
  5233. },
  5234. async () =>
  5235. {
  5236. using (await gate.LockAsync().ConfigureAwait(false))
  5237. {
  5238. isDone2 = true;
  5239. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5240. {
  5241. await observer.OnCompletedAsync().ConfigureAwait(false);
  5242. }
  5243. }
  5244. }
  5245. ),
  5246. Create<T3>(
  5247. async x =>
  5248. {
  5249. using (await gate.LockAsync().ConfigureAwait(false))
  5250. {
  5251. if (!hasValue3)
  5252. {
  5253. hasValue3 = true;
  5254. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5255. }
  5256. latestValue3 = x;
  5257. if (allHasValue)
  5258. {
  5259. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5260. }
  5261. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5262. {
  5263. await observer.OnCompletedAsync().ConfigureAwait(false);
  5264. }
  5265. }
  5266. },
  5267. async ex =>
  5268. {
  5269. using (await gate.LockAsync().ConfigureAwait(false))
  5270. {
  5271. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5272. }
  5273. },
  5274. async () =>
  5275. {
  5276. using (await gate.LockAsync().ConfigureAwait(false))
  5277. {
  5278. isDone3 = true;
  5279. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5280. {
  5281. await observer.OnCompletedAsync().ConfigureAwait(false);
  5282. }
  5283. }
  5284. }
  5285. ),
  5286. Create<T4>(
  5287. async x =>
  5288. {
  5289. using (await gate.LockAsync().ConfigureAwait(false))
  5290. {
  5291. if (!hasValue4)
  5292. {
  5293. hasValue4 = true;
  5294. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5295. }
  5296. latestValue4 = x;
  5297. if (allHasValue)
  5298. {
  5299. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5300. }
  5301. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5302. {
  5303. await observer.OnCompletedAsync().ConfigureAwait(false);
  5304. }
  5305. }
  5306. },
  5307. async ex =>
  5308. {
  5309. using (await gate.LockAsync().ConfigureAwait(false))
  5310. {
  5311. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5312. }
  5313. },
  5314. async () =>
  5315. {
  5316. using (await gate.LockAsync().ConfigureAwait(false))
  5317. {
  5318. isDone4 = true;
  5319. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5320. {
  5321. await observer.OnCompletedAsync().ConfigureAwait(false);
  5322. }
  5323. }
  5324. }
  5325. ),
  5326. Create<T5>(
  5327. async x =>
  5328. {
  5329. using (await gate.LockAsync().ConfigureAwait(false))
  5330. {
  5331. if (!hasValue5)
  5332. {
  5333. hasValue5 = true;
  5334. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5335. }
  5336. latestValue5 = x;
  5337. if (allHasValue)
  5338. {
  5339. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5340. }
  5341. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9)
  5342. {
  5343. await observer.OnCompletedAsync().ConfigureAwait(false);
  5344. }
  5345. }
  5346. },
  5347. async ex =>
  5348. {
  5349. using (await gate.LockAsync().ConfigureAwait(false))
  5350. {
  5351. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5352. }
  5353. },
  5354. async () =>
  5355. {
  5356. using (await gate.LockAsync().ConfigureAwait(false))
  5357. {
  5358. isDone5 = true;
  5359. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5360. {
  5361. await observer.OnCompletedAsync().ConfigureAwait(false);
  5362. }
  5363. }
  5364. }
  5365. ),
  5366. Create<T6>(
  5367. async x =>
  5368. {
  5369. using (await gate.LockAsync().ConfigureAwait(false))
  5370. {
  5371. if (!hasValue6)
  5372. {
  5373. hasValue6 = true;
  5374. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5375. }
  5376. latestValue6 = x;
  5377. if (allHasValue)
  5378. {
  5379. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5380. }
  5381. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9)
  5382. {
  5383. await observer.OnCompletedAsync().ConfigureAwait(false);
  5384. }
  5385. }
  5386. },
  5387. async ex =>
  5388. {
  5389. using (await gate.LockAsync().ConfigureAwait(false))
  5390. {
  5391. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5392. }
  5393. },
  5394. async () =>
  5395. {
  5396. using (await gate.LockAsync().ConfigureAwait(false))
  5397. {
  5398. isDone6 = true;
  5399. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5400. {
  5401. await observer.OnCompletedAsync().ConfigureAwait(false);
  5402. }
  5403. }
  5404. }
  5405. ),
  5406. Create<T7>(
  5407. async x =>
  5408. {
  5409. using (await gate.LockAsync().ConfigureAwait(false))
  5410. {
  5411. if (!hasValue7)
  5412. {
  5413. hasValue7 = true;
  5414. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5415. }
  5416. latestValue7 = x;
  5417. if (allHasValue)
  5418. {
  5419. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5420. }
  5421. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9)
  5422. {
  5423. await observer.OnCompletedAsync().ConfigureAwait(false);
  5424. }
  5425. }
  5426. },
  5427. async ex =>
  5428. {
  5429. using (await gate.LockAsync().ConfigureAwait(false))
  5430. {
  5431. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5432. }
  5433. },
  5434. async () =>
  5435. {
  5436. using (await gate.LockAsync().ConfigureAwait(false))
  5437. {
  5438. isDone7 = true;
  5439. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5440. {
  5441. await observer.OnCompletedAsync().ConfigureAwait(false);
  5442. }
  5443. }
  5444. }
  5445. ),
  5446. Create<T8>(
  5447. async x =>
  5448. {
  5449. using (await gate.LockAsync().ConfigureAwait(false))
  5450. {
  5451. if (!hasValue8)
  5452. {
  5453. hasValue8 = true;
  5454. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5455. }
  5456. latestValue8 = x;
  5457. if (allHasValue)
  5458. {
  5459. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5460. }
  5461. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9)
  5462. {
  5463. await observer.OnCompletedAsync().ConfigureAwait(false);
  5464. }
  5465. }
  5466. },
  5467. async ex =>
  5468. {
  5469. using (await gate.LockAsync().ConfigureAwait(false))
  5470. {
  5471. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5472. }
  5473. },
  5474. async () =>
  5475. {
  5476. using (await gate.LockAsync().ConfigureAwait(false))
  5477. {
  5478. isDone8 = true;
  5479. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5480. {
  5481. await observer.OnCompletedAsync().ConfigureAwait(false);
  5482. }
  5483. }
  5484. }
  5485. ),
  5486. Create<T9>(
  5487. async x =>
  5488. {
  5489. using (await gate.LockAsync().ConfigureAwait(false))
  5490. {
  5491. if (!hasValue9)
  5492. {
  5493. hasValue9 = true;
  5494. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5495. }
  5496. latestValue9 = x;
  5497. if (allHasValue)
  5498. {
  5499. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5500. }
  5501. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  5502. {
  5503. await observer.OnCompletedAsync().ConfigureAwait(false);
  5504. }
  5505. }
  5506. },
  5507. async ex =>
  5508. {
  5509. using (await gate.LockAsync().ConfigureAwait(false))
  5510. {
  5511. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5512. }
  5513. },
  5514. async () =>
  5515. {
  5516. using (await gate.LockAsync().ConfigureAwait(false))
  5517. {
  5518. isDone9 = true;
  5519. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5520. {
  5521. await observer.OnCompletedAsync().ConfigureAwait(false);
  5522. }
  5523. }
  5524. }
  5525. )
  5526. );
  5527. }
  5528. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult> selector)
  5529. {
  5530. if (observer == null)
  5531. throw new ArgumentNullException(nameof(observer));
  5532. if (selector == null)
  5533. throw new ArgumentNullException(nameof(selector));
  5534. return CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(observer, (x1, x2, x3, x4, x5, x6, x7, x8, x9) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5, x6, x7, x8, x9)));
  5535. }
  5536. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, ValueTask<TResult>> selector)
  5537. {
  5538. if (observer == null)
  5539. throw new ArgumentNullException(nameof(observer));
  5540. if (selector == null)
  5541. throw new ArgumentNullException(nameof(selector));
  5542. bool allHasValue = false;
  5543. bool hasValue1 = false;
  5544. bool isDone1 = false;
  5545. T1 latestValue1 = default(T1);
  5546. bool hasValue2 = false;
  5547. bool isDone2 = false;
  5548. T2 latestValue2 = default(T2);
  5549. bool hasValue3 = false;
  5550. bool isDone3 = false;
  5551. T3 latestValue3 = default(T3);
  5552. bool hasValue4 = false;
  5553. bool isDone4 = false;
  5554. T4 latestValue4 = default(T4);
  5555. bool hasValue5 = false;
  5556. bool isDone5 = false;
  5557. T5 latestValue5 = default(T5);
  5558. bool hasValue6 = false;
  5559. bool isDone6 = false;
  5560. T6 latestValue6 = default(T6);
  5561. bool hasValue7 = false;
  5562. bool isDone7 = false;
  5563. T7 latestValue7 = default(T7);
  5564. bool hasValue8 = false;
  5565. bool isDone8 = false;
  5566. T8 latestValue8 = default(T8);
  5567. bool hasValue9 = false;
  5568. bool isDone9 = false;
  5569. T9 latestValue9 = default(T9);
  5570. var gate = new AsyncGate();
  5571. return
  5572. (
  5573. Create<T1>(
  5574. async x =>
  5575. {
  5576. using (await gate.LockAsync().ConfigureAwait(false))
  5577. {
  5578. if (!hasValue1)
  5579. {
  5580. hasValue1 = true;
  5581. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5582. }
  5583. latestValue1 = x;
  5584. if (allHasValue)
  5585. {
  5586. TResult res;
  5587. try
  5588. {
  5589. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5590. }
  5591. catch (Exception ex)
  5592. {
  5593. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5594. return;
  5595. }
  5596. await observer.OnNextAsync(res).ConfigureAwait(false);
  5597. }
  5598. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5599. {
  5600. await observer.OnCompletedAsync().ConfigureAwait(false);
  5601. }
  5602. }
  5603. },
  5604. async ex =>
  5605. {
  5606. using (await gate.LockAsync().ConfigureAwait(false))
  5607. {
  5608. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5609. }
  5610. },
  5611. async () =>
  5612. {
  5613. using (await gate.LockAsync().ConfigureAwait(false))
  5614. {
  5615. isDone1 = true;
  5616. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5617. {
  5618. await observer.OnCompletedAsync().ConfigureAwait(false);
  5619. }
  5620. }
  5621. }
  5622. ),
  5623. Create<T2>(
  5624. async x =>
  5625. {
  5626. using (await gate.LockAsync().ConfigureAwait(false))
  5627. {
  5628. if (!hasValue2)
  5629. {
  5630. hasValue2 = true;
  5631. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5632. }
  5633. latestValue2 = x;
  5634. if (allHasValue)
  5635. {
  5636. TResult res;
  5637. try
  5638. {
  5639. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5640. }
  5641. catch (Exception ex)
  5642. {
  5643. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5644. return;
  5645. }
  5646. await observer.OnNextAsync(res).ConfigureAwait(false);
  5647. }
  5648. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5649. {
  5650. await observer.OnCompletedAsync().ConfigureAwait(false);
  5651. }
  5652. }
  5653. },
  5654. async ex =>
  5655. {
  5656. using (await gate.LockAsync().ConfigureAwait(false))
  5657. {
  5658. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5659. }
  5660. },
  5661. async () =>
  5662. {
  5663. using (await gate.LockAsync().ConfigureAwait(false))
  5664. {
  5665. isDone2 = true;
  5666. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5667. {
  5668. await observer.OnCompletedAsync().ConfigureAwait(false);
  5669. }
  5670. }
  5671. }
  5672. ),
  5673. Create<T3>(
  5674. async x =>
  5675. {
  5676. using (await gate.LockAsync().ConfigureAwait(false))
  5677. {
  5678. if (!hasValue3)
  5679. {
  5680. hasValue3 = true;
  5681. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5682. }
  5683. latestValue3 = x;
  5684. if (allHasValue)
  5685. {
  5686. TResult res;
  5687. try
  5688. {
  5689. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5690. }
  5691. catch (Exception ex)
  5692. {
  5693. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5694. return;
  5695. }
  5696. await observer.OnNextAsync(res).ConfigureAwait(false);
  5697. }
  5698. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5699. {
  5700. await observer.OnCompletedAsync().ConfigureAwait(false);
  5701. }
  5702. }
  5703. },
  5704. async ex =>
  5705. {
  5706. using (await gate.LockAsync().ConfigureAwait(false))
  5707. {
  5708. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5709. }
  5710. },
  5711. async () =>
  5712. {
  5713. using (await gate.LockAsync().ConfigureAwait(false))
  5714. {
  5715. isDone3 = true;
  5716. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5717. {
  5718. await observer.OnCompletedAsync().ConfigureAwait(false);
  5719. }
  5720. }
  5721. }
  5722. ),
  5723. Create<T4>(
  5724. async x =>
  5725. {
  5726. using (await gate.LockAsync().ConfigureAwait(false))
  5727. {
  5728. if (!hasValue4)
  5729. {
  5730. hasValue4 = true;
  5731. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5732. }
  5733. latestValue4 = x;
  5734. if (allHasValue)
  5735. {
  5736. TResult res;
  5737. try
  5738. {
  5739. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5740. }
  5741. catch (Exception ex)
  5742. {
  5743. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5744. return;
  5745. }
  5746. await observer.OnNextAsync(res).ConfigureAwait(false);
  5747. }
  5748. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5749. {
  5750. await observer.OnCompletedAsync().ConfigureAwait(false);
  5751. }
  5752. }
  5753. },
  5754. async ex =>
  5755. {
  5756. using (await gate.LockAsync().ConfigureAwait(false))
  5757. {
  5758. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5759. }
  5760. },
  5761. async () =>
  5762. {
  5763. using (await gate.LockAsync().ConfigureAwait(false))
  5764. {
  5765. isDone4 = true;
  5766. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5767. {
  5768. await observer.OnCompletedAsync().ConfigureAwait(false);
  5769. }
  5770. }
  5771. }
  5772. ),
  5773. Create<T5>(
  5774. async x =>
  5775. {
  5776. using (await gate.LockAsync().ConfigureAwait(false))
  5777. {
  5778. if (!hasValue5)
  5779. {
  5780. hasValue5 = true;
  5781. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5782. }
  5783. latestValue5 = x;
  5784. if (allHasValue)
  5785. {
  5786. TResult res;
  5787. try
  5788. {
  5789. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5790. }
  5791. catch (Exception ex)
  5792. {
  5793. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5794. return;
  5795. }
  5796. await observer.OnNextAsync(res).ConfigureAwait(false);
  5797. }
  5798. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9)
  5799. {
  5800. await observer.OnCompletedAsync().ConfigureAwait(false);
  5801. }
  5802. }
  5803. },
  5804. async ex =>
  5805. {
  5806. using (await gate.LockAsync().ConfigureAwait(false))
  5807. {
  5808. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5809. }
  5810. },
  5811. async () =>
  5812. {
  5813. using (await gate.LockAsync().ConfigureAwait(false))
  5814. {
  5815. isDone5 = true;
  5816. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5817. {
  5818. await observer.OnCompletedAsync().ConfigureAwait(false);
  5819. }
  5820. }
  5821. }
  5822. ),
  5823. Create<T6>(
  5824. async x =>
  5825. {
  5826. using (await gate.LockAsync().ConfigureAwait(false))
  5827. {
  5828. if (!hasValue6)
  5829. {
  5830. hasValue6 = true;
  5831. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5832. }
  5833. latestValue6 = x;
  5834. if (allHasValue)
  5835. {
  5836. TResult res;
  5837. try
  5838. {
  5839. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5840. }
  5841. catch (Exception ex)
  5842. {
  5843. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5844. return;
  5845. }
  5846. await observer.OnNextAsync(res).ConfigureAwait(false);
  5847. }
  5848. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9)
  5849. {
  5850. await observer.OnCompletedAsync().ConfigureAwait(false);
  5851. }
  5852. }
  5853. },
  5854. async ex =>
  5855. {
  5856. using (await gate.LockAsync().ConfigureAwait(false))
  5857. {
  5858. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5859. }
  5860. },
  5861. async () =>
  5862. {
  5863. using (await gate.LockAsync().ConfigureAwait(false))
  5864. {
  5865. isDone6 = true;
  5866. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5867. {
  5868. await observer.OnCompletedAsync().ConfigureAwait(false);
  5869. }
  5870. }
  5871. }
  5872. ),
  5873. Create<T7>(
  5874. async x =>
  5875. {
  5876. using (await gate.LockAsync().ConfigureAwait(false))
  5877. {
  5878. if (!hasValue7)
  5879. {
  5880. hasValue7 = true;
  5881. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5882. }
  5883. latestValue7 = x;
  5884. if (allHasValue)
  5885. {
  5886. TResult res;
  5887. try
  5888. {
  5889. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5890. }
  5891. catch (Exception ex)
  5892. {
  5893. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5894. return;
  5895. }
  5896. await observer.OnNextAsync(res).ConfigureAwait(false);
  5897. }
  5898. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9)
  5899. {
  5900. await observer.OnCompletedAsync().ConfigureAwait(false);
  5901. }
  5902. }
  5903. },
  5904. async ex =>
  5905. {
  5906. using (await gate.LockAsync().ConfigureAwait(false))
  5907. {
  5908. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5909. }
  5910. },
  5911. async () =>
  5912. {
  5913. using (await gate.LockAsync().ConfigureAwait(false))
  5914. {
  5915. isDone7 = true;
  5916. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5917. {
  5918. await observer.OnCompletedAsync().ConfigureAwait(false);
  5919. }
  5920. }
  5921. }
  5922. ),
  5923. Create<T8>(
  5924. async x =>
  5925. {
  5926. using (await gate.LockAsync().ConfigureAwait(false))
  5927. {
  5928. if (!hasValue8)
  5929. {
  5930. hasValue8 = true;
  5931. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5932. }
  5933. latestValue8 = x;
  5934. if (allHasValue)
  5935. {
  5936. TResult res;
  5937. try
  5938. {
  5939. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5940. }
  5941. catch (Exception ex)
  5942. {
  5943. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5944. return;
  5945. }
  5946. await observer.OnNextAsync(res).ConfigureAwait(false);
  5947. }
  5948. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9)
  5949. {
  5950. await observer.OnCompletedAsync().ConfigureAwait(false);
  5951. }
  5952. }
  5953. },
  5954. async ex =>
  5955. {
  5956. using (await gate.LockAsync().ConfigureAwait(false))
  5957. {
  5958. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5959. }
  5960. },
  5961. async () =>
  5962. {
  5963. using (await gate.LockAsync().ConfigureAwait(false))
  5964. {
  5965. isDone8 = true;
  5966. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5967. {
  5968. await observer.OnCompletedAsync().ConfigureAwait(false);
  5969. }
  5970. }
  5971. }
  5972. ),
  5973. Create<T9>(
  5974. async x =>
  5975. {
  5976. using (await gate.LockAsync().ConfigureAwait(false))
  5977. {
  5978. if (!hasValue9)
  5979. {
  5980. hasValue9 = true;
  5981. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5982. }
  5983. latestValue9 = x;
  5984. if (allHasValue)
  5985. {
  5986. TResult res;
  5987. try
  5988. {
  5989. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5990. }
  5991. catch (Exception ex)
  5992. {
  5993. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5994. return;
  5995. }
  5996. await observer.OnNextAsync(res).ConfigureAwait(false);
  5997. }
  5998. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  5999. {
  6000. await observer.OnCompletedAsync().ConfigureAwait(false);
  6001. }
  6002. }
  6003. },
  6004. async ex =>
  6005. {
  6006. using (await gate.LockAsync().ConfigureAwait(false))
  6007. {
  6008. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6009. }
  6010. },
  6011. async () =>
  6012. {
  6013. using (await gate.LockAsync().ConfigureAwait(false))
  6014. {
  6015. isDone9 = true;
  6016. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  6017. {
  6018. await observer.OnCompletedAsync().ConfigureAwait(false);
  6019. }
  6020. }
  6021. }
  6022. )
  6023. );
  6024. }
  6025. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(IAsyncObserver<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)> observer)
  6026. {
  6027. if (observer == null)
  6028. throw new ArgumentNullException(nameof(observer));
  6029. bool allHasValue = false;
  6030. bool hasValue1 = false;
  6031. bool isDone1 = false;
  6032. T1 latestValue1 = default(T1);
  6033. bool hasValue2 = false;
  6034. bool isDone2 = false;
  6035. T2 latestValue2 = default(T2);
  6036. bool hasValue3 = false;
  6037. bool isDone3 = false;
  6038. T3 latestValue3 = default(T3);
  6039. bool hasValue4 = false;
  6040. bool isDone4 = false;
  6041. T4 latestValue4 = default(T4);
  6042. bool hasValue5 = false;
  6043. bool isDone5 = false;
  6044. T5 latestValue5 = default(T5);
  6045. bool hasValue6 = false;
  6046. bool isDone6 = false;
  6047. T6 latestValue6 = default(T6);
  6048. bool hasValue7 = false;
  6049. bool isDone7 = false;
  6050. T7 latestValue7 = default(T7);
  6051. bool hasValue8 = false;
  6052. bool isDone8 = false;
  6053. T8 latestValue8 = default(T8);
  6054. bool hasValue9 = false;
  6055. bool isDone9 = false;
  6056. T9 latestValue9 = default(T9);
  6057. bool hasValue10 = false;
  6058. bool isDone10 = false;
  6059. T10 latestValue10 = default(T10);
  6060. var gate = new AsyncGate();
  6061. return
  6062. (
  6063. Create<T1>(
  6064. async x =>
  6065. {
  6066. using (await gate.LockAsync().ConfigureAwait(false))
  6067. {
  6068. if (!hasValue1)
  6069. {
  6070. hasValue1 = true;
  6071. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6072. }
  6073. latestValue1 = x;
  6074. if (allHasValue)
  6075. {
  6076. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6077. }
  6078. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6079. {
  6080. await observer.OnCompletedAsync().ConfigureAwait(false);
  6081. }
  6082. }
  6083. },
  6084. async ex =>
  6085. {
  6086. using (await gate.LockAsync().ConfigureAwait(false))
  6087. {
  6088. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6089. }
  6090. },
  6091. async () =>
  6092. {
  6093. using (await gate.LockAsync().ConfigureAwait(false))
  6094. {
  6095. isDone1 = true;
  6096. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6097. {
  6098. await observer.OnCompletedAsync().ConfigureAwait(false);
  6099. }
  6100. }
  6101. }
  6102. ),
  6103. Create<T2>(
  6104. async x =>
  6105. {
  6106. using (await gate.LockAsync().ConfigureAwait(false))
  6107. {
  6108. if (!hasValue2)
  6109. {
  6110. hasValue2 = true;
  6111. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6112. }
  6113. latestValue2 = x;
  6114. if (allHasValue)
  6115. {
  6116. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6117. }
  6118. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6119. {
  6120. await observer.OnCompletedAsync().ConfigureAwait(false);
  6121. }
  6122. }
  6123. },
  6124. async ex =>
  6125. {
  6126. using (await gate.LockAsync().ConfigureAwait(false))
  6127. {
  6128. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6129. }
  6130. },
  6131. async () =>
  6132. {
  6133. using (await gate.LockAsync().ConfigureAwait(false))
  6134. {
  6135. isDone2 = true;
  6136. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6137. {
  6138. await observer.OnCompletedAsync().ConfigureAwait(false);
  6139. }
  6140. }
  6141. }
  6142. ),
  6143. Create<T3>(
  6144. async x =>
  6145. {
  6146. using (await gate.LockAsync().ConfigureAwait(false))
  6147. {
  6148. if (!hasValue3)
  6149. {
  6150. hasValue3 = true;
  6151. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6152. }
  6153. latestValue3 = x;
  6154. if (allHasValue)
  6155. {
  6156. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6157. }
  6158. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6159. {
  6160. await observer.OnCompletedAsync().ConfigureAwait(false);
  6161. }
  6162. }
  6163. },
  6164. async ex =>
  6165. {
  6166. using (await gate.LockAsync().ConfigureAwait(false))
  6167. {
  6168. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6169. }
  6170. },
  6171. async () =>
  6172. {
  6173. using (await gate.LockAsync().ConfigureAwait(false))
  6174. {
  6175. isDone3 = true;
  6176. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6177. {
  6178. await observer.OnCompletedAsync().ConfigureAwait(false);
  6179. }
  6180. }
  6181. }
  6182. ),
  6183. Create<T4>(
  6184. async x =>
  6185. {
  6186. using (await gate.LockAsync().ConfigureAwait(false))
  6187. {
  6188. if (!hasValue4)
  6189. {
  6190. hasValue4 = true;
  6191. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6192. }
  6193. latestValue4 = x;
  6194. if (allHasValue)
  6195. {
  6196. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6197. }
  6198. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6199. {
  6200. await observer.OnCompletedAsync().ConfigureAwait(false);
  6201. }
  6202. }
  6203. },
  6204. async ex =>
  6205. {
  6206. using (await gate.LockAsync().ConfigureAwait(false))
  6207. {
  6208. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6209. }
  6210. },
  6211. async () =>
  6212. {
  6213. using (await gate.LockAsync().ConfigureAwait(false))
  6214. {
  6215. isDone4 = true;
  6216. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6217. {
  6218. await observer.OnCompletedAsync().ConfigureAwait(false);
  6219. }
  6220. }
  6221. }
  6222. ),
  6223. Create<T5>(
  6224. async x =>
  6225. {
  6226. using (await gate.LockAsync().ConfigureAwait(false))
  6227. {
  6228. if (!hasValue5)
  6229. {
  6230. hasValue5 = true;
  6231. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6232. }
  6233. latestValue5 = x;
  6234. if (allHasValue)
  6235. {
  6236. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6237. }
  6238. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6239. {
  6240. await observer.OnCompletedAsync().ConfigureAwait(false);
  6241. }
  6242. }
  6243. },
  6244. async ex =>
  6245. {
  6246. using (await gate.LockAsync().ConfigureAwait(false))
  6247. {
  6248. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6249. }
  6250. },
  6251. async () =>
  6252. {
  6253. using (await gate.LockAsync().ConfigureAwait(false))
  6254. {
  6255. isDone5 = true;
  6256. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6257. {
  6258. await observer.OnCompletedAsync().ConfigureAwait(false);
  6259. }
  6260. }
  6261. }
  6262. ),
  6263. Create<T6>(
  6264. async x =>
  6265. {
  6266. using (await gate.LockAsync().ConfigureAwait(false))
  6267. {
  6268. if (!hasValue6)
  6269. {
  6270. hasValue6 = true;
  6271. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6272. }
  6273. latestValue6 = x;
  6274. if (allHasValue)
  6275. {
  6276. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6277. }
  6278. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10)
  6279. {
  6280. await observer.OnCompletedAsync().ConfigureAwait(false);
  6281. }
  6282. }
  6283. },
  6284. async ex =>
  6285. {
  6286. using (await gate.LockAsync().ConfigureAwait(false))
  6287. {
  6288. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6289. }
  6290. },
  6291. async () =>
  6292. {
  6293. using (await gate.LockAsync().ConfigureAwait(false))
  6294. {
  6295. isDone6 = true;
  6296. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6297. {
  6298. await observer.OnCompletedAsync().ConfigureAwait(false);
  6299. }
  6300. }
  6301. }
  6302. ),
  6303. Create<T7>(
  6304. async x =>
  6305. {
  6306. using (await gate.LockAsync().ConfigureAwait(false))
  6307. {
  6308. if (!hasValue7)
  6309. {
  6310. hasValue7 = true;
  6311. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6312. }
  6313. latestValue7 = x;
  6314. if (allHasValue)
  6315. {
  6316. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6317. }
  6318. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10)
  6319. {
  6320. await observer.OnCompletedAsync().ConfigureAwait(false);
  6321. }
  6322. }
  6323. },
  6324. async ex =>
  6325. {
  6326. using (await gate.LockAsync().ConfigureAwait(false))
  6327. {
  6328. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6329. }
  6330. },
  6331. async () =>
  6332. {
  6333. using (await gate.LockAsync().ConfigureAwait(false))
  6334. {
  6335. isDone7 = true;
  6336. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6337. {
  6338. await observer.OnCompletedAsync().ConfigureAwait(false);
  6339. }
  6340. }
  6341. }
  6342. ),
  6343. Create<T8>(
  6344. async x =>
  6345. {
  6346. using (await gate.LockAsync().ConfigureAwait(false))
  6347. {
  6348. if (!hasValue8)
  6349. {
  6350. hasValue8 = true;
  6351. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6352. }
  6353. latestValue8 = x;
  6354. if (allHasValue)
  6355. {
  6356. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6357. }
  6358. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10)
  6359. {
  6360. await observer.OnCompletedAsync().ConfigureAwait(false);
  6361. }
  6362. }
  6363. },
  6364. async ex =>
  6365. {
  6366. using (await gate.LockAsync().ConfigureAwait(false))
  6367. {
  6368. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6369. }
  6370. },
  6371. async () =>
  6372. {
  6373. using (await gate.LockAsync().ConfigureAwait(false))
  6374. {
  6375. isDone8 = true;
  6376. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6377. {
  6378. await observer.OnCompletedAsync().ConfigureAwait(false);
  6379. }
  6380. }
  6381. }
  6382. ),
  6383. Create<T9>(
  6384. async x =>
  6385. {
  6386. using (await gate.LockAsync().ConfigureAwait(false))
  6387. {
  6388. if (!hasValue9)
  6389. {
  6390. hasValue9 = true;
  6391. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6392. }
  6393. latestValue9 = x;
  6394. if (allHasValue)
  6395. {
  6396. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6397. }
  6398. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10)
  6399. {
  6400. await observer.OnCompletedAsync().ConfigureAwait(false);
  6401. }
  6402. }
  6403. },
  6404. async ex =>
  6405. {
  6406. using (await gate.LockAsync().ConfigureAwait(false))
  6407. {
  6408. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6409. }
  6410. },
  6411. async () =>
  6412. {
  6413. using (await gate.LockAsync().ConfigureAwait(false))
  6414. {
  6415. isDone9 = true;
  6416. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6417. {
  6418. await observer.OnCompletedAsync().ConfigureAwait(false);
  6419. }
  6420. }
  6421. }
  6422. ),
  6423. Create<T10>(
  6424. async x =>
  6425. {
  6426. using (await gate.LockAsync().ConfigureAwait(false))
  6427. {
  6428. if (!hasValue10)
  6429. {
  6430. hasValue10 = true;
  6431. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6432. }
  6433. latestValue10 = x;
  6434. if (allHasValue)
  6435. {
  6436. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6437. }
  6438. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  6439. {
  6440. await observer.OnCompletedAsync().ConfigureAwait(false);
  6441. }
  6442. }
  6443. },
  6444. async ex =>
  6445. {
  6446. using (await gate.LockAsync().ConfigureAwait(false))
  6447. {
  6448. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6449. }
  6450. },
  6451. async () =>
  6452. {
  6453. using (await gate.LockAsync().ConfigureAwait(false))
  6454. {
  6455. isDone10 = true;
  6456. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6457. {
  6458. await observer.OnCompletedAsync().ConfigureAwait(false);
  6459. }
  6460. }
  6461. }
  6462. )
  6463. );
  6464. }
  6465. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult> selector)
  6466. {
  6467. if (observer == null)
  6468. throw new ArgumentNullException(nameof(observer));
  6469. if (selector == null)
  6470. throw new ArgumentNullException(nameof(selector));
  6471. return CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>(observer, (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)));
  6472. }
  6473. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, ValueTask<TResult>> selector)
  6474. {
  6475. if (observer == null)
  6476. throw new ArgumentNullException(nameof(observer));
  6477. if (selector == null)
  6478. throw new ArgumentNullException(nameof(selector));
  6479. bool allHasValue = false;
  6480. bool hasValue1 = false;
  6481. bool isDone1 = false;
  6482. T1 latestValue1 = default(T1);
  6483. bool hasValue2 = false;
  6484. bool isDone2 = false;
  6485. T2 latestValue2 = default(T2);
  6486. bool hasValue3 = false;
  6487. bool isDone3 = false;
  6488. T3 latestValue3 = default(T3);
  6489. bool hasValue4 = false;
  6490. bool isDone4 = false;
  6491. T4 latestValue4 = default(T4);
  6492. bool hasValue5 = false;
  6493. bool isDone5 = false;
  6494. T5 latestValue5 = default(T5);
  6495. bool hasValue6 = false;
  6496. bool isDone6 = false;
  6497. T6 latestValue6 = default(T6);
  6498. bool hasValue7 = false;
  6499. bool isDone7 = false;
  6500. T7 latestValue7 = default(T7);
  6501. bool hasValue8 = false;
  6502. bool isDone8 = false;
  6503. T8 latestValue8 = default(T8);
  6504. bool hasValue9 = false;
  6505. bool isDone9 = false;
  6506. T9 latestValue9 = default(T9);
  6507. bool hasValue10 = false;
  6508. bool isDone10 = false;
  6509. T10 latestValue10 = default(T10);
  6510. var gate = new AsyncGate();
  6511. return
  6512. (
  6513. Create<T1>(
  6514. async x =>
  6515. {
  6516. using (await gate.LockAsync().ConfigureAwait(false))
  6517. {
  6518. if (!hasValue1)
  6519. {
  6520. hasValue1 = true;
  6521. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6522. }
  6523. latestValue1 = x;
  6524. if (allHasValue)
  6525. {
  6526. TResult res;
  6527. try
  6528. {
  6529. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6530. }
  6531. catch (Exception ex)
  6532. {
  6533. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6534. return;
  6535. }
  6536. await observer.OnNextAsync(res).ConfigureAwait(false);
  6537. }
  6538. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6539. {
  6540. await observer.OnCompletedAsync().ConfigureAwait(false);
  6541. }
  6542. }
  6543. },
  6544. async ex =>
  6545. {
  6546. using (await gate.LockAsync().ConfigureAwait(false))
  6547. {
  6548. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6549. }
  6550. },
  6551. async () =>
  6552. {
  6553. using (await gate.LockAsync().ConfigureAwait(false))
  6554. {
  6555. isDone1 = true;
  6556. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6557. {
  6558. await observer.OnCompletedAsync().ConfigureAwait(false);
  6559. }
  6560. }
  6561. }
  6562. ),
  6563. Create<T2>(
  6564. async x =>
  6565. {
  6566. using (await gate.LockAsync().ConfigureAwait(false))
  6567. {
  6568. if (!hasValue2)
  6569. {
  6570. hasValue2 = true;
  6571. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6572. }
  6573. latestValue2 = x;
  6574. if (allHasValue)
  6575. {
  6576. TResult res;
  6577. try
  6578. {
  6579. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6580. }
  6581. catch (Exception ex)
  6582. {
  6583. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6584. return;
  6585. }
  6586. await observer.OnNextAsync(res).ConfigureAwait(false);
  6587. }
  6588. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6589. {
  6590. await observer.OnCompletedAsync().ConfigureAwait(false);
  6591. }
  6592. }
  6593. },
  6594. async ex =>
  6595. {
  6596. using (await gate.LockAsync().ConfigureAwait(false))
  6597. {
  6598. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6599. }
  6600. },
  6601. async () =>
  6602. {
  6603. using (await gate.LockAsync().ConfigureAwait(false))
  6604. {
  6605. isDone2 = true;
  6606. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6607. {
  6608. await observer.OnCompletedAsync().ConfigureAwait(false);
  6609. }
  6610. }
  6611. }
  6612. ),
  6613. Create<T3>(
  6614. async x =>
  6615. {
  6616. using (await gate.LockAsync().ConfigureAwait(false))
  6617. {
  6618. if (!hasValue3)
  6619. {
  6620. hasValue3 = true;
  6621. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6622. }
  6623. latestValue3 = x;
  6624. if (allHasValue)
  6625. {
  6626. TResult res;
  6627. try
  6628. {
  6629. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6630. }
  6631. catch (Exception ex)
  6632. {
  6633. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6634. return;
  6635. }
  6636. await observer.OnNextAsync(res).ConfigureAwait(false);
  6637. }
  6638. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6639. {
  6640. await observer.OnCompletedAsync().ConfigureAwait(false);
  6641. }
  6642. }
  6643. },
  6644. async ex =>
  6645. {
  6646. using (await gate.LockAsync().ConfigureAwait(false))
  6647. {
  6648. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6649. }
  6650. },
  6651. async () =>
  6652. {
  6653. using (await gate.LockAsync().ConfigureAwait(false))
  6654. {
  6655. isDone3 = true;
  6656. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6657. {
  6658. await observer.OnCompletedAsync().ConfigureAwait(false);
  6659. }
  6660. }
  6661. }
  6662. ),
  6663. Create<T4>(
  6664. async x =>
  6665. {
  6666. using (await gate.LockAsync().ConfigureAwait(false))
  6667. {
  6668. if (!hasValue4)
  6669. {
  6670. hasValue4 = true;
  6671. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6672. }
  6673. latestValue4 = x;
  6674. if (allHasValue)
  6675. {
  6676. TResult res;
  6677. try
  6678. {
  6679. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6680. }
  6681. catch (Exception ex)
  6682. {
  6683. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6684. return;
  6685. }
  6686. await observer.OnNextAsync(res).ConfigureAwait(false);
  6687. }
  6688. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6689. {
  6690. await observer.OnCompletedAsync().ConfigureAwait(false);
  6691. }
  6692. }
  6693. },
  6694. async ex =>
  6695. {
  6696. using (await gate.LockAsync().ConfigureAwait(false))
  6697. {
  6698. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6699. }
  6700. },
  6701. async () =>
  6702. {
  6703. using (await gate.LockAsync().ConfigureAwait(false))
  6704. {
  6705. isDone4 = true;
  6706. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6707. {
  6708. await observer.OnCompletedAsync().ConfigureAwait(false);
  6709. }
  6710. }
  6711. }
  6712. ),
  6713. Create<T5>(
  6714. async x =>
  6715. {
  6716. using (await gate.LockAsync().ConfigureAwait(false))
  6717. {
  6718. if (!hasValue5)
  6719. {
  6720. hasValue5 = true;
  6721. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6722. }
  6723. latestValue5 = x;
  6724. if (allHasValue)
  6725. {
  6726. TResult res;
  6727. try
  6728. {
  6729. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6730. }
  6731. catch (Exception ex)
  6732. {
  6733. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6734. return;
  6735. }
  6736. await observer.OnNextAsync(res).ConfigureAwait(false);
  6737. }
  6738. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6739. {
  6740. await observer.OnCompletedAsync().ConfigureAwait(false);
  6741. }
  6742. }
  6743. },
  6744. async ex =>
  6745. {
  6746. using (await gate.LockAsync().ConfigureAwait(false))
  6747. {
  6748. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6749. }
  6750. },
  6751. async () =>
  6752. {
  6753. using (await gate.LockAsync().ConfigureAwait(false))
  6754. {
  6755. isDone5 = true;
  6756. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6757. {
  6758. await observer.OnCompletedAsync().ConfigureAwait(false);
  6759. }
  6760. }
  6761. }
  6762. ),
  6763. Create<T6>(
  6764. async x =>
  6765. {
  6766. using (await gate.LockAsync().ConfigureAwait(false))
  6767. {
  6768. if (!hasValue6)
  6769. {
  6770. hasValue6 = true;
  6771. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6772. }
  6773. latestValue6 = x;
  6774. if (allHasValue)
  6775. {
  6776. TResult res;
  6777. try
  6778. {
  6779. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6780. }
  6781. catch (Exception ex)
  6782. {
  6783. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6784. return;
  6785. }
  6786. await observer.OnNextAsync(res).ConfigureAwait(false);
  6787. }
  6788. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10)
  6789. {
  6790. await observer.OnCompletedAsync().ConfigureAwait(false);
  6791. }
  6792. }
  6793. },
  6794. async ex =>
  6795. {
  6796. using (await gate.LockAsync().ConfigureAwait(false))
  6797. {
  6798. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6799. }
  6800. },
  6801. async () =>
  6802. {
  6803. using (await gate.LockAsync().ConfigureAwait(false))
  6804. {
  6805. isDone6 = true;
  6806. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6807. {
  6808. await observer.OnCompletedAsync().ConfigureAwait(false);
  6809. }
  6810. }
  6811. }
  6812. ),
  6813. Create<T7>(
  6814. async x =>
  6815. {
  6816. using (await gate.LockAsync().ConfigureAwait(false))
  6817. {
  6818. if (!hasValue7)
  6819. {
  6820. hasValue7 = true;
  6821. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6822. }
  6823. latestValue7 = x;
  6824. if (allHasValue)
  6825. {
  6826. TResult res;
  6827. try
  6828. {
  6829. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6830. }
  6831. catch (Exception ex)
  6832. {
  6833. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6834. return;
  6835. }
  6836. await observer.OnNextAsync(res).ConfigureAwait(false);
  6837. }
  6838. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10)
  6839. {
  6840. await observer.OnCompletedAsync().ConfigureAwait(false);
  6841. }
  6842. }
  6843. },
  6844. async ex =>
  6845. {
  6846. using (await gate.LockAsync().ConfigureAwait(false))
  6847. {
  6848. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6849. }
  6850. },
  6851. async () =>
  6852. {
  6853. using (await gate.LockAsync().ConfigureAwait(false))
  6854. {
  6855. isDone7 = true;
  6856. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6857. {
  6858. await observer.OnCompletedAsync().ConfigureAwait(false);
  6859. }
  6860. }
  6861. }
  6862. ),
  6863. Create<T8>(
  6864. async x =>
  6865. {
  6866. using (await gate.LockAsync().ConfigureAwait(false))
  6867. {
  6868. if (!hasValue8)
  6869. {
  6870. hasValue8 = true;
  6871. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6872. }
  6873. latestValue8 = x;
  6874. if (allHasValue)
  6875. {
  6876. TResult res;
  6877. try
  6878. {
  6879. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6880. }
  6881. catch (Exception ex)
  6882. {
  6883. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6884. return;
  6885. }
  6886. await observer.OnNextAsync(res).ConfigureAwait(false);
  6887. }
  6888. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10)
  6889. {
  6890. await observer.OnCompletedAsync().ConfigureAwait(false);
  6891. }
  6892. }
  6893. },
  6894. async ex =>
  6895. {
  6896. using (await gate.LockAsync().ConfigureAwait(false))
  6897. {
  6898. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6899. }
  6900. },
  6901. async () =>
  6902. {
  6903. using (await gate.LockAsync().ConfigureAwait(false))
  6904. {
  6905. isDone8 = true;
  6906. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6907. {
  6908. await observer.OnCompletedAsync().ConfigureAwait(false);
  6909. }
  6910. }
  6911. }
  6912. ),
  6913. Create<T9>(
  6914. async x =>
  6915. {
  6916. using (await gate.LockAsync().ConfigureAwait(false))
  6917. {
  6918. if (!hasValue9)
  6919. {
  6920. hasValue9 = true;
  6921. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6922. }
  6923. latestValue9 = x;
  6924. if (allHasValue)
  6925. {
  6926. TResult res;
  6927. try
  6928. {
  6929. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6930. }
  6931. catch (Exception ex)
  6932. {
  6933. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6934. return;
  6935. }
  6936. await observer.OnNextAsync(res).ConfigureAwait(false);
  6937. }
  6938. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10)
  6939. {
  6940. await observer.OnCompletedAsync().ConfigureAwait(false);
  6941. }
  6942. }
  6943. },
  6944. async ex =>
  6945. {
  6946. using (await gate.LockAsync().ConfigureAwait(false))
  6947. {
  6948. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6949. }
  6950. },
  6951. async () =>
  6952. {
  6953. using (await gate.LockAsync().ConfigureAwait(false))
  6954. {
  6955. isDone9 = true;
  6956. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6957. {
  6958. await observer.OnCompletedAsync().ConfigureAwait(false);
  6959. }
  6960. }
  6961. }
  6962. ),
  6963. Create<T10>(
  6964. async x =>
  6965. {
  6966. using (await gate.LockAsync().ConfigureAwait(false))
  6967. {
  6968. if (!hasValue10)
  6969. {
  6970. hasValue10 = true;
  6971. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6972. }
  6973. latestValue10 = x;
  6974. if (allHasValue)
  6975. {
  6976. TResult res;
  6977. try
  6978. {
  6979. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6980. }
  6981. catch (Exception ex)
  6982. {
  6983. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6984. return;
  6985. }
  6986. await observer.OnNextAsync(res).ConfigureAwait(false);
  6987. }
  6988. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  6989. {
  6990. await observer.OnCompletedAsync().ConfigureAwait(false);
  6991. }
  6992. }
  6993. },
  6994. async ex =>
  6995. {
  6996. using (await gate.LockAsync().ConfigureAwait(false))
  6997. {
  6998. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6999. }
  7000. },
  7001. async () =>
  7002. {
  7003. using (await gate.LockAsync().ConfigureAwait(false))
  7004. {
  7005. isDone10 = true;
  7006. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  7007. {
  7008. await observer.OnCompletedAsync().ConfigureAwait(false);
  7009. }
  7010. }
  7011. }
  7012. )
  7013. );
  7014. }
  7015. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(IAsyncObserver<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)> observer)
  7016. {
  7017. if (observer == null)
  7018. throw new ArgumentNullException(nameof(observer));
  7019. bool allHasValue = false;
  7020. bool hasValue1 = false;
  7021. bool isDone1 = false;
  7022. T1 latestValue1 = default(T1);
  7023. bool hasValue2 = false;
  7024. bool isDone2 = false;
  7025. T2 latestValue2 = default(T2);
  7026. bool hasValue3 = false;
  7027. bool isDone3 = false;
  7028. T3 latestValue3 = default(T3);
  7029. bool hasValue4 = false;
  7030. bool isDone4 = false;
  7031. T4 latestValue4 = default(T4);
  7032. bool hasValue5 = false;
  7033. bool isDone5 = false;
  7034. T5 latestValue5 = default(T5);
  7035. bool hasValue6 = false;
  7036. bool isDone6 = false;
  7037. T6 latestValue6 = default(T6);
  7038. bool hasValue7 = false;
  7039. bool isDone7 = false;
  7040. T7 latestValue7 = default(T7);
  7041. bool hasValue8 = false;
  7042. bool isDone8 = false;
  7043. T8 latestValue8 = default(T8);
  7044. bool hasValue9 = false;
  7045. bool isDone9 = false;
  7046. T9 latestValue9 = default(T9);
  7047. bool hasValue10 = false;
  7048. bool isDone10 = false;
  7049. T10 latestValue10 = default(T10);
  7050. bool hasValue11 = false;
  7051. bool isDone11 = false;
  7052. T11 latestValue11 = default(T11);
  7053. var gate = new AsyncGate();
  7054. return
  7055. (
  7056. Create<T1>(
  7057. async x =>
  7058. {
  7059. using (await gate.LockAsync().ConfigureAwait(false))
  7060. {
  7061. if (!hasValue1)
  7062. {
  7063. hasValue1 = true;
  7064. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7065. }
  7066. latestValue1 = x;
  7067. if (allHasValue)
  7068. {
  7069. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7070. }
  7071. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7072. {
  7073. await observer.OnCompletedAsync().ConfigureAwait(false);
  7074. }
  7075. }
  7076. },
  7077. async ex =>
  7078. {
  7079. using (await gate.LockAsync().ConfigureAwait(false))
  7080. {
  7081. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7082. }
  7083. },
  7084. async () =>
  7085. {
  7086. using (await gate.LockAsync().ConfigureAwait(false))
  7087. {
  7088. isDone1 = true;
  7089. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7090. {
  7091. await observer.OnCompletedAsync().ConfigureAwait(false);
  7092. }
  7093. }
  7094. }
  7095. ),
  7096. Create<T2>(
  7097. async x =>
  7098. {
  7099. using (await gate.LockAsync().ConfigureAwait(false))
  7100. {
  7101. if (!hasValue2)
  7102. {
  7103. hasValue2 = true;
  7104. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7105. }
  7106. latestValue2 = x;
  7107. if (allHasValue)
  7108. {
  7109. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7110. }
  7111. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7112. {
  7113. await observer.OnCompletedAsync().ConfigureAwait(false);
  7114. }
  7115. }
  7116. },
  7117. async ex =>
  7118. {
  7119. using (await gate.LockAsync().ConfigureAwait(false))
  7120. {
  7121. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7122. }
  7123. },
  7124. async () =>
  7125. {
  7126. using (await gate.LockAsync().ConfigureAwait(false))
  7127. {
  7128. isDone2 = true;
  7129. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7130. {
  7131. await observer.OnCompletedAsync().ConfigureAwait(false);
  7132. }
  7133. }
  7134. }
  7135. ),
  7136. Create<T3>(
  7137. async x =>
  7138. {
  7139. using (await gate.LockAsync().ConfigureAwait(false))
  7140. {
  7141. if (!hasValue3)
  7142. {
  7143. hasValue3 = true;
  7144. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7145. }
  7146. latestValue3 = x;
  7147. if (allHasValue)
  7148. {
  7149. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7150. }
  7151. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7152. {
  7153. await observer.OnCompletedAsync().ConfigureAwait(false);
  7154. }
  7155. }
  7156. },
  7157. async ex =>
  7158. {
  7159. using (await gate.LockAsync().ConfigureAwait(false))
  7160. {
  7161. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7162. }
  7163. },
  7164. async () =>
  7165. {
  7166. using (await gate.LockAsync().ConfigureAwait(false))
  7167. {
  7168. isDone3 = true;
  7169. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7170. {
  7171. await observer.OnCompletedAsync().ConfigureAwait(false);
  7172. }
  7173. }
  7174. }
  7175. ),
  7176. Create<T4>(
  7177. async x =>
  7178. {
  7179. using (await gate.LockAsync().ConfigureAwait(false))
  7180. {
  7181. if (!hasValue4)
  7182. {
  7183. hasValue4 = true;
  7184. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7185. }
  7186. latestValue4 = x;
  7187. if (allHasValue)
  7188. {
  7189. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7190. }
  7191. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7192. {
  7193. await observer.OnCompletedAsync().ConfigureAwait(false);
  7194. }
  7195. }
  7196. },
  7197. async ex =>
  7198. {
  7199. using (await gate.LockAsync().ConfigureAwait(false))
  7200. {
  7201. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7202. }
  7203. },
  7204. async () =>
  7205. {
  7206. using (await gate.LockAsync().ConfigureAwait(false))
  7207. {
  7208. isDone4 = true;
  7209. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7210. {
  7211. await observer.OnCompletedAsync().ConfigureAwait(false);
  7212. }
  7213. }
  7214. }
  7215. ),
  7216. Create<T5>(
  7217. async x =>
  7218. {
  7219. using (await gate.LockAsync().ConfigureAwait(false))
  7220. {
  7221. if (!hasValue5)
  7222. {
  7223. hasValue5 = true;
  7224. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7225. }
  7226. latestValue5 = x;
  7227. if (allHasValue)
  7228. {
  7229. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7230. }
  7231. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7232. {
  7233. await observer.OnCompletedAsync().ConfigureAwait(false);
  7234. }
  7235. }
  7236. },
  7237. async ex =>
  7238. {
  7239. using (await gate.LockAsync().ConfigureAwait(false))
  7240. {
  7241. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7242. }
  7243. },
  7244. async () =>
  7245. {
  7246. using (await gate.LockAsync().ConfigureAwait(false))
  7247. {
  7248. isDone5 = true;
  7249. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7250. {
  7251. await observer.OnCompletedAsync().ConfigureAwait(false);
  7252. }
  7253. }
  7254. }
  7255. ),
  7256. Create<T6>(
  7257. async x =>
  7258. {
  7259. using (await gate.LockAsync().ConfigureAwait(false))
  7260. {
  7261. if (!hasValue6)
  7262. {
  7263. hasValue6 = true;
  7264. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7265. }
  7266. latestValue6 = x;
  7267. if (allHasValue)
  7268. {
  7269. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7270. }
  7271. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7272. {
  7273. await observer.OnCompletedAsync().ConfigureAwait(false);
  7274. }
  7275. }
  7276. },
  7277. async ex =>
  7278. {
  7279. using (await gate.LockAsync().ConfigureAwait(false))
  7280. {
  7281. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7282. }
  7283. },
  7284. async () =>
  7285. {
  7286. using (await gate.LockAsync().ConfigureAwait(false))
  7287. {
  7288. isDone6 = true;
  7289. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7290. {
  7291. await observer.OnCompletedAsync().ConfigureAwait(false);
  7292. }
  7293. }
  7294. }
  7295. ),
  7296. Create<T7>(
  7297. async x =>
  7298. {
  7299. using (await gate.LockAsync().ConfigureAwait(false))
  7300. {
  7301. if (!hasValue7)
  7302. {
  7303. hasValue7 = true;
  7304. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7305. }
  7306. latestValue7 = x;
  7307. if (allHasValue)
  7308. {
  7309. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7310. }
  7311. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11)
  7312. {
  7313. await observer.OnCompletedAsync().ConfigureAwait(false);
  7314. }
  7315. }
  7316. },
  7317. async ex =>
  7318. {
  7319. using (await gate.LockAsync().ConfigureAwait(false))
  7320. {
  7321. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7322. }
  7323. },
  7324. async () =>
  7325. {
  7326. using (await gate.LockAsync().ConfigureAwait(false))
  7327. {
  7328. isDone7 = true;
  7329. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7330. {
  7331. await observer.OnCompletedAsync().ConfigureAwait(false);
  7332. }
  7333. }
  7334. }
  7335. ),
  7336. Create<T8>(
  7337. async x =>
  7338. {
  7339. using (await gate.LockAsync().ConfigureAwait(false))
  7340. {
  7341. if (!hasValue8)
  7342. {
  7343. hasValue8 = true;
  7344. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7345. }
  7346. latestValue8 = x;
  7347. if (allHasValue)
  7348. {
  7349. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7350. }
  7351. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11)
  7352. {
  7353. await observer.OnCompletedAsync().ConfigureAwait(false);
  7354. }
  7355. }
  7356. },
  7357. async ex =>
  7358. {
  7359. using (await gate.LockAsync().ConfigureAwait(false))
  7360. {
  7361. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7362. }
  7363. },
  7364. async () =>
  7365. {
  7366. using (await gate.LockAsync().ConfigureAwait(false))
  7367. {
  7368. isDone8 = true;
  7369. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7370. {
  7371. await observer.OnCompletedAsync().ConfigureAwait(false);
  7372. }
  7373. }
  7374. }
  7375. ),
  7376. Create<T9>(
  7377. async x =>
  7378. {
  7379. using (await gate.LockAsync().ConfigureAwait(false))
  7380. {
  7381. if (!hasValue9)
  7382. {
  7383. hasValue9 = true;
  7384. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7385. }
  7386. latestValue9 = x;
  7387. if (allHasValue)
  7388. {
  7389. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7390. }
  7391. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11)
  7392. {
  7393. await observer.OnCompletedAsync().ConfigureAwait(false);
  7394. }
  7395. }
  7396. },
  7397. async ex =>
  7398. {
  7399. using (await gate.LockAsync().ConfigureAwait(false))
  7400. {
  7401. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7402. }
  7403. },
  7404. async () =>
  7405. {
  7406. using (await gate.LockAsync().ConfigureAwait(false))
  7407. {
  7408. isDone9 = true;
  7409. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7410. {
  7411. await observer.OnCompletedAsync().ConfigureAwait(false);
  7412. }
  7413. }
  7414. }
  7415. ),
  7416. Create<T10>(
  7417. async x =>
  7418. {
  7419. using (await gate.LockAsync().ConfigureAwait(false))
  7420. {
  7421. if (!hasValue10)
  7422. {
  7423. hasValue10 = true;
  7424. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7425. }
  7426. latestValue10 = x;
  7427. if (allHasValue)
  7428. {
  7429. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7430. }
  7431. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11)
  7432. {
  7433. await observer.OnCompletedAsync().ConfigureAwait(false);
  7434. }
  7435. }
  7436. },
  7437. async ex =>
  7438. {
  7439. using (await gate.LockAsync().ConfigureAwait(false))
  7440. {
  7441. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7442. }
  7443. },
  7444. async () =>
  7445. {
  7446. using (await gate.LockAsync().ConfigureAwait(false))
  7447. {
  7448. isDone10 = true;
  7449. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7450. {
  7451. await observer.OnCompletedAsync().ConfigureAwait(false);
  7452. }
  7453. }
  7454. }
  7455. ),
  7456. Create<T11>(
  7457. async x =>
  7458. {
  7459. using (await gate.LockAsync().ConfigureAwait(false))
  7460. {
  7461. if (!hasValue11)
  7462. {
  7463. hasValue11 = true;
  7464. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7465. }
  7466. latestValue11 = x;
  7467. if (allHasValue)
  7468. {
  7469. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7470. }
  7471. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  7472. {
  7473. await observer.OnCompletedAsync().ConfigureAwait(false);
  7474. }
  7475. }
  7476. },
  7477. async ex =>
  7478. {
  7479. using (await gate.LockAsync().ConfigureAwait(false))
  7480. {
  7481. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7482. }
  7483. },
  7484. async () =>
  7485. {
  7486. using (await gate.LockAsync().ConfigureAwait(false))
  7487. {
  7488. isDone11 = true;
  7489. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7490. {
  7491. await observer.OnCompletedAsync().ConfigureAwait(false);
  7492. }
  7493. }
  7494. }
  7495. )
  7496. );
  7497. }
  7498. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult> selector)
  7499. {
  7500. if (observer == null)
  7501. throw new ArgumentNullException(nameof(observer));
  7502. if (selector == null)
  7503. throw new ArgumentNullException(nameof(selector));
  7504. return CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>(observer, (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11)));
  7505. }
  7506. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, ValueTask<TResult>> selector)
  7507. {
  7508. if (observer == null)
  7509. throw new ArgumentNullException(nameof(observer));
  7510. if (selector == null)
  7511. throw new ArgumentNullException(nameof(selector));
  7512. bool allHasValue = false;
  7513. bool hasValue1 = false;
  7514. bool isDone1 = false;
  7515. T1 latestValue1 = default(T1);
  7516. bool hasValue2 = false;
  7517. bool isDone2 = false;
  7518. T2 latestValue2 = default(T2);
  7519. bool hasValue3 = false;
  7520. bool isDone3 = false;
  7521. T3 latestValue3 = default(T3);
  7522. bool hasValue4 = false;
  7523. bool isDone4 = false;
  7524. T4 latestValue4 = default(T4);
  7525. bool hasValue5 = false;
  7526. bool isDone5 = false;
  7527. T5 latestValue5 = default(T5);
  7528. bool hasValue6 = false;
  7529. bool isDone6 = false;
  7530. T6 latestValue6 = default(T6);
  7531. bool hasValue7 = false;
  7532. bool isDone7 = false;
  7533. T7 latestValue7 = default(T7);
  7534. bool hasValue8 = false;
  7535. bool isDone8 = false;
  7536. T8 latestValue8 = default(T8);
  7537. bool hasValue9 = false;
  7538. bool isDone9 = false;
  7539. T9 latestValue9 = default(T9);
  7540. bool hasValue10 = false;
  7541. bool isDone10 = false;
  7542. T10 latestValue10 = default(T10);
  7543. bool hasValue11 = false;
  7544. bool isDone11 = false;
  7545. T11 latestValue11 = default(T11);
  7546. var gate = new AsyncGate();
  7547. return
  7548. (
  7549. Create<T1>(
  7550. async x =>
  7551. {
  7552. using (await gate.LockAsync().ConfigureAwait(false))
  7553. {
  7554. if (!hasValue1)
  7555. {
  7556. hasValue1 = true;
  7557. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7558. }
  7559. latestValue1 = x;
  7560. if (allHasValue)
  7561. {
  7562. TResult res;
  7563. try
  7564. {
  7565. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7566. }
  7567. catch (Exception ex)
  7568. {
  7569. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7570. return;
  7571. }
  7572. await observer.OnNextAsync(res).ConfigureAwait(false);
  7573. }
  7574. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7575. {
  7576. await observer.OnCompletedAsync().ConfigureAwait(false);
  7577. }
  7578. }
  7579. },
  7580. async ex =>
  7581. {
  7582. using (await gate.LockAsync().ConfigureAwait(false))
  7583. {
  7584. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7585. }
  7586. },
  7587. async () =>
  7588. {
  7589. using (await gate.LockAsync().ConfigureAwait(false))
  7590. {
  7591. isDone1 = true;
  7592. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7593. {
  7594. await observer.OnCompletedAsync().ConfigureAwait(false);
  7595. }
  7596. }
  7597. }
  7598. ),
  7599. Create<T2>(
  7600. async x =>
  7601. {
  7602. using (await gate.LockAsync().ConfigureAwait(false))
  7603. {
  7604. if (!hasValue2)
  7605. {
  7606. hasValue2 = true;
  7607. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7608. }
  7609. latestValue2 = x;
  7610. if (allHasValue)
  7611. {
  7612. TResult res;
  7613. try
  7614. {
  7615. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7616. }
  7617. catch (Exception ex)
  7618. {
  7619. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7620. return;
  7621. }
  7622. await observer.OnNextAsync(res).ConfigureAwait(false);
  7623. }
  7624. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7625. {
  7626. await observer.OnCompletedAsync().ConfigureAwait(false);
  7627. }
  7628. }
  7629. },
  7630. async ex =>
  7631. {
  7632. using (await gate.LockAsync().ConfigureAwait(false))
  7633. {
  7634. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7635. }
  7636. },
  7637. async () =>
  7638. {
  7639. using (await gate.LockAsync().ConfigureAwait(false))
  7640. {
  7641. isDone2 = true;
  7642. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7643. {
  7644. await observer.OnCompletedAsync().ConfigureAwait(false);
  7645. }
  7646. }
  7647. }
  7648. ),
  7649. Create<T3>(
  7650. async x =>
  7651. {
  7652. using (await gate.LockAsync().ConfigureAwait(false))
  7653. {
  7654. if (!hasValue3)
  7655. {
  7656. hasValue3 = true;
  7657. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7658. }
  7659. latestValue3 = x;
  7660. if (allHasValue)
  7661. {
  7662. TResult res;
  7663. try
  7664. {
  7665. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7666. }
  7667. catch (Exception ex)
  7668. {
  7669. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7670. return;
  7671. }
  7672. await observer.OnNextAsync(res).ConfigureAwait(false);
  7673. }
  7674. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7675. {
  7676. await observer.OnCompletedAsync().ConfigureAwait(false);
  7677. }
  7678. }
  7679. },
  7680. async ex =>
  7681. {
  7682. using (await gate.LockAsync().ConfigureAwait(false))
  7683. {
  7684. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7685. }
  7686. },
  7687. async () =>
  7688. {
  7689. using (await gate.LockAsync().ConfigureAwait(false))
  7690. {
  7691. isDone3 = true;
  7692. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7693. {
  7694. await observer.OnCompletedAsync().ConfigureAwait(false);
  7695. }
  7696. }
  7697. }
  7698. ),
  7699. Create<T4>(
  7700. async x =>
  7701. {
  7702. using (await gate.LockAsync().ConfigureAwait(false))
  7703. {
  7704. if (!hasValue4)
  7705. {
  7706. hasValue4 = true;
  7707. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7708. }
  7709. latestValue4 = x;
  7710. if (allHasValue)
  7711. {
  7712. TResult res;
  7713. try
  7714. {
  7715. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7716. }
  7717. catch (Exception ex)
  7718. {
  7719. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7720. return;
  7721. }
  7722. await observer.OnNextAsync(res).ConfigureAwait(false);
  7723. }
  7724. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7725. {
  7726. await observer.OnCompletedAsync().ConfigureAwait(false);
  7727. }
  7728. }
  7729. },
  7730. async ex =>
  7731. {
  7732. using (await gate.LockAsync().ConfigureAwait(false))
  7733. {
  7734. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7735. }
  7736. },
  7737. async () =>
  7738. {
  7739. using (await gate.LockAsync().ConfigureAwait(false))
  7740. {
  7741. isDone4 = true;
  7742. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7743. {
  7744. await observer.OnCompletedAsync().ConfigureAwait(false);
  7745. }
  7746. }
  7747. }
  7748. ),
  7749. Create<T5>(
  7750. async x =>
  7751. {
  7752. using (await gate.LockAsync().ConfigureAwait(false))
  7753. {
  7754. if (!hasValue5)
  7755. {
  7756. hasValue5 = true;
  7757. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7758. }
  7759. latestValue5 = x;
  7760. if (allHasValue)
  7761. {
  7762. TResult res;
  7763. try
  7764. {
  7765. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7766. }
  7767. catch (Exception ex)
  7768. {
  7769. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7770. return;
  7771. }
  7772. await observer.OnNextAsync(res).ConfigureAwait(false);
  7773. }
  7774. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7775. {
  7776. await observer.OnCompletedAsync().ConfigureAwait(false);
  7777. }
  7778. }
  7779. },
  7780. async ex =>
  7781. {
  7782. using (await gate.LockAsync().ConfigureAwait(false))
  7783. {
  7784. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7785. }
  7786. },
  7787. async () =>
  7788. {
  7789. using (await gate.LockAsync().ConfigureAwait(false))
  7790. {
  7791. isDone5 = true;
  7792. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7793. {
  7794. await observer.OnCompletedAsync().ConfigureAwait(false);
  7795. }
  7796. }
  7797. }
  7798. ),
  7799. Create<T6>(
  7800. async x =>
  7801. {
  7802. using (await gate.LockAsync().ConfigureAwait(false))
  7803. {
  7804. if (!hasValue6)
  7805. {
  7806. hasValue6 = true;
  7807. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7808. }
  7809. latestValue6 = x;
  7810. if (allHasValue)
  7811. {
  7812. TResult res;
  7813. try
  7814. {
  7815. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7816. }
  7817. catch (Exception ex)
  7818. {
  7819. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7820. return;
  7821. }
  7822. await observer.OnNextAsync(res).ConfigureAwait(false);
  7823. }
  7824. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7825. {
  7826. await observer.OnCompletedAsync().ConfigureAwait(false);
  7827. }
  7828. }
  7829. },
  7830. async ex =>
  7831. {
  7832. using (await gate.LockAsync().ConfigureAwait(false))
  7833. {
  7834. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7835. }
  7836. },
  7837. async () =>
  7838. {
  7839. using (await gate.LockAsync().ConfigureAwait(false))
  7840. {
  7841. isDone6 = true;
  7842. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7843. {
  7844. await observer.OnCompletedAsync().ConfigureAwait(false);
  7845. }
  7846. }
  7847. }
  7848. ),
  7849. Create<T7>(
  7850. async x =>
  7851. {
  7852. using (await gate.LockAsync().ConfigureAwait(false))
  7853. {
  7854. if (!hasValue7)
  7855. {
  7856. hasValue7 = true;
  7857. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7858. }
  7859. latestValue7 = x;
  7860. if (allHasValue)
  7861. {
  7862. TResult res;
  7863. try
  7864. {
  7865. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7866. }
  7867. catch (Exception ex)
  7868. {
  7869. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7870. return;
  7871. }
  7872. await observer.OnNextAsync(res).ConfigureAwait(false);
  7873. }
  7874. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11)
  7875. {
  7876. await observer.OnCompletedAsync().ConfigureAwait(false);
  7877. }
  7878. }
  7879. },
  7880. async ex =>
  7881. {
  7882. using (await gate.LockAsync().ConfigureAwait(false))
  7883. {
  7884. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7885. }
  7886. },
  7887. async () =>
  7888. {
  7889. using (await gate.LockAsync().ConfigureAwait(false))
  7890. {
  7891. isDone7 = true;
  7892. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7893. {
  7894. await observer.OnCompletedAsync().ConfigureAwait(false);
  7895. }
  7896. }
  7897. }
  7898. ),
  7899. Create<T8>(
  7900. async x =>
  7901. {
  7902. using (await gate.LockAsync().ConfigureAwait(false))
  7903. {
  7904. if (!hasValue8)
  7905. {
  7906. hasValue8 = true;
  7907. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7908. }
  7909. latestValue8 = x;
  7910. if (allHasValue)
  7911. {
  7912. TResult res;
  7913. try
  7914. {
  7915. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7916. }
  7917. catch (Exception ex)
  7918. {
  7919. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7920. return;
  7921. }
  7922. await observer.OnNextAsync(res).ConfigureAwait(false);
  7923. }
  7924. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11)
  7925. {
  7926. await observer.OnCompletedAsync().ConfigureAwait(false);
  7927. }
  7928. }
  7929. },
  7930. async ex =>
  7931. {
  7932. using (await gate.LockAsync().ConfigureAwait(false))
  7933. {
  7934. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7935. }
  7936. },
  7937. async () =>
  7938. {
  7939. using (await gate.LockAsync().ConfigureAwait(false))
  7940. {
  7941. isDone8 = true;
  7942. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7943. {
  7944. await observer.OnCompletedAsync().ConfigureAwait(false);
  7945. }
  7946. }
  7947. }
  7948. ),
  7949. Create<T9>(
  7950. async x =>
  7951. {
  7952. using (await gate.LockAsync().ConfigureAwait(false))
  7953. {
  7954. if (!hasValue9)
  7955. {
  7956. hasValue9 = true;
  7957. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7958. }
  7959. latestValue9 = x;
  7960. if (allHasValue)
  7961. {
  7962. TResult res;
  7963. try
  7964. {
  7965. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7966. }
  7967. catch (Exception ex)
  7968. {
  7969. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7970. return;
  7971. }
  7972. await observer.OnNextAsync(res).ConfigureAwait(false);
  7973. }
  7974. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11)
  7975. {
  7976. await observer.OnCompletedAsync().ConfigureAwait(false);
  7977. }
  7978. }
  7979. },
  7980. async ex =>
  7981. {
  7982. using (await gate.LockAsync().ConfigureAwait(false))
  7983. {
  7984. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7985. }
  7986. },
  7987. async () =>
  7988. {
  7989. using (await gate.LockAsync().ConfigureAwait(false))
  7990. {
  7991. isDone9 = true;
  7992. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7993. {
  7994. await observer.OnCompletedAsync().ConfigureAwait(false);
  7995. }
  7996. }
  7997. }
  7998. ),
  7999. Create<T10>(
  8000. async x =>
  8001. {
  8002. using (await gate.LockAsync().ConfigureAwait(false))
  8003. {
  8004. if (!hasValue10)
  8005. {
  8006. hasValue10 = true;
  8007. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  8008. }
  8009. latestValue10 = x;
  8010. if (allHasValue)
  8011. {
  8012. TResult res;
  8013. try
  8014. {
  8015. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  8016. }
  8017. catch (Exception ex)
  8018. {
  8019. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8020. return;
  8021. }
  8022. await observer.OnNextAsync(res).ConfigureAwait(false);
  8023. }
  8024. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11)
  8025. {
  8026. await observer.OnCompletedAsync().ConfigureAwait(false);
  8027. }
  8028. }
  8029. },
  8030. async ex =>
  8031. {
  8032. using (await gate.LockAsync().ConfigureAwait(false))
  8033. {
  8034. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8035. }
  8036. },
  8037. async () =>
  8038. {
  8039. using (await gate.LockAsync().ConfigureAwait(false))
  8040. {
  8041. isDone10 = true;
  8042. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  8043. {
  8044. await observer.OnCompletedAsync().ConfigureAwait(false);
  8045. }
  8046. }
  8047. }
  8048. ),
  8049. Create<T11>(
  8050. async x =>
  8051. {
  8052. using (await gate.LockAsync().ConfigureAwait(false))
  8053. {
  8054. if (!hasValue11)
  8055. {
  8056. hasValue11 = true;
  8057. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  8058. }
  8059. latestValue11 = x;
  8060. if (allHasValue)
  8061. {
  8062. TResult res;
  8063. try
  8064. {
  8065. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  8066. }
  8067. catch (Exception ex)
  8068. {
  8069. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8070. return;
  8071. }
  8072. await observer.OnNextAsync(res).ConfigureAwait(false);
  8073. }
  8074. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  8075. {
  8076. await observer.OnCompletedAsync().ConfigureAwait(false);
  8077. }
  8078. }
  8079. },
  8080. async ex =>
  8081. {
  8082. using (await gate.LockAsync().ConfigureAwait(false))
  8083. {
  8084. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8085. }
  8086. },
  8087. async () =>
  8088. {
  8089. using (await gate.LockAsync().ConfigureAwait(false))
  8090. {
  8091. isDone11 = true;
  8092. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  8093. {
  8094. await observer.OnCompletedAsync().ConfigureAwait(false);
  8095. }
  8096. }
  8097. }
  8098. )
  8099. );
  8100. }
  8101. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(IAsyncObserver<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)> observer)
  8102. {
  8103. if (observer == null)
  8104. throw new ArgumentNullException(nameof(observer));
  8105. bool allHasValue = false;
  8106. bool hasValue1 = false;
  8107. bool isDone1 = false;
  8108. T1 latestValue1 = default(T1);
  8109. bool hasValue2 = false;
  8110. bool isDone2 = false;
  8111. T2 latestValue2 = default(T2);
  8112. bool hasValue3 = false;
  8113. bool isDone3 = false;
  8114. T3 latestValue3 = default(T3);
  8115. bool hasValue4 = false;
  8116. bool isDone4 = false;
  8117. T4 latestValue4 = default(T4);
  8118. bool hasValue5 = false;
  8119. bool isDone5 = false;
  8120. T5 latestValue5 = default(T5);
  8121. bool hasValue6 = false;
  8122. bool isDone6 = false;
  8123. T6 latestValue6 = default(T6);
  8124. bool hasValue7 = false;
  8125. bool isDone7 = false;
  8126. T7 latestValue7 = default(T7);
  8127. bool hasValue8 = false;
  8128. bool isDone8 = false;
  8129. T8 latestValue8 = default(T8);
  8130. bool hasValue9 = false;
  8131. bool isDone9 = false;
  8132. T9 latestValue9 = default(T9);
  8133. bool hasValue10 = false;
  8134. bool isDone10 = false;
  8135. T10 latestValue10 = default(T10);
  8136. bool hasValue11 = false;
  8137. bool isDone11 = false;
  8138. T11 latestValue11 = default(T11);
  8139. bool hasValue12 = false;
  8140. bool isDone12 = false;
  8141. T12 latestValue12 = default(T12);
  8142. var gate = new AsyncGate();
  8143. return
  8144. (
  8145. Create<T1>(
  8146. async x =>
  8147. {
  8148. using (await gate.LockAsync().ConfigureAwait(false))
  8149. {
  8150. if (!hasValue1)
  8151. {
  8152. hasValue1 = true;
  8153. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8154. }
  8155. latestValue1 = x;
  8156. if (allHasValue)
  8157. {
  8158. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8159. }
  8160. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8161. {
  8162. await observer.OnCompletedAsync().ConfigureAwait(false);
  8163. }
  8164. }
  8165. },
  8166. async ex =>
  8167. {
  8168. using (await gate.LockAsync().ConfigureAwait(false))
  8169. {
  8170. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8171. }
  8172. },
  8173. async () =>
  8174. {
  8175. using (await gate.LockAsync().ConfigureAwait(false))
  8176. {
  8177. isDone1 = true;
  8178. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8179. {
  8180. await observer.OnCompletedAsync().ConfigureAwait(false);
  8181. }
  8182. }
  8183. }
  8184. ),
  8185. Create<T2>(
  8186. async x =>
  8187. {
  8188. using (await gate.LockAsync().ConfigureAwait(false))
  8189. {
  8190. if (!hasValue2)
  8191. {
  8192. hasValue2 = true;
  8193. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8194. }
  8195. latestValue2 = x;
  8196. if (allHasValue)
  8197. {
  8198. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8199. }
  8200. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8201. {
  8202. await observer.OnCompletedAsync().ConfigureAwait(false);
  8203. }
  8204. }
  8205. },
  8206. async ex =>
  8207. {
  8208. using (await gate.LockAsync().ConfigureAwait(false))
  8209. {
  8210. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8211. }
  8212. },
  8213. async () =>
  8214. {
  8215. using (await gate.LockAsync().ConfigureAwait(false))
  8216. {
  8217. isDone2 = true;
  8218. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8219. {
  8220. await observer.OnCompletedAsync().ConfigureAwait(false);
  8221. }
  8222. }
  8223. }
  8224. ),
  8225. Create<T3>(
  8226. async x =>
  8227. {
  8228. using (await gate.LockAsync().ConfigureAwait(false))
  8229. {
  8230. if (!hasValue3)
  8231. {
  8232. hasValue3 = true;
  8233. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8234. }
  8235. latestValue3 = x;
  8236. if (allHasValue)
  8237. {
  8238. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8239. }
  8240. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8241. {
  8242. await observer.OnCompletedAsync().ConfigureAwait(false);
  8243. }
  8244. }
  8245. },
  8246. async ex =>
  8247. {
  8248. using (await gate.LockAsync().ConfigureAwait(false))
  8249. {
  8250. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8251. }
  8252. },
  8253. async () =>
  8254. {
  8255. using (await gate.LockAsync().ConfigureAwait(false))
  8256. {
  8257. isDone3 = true;
  8258. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8259. {
  8260. await observer.OnCompletedAsync().ConfigureAwait(false);
  8261. }
  8262. }
  8263. }
  8264. ),
  8265. Create<T4>(
  8266. async x =>
  8267. {
  8268. using (await gate.LockAsync().ConfigureAwait(false))
  8269. {
  8270. if (!hasValue4)
  8271. {
  8272. hasValue4 = true;
  8273. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8274. }
  8275. latestValue4 = x;
  8276. if (allHasValue)
  8277. {
  8278. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8279. }
  8280. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8281. {
  8282. await observer.OnCompletedAsync().ConfigureAwait(false);
  8283. }
  8284. }
  8285. },
  8286. async ex =>
  8287. {
  8288. using (await gate.LockAsync().ConfigureAwait(false))
  8289. {
  8290. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8291. }
  8292. },
  8293. async () =>
  8294. {
  8295. using (await gate.LockAsync().ConfigureAwait(false))
  8296. {
  8297. isDone4 = true;
  8298. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8299. {
  8300. await observer.OnCompletedAsync().ConfigureAwait(false);
  8301. }
  8302. }
  8303. }
  8304. ),
  8305. Create<T5>(
  8306. async x =>
  8307. {
  8308. using (await gate.LockAsync().ConfigureAwait(false))
  8309. {
  8310. if (!hasValue5)
  8311. {
  8312. hasValue5 = true;
  8313. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8314. }
  8315. latestValue5 = x;
  8316. if (allHasValue)
  8317. {
  8318. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8319. }
  8320. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8321. {
  8322. await observer.OnCompletedAsync().ConfigureAwait(false);
  8323. }
  8324. }
  8325. },
  8326. async ex =>
  8327. {
  8328. using (await gate.LockAsync().ConfigureAwait(false))
  8329. {
  8330. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8331. }
  8332. },
  8333. async () =>
  8334. {
  8335. using (await gate.LockAsync().ConfigureAwait(false))
  8336. {
  8337. isDone5 = true;
  8338. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8339. {
  8340. await observer.OnCompletedAsync().ConfigureAwait(false);
  8341. }
  8342. }
  8343. }
  8344. ),
  8345. Create<T6>(
  8346. async x =>
  8347. {
  8348. using (await gate.LockAsync().ConfigureAwait(false))
  8349. {
  8350. if (!hasValue6)
  8351. {
  8352. hasValue6 = true;
  8353. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8354. }
  8355. latestValue6 = x;
  8356. if (allHasValue)
  8357. {
  8358. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8359. }
  8360. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8361. {
  8362. await observer.OnCompletedAsync().ConfigureAwait(false);
  8363. }
  8364. }
  8365. },
  8366. async ex =>
  8367. {
  8368. using (await gate.LockAsync().ConfigureAwait(false))
  8369. {
  8370. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8371. }
  8372. },
  8373. async () =>
  8374. {
  8375. using (await gate.LockAsync().ConfigureAwait(false))
  8376. {
  8377. isDone6 = true;
  8378. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8379. {
  8380. await observer.OnCompletedAsync().ConfigureAwait(false);
  8381. }
  8382. }
  8383. }
  8384. ),
  8385. Create<T7>(
  8386. async x =>
  8387. {
  8388. using (await gate.LockAsync().ConfigureAwait(false))
  8389. {
  8390. if (!hasValue7)
  8391. {
  8392. hasValue7 = true;
  8393. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8394. }
  8395. latestValue7 = x;
  8396. if (allHasValue)
  8397. {
  8398. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8399. }
  8400. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8401. {
  8402. await observer.OnCompletedAsync().ConfigureAwait(false);
  8403. }
  8404. }
  8405. },
  8406. async ex =>
  8407. {
  8408. using (await gate.LockAsync().ConfigureAwait(false))
  8409. {
  8410. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8411. }
  8412. },
  8413. async () =>
  8414. {
  8415. using (await gate.LockAsync().ConfigureAwait(false))
  8416. {
  8417. isDone7 = true;
  8418. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8419. {
  8420. await observer.OnCompletedAsync().ConfigureAwait(false);
  8421. }
  8422. }
  8423. }
  8424. ),
  8425. Create<T8>(
  8426. async x =>
  8427. {
  8428. using (await gate.LockAsync().ConfigureAwait(false))
  8429. {
  8430. if (!hasValue8)
  8431. {
  8432. hasValue8 = true;
  8433. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8434. }
  8435. latestValue8 = x;
  8436. if (allHasValue)
  8437. {
  8438. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8439. }
  8440. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12)
  8441. {
  8442. await observer.OnCompletedAsync().ConfigureAwait(false);
  8443. }
  8444. }
  8445. },
  8446. async ex =>
  8447. {
  8448. using (await gate.LockAsync().ConfigureAwait(false))
  8449. {
  8450. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8451. }
  8452. },
  8453. async () =>
  8454. {
  8455. using (await gate.LockAsync().ConfigureAwait(false))
  8456. {
  8457. isDone8 = true;
  8458. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8459. {
  8460. await observer.OnCompletedAsync().ConfigureAwait(false);
  8461. }
  8462. }
  8463. }
  8464. ),
  8465. Create<T9>(
  8466. async x =>
  8467. {
  8468. using (await gate.LockAsync().ConfigureAwait(false))
  8469. {
  8470. if (!hasValue9)
  8471. {
  8472. hasValue9 = true;
  8473. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8474. }
  8475. latestValue9 = x;
  8476. if (allHasValue)
  8477. {
  8478. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8479. }
  8480. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12)
  8481. {
  8482. await observer.OnCompletedAsync().ConfigureAwait(false);
  8483. }
  8484. }
  8485. },
  8486. async ex =>
  8487. {
  8488. using (await gate.LockAsync().ConfigureAwait(false))
  8489. {
  8490. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8491. }
  8492. },
  8493. async () =>
  8494. {
  8495. using (await gate.LockAsync().ConfigureAwait(false))
  8496. {
  8497. isDone9 = true;
  8498. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8499. {
  8500. await observer.OnCompletedAsync().ConfigureAwait(false);
  8501. }
  8502. }
  8503. }
  8504. ),
  8505. Create<T10>(
  8506. async x =>
  8507. {
  8508. using (await gate.LockAsync().ConfigureAwait(false))
  8509. {
  8510. if (!hasValue10)
  8511. {
  8512. hasValue10 = true;
  8513. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8514. }
  8515. latestValue10 = x;
  8516. if (allHasValue)
  8517. {
  8518. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8519. }
  8520. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12)
  8521. {
  8522. await observer.OnCompletedAsync().ConfigureAwait(false);
  8523. }
  8524. }
  8525. },
  8526. async ex =>
  8527. {
  8528. using (await gate.LockAsync().ConfigureAwait(false))
  8529. {
  8530. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8531. }
  8532. },
  8533. async () =>
  8534. {
  8535. using (await gate.LockAsync().ConfigureAwait(false))
  8536. {
  8537. isDone10 = true;
  8538. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8539. {
  8540. await observer.OnCompletedAsync().ConfigureAwait(false);
  8541. }
  8542. }
  8543. }
  8544. ),
  8545. Create<T11>(
  8546. async x =>
  8547. {
  8548. using (await gate.LockAsync().ConfigureAwait(false))
  8549. {
  8550. if (!hasValue11)
  8551. {
  8552. hasValue11 = true;
  8553. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8554. }
  8555. latestValue11 = x;
  8556. if (allHasValue)
  8557. {
  8558. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8559. }
  8560. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12)
  8561. {
  8562. await observer.OnCompletedAsync().ConfigureAwait(false);
  8563. }
  8564. }
  8565. },
  8566. async ex =>
  8567. {
  8568. using (await gate.LockAsync().ConfigureAwait(false))
  8569. {
  8570. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8571. }
  8572. },
  8573. async () =>
  8574. {
  8575. using (await gate.LockAsync().ConfigureAwait(false))
  8576. {
  8577. isDone11 = true;
  8578. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8579. {
  8580. await observer.OnCompletedAsync().ConfigureAwait(false);
  8581. }
  8582. }
  8583. }
  8584. ),
  8585. Create<T12>(
  8586. async x =>
  8587. {
  8588. using (await gate.LockAsync().ConfigureAwait(false))
  8589. {
  8590. if (!hasValue12)
  8591. {
  8592. hasValue12 = true;
  8593. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8594. }
  8595. latestValue12 = x;
  8596. if (allHasValue)
  8597. {
  8598. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8599. }
  8600. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  8601. {
  8602. await observer.OnCompletedAsync().ConfigureAwait(false);
  8603. }
  8604. }
  8605. },
  8606. async ex =>
  8607. {
  8608. using (await gate.LockAsync().ConfigureAwait(false))
  8609. {
  8610. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8611. }
  8612. },
  8613. async () =>
  8614. {
  8615. using (await gate.LockAsync().ConfigureAwait(false))
  8616. {
  8617. isDone12 = true;
  8618. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8619. {
  8620. await observer.OnCompletedAsync().ConfigureAwait(false);
  8621. }
  8622. }
  8623. }
  8624. )
  8625. );
  8626. }
  8627. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult> selector)
  8628. {
  8629. if (observer == null)
  8630. throw new ArgumentNullException(nameof(observer));
  8631. if (selector == null)
  8632. throw new ArgumentNullException(nameof(selector));
  8633. return CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>(observer, (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12)));
  8634. }
  8635. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, ValueTask<TResult>> selector)
  8636. {
  8637. if (observer == null)
  8638. throw new ArgumentNullException(nameof(observer));
  8639. if (selector == null)
  8640. throw new ArgumentNullException(nameof(selector));
  8641. bool allHasValue = false;
  8642. bool hasValue1 = false;
  8643. bool isDone1 = false;
  8644. T1 latestValue1 = default(T1);
  8645. bool hasValue2 = false;
  8646. bool isDone2 = false;
  8647. T2 latestValue2 = default(T2);
  8648. bool hasValue3 = false;
  8649. bool isDone3 = false;
  8650. T3 latestValue3 = default(T3);
  8651. bool hasValue4 = false;
  8652. bool isDone4 = false;
  8653. T4 latestValue4 = default(T4);
  8654. bool hasValue5 = false;
  8655. bool isDone5 = false;
  8656. T5 latestValue5 = default(T5);
  8657. bool hasValue6 = false;
  8658. bool isDone6 = false;
  8659. T6 latestValue6 = default(T6);
  8660. bool hasValue7 = false;
  8661. bool isDone7 = false;
  8662. T7 latestValue7 = default(T7);
  8663. bool hasValue8 = false;
  8664. bool isDone8 = false;
  8665. T8 latestValue8 = default(T8);
  8666. bool hasValue9 = false;
  8667. bool isDone9 = false;
  8668. T9 latestValue9 = default(T9);
  8669. bool hasValue10 = false;
  8670. bool isDone10 = false;
  8671. T10 latestValue10 = default(T10);
  8672. bool hasValue11 = false;
  8673. bool isDone11 = false;
  8674. T11 latestValue11 = default(T11);
  8675. bool hasValue12 = false;
  8676. bool isDone12 = false;
  8677. T12 latestValue12 = default(T12);
  8678. var gate = new AsyncGate();
  8679. return
  8680. (
  8681. Create<T1>(
  8682. async x =>
  8683. {
  8684. using (await gate.LockAsync().ConfigureAwait(false))
  8685. {
  8686. if (!hasValue1)
  8687. {
  8688. hasValue1 = true;
  8689. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8690. }
  8691. latestValue1 = x;
  8692. if (allHasValue)
  8693. {
  8694. TResult res;
  8695. try
  8696. {
  8697. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8698. }
  8699. catch (Exception ex)
  8700. {
  8701. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8702. return;
  8703. }
  8704. await observer.OnNextAsync(res).ConfigureAwait(false);
  8705. }
  8706. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8707. {
  8708. await observer.OnCompletedAsync().ConfigureAwait(false);
  8709. }
  8710. }
  8711. },
  8712. async ex =>
  8713. {
  8714. using (await gate.LockAsync().ConfigureAwait(false))
  8715. {
  8716. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8717. }
  8718. },
  8719. async () =>
  8720. {
  8721. using (await gate.LockAsync().ConfigureAwait(false))
  8722. {
  8723. isDone1 = true;
  8724. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8725. {
  8726. await observer.OnCompletedAsync().ConfigureAwait(false);
  8727. }
  8728. }
  8729. }
  8730. ),
  8731. Create<T2>(
  8732. async x =>
  8733. {
  8734. using (await gate.LockAsync().ConfigureAwait(false))
  8735. {
  8736. if (!hasValue2)
  8737. {
  8738. hasValue2 = true;
  8739. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8740. }
  8741. latestValue2 = x;
  8742. if (allHasValue)
  8743. {
  8744. TResult res;
  8745. try
  8746. {
  8747. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8748. }
  8749. catch (Exception ex)
  8750. {
  8751. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8752. return;
  8753. }
  8754. await observer.OnNextAsync(res).ConfigureAwait(false);
  8755. }
  8756. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8757. {
  8758. await observer.OnCompletedAsync().ConfigureAwait(false);
  8759. }
  8760. }
  8761. },
  8762. async ex =>
  8763. {
  8764. using (await gate.LockAsync().ConfigureAwait(false))
  8765. {
  8766. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8767. }
  8768. },
  8769. async () =>
  8770. {
  8771. using (await gate.LockAsync().ConfigureAwait(false))
  8772. {
  8773. isDone2 = true;
  8774. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8775. {
  8776. await observer.OnCompletedAsync().ConfigureAwait(false);
  8777. }
  8778. }
  8779. }
  8780. ),
  8781. Create<T3>(
  8782. async x =>
  8783. {
  8784. using (await gate.LockAsync().ConfigureAwait(false))
  8785. {
  8786. if (!hasValue3)
  8787. {
  8788. hasValue3 = true;
  8789. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8790. }
  8791. latestValue3 = x;
  8792. if (allHasValue)
  8793. {
  8794. TResult res;
  8795. try
  8796. {
  8797. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8798. }
  8799. catch (Exception ex)
  8800. {
  8801. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8802. return;
  8803. }
  8804. await observer.OnNextAsync(res).ConfigureAwait(false);
  8805. }
  8806. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8807. {
  8808. await observer.OnCompletedAsync().ConfigureAwait(false);
  8809. }
  8810. }
  8811. },
  8812. async ex =>
  8813. {
  8814. using (await gate.LockAsync().ConfigureAwait(false))
  8815. {
  8816. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8817. }
  8818. },
  8819. async () =>
  8820. {
  8821. using (await gate.LockAsync().ConfigureAwait(false))
  8822. {
  8823. isDone3 = true;
  8824. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8825. {
  8826. await observer.OnCompletedAsync().ConfigureAwait(false);
  8827. }
  8828. }
  8829. }
  8830. ),
  8831. Create<T4>(
  8832. async x =>
  8833. {
  8834. using (await gate.LockAsync().ConfigureAwait(false))
  8835. {
  8836. if (!hasValue4)
  8837. {
  8838. hasValue4 = true;
  8839. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8840. }
  8841. latestValue4 = x;
  8842. if (allHasValue)
  8843. {
  8844. TResult res;
  8845. try
  8846. {
  8847. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8848. }
  8849. catch (Exception ex)
  8850. {
  8851. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8852. return;
  8853. }
  8854. await observer.OnNextAsync(res).ConfigureAwait(false);
  8855. }
  8856. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8857. {
  8858. await observer.OnCompletedAsync().ConfigureAwait(false);
  8859. }
  8860. }
  8861. },
  8862. async ex =>
  8863. {
  8864. using (await gate.LockAsync().ConfigureAwait(false))
  8865. {
  8866. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8867. }
  8868. },
  8869. async () =>
  8870. {
  8871. using (await gate.LockAsync().ConfigureAwait(false))
  8872. {
  8873. isDone4 = true;
  8874. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8875. {
  8876. await observer.OnCompletedAsync().ConfigureAwait(false);
  8877. }
  8878. }
  8879. }
  8880. ),
  8881. Create<T5>(
  8882. async x =>
  8883. {
  8884. using (await gate.LockAsync().ConfigureAwait(false))
  8885. {
  8886. if (!hasValue5)
  8887. {
  8888. hasValue5 = true;
  8889. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8890. }
  8891. latestValue5 = x;
  8892. if (allHasValue)
  8893. {
  8894. TResult res;
  8895. try
  8896. {
  8897. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8898. }
  8899. catch (Exception ex)
  8900. {
  8901. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8902. return;
  8903. }
  8904. await observer.OnNextAsync(res).ConfigureAwait(false);
  8905. }
  8906. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8907. {
  8908. await observer.OnCompletedAsync().ConfigureAwait(false);
  8909. }
  8910. }
  8911. },
  8912. async ex =>
  8913. {
  8914. using (await gate.LockAsync().ConfigureAwait(false))
  8915. {
  8916. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8917. }
  8918. },
  8919. async () =>
  8920. {
  8921. using (await gate.LockAsync().ConfigureAwait(false))
  8922. {
  8923. isDone5 = true;
  8924. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8925. {
  8926. await observer.OnCompletedAsync().ConfigureAwait(false);
  8927. }
  8928. }
  8929. }
  8930. ),
  8931. Create<T6>(
  8932. async x =>
  8933. {
  8934. using (await gate.LockAsync().ConfigureAwait(false))
  8935. {
  8936. if (!hasValue6)
  8937. {
  8938. hasValue6 = true;
  8939. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8940. }
  8941. latestValue6 = x;
  8942. if (allHasValue)
  8943. {
  8944. TResult res;
  8945. try
  8946. {
  8947. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8948. }
  8949. catch (Exception ex)
  8950. {
  8951. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8952. return;
  8953. }
  8954. await observer.OnNextAsync(res).ConfigureAwait(false);
  8955. }
  8956. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8957. {
  8958. await observer.OnCompletedAsync().ConfigureAwait(false);
  8959. }
  8960. }
  8961. },
  8962. async ex =>
  8963. {
  8964. using (await gate.LockAsync().ConfigureAwait(false))
  8965. {
  8966. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8967. }
  8968. },
  8969. async () =>
  8970. {
  8971. using (await gate.LockAsync().ConfigureAwait(false))
  8972. {
  8973. isDone6 = true;
  8974. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8975. {
  8976. await observer.OnCompletedAsync().ConfigureAwait(false);
  8977. }
  8978. }
  8979. }
  8980. ),
  8981. Create<T7>(
  8982. async x =>
  8983. {
  8984. using (await gate.LockAsync().ConfigureAwait(false))
  8985. {
  8986. if (!hasValue7)
  8987. {
  8988. hasValue7 = true;
  8989. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8990. }
  8991. latestValue7 = x;
  8992. if (allHasValue)
  8993. {
  8994. TResult res;
  8995. try
  8996. {
  8997. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8998. }
  8999. catch (Exception ex)
  9000. {
  9001. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9002. return;
  9003. }
  9004. await observer.OnNextAsync(res).ConfigureAwait(false);
  9005. }
  9006. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9007. {
  9008. await observer.OnCompletedAsync().ConfigureAwait(false);
  9009. }
  9010. }
  9011. },
  9012. async ex =>
  9013. {
  9014. using (await gate.LockAsync().ConfigureAwait(false))
  9015. {
  9016. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9017. }
  9018. },
  9019. async () =>
  9020. {
  9021. using (await gate.LockAsync().ConfigureAwait(false))
  9022. {
  9023. isDone7 = true;
  9024. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9025. {
  9026. await observer.OnCompletedAsync().ConfigureAwait(false);
  9027. }
  9028. }
  9029. }
  9030. ),
  9031. Create<T8>(
  9032. async x =>
  9033. {
  9034. using (await gate.LockAsync().ConfigureAwait(false))
  9035. {
  9036. if (!hasValue8)
  9037. {
  9038. hasValue8 = true;
  9039. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  9040. }
  9041. latestValue8 = x;
  9042. if (allHasValue)
  9043. {
  9044. TResult res;
  9045. try
  9046. {
  9047. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  9048. }
  9049. catch (Exception ex)
  9050. {
  9051. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9052. return;
  9053. }
  9054. await observer.OnNextAsync(res).ConfigureAwait(false);
  9055. }
  9056. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12)
  9057. {
  9058. await observer.OnCompletedAsync().ConfigureAwait(false);
  9059. }
  9060. }
  9061. },
  9062. async ex =>
  9063. {
  9064. using (await gate.LockAsync().ConfigureAwait(false))
  9065. {
  9066. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9067. }
  9068. },
  9069. async () =>
  9070. {
  9071. using (await gate.LockAsync().ConfigureAwait(false))
  9072. {
  9073. isDone8 = true;
  9074. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9075. {
  9076. await observer.OnCompletedAsync().ConfigureAwait(false);
  9077. }
  9078. }
  9079. }
  9080. ),
  9081. Create<T9>(
  9082. async x =>
  9083. {
  9084. using (await gate.LockAsync().ConfigureAwait(false))
  9085. {
  9086. if (!hasValue9)
  9087. {
  9088. hasValue9 = true;
  9089. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  9090. }
  9091. latestValue9 = x;
  9092. if (allHasValue)
  9093. {
  9094. TResult res;
  9095. try
  9096. {
  9097. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  9098. }
  9099. catch (Exception ex)
  9100. {
  9101. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9102. return;
  9103. }
  9104. await observer.OnNextAsync(res).ConfigureAwait(false);
  9105. }
  9106. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12)
  9107. {
  9108. await observer.OnCompletedAsync().ConfigureAwait(false);
  9109. }
  9110. }
  9111. },
  9112. async ex =>
  9113. {
  9114. using (await gate.LockAsync().ConfigureAwait(false))
  9115. {
  9116. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9117. }
  9118. },
  9119. async () =>
  9120. {
  9121. using (await gate.LockAsync().ConfigureAwait(false))
  9122. {
  9123. isDone9 = true;
  9124. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9125. {
  9126. await observer.OnCompletedAsync().ConfigureAwait(false);
  9127. }
  9128. }
  9129. }
  9130. ),
  9131. Create<T10>(
  9132. async x =>
  9133. {
  9134. using (await gate.LockAsync().ConfigureAwait(false))
  9135. {
  9136. if (!hasValue10)
  9137. {
  9138. hasValue10 = true;
  9139. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  9140. }
  9141. latestValue10 = x;
  9142. if (allHasValue)
  9143. {
  9144. TResult res;
  9145. try
  9146. {
  9147. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  9148. }
  9149. catch (Exception ex)
  9150. {
  9151. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9152. return;
  9153. }
  9154. await observer.OnNextAsync(res).ConfigureAwait(false);
  9155. }
  9156. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12)
  9157. {
  9158. await observer.OnCompletedAsync().ConfigureAwait(false);
  9159. }
  9160. }
  9161. },
  9162. async ex =>
  9163. {
  9164. using (await gate.LockAsync().ConfigureAwait(false))
  9165. {
  9166. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9167. }
  9168. },
  9169. async () =>
  9170. {
  9171. using (await gate.LockAsync().ConfigureAwait(false))
  9172. {
  9173. isDone10 = true;
  9174. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9175. {
  9176. await observer.OnCompletedAsync().ConfigureAwait(false);
  9177. }
  9178. }
  9179. }
  9180. ),
  9181. Create<T11>(
  9182. async x =>
  9183. {
  9184. using (await gate.LockAsync().ConfigureAwait(false))
  9185. {
  9186. if (!hasValue11)
  9187. {
  9188. hasValue11 = true;
  9189. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  9190. }
  9191. latestValue11 = x;
  9192. if (allHasValue)
  9193. {
  9194. TResult res;
  9195. try
  9196. {
  9197. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  9198. }
  9199. catch (Exception ex)
  9200. {
  9201. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9202. return;
  9203. }
  9204. await observer.OnNextAsync(res).ConfigureAwait(false);
  9205. }
  9206. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12)
  9207. {
  9208. await observer.OnCompletedAsync().ConfigureAwait(false);
  9209. }
  9210. }
  9211. },
  9212. async ex =>
  9213. {
  9214. using (await gate.LockAsync().ConfigureAwait(false))
  9215. {
  9216. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9217. }
  9218. },
  9219. async () =>
  9220. {
  9221. using (await gate.LockAsync().ConfigureAwait(false))
  9222. {
  9223. isDone11 = true;
  9224. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9225. {
  9226. await observer.OnCompletedAsync().ConfigureAwait(false);
  9227. }
  9228. }
  9229. }
  9230. ),
  9231. Create<T12>(
  9232. async x =>
  9233. {
  9234. using (await gate.LockAsync().ConfigureAwait(false))
  9235. {
  9236. if (!hasValue12)
  9237. {
  9238. hasValue12 = true;
  9239. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  9240. }
  9241. latestValue12 = x;
  9242. if (allHasValue)
  9243. {
  9244. TResult res;
  9245. try
  9246. {
  9247. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  9248. }
  9249. catch (Exception ex)
  9250. {
  9251. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9252. return;
  9253. }
  9254. await observer.OnNextAsync(res).ConfigureAwait(false);
  9255. }
  9256. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  9257. {
  9258. await observer.OnCompletedAsync().ConfigureAwait(false);
  9259. }
  9260. }
  9261. },
  9262. async ex =>
  9263. {
  9264. using (await gate.LockAsync().ConfigureAwait(false))
  9265. {
  9266. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9267. }
  9268. },
  9269. async () =>
  9270. {
  9271. using (await gate.LockAsync().ConfigureAwait(false))
  9272. {
  9273. isDone12 = true;
  9274. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9275. {
  9276. await observer.OnCompletedAsync().ConfigureAwait(false);
  9277. }
  9278. }
  9279. }
  9280. )
  9281. );
  9282. }
  9283. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>, IAsyncObserver<T13>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13>(IAsyncObserver<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)> observer)
  9284. {
  9285. if (observer == null)
  9286. throw new ArgumentNullException(nameof(observer));
  9287. bool allHasValue = false;
  9288. bool hasValue1 = false;
  9289. bool isDone1 = false;
  9290. T1 latestValue1 = default(T1);
  9291. bool hasValue2 = false;
  9292. bool isDone2 = false;
  9293. T2 latestValue2 = default(T2);
  9294. bool hasValue3 = false;
  9295. bool isDone3 = false;
  9296. T3 latestValue3 = default(T3);
  9297. bool hasValue4 = false;
  9298. bool isDone4 = false;
  9299. T4 latestValue4 = default(T4);
  9300. bool hasValue5 = false;
  9301. bool isDone5 = false;
  9302. T5 latestValue5 = default(T5);
  9303. bool hasValue6 = false;
  9304. bool isDone6 = false;
  9305. T6 latestValue6 = default(T6);
  9306. bool hasValue7 = false;
  9307. bool isDone7 = false;
  9308. T7 latestValue7 = default(T7);
  9309. bool hasValue8 = false;
  9310. bool isDone8 = false;
  9311. T8 latestValue8 = default(T8);
  9312. bool hasValue9 = false;
  9313. bool isDone9 = false;
  9314. T9 latestValue9 = default(T9);
  9315. bool hasValue10 = false;
  9316. bool isDone10 = false;
  9317. T10 latestValue10 = default(T10);
  9318. bool hasValue11 = false;
  9319. bool isDone11 = false;
  9320. T11 latestValue11 = default(T11);
  9321. bool hasValue12 = false;
  9322. bool isDone12 = false;
  9323. T12 latestValue12 = default(T12);
  9324. bool hasValue13 = false;
  9325. bool isDone13 = false;
  9326. T13 latestValue13 = default(T13);
  9327. var gate = new AsyncGate();
  9328. return
  9329. (
  9330. Create<T1>(
  9331. async x =>
  9332. {
  9333. using (await gate.LockAsync().ConfigureAwait(false))
  9334. {
  9335. if (!hasValue1)
  9336. {
  9337. hasValue1 = true;
  9338. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9339. }
  9340. latestValue1 = x;
  9341. if (allHasValue)
  9342. {
  9343. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9344. }
  9345. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9346. {
  9347. await observer.OnCompletedAsync().ConfigureAwait(false);
  9348. }
  9349. }
  9350. },
  9351. async ex =>
  9352. {
  9353. using (await gate.LockAsync().ConfigureAwait(false))
  9354. {
  9355. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9356. }
  9357. },
  9358. async () =>
  9359. {
  9360. using (await gate.LockAsync().ConfigureAwait(false))
  9361. {
  9362. isDone1 = true;
  9363. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9364. {
  9365. await observer.OnCompletedAsync().ConfigureAwait(false);
  9366. }
  9367. }
  9368. }
  9369. ),
  9370. Create<T2>(
  9371. async x =>
  9372. {
  9373. using (await gate.LockAsync().ConfigureAwait(false))
  9374. {
  9375. if (!hasValue2)
  9376. {
  9377. hasValue2 = true;
  9378. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9379. }
  9380. latestValue2 = x;
  9381. if (allHasValue)
  9382. {
  9383. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9384. }
  9385. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9386. {
  9387. await observer.OnCompletedAsync().ConfigureAwait(false);
  9388. }
  9389. }
  9390. },
  9391. async ex =>
  9392. {
  9393. using (await gate.LockAsync().ConfigureAwait(false))
  9394. {
  9395. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9396. }
  9397. },
  9398. async () =>
  9399. {
  9400. using (await gate.LockAsync().ConfigureAwait(false))
  9401. {
  9402. isDone2 = true;
  9403. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9404. {
  9405. await observer.OnCompletedAsync().ConfigureAwait(false);
  9406. }
  9407. }
  9408. }
  9409. ),
  9410. Create<T3>(
  9411. async x =>
  9412. {
  9413. using (await gate.LockAsync().ConfigureAwait(false))
  9414. {
  9415. if (!hasValue3)
  9416. {
  9417. hasValue3 = true;
  9418. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9419. }
  9420. latestValue3 = x;
  9421. if (allHasValue)
  9422. {
  9423. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9424. }
  9425. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9426. {
  9427. await observer.OnCompletedAsync().ConfigureAwait(false);
  9428. }
  9429. }
  9430. },
  9431. async ex =>
  9432. {
  9433. using (await gate.LockAsync().ConfigureAwait(false))
  9434. {
  9435. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9436. }
  9437. },
  9438. async () =>
  9439. {
  9440. using (await gate.LockAsync().ConfigureAwait(false))
  9441. {
  9442. isDone3 = true;
  9443. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9444. {
  9445. await observer.OnCompletedAsync().ConfigureAwait(false);
  9446. }
  9447. }
  9448. }
  9449. ),
  9450. Create<T4>(
  9451. async x =>
  9452. {
  9453. using (await gate.LockAsync().ConfigureAwait(false))
  9454. {
  9455. if (!hasValue4)
  9456. {
  9457. hasValue4 = true;
  9458. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9459. }
  9460. latestValue4 = x;
  9461. if (allHasValue)
  9462. {
  9463. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9464. }
  9465. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9466. {
  9467. await observer.OnCompletedAsync().ConfigureAwait(false);
  9468. }
  9469. }
  9470. },
  9471. async ex =>
  9472. {
  9473. using (await gate.LockAsync().ConfigureAwait(false))
  9474. {
  9475. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9476. }
  9477. },
  9478. async () =>
  9479. {
  9480. using (await gate.LockAsync().ConfigureAwait(false))
  9481. {
  9482. isDone4 = true;
  9483. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9484. {
  9485. await observer.OnCompletedAsync().ConfigureAwait(false);
  9486. }
  9487. }
  9488. }
  9489. ),
  9490. Create<T5>(
  9491. async x =>
  9492. {
  9493. using (await gate.LockAsync().ConfigureAwait(false))
  9494. {
  9495. if (!hasValue5)
  9496. {
  9497. hasValue5 = true;
  9498. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9499. }
  9500. latestValue5 = x;
  9501. if (allHasValue)
  9502. {
  9503. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9504. }
  9505. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9506. {
  9507. await observer.OnCompletedAsync().ConfigureAwait(false);
  9508. }
  9509. }
  9510. },
  9511. async ex =>
  9512. {
  9513. using (await gate.LockAsync().ConfigureAwait(false))
  9514. {
  9515. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9516. }
  9517. },
  9518. async () =>
  9519. {
  9520. using (await gate.LockAsync().ConfigureAwait(false))
  9521. {
  9522. isDone5 = true;
  9523. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9524. {
  9525. await observer.OnCompletedAsync().ConfigureAwait(false);
  9526. }
  9527. }
  9528. }
  9529. ),
  9530. Create<T6>(
  9531. async x =>
  9532. {
  9533. using (await gate.LockAsync().ConfigureAwait(false))
  9534. {
  9535. if (!hasValue6)
  9536. {
  9537. hasValue6 = true;
  9538. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9539. }
  9540. latestValue6 = x;
  9541. if (allHasValue)
  9542. {
  9543. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9544. }
  9545. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9546. {
  9547. await observer.OnCompletedAsync().ConfigureAwait(false);
  9548. }
  9549. }
  9550. },
  9551. async ex =>
  9552. {
  9553. using (await gate.LockAsync().ConfigureAwait(false))
  9554. {
  9555. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9556. }
  9557. },
  9558. async () =>
  9559. {
  9560. using (await gate.LockAsync().ConfigureAwait(false))
  9561. {
  9562. isDone6 = true;
  9563. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9564. {
  9565. await observer.OnCompletedAsync().ConfigureAwait(false);
  9566. }
  9567. }
  9568. }
  9569. ),
  9570. Create<T7>(
  9571. async x =>
  9572. {
  9573. using (await gate.LockAsync().ConfigureAwait(false))
  9574. {
  9575. if (!hasValue7)
  9576. {
  9577. hasValue7 = true;
  9578. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9579. }
  9580. latestValue7 = x;
  9581. if (allHasValue)
  9582. {
  9583. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9584. }
  9585. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9586. {
  9587. await observer.OnCompletedAsync().ConfigureAwait(false);
  9588. }
  9589. }
  9590. },
  9591. async ex =>
  9592. {
  9593. using (await gate.LockAsync().ConfigureAwait(false))
  9594. {
  9595. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9596. }
  9597. },
  9598. async () =>
  9599. {
  9600. using (await gate.LockAsync().ConfigureAwait(false))
  9601. {
  9602. isDone7 = true;
  9603. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9604. {
  9605. await observer.OnCompletedAsync().ConfigureAwait(false);
  9606. }
  9607. }
  9608. }
  9609. ),
  9610. Create<T8>(
  9611. async x =>
  9612. {
  9613. using (await gate.LockAsync().ConfigureAwait(false))
  9614. {
  9615. if (!hasValue8)
  9616. {
  9617. hasValue8 = true;
  9618. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9619. }
  9620. latestValue8 = x;
  9621. if (allHasValue)
  9622. {
  9623. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9624. }
  9625. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9626. {
  9627. await observer.OnCompletedAsync().ConfigureAwait(false);
  9628. }
  9629. }
  9630. },
  9631. async ex =>
  9632. {
  9633. using (await gate.LockAsync().ConfigureAwait(false))
  9634. {
  9635. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9636. }
  9637. },
  9638. async () =>
  9639. {
  9640. using (await gate.LockAsync().ConfigureAwait(false))
  9641. {
  9642. isDone8 = true;
  9643. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9644. {
  9645. await observer.OnCompletedAsync().ConfigureAwait(false);
  9646. }
  9647. }
  9648. }
  9649. ),
  9650. Create<T9>(
  9651. async x =>
  9652. {
  9653. using (await gate.LockAsync().ConfigureAwait(false))
  9654. {
  9655. if (!hasValue9)
  9656. {
  9657. hasValue9 = true;
  9658. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9659. }
  9660. latestValue9 = x;
  9661. if (allHasValue)
  9662. {
  9663. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9664. }
  9665. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13)
  9666. {
  9667. await observer.OnCompletedAsync().ConfigureAwait(false);
  9668. }
  9669. }
  9670. },
  9671. async ex =>
  9672. {
  9673. using (await gate.LockAsync().ConfigureAwait(false))
  9674. {
  9675. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9676. }
  9677. },
  9678. async () =>
  9679. {
  9680. using (await gate.LockAsync().ConfigureAwait(false))
  9681. {
  9682. isDone9 = true;
  9683. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9684. {
  9685. await observer.OnCompletedAsync().ConfigureAwait(false);
  9686. }
  9687. }
  9688. }
  9689. ),
  9690. Create<T10>(
  9691. async x =>
  9692. {
  9693. using (await gate.LockAsync().ConfigureAwait(false))
  9694. {
  9695. if (!hasValue10)
  9696. {
  9697. hasValue10 = true;
  9698. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9699. }
  9700. latestValue10 = x;
  9701. if (allHasValue)
  9702. {
  9703. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9704. }
  9705. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13)
  9706. {
  9707. await observer.OnCompletedAsync().ConfigureAwait(false);
  9708. }
  9709. }
  9710. },
  9711. async ex =>
  9712. {
  9713. using (await gate.LockAsync().ConfigureAwait(false))
  9714. {
  9715. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9716. }
  9717. },
  9718. async () =>
  9719. {
  9720. using (await gate.LockAsync().ConfigureAwait(false))
  9721. {
  9722. isDone10 = true;
  9723. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9724. {
  9725. await observer.OnCompletedAsync().ConfigureAwait(false);
  9726. }
  9727. }
  9728. }
  9729. ),
  9730. Create<T11>(
  9731. async x =>
  9732. {
  9733. using (await gate.LockAsync().ConfigureAwait(false))
  9734. {
  9735. if (!hasValue11)
  9736. {
  9737. hasValue11 = true;
  9738. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9739. }
  9740. latestValue11 = x;
  9741. if (allHasValue)
  9742. {
  9743. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9744. }
  9745. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13)
  9746. {
  9747. await observer.OnCompletedAsync().ConfigureAwait(false);
  9748. }
  9749. }
  9750. },
  9751. async ex =>
  9752. {
  9753. using (await gate.LockAsync().ConfigureAwait(false))
  9754. {
  9755. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9756. }
  9757. },
  9758. async () =>
  9759. {
  9760. using (await gate.LockAsync().ConfigureAwait(false))
  9761. {
  9762. isDone11 = true;
  9763. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9764. {
  9765. await observer.OnCompletedAsync().ConfigureAwait(false);
  9766. }
  9767. }
  9768. }
  9769. ),
  9770. Create<T12>(
  9771. async x =>
  9772. {
  9773. using (await gate.LockAsync().ConfigureAwait(false))
  9774. {
  9775. if (!hasValue12)
  9776. {
  9777. hasValue12 = true;
  9778. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9779. }
  9780. latestValue12 = x;
  9781. if (allHasValue)
  9782. {
  9783. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9784. }
  9785. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13)
  9786. {
  9787. await observer.OnCompletedAsync().ConfigureAwait(false);
  9788. }
  9789. }
  9790. },
  9791. async ex =>
  9792. {
  9793. using (await gate.LockAsync().ConfigureAwait(false))
  9794. {
  9795. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9796. }
  9797. },
  9798. async () =>
  9799. {
  9800. using (await gate.LockAsync().ConfigureAwait(false))
  9801. {
  9802. isDone12 = true;
  9803. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9804. {
  9805. await observer.OnCompletedAsync().ConfigureAwait(false);
  9806. }
  9807. }
  9808. }
  9809. ),
  9810. Create<T13>(
  9811. async x =>
  9812. {
  9813. using (await gate.LockAsync().ConfigureAwait(false))
  9814. {
  9815. if (!hasValue13)
  9816. {
  9817. hasValue13 = true;
  9818. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9819. }
  9820. latestValue13 = x;
  9821. if (allHasValue)
  9822. {
  9823. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9824. }
  9825. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9826. {
  9827. await observer.OnCompletedAsync().ConfigureAwait(false);
  9828. }
  9829. }
  9830. },
  9831. async ex =>
  9832. {
  9833. using (await gate.LockAsync().ConfigureAwait(false))
  9834. {
  9835. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9836. }
  9837. },
  9838. async () =>
  9839. {
  9840. using (await gate.LockAsync().ConfigureAwait(false))
  9841. {
  9842. isDone13 = true;
  9843. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9844. {
  9845. await observer.OnCompletedAsync().ConfigureAwait(false);
  9846. }
  9847. }
  9848. }
  9849. )
  9850. );
  9851. }
  9852. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>, IAsyncObserver<T13>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult> selector)
  9853. {
  9854. if (observer == null)
  9855. throw new ArgumentNullException(nameof(observer));
  9856. if (selector == null)
  9857. throw new ArgumentNullException(nameof(selector));
  9858. return CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>(observer, (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13)));
  9859. }
  9860. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>, IAsyncObserver<T13>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, ValueTask<TResult>> selector)
  9861. {
  9862. if (observer == null)
  9863. throw new ArgumentNullException(nameof(observer));
  9864. if (selector == null)
  9865. throw new ArgumentNullException(nameof(selector));
  9866. bool allHasValue = false;
  9867. bool hasValue1 = false;
  9868. bool isDone1 = false;
  9869. T1 latestValue1 = default(T1);
  9870. bool hasValue2 = false;
  9871. bool isDone2 = false;
  9872. T2 latestValue2 = default(T2);
  9873. bool hasValue3 = false;
  9874. bool isDone3 = false;
  9875. T3 latestValue3 = default(T3);
  9876. bool hasValue4 = false;
  9877. bool isDone4 = false;
  9878. T4 latestValue4 = default(T4);
  9879. bool hasValue5 = false;
  9880. bool isDone5 = false;
  9881. T5 latestValue5 = default(T5);
  9882. bool hasValue6 = false;
  9883. bool isDone6 = false;
  9884. T6 latestValue6 = default(T6);
  9885. bool hasValue7 = false;
  9886. bool isDone7 = false;
  9887. T7 latestValue7 = default(T7);
  9888. bool hasValue8 = false;
  9889. bool isDone8 = false;
  9890. T8 latestValue8 = default(T8);
  9891. bool hasValue9 = false;
  9892. bool isDone9 = false;
  9893. T9 latestValue9 = default(T9);
  9894. bool hasValue10 = false;
  9895. bool isDone10 = false;
  9896. T10 latestValue10 = default(T10);
  9897. bool hasValue11 = false;
  9898. bool isDone11 = false;
  9899. T11 latestValue11 = default(T11);
  9900. bool hasValue12 = false;
  9901. bool isDone12 = false;
  9902. T12 latestValue12 = default(T12);
  9903. bool hasValue13 = false;
  9904. bool isDone13 = false;
  9905. T13 latestValue13 = default(T13);
  9906. var gate = new AsyncGate();
  9907. return
  9908. (
  9909. Create<T1>(
  9910. async x =>
  9911. {
  9912. using (await gate.LockAsync().ConfigureAwait(false))
  9913. {
  9914. if (!hasValue1)
  9915. {
  9916. hasValue1 = true;
  9917. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9918. }
  9919. latestValue1 = x;
  9920. if (allHasValue)
  9921. {
  9922. TResult res;
  9923. try
  9924. {
  9925. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  9926. }
  9927. catch (Exception ex)
  9928. {
  9929. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9930. return;
  9931. }
  9932. await observer.OnNextAsync(res).ConfigureAwait(false);
  9933. }
  9934. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9935. {
  9936. await observer.OnCompletedAsync().ConfigureAwait(false);
  9937. }
  9938. }
  9939. },
  9940. async ex =>
  9941. {
  9942. using (await gate.LockAsync().ConfigureAwait(false))
  9943. {
  9944. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9945. }
  9946. },
  9947. async () =>
  9948. {
  9949. using (await gate.LockAsync().ConfigureAwait(false))
  9950. {
  9951. isDone1 = true;
  9952. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9953. {
  9954. await observer.OnCompletedAsync().ConfigureAwait(false);
  9955. }
  9956. }
  9957. }
  9958. ),
  9959. Create<T2>(
  9960. async x =>
  9961. {
  9962. using (await gate.LockAsync().ConfigureAwait(false))
  9963. {
  9964. if (!hasValue2)
  9965. {
  9966. hasValue2 = true;
  9967. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9968. }
  9969. latestValue2 = x;
  9970. if (allHasValue)
  9971. {
  9972. TResult res;
  9973. try
  9974. {
  9975. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  9976. }
  9977. catch (Exception ex)
  9978. {
  9979. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9980. return;
  9981. }
  9982. await observer.OnNextAsync(res).ConfigureAwait(false);
  9983. }
  9984. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9985. {
  9986. await observer.OnCompletedAsync().ConfigureAwait(false);
  9987. }
  9988. }
  9989. },
  9990. async ex =>
  9991. {
  9992. using (await gate.LockAsync().ConfigureAwait(false))
  9993. {
  9994. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9995. }
  9996. },
  9997. async () =>
  9998. {
  9999. using (await gate.LockAsync().ConfigureAwait(false))
  10000. {
  10001. isDone2 = true;
  10002. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10003. {
  10004. await observer.OnCompletedAsync().ConfigureAwait(false);
  10005. }
  10006. }
  10007. }
  10008. ),
  10009. Create<T3>(
  10010. async x =>
  10011. {
  10012. using (await gate.LockAsync().ConfigureAwait(false))
  10013. {
  10014. if (!hasValue3)
  10015. {
  10016. hasValue3 = true;
  10017. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10018. }
  10019. latestValue3 = x;
  10020. if (allHasValue)
  10021. {
  10022. TResult res;
  10023. try
  10024. {
  10025. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10026. }
  10027. catch (Exception ex)
  10028. {
  10029. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10030. return;
  10031. }
  10032. await observer.OnNextAsync(res).ConfigureAwait(false);
  10033. }
  10034. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10035. {
  10036. await observer.OnCompletedAsync().ConfigureAwait(false);
  10037. }
  10038. }
  10039. },
  10040. async ex =>
  10041. {
  10042. using (await gate.LockAsync().ConfigureAwait(false))
  10043. {
  10044. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10045. }
  10046. },
  10047. async () =>
  10048. {
  10049. using (await gate.LockAsync().ConfigureAwait(false))
  10050. {
  10051. isDone3 = true;
  10052. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10053. {
  10054. await observer.OnCompletedAsync().ConfigureAwait(false);
  10055. }
  10056. }
  10057. }
  10058. ),
  10059. Create<T4>(
  10060. async x =>
  10061. {
  10062. using (await gate.LockAsync().ConfigureAwait(false))
  10063. {
  10064. if (!hasValue4)
  10065. {
  10066. hasValue4 = true;
  10067. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10068. }
  10069. latestValue4 = x;
  10070. if (allHasValue)
  10071. {
  10072. TResult res;
  10073. try
  10074. {
  10075. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10076. }
  10077. catch (Exception ex)
  10078. {
  10079. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10080. return;
  10081. }
  10082. await observer.OnNextAsync(res).ConfigureAwait(false);
  10083. }
  10084. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10085. {
  10086. await observer.OnCompletedAsync().ConfigureAwait(false);
  10087. }
  10088. }
  10089. },
  10090. async ex =>
  10091. {
  10092. using (await gate.LockAsync().ConfigureAwait(false))
  10093. {
  10094. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10095. }
  10096. },
  10097. async () =>
  10098. {
  10099. using (await gate.LockAsync().ConfigureAwait(false))
  10100. {
  10101. isDone4 = true;
  10102. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10103. {
  10104. await observer.OnCompletedAsync().ConfigureAwait(false);
  10105. }
  10106. }
  10107. }
  10108. ),
  10109. Create<T5>(
  10110. async x =>
  10111. {
  10112. using (await gate.LockAsync().ConfigureAwait(false))
  10113. {
  10114. if (!hasValue5)
  10115. {
  10116. hasValue5 = true;
  10117. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10118. }
  10119. latestValue5 = x;
  10120. if (allHasValue)
  10121. {
  10122. TResult res;
  10123. try
  10124. {
  10125. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10126. }
  10127. catch (Exception ex)
  10128. {
  10129. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10130. return;
  10131. }
  10132. await observer.OnNextAsync(res).ConfigureAwait(false);
  10133. }
  10134. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10135. {
  10136. await observer.OnCompletedAsync().ConfigureAwait(false);
  10137. }
  10138. }
  10139. },
  10140. async ex =>
  10141. {
  10142. using (await gate.LockAsync().ConfigureAwait(false))
  10143. {
  10144. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10145. }
  10146. },
  10147. async () =>
  10148. {
  10149. using (await gate.LockAsync().ConfigureAwait(false))
  10150. {
  10151. isDone5 = true;
  10152. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10153. {
  10154. await observer.OnCompletedAsync().ConfigureAwait(false);
  10155. }
  10156. }
  10157. }
  10158. ),
  10159. Create<T6>(
  10160. async x =>
  10161. {
  10162. using (await gate.LockAsync().ConfigureAwait(false))
  10163. {
  10164. if (!hasValue6)
  10165. {
  10166. hasValue6 = true;
  10167. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10168. }
  10169. latestValue6 = x;
  10170. if (allHasValue)
  10171. {
  10172. TResult res;
  10173. try
  10174. {
  10175. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10176. }
  10177. catch (Exception ex)
  10178. {
  10179. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10180. return;
  10181. }
  10182. await observer.OnNextAsync(res).ConfigureAwait(false);
  10183. }
  10184. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10185. {
  10186. await observer.OnCompletedAsync().ConfigureAwait(false);
  10187. }
  10188. }
  10189. },
  10190. async ex =>
  10191. {
  10192. using (await gate.LockAsync().ConfigureAwait(false))
  10193. {
  10194. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10195. }
  10196. },
  10197. async () =>
  10198. {
  10199. using (await gate.LockAsync().ConfigureAwait(false))
  10200. {
  10201. isDone6 = true;
  10202. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10203. {
  10204. await observer.OnCompletedAsync().ConfigureAwait(false);
  10205. }
  10206. }
  10207. }
  10208. ),
  10209. Create<T7>(
  10210. async x =>
  10211. {
  10212. using (await gate.LockAsync().ConfigureAwait(false))
  10213. {
  10214. if (!hasValue7)
  10215. {
  10216. hasValue7 = true;
  10217. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10218. }
  10219. latestValue7 = x;
  10220. if (allHasValue)
  10221. {
  10222. TResult res;
  10223. try
  10224. {
  10225. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10226. }
  10227. catch (Exception ex)
  10228. {
  10229. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10230. return;
  10231. }
  10232. await observer.OnNextAsync(res).ConfigureAwait(false);
  10233. }
  10234. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10235. {
  10236. await observer.OnCompletedAsync().ConfigureAwait(false);
  10237. }
  10238. }
  10239. },
  10240. async ex =>
  10241. {
  10242. using (await gate.LockAsync().ConfigureAwait(false))
  10243. {
  10244. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10245. }
  10246. },
  10247. async () =>
  10248. {
  10249. using (await gate.LockAsync().ConfigureAwait(false))
  10250. {
  10251. isDone7 = true;
  10252. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10253. {
  10254. await observer.OnCompletedAsync().ConfigureAwait(false);
  10255. }
  10256. }
  10257. }
  10258. ),
  10259. Create<T8>(
  10260. async x =>
  10261. {
  10262. using (await gate.LockAsync().ConfigureAwait(false))
  10263. {
  10264. if (!hasValue8)
  10265. {
  10266. hasValue8 = true;
  10267. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10268. }
  10269. latestValue8 = x;
  10270. if (allHasValue)
  10271. {
  10272. TResult res;
  10273. try
  10274. {
  10275. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10276. }
  10277. catch (Exception ex)
  10278. {
  10279. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10280. return;
  10281. }
  10282. await observer.OnNextAsync(res).ConfigureAwait(false);
  10283. }
  10284. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10285. {
  10286. await observer.OnCompletedAsync().ConfigureAwait(false);
  10287. }
  10288. }
  10289. },
  10290. async ex =>
  10291. {
  10292. using (await gate.LockAsync().ConfigureAwait(false))
  10293. {
  10294. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10295. }
  10296. },
  10297. async () =>
  10298. {
  10299. using (await gate.LockAsync().ConfigureAwait(false))
  10300. {
  10301. isDone8 = true;
  10302. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10303. {
  10304. await observer.OnCompletedAsync().ConfigureAwait(false);
  10305. }
  10306. }
  10307. }
  10308. ),
  10309. Create<T9>(
  10310. async x =>
  10311. {
  10312. using (await gate.LockAsync().ConfigureAwait(false))
  10313. {
  10314. if (!hasValue9)
  10315. {
  10316. hasValue9 = true;
  10317. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10318. }
  10319. latestValue9 = x;
  10320. if (allHasValue)
  10321. {
  10322. TResult res;
  10323. try
  10324. {
  10325. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10326. }
  10327. catch (Exception ex)
  10328. {
  10329. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10330. return;
  10331. }
  10332. await observer.OnNextAsync(res).ConfigureAwait(false);
  10333. }
  10334. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13)
  10335. {
  10336. await observer.OnCompletedAsync().ConfigureAwait(false);
  10337. }
  10338. }
  10339. },
  10340. async ex =>
  10341. {
  10342. using (await gate.LockAsync().ConfigureAwait(false))
  10343. {
  10344. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10345. }
  10346. },
  10347. async () =>
  10348. {
  10349. using (await gate.LockAsync().ConfigureAwait(false))
  10350. {
  10351. isDone9 = true;
  10352. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10353. {
  10354. await observer.OnCompletedAsync().ConfigureAwait(false);
  10355. }
  10356. }
  10357. }
  10358. ),
  10359. Create<T10>(
  10360. async x =>
  10361. {
  10362. using (await gate.LockAsync().ConfigureAwait(false))
  10363. {
  10364. if (!hasValue10)
  10365. {
  10366. hasValue10 = true;
  10367. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10368. }
  10369. latestValue10 = x;
  10370. if (allHasValue)
  10371. {
  10372. TResult res;
  10373. try
  10374. {
  10375. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10376. }
  10377. catch (Exception ex)
  10378. {
  10379. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10380. return;
  10381. }
  10382. await observer.OnNextAsync(res).ConfigureAwait(false);
  10383. }
  10384. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13)
  10385. {
  10386. await observer.OnCompletedAsync().ConfigureAwait(false);
  10387. }
  10388. }
  10389. },
  10390. async ex =>
  10391. {
  10392. using (await gate.LockAsync().ConfigureAwait(false))
  10393. {
  10394. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10395. }
  10396. },
  10397. async () =>
  10398. {
  10399. using (await gate.LockAsync().ConfigureAwait(false))
  10400. {
  10401. isDone10 = true;
  10402. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10403. {
  10404. await observer.OnCompletedAsync().ConfigureAwait(false);
  10405. }
  10406. }
  10407. }
  10408. ),
  10409. Create<T11>(
  10410. async x =>
  10411. {
  10412. using (await gate.LockAsync().ConfigureAwait(false))
  10413. {
  10414. if (!hasValue11)
  10415. {
  10416. hasValue11 = true;
  10417. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10418. }
  10419. latestValue11 = x;
  10420. if (allHasValue)
  10421. {
  10422. TResult res;
  10423. try
  10424. {
  10425. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10426. }
  10427. catch (Exception ex)
  10428. {
  10429. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10430. return;
  10431. }
  10432. await observer.OnNextAsync(res).ConfigureAwait(false);
  10433. }
  10434. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13)
  10435. {
  10436. await observer.OnCompletedAsync().ConfigureAwait(false);
  10437. }
  10438. }
  10439. },
  10440. async ex =>
  10441. {
  10442. using (await gate.LockAsync().ConfigureAwait(false))
  10443. {
  10444. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10445. }
  10446. },
  10447. async () =>
  10448. {
  10449. using (await gate.LockAsync().ConfigureAwait(false))
  10450. {
  10451. isDone11 = true;
  10452. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10453. {
  10454. await observer.OnCompletedAsync().ConfigureAwait(false);
  10455. }
  10456. }
  10457. }
  10458. ),
  10459. Create<T12>(
  10460. async x =>
  10461. {
  10462. using (await gate.LockAsync().ConfigureAwait(false))
  10463. {
  10464. if (!hasValue12)
  10465. {
  10466. hasValue12 = true;
  10467. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10468. }
  10469. latestValue12 = x;
  10470. if (allHasValue)
  10471. {
  10472. TResult res;
  10473. try
  10474. {
  10475. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10476. }
  10477. catch (Exception ex)
  10478. {
  10479. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10480. return;
  10481. }
  10482. await observer.OnNextAsync(res).ConfigureAwait(false);
  10483. }
  10484. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13)
  10485. {
  10486. await observer.OnCompletedAsync().ConfigureAwait(false);
  10487. }
  10488. }
  10489. },
  10490. async ex =>
  10491. {
  10492. using (await gate.LockAsync().ConfigureAwait(false))
  10493. {
  10494. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10495. }
  10496. },
  10497. async () =>
  10498. {
  10499. using (await gate.LockAsync().ConfigureAwait(false))
  10500. {
  10501. isDone12 = true;
  10502. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10503. {
  10504. await observer.OnCompletedAsync().ConfigureAwait(false);
  10505. }
  10506. }
  10507. }
  10508. ),
  10509. Create<T13>(
  10510. async x =>
  10511. {
  10512. using (await gate.LockAsync().ConfigureAwait(false))
  10513. {
  10514. if (!hasValue13)
  10515. {
  10516. hasValue13 = true;
  10517. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10518. }
  10519. latestValue13 = x;
  10520. if (allHasValue)
  10521. {
  10522. TResult res;
  10523. try
  10524. {
  10525. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10526. }
  10527. catch (Exception ex)
  10528. {
  10529. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10530. return;
  10531. }
  10532. await observer.OnNextAsync(res).ConfigureAwait(false);
  10533. }
  10534. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  10535. {
  10536. await observer.OnCompletedAsync().ConfigureAwait(false);
  10537. }
  10538. }
  10539. },
  10540. async ex =>
  10541. {
  10542. using (await gate.LockAsync().ConfigureAwait(false))
  10543. {
  10544. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10545. }
  10546. },
  10547. async () =>
  10548. {
  10549. using (await gate.LockAsync().ConfigureAwait(false))
  10550. {
  10551. isDone13 = true;
  10552. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10553. {
  10554. await observer.OnCompletedAsync().ConfigureAwait(false);
  10555. }
  10556. }
  10557. }
  10558. )
  10559. );
  10560. }
  10561. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>, IAsyncObserver<T13>, IAsyncObserver<T14>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14>(IAsyncObserver<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)> observer)
  10562. {
  10563. if (observer == null)
  10564. throw new ArgumentNullException(nameof(observer));
  10565. bool allHasValue = false;
  10566. bool hasValue1 = false;
  10567. bool isDone1 = false;
  10568. T1 latestValue1 = default(T1);
  10569. bool hasValue2 = false;
  10570. bool isDone2 = false;
  10571. T2 latestValue2 = default(T2);
  10572. bool hasValue3 = false;
  10573. bool isDone3 = false;
  10574. T3 latestValue3 = default(T3);
  10575. bool hasValue4 = false;
  10576. bool isDone4 = false;
  10577. T4 latestValue4 = default(T4);
  10578. bool hasValue5 = false;
  10579. bool isDone5 = false;
  10580. T5 latestValue5 = default(T5);
  10581. bool hasValue6 = false;
  10582. bool isDone6 = false;
  10583. T6 latestValue6 = default(T6);
  10584. bool hasValue7 = false;
  10585. bool isDone7 = false;
  10586. T7 latestValue7 = default(T7);
  10587. bool hasValue8 = false;
  10588. bool isDone8 = false;
  10589. T8 latestValue8 = default(T8);
  10590. bool hasValue9 = false;
  10591. bool isDone9 = false;
  10592. T9 latestValue9 = default(T9);
  10593. bool hasValue10 = false;
  10594. bool isDone10 = false;
  10595. T10 latestValue10 = default(T10);
  10596. bool hasValue11 = false;
  10597. bool isDone11 = false;
  10598. T11 latestValue11 = default(T11);
  10599. bool hasValue12 = false;
  10600. bool isDone12 = false;
  10601. T12 latestValue12 = default(T12);
  10602. bool hasValue13 = false;
  10603. bool isDone13 = false;
  10604. T13 latestValue13 = default(T13);
  10605. bool hasValue14 = false;
  10606. bool isDone14 = false;
  10607. T14 latestValue14 = default(T14);
  10608. var gate = new AsyncGate();
  10609. return
  10610. (
  10611. Create<T1>(
  10612. async x =>
  10613. {
  10614. using (await gate.LockAsync().ConfigureAwait(false))
  10615. {
  10616. if (!hasValue1)
  10617. {
  10618. hasValue1 = true;
  10619. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10620. }
  10621. latestValue1 = x;
  10622. if (allHasValue)
  10623. {
  10624. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10625. }
  10626. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10627. {
  10628. await observer.OnCompletedAsync().ConfigureAwait(false);
  10629. }
  10630. }
  10631. },
  10632. async ex =>
  10633. {
  10634. using (await gate.LockAsync().ConfigureAwait(false))
  10635. {
  10636. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10637. }
  10638. },
  10639. async () =>
  10640. {
  10641. using (await gate.LockAsync().ConfigureAwait(false))
  10642. {
  10643. isDone1 = true;
  10644. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10645. {
  10646. await observer.OnCompletedAsync().ConfigureAwait(false);
  10647. }
  10648. }
  10649. }
  10650. ),
  10651. Create<T2>(
  10652. async x =>
  10653. {
  10654. using (await gate.LockAsync().ConfigureAwait(false))
  10655. {
  10656. if (!hasValue2)
  10657. {
  10658. hasValue2 = true;
  10659. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10660. }
  10661. latestValue2 = x;
  10662. if (allHasValue)
  10663. {
  10664. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10665. }
  10666. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10667. {
  10668. await observer.OnCompletedAsync().ConfigureAwait(false);
  10669. }
  10670. }
  10671. },
  10672. async ex =>
  10673. {
  10674. using (await gate.LockAsync().ConfigureAwait(false))
  10675. {
  10676. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10677. }
  10678. },
  10679. async () =>
  10680. {
  10681. using (await gate.LockAsync().ConfigureAwait(false))
  10682. {
  10683. isDone2 = true;
  10684. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10685. {
  10686. await observer.OnCompletedAsync().ConfigureAwait(false);
  10687. }
  10688. }
  10689. }
  10690. ),
  10691. Create<T3>(
  10692. async x =>
  10693. {
  10694. using (await gate.LockAsync().ConfigureAwait(false))
  10695. {
  10696. if (!hasValue3)
  10697. {
  10698. hasValue3 = true;
  10699. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10700. }
  10701. latestValue3 = x;
  10702. if (allHasValue)
  10703. {
  10704. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10705. }
  10706. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10707. {
  10708. await observer.OnCompletedAsync().ConfigureAwait(false);
  10709. }
  10710. }
  10711. },
  10712. async ex =>
  10713. {
  10714. using (await gate.LockAsync().ConfigureAwait(false))
  10715. {
  10716. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10717. }
  10718. },
  10719. async () =>
  10720. {
  10721. using (await gate.LockAsync().ConfigureAwait(false))
  10722. {
  10723. isDone3 = true;
  10724. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10725. {
  10726. await observer.OnCompletedAsync().ConfigureAwait(false);
  10727. }
  10728. }
  10729. }
  10730. ),
  10731. Create<T4>(
  10732. async x =>
  10733. {
  10734. using (await gate.LockAsync().ConfigureAwait(false))
  10735. {
  10736. if (!hasValue4)
  10737. {
  10738. hasValue4 = true;
  10739. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10740. }
  10741. latestValue4 = x;
  10742. if (allHasValue)
  10743. {
  10744. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10745. }
  10746. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10747. {
  10748. await observer.OnCompletedAsync().ConfigureAwait(false);
  10749. }
  10750. }
  10751. },
  10752. async ex =>
  10753. {
  10754. using (await gate.LockAsync().ConfigureAwait(false))
  10755. {
  10756. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10757. }
  10758. },
  10759. async () =>
  10760. {
  10761. using (await gate.LockAsync().ConfigureAwait(false))
  10762. {
  10763. isDone4 = true;
  10764. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10765. {
  10766. await observer.OnCompletedAsync().ConfigureAwait(false);
  10767. }
  10768. }
  10769. }
  10770. ),
  10771. Create<T5>(
  10772. async x =>
  10773. {
  10774. using (await gate.LockAsync().ConfigureAwait(false))
  10775. {
  10776. if (!hasValue5)
  10777. {
  10778. hasValue5 = true;
  10779. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10780. }
  10781. latestValue5 = x;
  10782. if (allHasValue)
  10783. {
  10784. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10785. }
  10786. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10787. {
  10788. await observer.OnCompletedAsync().ConfigureAwait(false);
  10789. }
  10790. }
  10791. },
  10792. async ex =>
  10793. {
  10794. using (await gate.LockAsync().ConfigureAwait(false))
  10795. {
  10796. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10797. }
  10798. },
  10799. async () =>
  10800. {
  10801. using (await gate.LockAsync().ConfigureAwait(false))
  10802. {
  10803. isDone5 = true;
  10804. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10805. {
  10806. await observer.OnCompletedAsync().ConfigureAwait(false);
  10807. }
  10808. }
  10809. }
  10810. ),
  10811. Create<T6>(
  10812. async x =>
  10813. {
  10814. using (await gate.LockAsync().ConfigureAwait(false))
  10815. {
  10816. if (!hasValue6)
  10817. {
  10818. hasValue6 = true;
  10819. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10820. }
  10821. latestValue6 = x;
  10822. if (allHasValue)
  10823. {
  10824. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10825. }
  10826. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10827. {
  10828. await observer.OnCompletedAsync().ConfigureAwait(false);
  10829. }
  10830. }
  10831. },
  10832. async ex =>
  10833. {
  10834. using (await gate.LockAsync().ConfigureAwait(false))
  10835. {
  10836. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10837. }
  10838. },
  10839. async () =>
  10840. {
  10841. using (await gate.LockAsync().ConfigureAwait(false))
  10842. {
  10843. isDone6 = true;
  10844. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10845. {
  10846. await observer.OnCompletedAsync().ConfigureAwait(false);
  10847. }
  10848. }
  10849. }
  10850. ),
  10851. Create<T7>(
  10852. async x =>
  10853. {
  10854. using (await gate.LockAsync().ConfigureAwait(false))
  10855. {
  10856. if (!hasValue7)
  10857. {
  10858. hasValue7 = true;
  10859. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10860. }
  10861. latestValue7 = x;
  10862. if (allHasValue)
  10863. {
  10864. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10865. }
  10866. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10867. {
  10868. await observer.OnCompletedAsync().ConfigureAwait(false);
  10869. }
  10870. }
  10871. },
  10872. async ex =>
  10873. {
  10874. using (await gate.LockAsync().ConfigureAwait(false))
  10875. {
  10876. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10877. }
  10878. },
  10879. async () =>
  10880. {
  10881. using (await gate.LockAsync().ConfigureAwait(false))
  10882. {
  10883. isDone7 = true;
  10884. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10885. {
  10886. await observer.OnCompletedAsync().ConfigureAwait(false);
  10887. }
  10888. }
  10889. }
  10890. ),
  10891. Create<T8>(
  10892. async x =>
  10893. {
  10894. using (await gate.LockAsync().ConfigureAwait(false))
  10895. {
  10896. if (!hasValue8)
  10897. {
  10898. hasValue8 = true;
  10899. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10900. }
  10901. latestValue8 = x;
  10902. if (allHasValue)
  10903. {
  10904. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10905. }
  10906. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10907. {
  10908. await observer.OnCompletedAsync().ConfigureAwait(false);
  10909. }
  10910. }
  10911. },
  10912. async ex =>
  10913. {
  10914. using (await gate.LockAsync().ConfigureAwait(false))
  10915. {
  10916. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10917. }
  10918. },
  10919. async () =>
  10920. {
  10921. using (await gate.LockAsync().ConfigureAwait(false))
  10922. {
  10923. isDone8 = true;
  10924. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10925. {
  10926. await observer.OnCompletedAsync().ConfigureAwait(false);
  10927. }
  10928. }
  10929. }
  10930. ),
  10931. Create<T9>(
  10932. async x =>
  10933. {
  10934. using (await gate.LockAsync().ConfigureAwait(false))
  10935. {
  10936. if (!hasValue9)
  10937. {
  10938. hasValue9 = true;
  10939. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10940. }
  10941. latestValue9 = x;
  10942. if (allHasValue)
  10943. {
  10944. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10945. }
  10946. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10947. {
  10948. await observer.OnCompletedAsync().ConfigureAwait(false);
  10949. }
  10950. }
  10951. },
  10952. async ex =>
  10953. {
  10954. using (await gate.LockAsync().ConfigureAwait(false))
  10955. {
  10956. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10957. }
  10958. },
  10959. async () =>
  10960. {
  10961. using (await gate.LockAsync().ConfigureAwait(false))
  10962. {
  10963. isDone9 = true;
  10964. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10965. {
  10966. await observer.OnCompletedAsync().ConfigureAwait(false);
  10967. }
  10968. }
  10969. }
  10970. ),
  10971. Create<T10>(
  10972. async x =>
  10973. {
  10974. using (await gate.LockAsync().ConfigureAwait(false))
  10975. {
  10976. if (!hasValue10)
  10977. {
  10978. hasValue10 = true;
  10979. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10980. }
  10981. latestValue10 = x;
  10982. if (allHasValue)
  10983. {
  10984. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10985. }
  10986. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13 && isDone14)
  10987. {
  10988. await observer.OnCompletedAsync().ConfigureAwait(false);
  10989. }
  10990. }
  10991. },
  10992. async ex =>
  10993. {
  10994. using (await gate.LockAsync().ConfigureAwait(false))
  10995. {
  10996. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10997. }
  10998. },
  10999. async () =>
  11000. {
  11001. using (await gate.LockAsync().ConfigureAwait(false))
  11002. {
  11003. isDone10 = true;
  11004. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11005. {
  11006. await observer.OnCompletedAsync().ConfigureAwait(false);
  11007. }
  11008. }
  11009. }
  11010. ),
  11011. Create<T11>(
  11012. async x =>
  11013. {
  11014. using (await gate.LockAsync().ConfigureAwait(false))
  11015. {
  11016. if (!hasValue11)
  11017. {
  11018. hasValue11 = true;
  11019. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11020. }
  11021. latestValue11 = x;
  11022. if (allHasValue)
  11023. {
  11024. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  11025. }
  11026. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13 && isDone14)
  11027. {
  11028. await observer.OnCompletedAsync().ConfigureAwait(false);
  11029. }
  11030. }
  11031. },
  11032. async ex =>
  11033. {
  11034. using (await gate.LockAsync().ConfigureAwait(false))
  11035. {
  11036. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11037. }
  11038. },
  11039. async () =>
  11040. {
  11041. using (await gate.LockAsync().ConfigureAwait(false))
  11042. {
  11043. isDone11 = true;
  11044. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11045. {
  11046. await observer.OnCompletedAsync().ConfigureAwait(false);
  11047. }
  11048. }
  11049. }
  11050. ),
  11051. Create<T12>(
  11052. async x =>
  11053. {
  11054. using (await gate.LockAsync().ConfigureAwait(false))
  11055. {
  11056. if (!hasValue12)
  11057. {
  11058. hasValue12 = true;
  11059. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11060. }
  11061. latestValue12 = x;
  11062. if (allHasValue)
  11063. {
  11064. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  11065. }
  11066. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13 && isDone14)
  11067. {
  11068. await observer.OnCompletedAsync().ConfigureAwait(false);
  11069. }
  11070. }
  11071. },
  11072. async ex =>
  11073. {
  11074. using (await gate.LockAsync().ConfigureAwait(false))
  11075. {
  11076. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11077. }
  11078. },
  11079. async () =>
  11080. {
  11081. using (await gate.LockAsync().ConfigureAwait(false))
  11082. {
  11083. isDone12 = true;
  11084. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11085. {
  11086. await observer.OnCompletedAsync().ConfigureAwait(false);
  11087. }
  11088. }
  11089. }
  11090. ),
  11091. Create<T13>(
  11092. async x =>
  11093. {
  11094. using (await gate.LockAsync().ConfigureAwait(false))
  11095. {
  11096. if (!hasValue13)
  11097. {
  11098. hasValue13 = true;
  11099. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11100. }
  11101. latestValue13 = x;
  11102. if (allHasValue)
  11103. {
  11104. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  11105. }
  11106. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone14)
  11107. {
  11108. await observer.OnCompletedAsync().ConfigureAwait(false);
  11109. }
  11110. }
  11111. },
  11112. async ex =>
  11113. {
  11114. using (await gate.LockAsync().ConfigureAwait(false))
  11115. {
  11116. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11117. }
  11118. },
  11119. async () =>
  11120. {
  11121. using (await gate.LockAsync().ConfigureAwait(false))
  11122. {
  11123. isDone13 = true;
  11124. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11125. {
  11126. await observer.OnCompletedAsync().ConfigureAwait(false);
  11127. }
  11128. }
  11129. }
  11130. ),
  11131. Create<T14>(
  11132. async x =>
  11133. {
  11134. using (await gate.LockAsync().ConfigureAwait(false))
  11135. {
  11136. if (!hasValue14)
  11137. {
  11138. hasValue14 = true;
  11139. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11140. }
  11141. latestValue14 = x;
  11142. if (allHasValue)
  11143. {
  11144. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  11145. }
  11146. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  11147. {
  11148. await observer.OnCompletedAsync().ConfigureAwait(false);
  11149. }
  11150. }
  11151. },
  11152. async ex =>
  11153. {
  11154. using (await gate.LockAsync().ConfigureAwait(false))
  11155. {
  11156. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11157. }
  11158. },
  11159. async () =>
  11160. {
  11161. using (await gate.LockAsync().ConfigureAwait(false))
  11162. {
  11163. isDone14 = true;
  11164. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11165. {
  11166. await observer.OnCompletedAsync().ConfigureAwait(false);
  11167. }
  11168. }
  11169. }
  11170. )
  11171. );
  11172. }
  11173. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>, IAsyncObserver<T13>, IAsyncObserver<T14>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult> selector)
  11174. {
  11175. if (observer == null)
  11176. throw new ArgumentNullException(nameof(observer));
  11177. if (selector == null)
  11178. throw new ArgumentNullException(nameof(selector));
  11179. return CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>(observer, (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14)));
  11180. }
  11181. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>, IAsyncObserver<T13>, IAsyncObserver<T14>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, ValueTask<TResult>> selector)
  11182. {
  11183. if (observer == null)
  11184. throw new ArgumentNullException(nameof(observer));
  11185. if (selector == null)
  11186. throw new ArgumentNullException(nameof(selector));
  11187. bool allHasValue = false;
  11188. bool hasValue1 = false;
  11189. bool isDone1 = false;
  11190. T1 latestValue1 = default(T1);
  11191. bool hasValue2 = false;
  11192. bool isDone2 = false;
  11193. T2 latestValue2 = default(T2);
  11194. bool hasValue3 = false;
  11195. bool isDone3 = false;
  11196. T3 latestValue3 = default(T3);
  11197. bool hasValue4 = false;
  11198. bool isDone4 = false;
  11199. T4 latestValue4 = default(T4);
  11200. bool hasValue5 = false;
  11201. bool isDone5 = false;
  11202. T5 latestValue5 = default(T5);
  11203. bool hasValue6 = false;
  11204. bool isDone6 = false;
  11205. T6 latestValue6 = default(T6);
  11206. bool hasValue7 = false;
  11207. bool isDone7 = false;
  11208. T7 latestValue7 = default(T7);
  11209. bool hasValue8 = false;
  11210. bool isDone8 = false;
  11211. T8 latestValue8 = default(T8);
  11212. bool hasValue9 = false;
  11213. bool isDone9 = false;
  11214. T9 latestValue9 = default(T9);
  11215. bool hasValue10 = false;
  11216. bool isDone10 = false;
  11217. T10 latestValue10 = default(T10);
  11218. bool hasValue11 = false;
  11219. bool isDone11 = false;
  11220. T11 latestValue11 = default(T11);
  11221. bool hasValue12 = false;
  11222. bool isDone12 = false;
  11223. T12 latestValue12 = default(T12);
  11224. bool hasValue13 = false;
  11225. bool isDone13 = false;
  11226. T13 latestValue13 = default(T13);
  11227. bool hasValue14 = false;
  11228. bool isDone14 = false;
  11229. T14 latestValue14 = default(T14);
  11230. var gate = new AsyncGate();
  11231. return
  11232. (
  11233. Create<T1>(
  11234. async x =>
  11235. {
  11236. using (await gate.LockAsync().ConfigureAwait(false))
  11237. {
  11238. if (!hasValue1)
  11239. {
  11240. hasValue1 = true;
  11241. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11242. }
  11243. latestValue1 = x;
  11244. if (allHasValue)
  11245. {
  11246. TResult res;
  11247. try
  11248. {
  11249. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11250. }
  11251. catch (Exception ex)
  11252. {
  11253. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11254. return;
  11255. }
  11256. await observer.OnNextAsync(res).ConfigureAwait(false);
  11257. }
  11258. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11259. {
  11260. await observer.OnCompletedAsync().ConfigureAwait(false);
  11261. }
  11262. }
  11263. },
  11264. async ex =>
  11265. {
  11266. using (await gate.LockAsync().ConfigureAwait(false))
  11267. {
  11268. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11269. }
  11270. },
  11271. async () =>
  11272. {
  11273. using (await gate.LockAsync().ConfigureAwait(false))
  11274. {
  11275. isDone1 = true;
  11276. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11277. {
  11278. await observer.OnCompletedAsync().ConfigureAwait(false);
  11279. }
  11280. }
  11281. }
  11282. ),
  11283. Create<T2>(
  11284. async x =>
  11285. {
  11286. using (await gate.LockAsync().ConfigureAwait(false))
  11287. {
  11288. if (!hasValue2)
  11289. {
  11290. hasValue2 = true;
  11291. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11292. }
  11293. latestValue2 = x;
  11294. if (allHasValue)
  11295. {
  11296. TResult res;
  11297. try
  11298. {
  11299. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11300. }
  11301. catch (Exception ex)
  11302. {
  11303. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11304. return;
  11305. }
  11306. await observer.OnNextAsync(res).ConfigureAwait(false);
  11307. }
  11308. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11309. {
  11310. await observer.OnCompletedAsync().ConfigureAwait(false);
  11311. }
  11312. }
  11313. },
  11314. async ex =>
  11315. {
  11316. using (await gate.LockAsync().ConfigureAwait(false))
  11317. {
  11318. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11319. }
  11320. },
  11321. async () =>
  11322. {
  11323. using (await gate.LockAsync().ConfigureAwait(false))
  11324. {
  11325. isDone2 = true;
  11326. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11327. {
  11328. await observer.OnCompletedAsync().ConfigureAwait(false);
  11329. }
  11330. }
  11331. }
  11332. ),
  11333. Create<T3>(
  11334. async x =>
  11335. {
  11336. using (await gate.LockAsync().ConfigureAwait(false))
  11337. {
  11338. if (!hasValue3)
  11339. {
  11340. hasValue3 = true;
  11341. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11342. }
  11343. latestValue3 = x;
  11344. if (allHasValue)
  11345. {
  11346. TResult res;
  11347. try
  11348. {
  11349. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11350. }
  11351. catch (Exception ex)
  11352. {
  11353. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11354. return;
  11355. }
  11356. await observer.OnNextAsync(res).ConfigureAwait(false);
  11357. }
  11358. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11359. {
  11360. await observer.OnCompletedAsync().ConfigureAwait(false);
  11361. }
  11362. }
  11363. },
  11364. async ex =>
  11365. {
  11366. using (await gate.LockAsync().ConfigureAwait(false))
  11367. {
  11368. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11369. }
  11370. },
  11371. async () =>
  11372. {
  11373. using (await gate.LockAsync().ConfigureAwait(false))
  11374. {
  11375. isDone3 = true;
  11376. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11377. {
  11378. await observer.OnCompletedAsync().ConfigureAwait(false);
  11379. }
  11380. }
  11381. }
  11382. ),
  11383. Create<T4>(
  11384. async x =>
  11385. {
  11386. using (await gate.LockAsync().ConfigureAwait(false))
  11387. {
  11388. if (!hasValue4)
  11389. {
  11390. hasValue4 = true;
  11391. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11392. }
  11393. latestValue4 = x;
  11394. if (allHasValue)
  11395. {
  11396. TResult res;
  11397. try
  11398. {
  11399. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11400. }
  11401. catch (Exception ex)
  11402. {
  11403. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11404. return;
  11405. }
  11406. await observer.OnNextAsync(res).ConfigureAwait(false);
  11407. }
  11408. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11409. {
  11410. await observer.OnCompletedAsync().ConfigureAwait(false);
  11411. }
  11412. }
  11413. },
  11414. async ex =>
  11415. {
  11416. using (await gate.LockAsync().ConfigureAwait(false))
  11417. {
  11418. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11419. }
  11420. },
  11421. async () =>
  11422. {
  11423. using (await gate.LockAsync().ConfigureAwait(false))
  11424. {
  11425. isDone4 = true;
  11426. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11427. {
  11428. await observer.OnCompletedAsync().ConfigureAwait(false);
  11429. }
  11430. }
  11431. }
  11432. ),
  11433. Create<T5>(
  11434. async x =>
  11435. {
  11436. using (await gate.LockAsync().ConfigureAwait(false))
  11437. {
  11438. if (!hasValue5)
  11439. {
  11440. hasValue5 = true;
  11441. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11442. }
  11443. latestValue5 = x;
  11444. if (allHasValue)
  11445. {
  11446. TResult res;
  11447. try
  11448. {
  11449. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11450. }
  11451. catch (Exception ex)
  11452. {
  11453. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11454. return;
  11455. }
  11456. await observer.OnNextAsync(res).ConfigureAwait(false);
  11457. }
  11458. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11459. {
  11460. await observer.OnCompletedAsync().ConfigureAwait(false);
  11461. }
  11462. }
  11463. },
  11464. async ex =>
  11465. {
  11466. using (await gate.LockAsync().ConfigureAwait(false))
  11467. {
  11468. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11469. }
  11470. },
  11471. async () =>
  11472. {
  11473. using (await gate.LockAsync().ConfigureAwait(false))
  11474. {
  11475. isDone5 = true;
  11476. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11477. {
  11478. await observer.OnCompletedAsync().ConfigureAwait(false);
  11479. }
  11480. }
  11481. }
  11482. ),
  11483. Create<T6>(
  11484. async x =>
  11485. {
  11486. using (await gate.LockAsync().ConfigureAwait(false))
  11487. {
  11488. if (!hasValue6)
  11489. {
  11490. hasValue6 = true;
  11491. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11492. }
  11493. latestValue6 = x;
  11494. if (allHasValue)
  11495. {
  11496. TResult res;
  11497. try
  11498. {
  11499. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11500. }
  11501. catch (Exception ex)
  11502. {
  11503. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11504. return;
  11505. }
  11506. await observer.OnNextAsync(res).ConfigureAwait(false);
  11507. }
  11508. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11509. {
  11510. await observer.OnCompletedAsync().ConfigureAwait(false);
  11511. }
  11512. }
  11513. },
  11514. async ex =>
  11515. {
  11516. using (await gate.LockAsync().ConfigureAwait(false))
  11517. {
  11518. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11519. }
  11520. },
  11521. async () =>
  11522. {
  11523. using (await gate.LockAsync().ConfigureAwait(false))
  11524. {
  11525. isDone6 = true;
  11526. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11527. {
  11528. await observer.OnCompletedAsync().ConfigureAwait(false);
  11529. }
  11530. }
  11531. }
  11532. ),
  11533. Create<T7>(
  11534. async x =>
  11535. {
  11536. using (await gate.LockAsync().ConfigureAwait(false))
  11537. {
  11538. if (!hasValue7)
  11539. {
  11540. hasValue7 = true;
  11541. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11542. }
  11543. latestValue7 = x;
  11544. if (allHasValue)
  11545. {
  11546. TResult res;
  11547. try
  11548. {
  11549. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11550. }
  11551. catch (Exception ex)
  11552. {
  11553. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11554. return;
  11555. }
  11556. await observer.OnNextAsync(res).ConfigureAwait(false);
  11557. }
  11558. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11559. {
  11560. await observer.OnCompletedAsync().ConfigureAwait(false);
  11561. }
  11562. }
  11563. },
  11564. async ex =>
  11565. {
  11566. using (await gate.LockAsync().ConfigureAwait(false))
  11567. {
  11568. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11569. }
  11570. },
  11571. async () =>
  11572. {
  11573. using (await gate.LockAsync().ConfigureAwait(false))
  11574. {
  11575. isDone7 = true;
  11576. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11577. {
  11578. await observer.OnCompletedAsync().ConfigureAwait(false);
  11579. }
  11580. }
  11581. }
  11582. ),
  11583. Create<T8>(
  11584. async x =>
  11585. {
  11586. using (await gate.LockAsync().ConfigureAwait(false))
  11587. {
  11588. if (!hasValue8)
  11589. {
  11590. hasValue8 = true;
  11591. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11592. }
  11593. latestValue8 = x;
  11594. if (allHasValue)
  11595. {
  11596. TResult res;
  11597. try
  11598. {
  11599. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11600. }
  11601. catch (Exception ex)
  11602. {
  11603. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11604. return;
  11605. }
  11606. await observer.OnNextAsync(res).ConfigureAwait(false);
  11607. }
  11608. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11609. {
  11610. await observer.OnCompletedAsync().ConfigureAwait(false);
  11611. }
  11612. }
  11613. },
  11614. async ex =>
  11615. {
  11616. using (await gate.LockAsync().ConfigureAwait(false))
  11617. {
  11618. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11619. }
  11620. },
  11621. async () =>
  11622. {
  11623. using (await gate.LockAsync().ConfigureAwait(false))
  11624. {
  11625. isDone8 = true;
  11626. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11627. {
  11628. await observer.OnCompletedAsync().ConfigureAwait(false);
  11629. }
  11630. }
  11631. }
  11632. ),
  11633. Create<T9>(
  11634. async x =>
  11635. {
  11636. using (await gate.LockAsync().ConfigureAwait(false))
  11637. {
  11638. if (!hasValue9)
  11639. {
  11640. hasValue9 = true;
  11641. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11642. }
  11643. latestValue9 = x;
  11644. if (allHasValue)
  11645. {
  11646. TResult res;
  11647. try
  11648. {
  11649. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11650. }
  11651. catch (Exception ex)
  11652. {
  11653. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11654. return;
  11655. }
  11656. await observer.OnNextAsync(res).ConfigureAwait(false);
  11657. }
  11658. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11659. {
  11660. await observer.OnCompletedAsync().ConfigureAwait(false);
  11661. }
  11662. }
  11663. },
  11664. async ex =>
  11665. {
  11666. using (await gate.LockAsync().ConfigureAwait(false))
  11667. {
  11668. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11669. }
  11670. },
  11671. async () =>
  11672. {
  11673. using (await gate.LockAsync().ConfigureAwait(false))
  11674. {
  11675. isDone9 = true;
  11676. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11677. {
  11678. await observer.OnCompletedAsync().ConfigureAwait(false);
  11679. }
  11680. }
  11681. }
  11682. ),
  11683. Create<T10>(
  11684. async x =>
  11685. {
  11686. using (await gate.LockAsync().ConfigureAwait(false))
  11687. {
  11688. if (!hasValue10)
  11689. {
  11690. hasValue10 = true;
  11691. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11692. }
  11693. latestValue10 = x;
  11694. if (allHasValue)
  11695. {
  11696. TResult res;
  11697. try
  11698. {
  11699. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11700. }
  11701. catch (Exception ex)
  11702. {
  11703. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11704. return;
  11705. }
  11706. await observer.OnNextAsync(res).ConfigureAwait(false);
  11707. }
  11708. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13 && isDone14)
  11709. {
  11710. await observer.OnCompletedAsync().ConfigureAwait(false);
  11711. }
  11712. }
  11713. },
  11714. async ex =>
  11715. {
  11716. using (await gate.LockAsync().ConfigureAwait(false))
  11717. {
  11718. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11719. }
  11720. },
  11721. async () =>
  11722. {
  11723. using (await gate.LockAsync().ConfigureAwait(false))
  11724. {
  11725. isDone10 = true;
  11726. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11727. {
  11728. await observer.OnCompletedAsync().ConfigureAwait(false);
  11729. }
  11730. }
  11731. }
  11732. ),
  11733. Create<T11>(
  11734. async x =>
  11735. {
  11736. using (await gate.LockAsync().ConfigureAwait(false))
  11737. {
  11738. if (!hasValue11)
  11739. {
  11740. hasValue11 = true;
  11741. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11742. }
  11743. latestValue11 = x;
  11744. if (allHasValue)
  11745. {
  11746. TResult res;
  11747. try
  11748. {
  11749. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11750. }
  11751. catch (Exception ex)
  11752. {
  11753. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11754. return;
  11755. }
  11756. await observer.OnNextAsync(res).ConfigureAwait(false);
  11757. }
  11758. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13 && isDone14)
  11759. {
  11760. await observer.OnCompletedAsync().ConfigureAwait(false);
  11761. }
  11762. }
  11763. },
  11764. async ex =>
  11765. {
  11766. using (await gate.LockAsync().ConfigureAwait(false))
  11767. {
  11768. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11769. }
  11770. },
  11771. async () =>
  11772. {
  11773. using (await gate.LockAsync().ConfigureAwait(false))
  11774. {
  11775. isDone11 = true;
  11776. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11777. {
  11778. await observer.OnCompletedAsync().ConfigureAwait(false);
  11779. }
  11780. }
  11781. }
  11782. ),
  11783. Create<T12>(
  11784. async x =>
  11785. {
  11786. using (await gate.LockAsync().ConfigureAwait(false))
  11787. {
  11788. if (!hasValue12)
  11789. {
  11790. hasValue12 = true;
  11791. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11792. }
  11793. latestValue12 = x;
  11794. if (allHasValue)
  11795. {
  11796. TResult res;
  11797. try
  11798. {
  11799. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11800. }
  11801. catch (Exception ex)
  11802. {
  11803. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11804. return;
  11805. }
  11806. await observer.OnNextAsync(res).ConfigureAwait(false);
  11807. }
  11808. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13 && isDone14)
  11809. {
  11810. await observer.OnCompletedAsync().ConfigureAwait(false);
  11811. }
  11812. }
  11813. },
  11814. async ex =>
  11815. {
  11816. using (await gate.LockAsync().ConfigureAwait(false))
  11817. {
  11818. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11819. }
  11820. },
  11821. async () =>
  11822. {
  11823. using (await gate.LockAsync().ConfigureAwait(false))
  11824. {
  11825. isDone12 = true;
  11826. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11827. {
  11828. await observer.OnCompletedAsync().ConfigureAwait(false);
  11829. }
  11830. }
  11831. }
  11832. ),
  11833. Create<T13>(
  11834. async x =>
  11835. {
  11836. using (await gate.LockAsync().ConfigureAwait(false))
  11837. {
  11838. if (!hasValue13)
  11839. {
  11840. hasValue13 = true;
  11841. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11842. }
  11843. latestValue13 = x;
  11844. if (allHasValue)
  11845. {
  11846. TResult res;
  11847. try
  11848. {
  11849. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11850. }
  11851. catch (Exception ex)
  11852. {
  11853. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11854. return;
  11855. }
  11856. await observer.OnNextAsync(res).ConfigureAwait(false);
  11857. }
  11858. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone14)
  11859. {
  11860. await observer.OnCompletedAsync().ConfigureAwait(false);
  11861. }
  11862. }
  11863. },
  11864. async ex =>
  11865. {
  11866. using (await gate.LockAsync().ConfigureAwait(false))
  11867. {
  11868. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11869. }
  11870. },
  11871. async () =>
  11872. {
  11873. using (await gate.LockAsync().ConfigureAwait(false))
  11874. {
  11875. isDone13 = true;
  11876. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11877. {
  11878. await observer.OnCompletedAsync().ConfigureAwait(false);
  11879. }
  11880. }
  11881. }
  11882. ),
  11883. Create<T14>(
  11884. async x =>
  11885. {
  11886. using (await gate.LockAsync().ConfigureAwait(false))
  11887. {
  11888. if (!hasValue14)
  11889. {
  11890. hasValue14 = true;
  11891. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11892. }
  11893. latestValue14 = x;
  11894. if (allHasValue)
  11895. {
  11896. TResult res;
  11897. try
  11898. {
  11899. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11900. }
  11901. catch (Exception ex)
  11902. {
  11903. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11904. return;
  11905. }
  11906. await observer.OnNextAsync(res).ConfigureAwait(false);
  11907. }
  11908. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  11909. {
  11910. await observer.OnCompletedAsync().ConfigureAwait(false);
  11911. }
  11912. }
  11913. },
  11914. async ex =>
  11915. {
  11916. using (await gate.LockAsync().ConfigureAwait(false))
  11917. {
  11918. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11919. }
  11920. },
  11921. async () =>
  11922. {
  11923. using (await gate.LockAsync().ConfigureAwait(false))
  11924. {
  11925. isDone14 = true;
  11926. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11927. {
  11928. await observer.OnCompletedAsync().ConfigureAwait(false);
  11929. }
  11930. }
  11931. }
  11932. )
  11933. );
  11934. }
  11935. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>, IAsyncObserver<T13>, IAsyncObserver<T14>, IAsyncObserver<T15>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>(IAsyncObserver<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)> observer)
  11936. {
  11937. if (observer == null)
  11938. throw new ArgumentNullException(nameof(observer));
  11939. bool allHasValue = false;
  11940. bool hasValue1 = false;
  11941. bool isDone1 = false;
  11942. T1 latestValue1 = default(T1);
  11943. bool hasValue2 = false;
  11944. bool isDone2 = false;
  11945. T2 latestValue2 = default(T2);
  11946. bool hasValue3 = false;
  11947. bool isDone3 = false;
  11948. T3 latestValue3 = default(T3);
  11949. bool hasValue4 = false;
  11950. bool isDone4 = false;
  11951. T4 latestValue4 = default(T4);
  11952. bool hasValue5 = false;
  11953. bool isDone5 = false;
  11954. T5 latestValue5 = default(T5);
  11955. bool hasValue6 = false;
  11956. bool isDone6 = false;
  11957. T6 latestValue6 = default(T6);
  11958. bool hasValue7 = false;
  11959. bool isDone7 = false;
  11960. T7 latestValue7 = default(T7);
  11961. bool hasValue8 = false;
  11962. bool isDone8 = false;
  11963. T8 latestValue8 = default(T8);
  11964. bool hasValue9 = false;
  11965. bool isDone9 = false;
  11966. T9 latestValue9 = default(T9);
  11967. bool hasValue10 = false;
  11968. bool isDone10 = false;
  11969. T10 latestValue10 = default(T10);
  11970. bool hasValue11 = false;
  11971. bool isDone11 = false;
  11972. T11 latestValue11 = default(T11);
  11973. bool hasValue12 = false;
  11974. bool isDone12 = false;
  11975. T12 latestValue12 = default(T12);
  11976. bool hasValue13 = false;
  11977. bool isDone13 = false;
  11978. T13 latestValue13 = default(T13);
  11979. bool hasValue14 = false;
  11980. bool isDone14 = false;
  11981. T14 latestValue14 = default(T14);
  11982. bool hasValue15 = false;
  11983. bool isDone15 = false;
  11984. T15 latestValue15 = default(T15);
  11985. var gate = new AsyncGate();
  11986. return
  11987. (
  11988. Create<T1>(
  11989. async x =>
  11990. {
  11991. using (await gate.LockAsync().ConfigureAwait(false))
  11992. {
  11993. if (!hasValue1)
  11994. {
  11995. hasValue1 = true;
  11996. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  11997. }
  11998. latestValue1 = x;
  11999. if (allHasValue)
  12000. {
  12001. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12002. }
  12003. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12004. {
  12005. await observer.OnCompletedAsync().ConfigureAwait(false);
  12006. }
  12007. }
  12008. },
  12009. async ex =>
  12010. {
  12011. using (await gate.LockAsync().ConfigureAwait(false))
  12012. {
  12013. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12014. }
  12015. },
  12016. async () =>
  12017. {
  12018. using (await gate.LockAsync().ConfigureAwait(false))
  12019. {
  12020. isDone1 = true;
  12021. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12022. {
  12023. await observer.OnCompletedAsync().ConfigureAwait(false);
  12024. }
  12025. }
  12026. }
  12027. ),
  12028. Create<T2>(
  12029. async x =>
  12030. {
  12031. using (await gate.LockAsync().ConfigureAwait(false))
  12032. {
  12033. if (!hasValue2)
  12034. {
  12035. hasValue2 = true;
  12036. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12037. }
  12038. latestValue2 = x;
  12039. if (allHasValue)
  12040. {
  12041. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12042. }
  12043. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12044. {
  12045. await observer.OnCompletedAsync().ConfigureAwait(false);
  12046. }
  12047. }
  12048. },
  12049. async ex =>
  12050. {
  12051. using (await gate.LockAsync().ConfigureAwait(false))
  12052. {
  12053. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12054. }
  12055. },
  12056. async () =>
  12057. {
  12058. using (await gate.LockAsync().ConfigureAwait(false))
  12059. {
  12060. isDone2 = true;
  12061. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12062. {
  12063. await observer.OnCompletedAsync().ConfigureAwait(false);
  12064. }
  12065. }
  12066. }
  12067. ),
  12068. Create<T3>(
  12069. async x =>
  12070. {
  12071. using (await gate.LockAsync().ConfigureAwait(false))
  12072. {
  12073. if (!hasValue3)
  12074. {
  12075. hasValue3 = true;
  12076. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12077. }
  12078. latestValue3 = x;
  12079. if (allHasValue)
  12080. {
  12081. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12082. }
  12083. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12084. {
  12085. await observer.OnCompletedAsync().ConfigureAwait(false);
  12086. }
  12087. }
  12088. },
  12089. async ex =>
  12090. {
  12091. using (await gate.LockAsync().ConfigureAwait(false))
  12092. {
  12093. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12094. }
  12095. },
  12096. async () =>
  12097. {
  12098. using (await gate.LockAsync().ConfigureAwait(false))
  12099. {
  12100. isDone3 = true;
  12101. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12102. {
  12103. await observer.OnCompletedAsync().ConfigureAwait(false);
  12104. }
  12105. }
  12106. }
  12107. ),
  12108. Create<T4>(
  12109. async x =>
  12110. {
  12111. using (await gate.LockAsync().ConfigureAwait(false))
  12112. {
  12113. if (!hasValue4)
  12114. {
  12115. hasValue4 = true;
  12116. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12117. }
  12118. latestValue4 = x;
  12119. if (allHasValue)
  12120. {
  12121. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12122. }
  12123. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12124. {
  12125. await observer.OnCompletedAsync().ConfigureAwait(false);
  12126. }
  12127. }
  12128. },
  12129. async ex =>
  12130. {
  12131. using (await gate.LockAsync().ConfigureAwait(false))
  12132. {
  12133. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12134. }
  12135. },
  12136. async () =>
  12137. {
  12138. using (await gate.LockAsync().ConfigureAwait(false))
  12139. {
  12140. isDone4 = true;
  12141. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12142. {
  12143. await observer.OnCompletedAsync().ConfigureAwait(false);
  12144. }
  12145. }
  12146. }
  12147. ),
  12148. Create<T5>(
  12149. async x =>
  12150. {
  12151. using (await gate.LockAsync().ConfigureAwait(false))
  12152. {
  12153. if (!hasValue5)
  12154. {
  12155. hasValue5 = true;
  12156. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12157. }
  12158. latestValue5 = x;
  12159. if (allHasValue)
  12160. {
  12161. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12162. }
  12163. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12164. {
  12165. await observer.OnCompletedAsync().ConfigureAwait(false);
  12166. }
  12167. }
  12168. },
  12169. async ex =>
  12170. {
  12171. using (await gate.LockAsync().ConfigureAwait(false))
  12172. {
  12173. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12174. }
  12175. },
  12176. async () =>
  12177. {
  12178. using (await gate.LockAsync().ConfigureAwait(false))
  12179. {
  12180. isDone5 = true;
  12181. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12182. {
  12183. await observer.OnCompletedAsync().ConfigureAwait(false);
  12184. }
  12185. }
  12186. }
  12187. ),
  12188. Create<T6>(
  12189. async x =>
  12190. {
  12191. using (await gate.LockAsync().ConfigureAwait(false))
  12192. {
  12193. if (!hasValue6)
  12194. {
  12195. hasValue6 = true;
  12196. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12197. }
  12198. latestValue6 = x;
  12199. if (allHasValue)
  12200. {
  12201. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12202. }
  12203. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12204. {
  12205. await observer.OnCompletedAsync().ConfigureAwait(false);
  12206. }
  12207. }
  12208. },
  12209. async ex =>
  12210. {
  12211. using (await gate.LockAsync().ConfigureAwait(false))
  12212. {
  12213. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12214. }
  12215. },
  12216. async () =>
  12217. {
  12218. using (await gate.LockAsync().ConfigureAwait(false))
  12219. {
  12220. isDone6 = true;
  12221. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12222. {
  12223. await observer.OnCompletedAsync().ConfigureAwait(false);
  12224. }
  12225. }
  12226. }
  12227. ),
  12228. Create<T7>(
  12229. async x =>
  12230. {
  12231. using (await gate.LockAsync().ConfigureAwait(false))
  12232. {
  12233. if (!hasValue7)
  12234. {
  12235. hasValue7 = true;
  12236. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12237. }
  12238. latestValue7 = x;
  12239. if (allHasValue)
  12240. {
  12241. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12242. }
  12243. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12244. {
  12245. await observer.OnCompletedAsync().ConfigureAwait(false);
  12246. }
  12247. }
  12248. },
  12249. async ex =>
  12250. {
  12251. using (await gate.LockAsync().ConfigureAwait(false))
  12252. {
  12253. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12254. }
  12255. },
  12256. async () =>
  12257. {
  12258. using (await gate.LockAsync().ConfigureAwait(false))
  12259. {
  12260. isDone7 = true;
  12261. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12262. {
  12263. await observer.OnCompletedAsync().ConfigureAwait(false);
  12264. }
  12265. }
  12266. }
  12267. ),
  12268. Create<T8>(
  12269. async x =>
  12270. {
  12271. using (await gate.LockAsync().ConfigureAwait(false))
  12272. {
  12273. if (!hasValue8)
  12274. {
  12275. hasValue8 = true;
  12276. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12277. }
  12278. latestValue8 = x;
  12279. if (allHasValue)
  12280. {
  12281. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12282. }
  12283. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12284. {
  12285. await observer.OnCompletedAsync().ConfigureAwait(false);
  12286. }
  12287. }
  12288. },
  12289. async ex =>
  12290. {
  12291. using (await gate.LockAsync().ConfigureAwait(false))
  12292. {
  12293. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12294. }
  12295. },
  12296. async () =>
  12297. {
  12298. using (await gate.LockAsync().ConfigureAwait(false))
  12299. {
  12300. isDone8 = true;
  12301. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12302. {
  12303. await observer.OnCompletedAsync().ConfigureAwait(false);
  12304. }
  12305. }
  12306. }
  12307. ),
  12308. Create<T9>(
  12309. async x =>
  12310. {
  12311. using (await gate.LockAsync().ConfigureAwait(false))
  12312. {
  12313. if (!hasValue9)
  12314. {
  12315. hasValue9 = true;
  12316. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12317. }
  12318. latestValue9 = x;
  12319. if (allHasValue)
  12320. {
  12321. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12322. }
  12323. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12324. {
  12325. await observer.OnCompletedAsync().ConfigureAwait(false);
  12326. }
  12327. }
  12328. },
  12329. async ex =>
  12330. {
  12331. using (await gate.LockAsync().ConfigureAwait(false))
  12332. {
  12333. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12334. }
  12335. },
  12336. async () =>
  12337. {
  12338. using (await gate.LockAsync().ConfigureAwait(false))
  12339. {
  12340. isDone9 = true;
  12341. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12342. {
  12343. await observer.OnCompletedAsync().ConfigureAwait(false);
  12344. }
  12345. }
  12346. }
  12347. ),
  12348. Create<T10>(
  12349. async x =>
  12350. {
  12351. using (await gate.LockAsync().ConfigureAwait(false))
  12352. {
  12353. if (!hasValue10)
  12354. {
  12355. hasValue10 = true;
  12356. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12357. }
  12358. latestValue10 = x;
  12359. if (allHasValue)
  12360. {
  12361. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12362. }
  12363. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12364. {
  12365. await observer.OnCompletedAsync().ConfigureAwait(false);
  12366. }
  12367. }
  12368. },
  12369. async ex =>
  12370. {
  12371. using (await gate.LockAsync().ConfigureAwait(false))
  12372. {
  12373. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12374. }
  12375. },
  12376. async () =>
  12377. {
  12378. using (await gate.LockAsync().ConfigureAwait(false))
  12379. {
  12380. isDone10 = true;
  12381. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12382. {
  12383. await observer.OnCompletedAsync().ConfigureAwait(false);
  12384. }
  12385. }
  12386. }
  12387. ),
  12388. Create<T11>(
  12389. async x =>
  12390. {
  12391. using (await gate.LockAsync().ConfigureAwait(false))
  12392. {
  12393. if (!hasValue11)
  12394. {
  12395. hasValue11 = true;
  12396. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12397. }
  12398. latestValue11 = x;
  12399. if (allHasValue)
  12400. {
  12401. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12402. }
  12403. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13 && isDone14 && isDone15)
  12404. {
  12405. await observer.OnCompletedAsync().ConfigureAwait(false);
  12406. }
  12407. }
  12408. },
  12409. async ex =>
  12410. {
  12411. using (await gate.LockAsync().ConfigureAwait(false))
  12412. {
  12413. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12414. }
  12415. },
  12416. async () =>
  12417. {
  12418. using (await gate.LockAsync().ConfigureAwait(false))
  12419. {
  12420. isDone11 = true;
  12421. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12422. {
  12423. await observer.OnCompletedAsync().ConfigureAwait(false);
  12424. }
  12425. }
  12426. }
  12427. ),
  12428. Create<T12>(
  12429. async x =>
  12430. {
  12431. using (await gate.LockAsync().ConfigureAwait(false))
  12432. {
  12433. if (!hasValue12)
  12434. {
  12435. hasValue12 = true;
  12436. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12437. }
  12438. latestValue12 = x;
  12439. if (allHasValue)
  12440. {
  12441. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12442. }
  12443. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13 && isDone14 && isDone15)
  12444. {
  12445. await observer.OnCompletedAsync().ConfigureAwait(false);
  12446. }
  12447. }
  12448. },
  12449. async ex =>
  12450. {
  12451. using (await gate.LockAsync().ConfigureAwait(false))
  12452. {
  12453. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12454. }
  12455. },
  12456. async () =>
  12457. {
  12458. using (await gate.LockAsync().ConfigureAwait(false))
  12459. {
  12460. isDone12 = true;
  12461. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12462. {
  12463. await observer.OnCompletedAsync().ConfigureAwait(false);
  12464. }
  12465. }
  12466. }
  12467. ),
  12468. Create<T13>(
  12469. async x =>
  12470. {
  12471. using (await gate.LockAsync().ConfigureAwait(false))
  12472. {
  12473. if (!hasValue13)
  12474. {
  12475. hasValue13 = true;
  12476. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12477. }
  12478. latestValue13 = x;
  12479. if (allHasValue)
  12480. {
  12481. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12482. }
  12483. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone14 && isDone15)
  12484. {
  12485. await observer.OnCompletedAsync().ConfigureAwait(false);
  12486. }
  12487. }
  12488. },
  12489. async ex =>
  12490. {
  12491. using (await gate.LockAsync().ConfigureAwait(false))
  12492. {
  12493. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12494. }
  12495. },
  12496. async () =>
  12497. {
  12498. using (await gate.LockAsync().ConfigureAwait(false))
  12499. {
  12500. isDone13 = true;
  12501. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12502. {
  12503. await observer.OnCompletedAsync().ConfigureAwait(false);
  12504. }
  12505. }
  12506. }
  12507. ),
  12508. Create<T14>(
  12509. async x =>
  12510. {
  12511. using (await gate.LockAsync().ConfigureAwait(false))
  12512. {
  12513. if (!hasValue14)
  12514. {
  12515. hasValue14 = true;
  12516. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12517. }
  12518. latestValue14 = x;
  12519. if (allHasValue)
  12520. {
  12521. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12522. }
  12523. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone15)
  12524. {
  12525. await observer.OnCompletedAsync().ConfigureAwait(false);
  12526. }
  12527. }
  12528. },
  12529. async ex =>
  12530. {
  12531. using (await gate.LockAsync().ConfigureAwait(false))
  12532. {
  12533. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12534. }
  12535. },
  12536. async () =>
  12537. {
  12538. using (await gate.LockAsync().ConfigureAwait(false))
  12539. {
  12540. isDone14 = true;
  12541. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12542. {
  12543. await observer.OnCompletedAsync().ConfigureAwait(false);
  12544. }
  12545. }
  12546. }
  12547. ),
  12548. Create<T15>(
  12549. async x =>
  12550. {
  12551. using (await gate.LockAsync().ConfigureAwait(false))
  12552. {
  12553. if (!hasValue15)
  12554. {
  12555. hasValue15 = true;
  12556. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12557. }
  12558. latestValue15 = x;
  12559. if (allHasValue)
  12560. {
  12561. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12562. }
  12563. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  12564. {
  12565. await observer.OnCompletedAsync().ConfigureAwait(false);
  12566. }
  12567. }
  12568. },
  12569. async ex =>
  12570. {
  12571. using (await gate.LockAsync().ConfigureAwait(false))
  12572. {
  12573. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12574. }
  12575. },
  12576. async () =>
  12577. {
  12578. using (await gate.LockAsync().ConfigureAwait(false))
  12579. {
  12580. isDone15 = true;
  12581. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12582. {
  12583. await observer.OnCompletedAsync().ConfigureAwait(false);
  12584. }
  12585. }
  12586. }
  12587. )
  12588. );
  12589. }
  12590. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>, IAsyncObserver<T13>, IAsyncObserver<T14>, IAsyncObserver<T15>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult> selector)
  12591. {
  12592. if (observer == null)
  12593. throw new ArgumentNullException(nameof(observer));
  12594. if (selector == null)
  12595. throw new ArgumentNullException(nameof(selector));
  12596. return CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>(observer, (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15)));
  12597. }
  12598. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>, IAsyncObserver<T5>, IAsyncObserver<T6>, IAsyncObserver<T7>, IAsyncObserver<T8>, IAsyncObserver<T9>, IAsyncObserver<T10>, IAsyncObserver<T11>, IAsyncObserver<T12>, IAsyncObserver<T13>, IAsyncObserver<T14>, IAsyncObserver<T15>) CombineLatest<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, ValueTask<TResult>> selector)
  12599. {
  12600. if (observer == null)
  12601. throw new ArgumentNullException(nameof(observer));
  12602. if (selector == null)
  12603. throw new ArgumentNullException(nameof(selector));
  12604. bool allHasValue = false;
  12605. bool hasValue1 = false;
  12606. bool isDone1 = false;
  12607. T1 latestValue1 = default(T1);
  12608. bool hasValue2 = false;
  12609. bool isDone2 = false;
  12610. T2 latestValue2 = default(T2);
  12611. bool hasValue3 = false;
  12612. bool isDone3 = false;
  12613. T3 latestValue3 = default(T3);
  12614. bool hasValue4 = false;
  12615. bool isDone4 = false;
  12616. T4 latestValue4 = default(T4);
  12617. bool hasValue5 = false;
  12618. bool isDone5 = false;
  12619. T5 latestValue5 = default(T5);
  12620. bool hasValue6 = false;
  12621. bool isDone6 = false;
  12622. T6 latestValue6 = default(T6);
  12623. bool hasValue7 = false;
  12624. bool isDone7 = false;
  12625. T7 latestValue7 = default(T7);
  12626. bool hasValue8 = false;
  12627. bool isDone8 = false;
  12628. T8 latestValue8 = default(T8);
  12629. bool hasValue9 = false;
  12630. bool isDone9 = false;
  12631. T9 latestValue9 = default(T9);
  12632. bool hasValue10 = false;
  12633. bool isDone10 = false;
  12634. T10 latestValue10 = default(T10);
  12635. bool hasValue11 = false;
  12636. bool isDone11 = false;
  12637. T11 latestValue11 = default(T11);
  12638. bool hasValue12 = false;
  12639. bool isDone12 = false;
  12640. T12 latestValue12 = default(T12);
  12641. bool hasValue13 = false;
  12642. bool isDone13 = false;
  12643. T13 latestValue13 = default(T13);
  12644. bool hasValue14 = false;
  12645. bool isDone14 = false;
  12646. T14 latestValue14 = default(T14);
  12647. bool hasValue15 = false;
  12648. bool isDone15 = false;
  12649. T15 latestValue15 = default(T15);
  12650. var gate = new AsyncGate();
  12651. return
  12652. (
  12653. Create<T1>(
  12654. async x =>
  12655. {
  12656. using (await gate.LockAsync().ConfigureAwait(false))
  12657. {
  12658. if (!hasValue1)
  12659. {
  12660. hasValue1 = true;
  12661. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12662. }
  12663. latestValue1 = x;
  12664. if (allHasValue)
  12665. {
  12666. TResult res;
  12667. try
  12668. {
  12669. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12670. }
  12671. catch (Exception ex)
  12672. {
  12673. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12674. return;
  12675. }
  12676. await observer.OnNextAsync(res).ConfigureAwait(false);
  12677. }
  12678. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12679. {
  12680. await observer.OnCompletedAsync().ConfigureAwait(false);
  12681. }
  12682. }
  12683. },
  12684. async ex =>
  12685. {
  12686. using (await gate.LockAsync().ConfigureAwait(false))
  12687. {
  12688. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12689. }
  12690. },
  12691. async () =>
  12692. {
  12693. using (await gate.LockAsync().ConfigureAwait(false))
  12694. {
  12695. isDone1 = true;
  12696. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12697. {
  12698. await observer.OnCompletedAsync().ConfigureAwait(false);
  12699. }
  12700. }
  12701. }
  12702. ),
  12703. Create<T2>(
  12704. async x =>
  12705. {
  12706. using (await gate.LockAsync().ConfigureAwait(false))
  12707. {
  12708. if (!hasValue2)
  12709. {
  12710. hasValue2 = true;
  12711. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12712. }
  12713. latestValue2 = x;
  12714. if (allHasValue)
  12715. {
  12716. TResult res;
  12717. try
  12718. {
  12719. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12720. }
  12721. catch (Exception ex)
  12722. {
  12723. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12724. return;
  12725. }
  12726. await observer.OnNextAsync(res).ConfigureAwait(false);
  12727. }
  12728. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12729. {
  12730. await observer.OnCompletedAsync().ConfigureAwait(false);
  12731. }
  12732. }
  12733. },
  12734. async ex =>
  12735. {
  12736. using (await gate.LockAsync().ConfigureAwait(false))
  12737. {
  12738. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12739. }
  12740. },
  12741. async () =>
  12742. {
  12743. using (await gate.LockAsync().ConfigureAwait(false))
  12744. {
  12745. isDone2 = true;
  12746. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12747. {
  12748. await observer.OnCompletedAsync().ConfigureAwait(false);
  12749. }
  12750. }
  12751. }
  12752. ),
  12753. Create<T3>(
  12754. async x =>
  12755. {
  12756. using (await gate.LockAsync().ConfigureAwait(false))
  12757. {
  12758. if (!hasValue3)
  12759. {
  12760. hasValue3 = true;
  12761. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12762. }
  12763. latestValue3 = x;
  12764. if (allHasValue)
  12765. {
  12766. TResult res;
  12767. try
  12768. {
  12769. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12770. }
  12771. catch (Exception ex)
  12772. {
  12773. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12774. return;
  12775. }
  12776. await observer.OnNextAsync(res).ConfigureAwait(false);
  12777. }
  12778. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12779. {
  12780. await observer.OnCompletedAsync().ConfigureAwait(false);
  12781. }
  12782. }
  12783. },
  12784. async ex =>
  12785. {
  12786. using (await gate.LockAsync().ConfigureAwait(false))
  12787. {
  12788. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12789. }
  12790. },
  12791. async () =>
  12792. {
  12793. using (await gate.LockAsync().ConfigureAwait(false))
  12794. {
  12795. isDone3 = true;
  12796. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12797. {
  12798. await observer.OnCompletedAsync().ConfigureAwait(false);
  12799. }
  12800. }
  12801. }
  12802. ),
  12803. Create<T4>(
  12804. async x =>
  12805. {
  12806. using (await gate.LockAsync().ConfigureAwait(false))
  12807. {
  12808. if (!hasValue4)
  12809. {
  12810. hasValue4 = true;
  12811. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12812. }
  12813. latestValue4 = x;
  12814. if (allHasValue)
  12815. {
  12816. TResult res;
  12817. try
  12818. {
  12819. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12820. }
  12821. catch (Exception ex)
  12822. {
  12823. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12824. return;
  12825. }
  12826. await observer.OnNextAsync(res).ConfigureAwait(false);
  12827. }
  12828. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12829. {
  12830. await observer.OnCompletedAsync().ConfigureAwait(false);
  12831. }
  12832. }
  12833. },
  12834. async ex =>
  12835. {
  12836. using (await gate.LockAsync().ConfigureAwait(false))
  12837. {
  12838. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12839. }
  12840. },
  12841. async () =>
  12842. {
  12843. using (await gate.LockAsync().ConfigureAwait(false))
  12844. {
  12845. isDone4 = true;
  12846. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12847. {
  12848. await observer.OnCompletedAsync().ConfigureAwait(false);
  12849. }
  12850. }
  12851. }
  12852. ),
  12853. Create<T5>(
  12854. async x =>
  12855. {
  12856. using (await gate.LockAsync().ConfigureAwait(false))
  12857. {
  12858. if (!hasValue5)
  12859. {
  12860. hasValue5 = true;
  12861. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12862. }
  12863. latestValue5 = x;
  12864. if (allHasValue)
  12865. {
  12866. TResult res;
  12867. try
  12868. {
  12869. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12870. }
  12871. catch (Exception ex)
  12872. {
  12873. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12874. return;
  12875. }
  12876. await observer.OnNextAsync(res).ConfigureAwait(false);
  12877. }
  12878. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12879. {
  12880. await observer.OnCompletedAsync().ConfigureAwait(false);
  12881. }
  12882. }
  12883. },
  12884. async ex =>
  12885. {
  12886. using (await gate.LockAsync().ConfigureAwait(false))
  12887. {
  12888. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12889. }
  12890. },
  12891. async () =>
  12892. {
  12893. using (await gate.LockAsync().ConfigureAwait(false))
  12894. {
  12895. isDone5 = true;
  12896. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12897. {
  12898. await observer.OnCompletedAsync().ConfigureAwait(false);
  12899. }
  12900. }
  12901. }
  12902. ),
  12903. Create<T6>(
  12904. async x =>
  12905. {
  12906. using (await gate.LockAsync().ConfigureAwait(false))
  12907. {
  12908. if (!hasValue6)
  12909. {
  12910. hasValue6 = true;
  12911. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12912. }
  12913. latestValue6 = x;
  12914. if (allHasValue)
  12915. {
  12916. TResult res;
  12917. try
  12918. {
  12919. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12920. }
  12921. catch (Exception ex)
  12922. {
  12923. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12924. return;
  12925. }
  12926. await observer.OnNextAsync(res).ConfigureAwait(false);
  12927. }
  12928. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12929. {
  12930. await observer.OnCompletedAsync().ConfigureAwait(false);
  12931. }
  12932. }
  12933. },
  12934. async ex =>
  12935. {
  12936. using (await gate.LockAsync().ConfigureAwait(false))
  12937. {
  12938. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12939. }
  12940. },
  12941. async () =>
  12942. {
  12943. using (await gate.LockAsync().ConfigureAwait(false))
  12944. {
  12945. isDone6 = true;
  12946. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12947. {
  12948. await observer.OnCompletedAsync().ConfigureAwait(false);
  12949. }
  12950. }
  12951. }
  12952. ),
  12953. Create<T7>(
  12954. async x =>
  12955. {
  12956. using (await gate.LockAsync().ConfigureAwait(false))
  12957. {
  12958. if (!hasValue7)
  12959. {
  12960. hasValue7 = true;
  12961. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12962. }
  12963. latestValue7 = x;
  12964. if (allHasValue)
  12965. {
  12966. TResult res;
  12967. try
  12968. {
  12969. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12970. }
  12971. catch (Exception ex)
  12972. {
  12973. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12974. return;
  12975. }
  12976. await observer.OnNextAsync(res).ConfigureAwait(false);
  12977. }
  12978. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12979. {
  12980. await observer.OnCompletedAsync().ConfigureAwait(false);
  12981. }
  12982. }
  12983. },
  12984. async ex =>
  12985. {
  12986. using (await gate.LockAsync().ConfigureAwait(false))
  12987. {
  12988. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12989. }
  12990. },
  12991. async () =>
  12992. {
  12993. using (await gate.LockAsync().ConfigureAwait(false))
  12994. {
  12995. isDone7 = true;
  12996. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12997. {
  12998. await observer.OnCompletedAsync().ConfigureAwait(false);
  12999. }
  13000. }
  13001. }
  13002. ),
  13003. Create<T8>(
  13004. async x =>
  13005. {
  13006. using (await gate.LockAsync().ConfigureAwait(false))
  13007. {
  13008. if (!hasValue8)
  13009. {
  13010. hasValue8 = true;
  13011. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13012. }
  13013. latestValue8 = x;
  13014. if (allHasValue)
  13015. {
  13016. TResult res;
  13017. try
  13018. {
  13019. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13020. }
  13021. catch (Exception ex)
  13022. {
  13023. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13024. return;
  13025. }
  13026. await observer.OnNextAsync(res).ConfigureAwait(false);
  13027. }
  13028. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13029. {
  13030. await observer.OnCompletedAsync().ConfigureAwait(false);
  13031. }
  13032. }
  13033. },
  13034. async ex =>
  13035. {
  13036. using (await gate.LockAsync().ConfigureAwait(false))
  13037. {
  13038. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13039. }
  13040. },
  13041. async () =>
  13042. {
  13043. using (await gate.LockAsync().ConfigureAwait(false))
  13044. {
  13045. isDone8 = true;
  13046. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13047. {
  13048. await observer.OnCompletedAsync().ConfigureAwait(false);
  13049. }
  13050. }
  13051. }
  13052. ),
  13053. Create<T9>(
  13054. async x =>
  13055. {
  13056. using (await gate.LockAsync().ConfigureAwait(false))
  13057. {
  13058. if (!hasValue9)
  13059. {
  13060. hasValue9 = true;
  13061. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13062. }
  13063. latestValue9 = x;
  13064. if (allHasValue)
  13065. {
  13066. TResult res;
  13067. try
  13068. {
  13069. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13070. }
  13071. catch (Exception ex)
  13072. {
  13073. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13074. return;
  13075. }
  13076. await observer.OnNextAsync(res).ConfigureAwait(false);
  13077. }
  13078. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13079. {
  13080. await observer.OnCompletedAsync().ConfigureAwait(false);
  13081. }
  13082. }
  13083. },
  13084. async ex =>
  13085. {
  13086. using (await gate.LockAsync().ConfigureAwait(false))
  13087. {
  13088. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13089. }
  13090. },
  13091. async () =>
  13092. {
  13093. using (await gate.LockAsync().ConfigureAwait(false))
  13094. {
  13095. isDone9 = true;
  13096. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13097. {
  13098. await observer.OnCompletedAsync().ConfigureAwait(false);
  13099. }
  13100. }
  13101. }
  13102. ),
  13103. Create<T10>(
  13104. async x =>
  13105. {
  13106. using (await gate.LockAsync().ConfigureAwait(false))
  13107. {
  13108. if (!hasValue10)
  13109. {
  13110. hasValue10 = true;
  13111. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13112. }
  13113. latestValue10 = x;
  13114. if (allHasValue)
  13115. {
  13116. TResult res;
  13117. try
  13118. {
  13119. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13120. }
  13121. catch (Exception ex)
  13122. {
  13123. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13124. return;
  13125. }
  13126. await observer.OnNextAsync(res).ConfigureAwait(false);
  13127. }
  13128. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13129. {
  13130. await observer.OnCompletedAsync().ConfigureAwait(false);
  13131. }
  13132. }
  13133. },
  13134. async ex =>
  13135. {
  13136. using (await gate.LockAsync().ConfigureAwait(false))
  13137. {
  13138. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13139. }
  13140. },
  13141. async () =>
  13142. {
  13143. using (await gate.LockAsync().ConfigureAwait(false))
  13144. {
  13145. isDone10 = true;
  13146. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13147. {
  13148. await observer.OnCompletedAsync().ConfigureAwait(false);
  13149. }
  13150. }
  13151. }
  13152. ),
  13153. Create<T11>(
  13154. async x =>
  13155. {
  13156. using (await gate.LockAsync().ConfigureAwait(false))
  13157. {
  13158. if (!hasValue11)
  13159. {
  13160. hasValue11 = true;
  13161. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13162. }
  13163. latestValue11 = x;
  13164. if (allHasValue)
  13165. {
  13166. TResult res;
  13167. try
  13168. {
  13169. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13170. }
  13171. catch (Exception ex)
  13172. {
  13173. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13174. return;
  13175. }
  13176. await observer.OnNextAsync(res).ConfigureAwait(false);
  13177. }
  13178. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13 && isDone14 && isDone15)
  13179. {
  13180. await observer.OnCompletedAsync().ConfigureAwait(false);
  13181. }
  13182. }
  13183. },
  13184. async ex =>
  13185. {
  13186. using (await gate.LockAsync().ConfigureAwait(false))
  13187. {
  13188. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13189. }
  13190. },
  13191. async () =>
  13192. {
  13193. using (await gate.LockAsync().ConfigureAwait(false))
  13194. {
  13195. isDone11 = true;
  13196. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13197. {
  13198. await observer.OnCompletedAsync().ConfigureAwait(false);
  13199. }
  13200. }
  13201. }
  13202. ),
  13203. Create<T12>(
  13204. async x =>
  13205. {
  13206. using (await gate.LockAsync().ConfigureAwait(false))
  13207. {
  13208. if (!hasValue12)
  13209. {
  13210. hasValue12 = true;
  13211. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13212. }
  13213. latestValue12 = x;
  13214. if (allHasValue)
  13215. {
  13216. TResult res;
  13217. try
  13218. {
  13219. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13220. }
  13221. catch (Exception ex)
  13222. {
  13223. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13224. return;
  13225. }
  13226. await observer.OnNextAsync(res).ConfigureAwait(false);
  13227. }
  13228. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13 && isDone14 && isDone15)
  13229. {
  13230. await observer.OnCompletedAsync().ConfigureAwait(false);
  13231. }
  13232. }
  13233. },
  13234. async ex =>
  13235. {
  13236. using (await gate.LockAsync().ConfigureAwait(false))
  13237. {
  13238. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13239. }
  13240. },
  13241. async () =>
  13242. {
  13243. using (await gate.LockAsync().ConfigureAwait(false))
  13244. {
  13245. isDone12 = true;
  13246. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13247. {
  13248. await observer.OnCompletedAsync().ConfigureAwait(false);
  13249. }
  13250. }
  13251. }
  13252. ),
  13253. Create<T13>(
  13254. async x =>
  13255. {
  13256. using (await gate.LockAsync().ConfigureAwait(false))
  13257. {
  13258. if (!hasValue13)
  13259. {
  13260. hasValue13 = true;
  13261. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13262. }
  13263. latestValue13 = x;
  13264. if (allHasValue)
  13265. {
  13266. TResult res;
  13267. try
  13268. {
  13269. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13270. }
  13271. catch (Exception ex)
  13272. {
  13273. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13274. return;
  13275. }
  13276. await observer.OnNextAsync(res).ConfigureAwait(false);
  13277. }
  13278. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone14 && isDone15)
  13279. {
  13280. await observer.OnCompletedAsync().ConfigureAwait(false);
  13281. }
  13282. }
  13283. },
  13284. async ex =>
  13285. {
  13286. using (await gate.LockAsync().ConfigureAwait(false))
  13287. {
  13288. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13289. }
  13290. },
  13291. async () =>
  13292. {
  13293. using (await gate.LockAsync().ConfigureAwait(false))
  13294. {
  13295. isDone13 = true;
  13296. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13297. {
  13298. await observer.OnCompletedAsync().ConfigureAwait(false);
  13299. }
  13300. }
  13301. }
  13302. ),
  13303. Create<T14>(
  13304. async x =>
  13305. {
  13306. using (await gate.LockAsync().ConfigureAwait(false))
  13307. {
  13308. if (!hasValue14)
  13309. {
  13310. hasValue14 = true;
  13311. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13312. }
  13313. latestValue14 = x;
  13314. if (allHasValue)
  13315. {
  13316. TResult res;
  13317. try
  13318. {
  13319. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13320. }
  13321. catch (Exception ex)
  13322. {
  13323. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13324. return;
  13325. }
  13326. await observer.OnNextAsync(res).ConfigureAwait(false);
  13327. }
  13328. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone15)
  13329. {
  13330. await observer.OnCompletedAsync().ConfigureAwait(false);
  13331. }
  13332. }
  13333. },
  13334. async ex =>
  13335. {
  13336. using (await gate.LockAsync().ConfigureAwait(false))
  13337. {
  13338. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13339. }
  13340. },
  13341. async () =>
  13342. {
  13343. using (await gate.LockAsync().ConfigureAwait(false))
  13344. {
  13345. isDone14 = true;
  13346. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13347. {
  13348. await observer.OnCompletedAsync().ConfigureAwait(false);
  13349. }
  13350. }
  13351. }
  13352. ),
  13353. Create<T15>(
  13354. async x =>
  13355. {
  13356. using (await gate.LockAsync().ConfigureAwait(false))
  13357. {
  13358. if (!hasValue15)
  13359. {
  13360. hasValue15 = true;
  13361. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13362. }
  13363. latestValue15 = x;
  13364. if (allHasValue)
  13365. {
  13366. TResult res;
  13367. try
  13368. {
  13369. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13370. }
  13371. catch (Exception ex)
  13372. {
  13373. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13374. return;
  13375. }
  13376. await observer.OnNextAsync(res).ConfigureAwait(false);
  13377. }
  13378. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  13379. {
  13380. await observer.OnCompletedAsync().ConfigureAwait(false);
  13381. }
  13382. }
  13383. },
  13384. async ex =>
  13385. {
  13386. using (await gate.LockAsync().ConfigureAwait(false))
  13387. {
  13388. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13389. }
  13390. },
  13391. async () =>
  13392. {
  13393. using (await gate.LockAsync().ConfigureAwait(false))
  13394. {
  13395. isDone15 = true;
  13396. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13397. {
  13398. await observer.OnCompletedAsync().ConfigureAwait(false);
  13399. }
  13400. }
  13401. }
  13402. )
  13403. );
  13404. }
  13405. }
  13406. }