1
0

CombineLatest.Generated.cs 726 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663
  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.Reactive.Threading;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. namespace System.Reactive.Linq
  9. {
  10. public partial class AsyncObservable
  11. {
  12. public static IAsyncObservable<(T1, T2)> CombineLatest<T1, T2>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2)
  13. {
  14. if (source1 == null)
  15. throw new ArgumentNullException(nameof(source1));
  16. if (source2 == null)
  17. throw new ArgumentNullException(nameof(source2));
  18. return Create<(T1, T2)>(async observer =>
  19. {
  20. var d = new CompositeAsyncDisposable();
  21. var (observer1, observer2) = AsyncObserver.CombineLatest(observer);
  22. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  23. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  24. await Task.WhenAll(sub1, sub2).ConfigureAwait(false);
  25. return d;
  26. });
  27. }
  28. public static IAsyncObservable<TResult> CombineLatest<T1, T2, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, Func<T1, T2, TResult> selector)
  29. {
  30. if (source1 == null)
  31. throw new ArgumentNullException(nameof(source1));
  32. if (source2 == null)
  33. throw new ArgumentNullException(nameof(source2));
  34. if (selector == null)
  35. throw new ArgumentNullException(nameof(selector));
  36. return Create<TResult>(async observer =>
  37. {
  38. var d = new CompositeAsyncDisposable();
  39. var (observer1, observer2) = AsyncObserver.CombineLatest(observer, selector);
  40. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  41. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  42. await Task.WhenAll(sub1, sub2).ConfigureAwait(false);
  43. return d;
  44. });
  45. }
  46. public static IAsyncObservable<TResult> CombineLatest<T1, T2, TResult>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, Func<T1, T2, ValueTask<TResult>> selector)
  47. {
  48. if (source1 == null)
  49. throw new ArgumentNullException(nameof(source1));
  50. if (source2 == null)
  51. throw new ArgumentNullException(nameof(source2));
  52. if (selector == null)
  53. throw new ArgumentNullException(nameof(selector));
  54. return Create<TResult>(async observer =>
  55. {
  56. var d = new CompositeAsyncDisposable();
  57. var (observer1, observer2) = AsyncObserver.CombineLatest(observer, selector);
  58. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  59. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  60. await Task.WhenAll(sub1, sub2).ConfigureAwait(false);
  61. return d;
  62. });
  63. }
  64. public static IAsyncObservable<(T1, T2, T3)> CombineLatest<T1, T2, T3>(this IAsyncObservable<T1> source1, IAsyncObservable<T2> source2, IAsyncObservable<T3> source3)
  65. {
  66. if (source1 == null)
  67. throw new ArgumentNullException(nameof(source1));
  68. if (source2 == null)
  69. throw new ArgumentNullException(nameof(source2));
  70. if (source3 == null)
  71. throw new ArgumentNullException(nameof(source3));
  72. return Create<(T1, T2, T3)>(async observer =>
  73. {
  74. var d = new CompositeAsyncDisposable();
  75. var (observer1, observer2, observer3) = AsyncObserver.CombineLatest(observer);
  76. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  77. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  78. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  79. await Task.WhenAll(sub1, sub2, sub3).ConfigureAwait(false);
  80. return d;
  81. });
  82. }
  83. 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)
  84. {
  85. if (source1 == null)
  86. throw new ArgumentNullException(nameof(source1));
  87. if (source2 == null)
  88. throw new ArgumentNullException(nameof(source2));
  89. if (source3 == null)
  90. throw new ArgumentNullException(nameof(source3));
  91. if (selector == null)
  92. throw new ArgumentNullException(nameof(selector));
  93. return Create<TResult>(async observer =>
  94. {
  95. var d = new CompositeAsyncDisposable();
  96. var (observer1, observer2, observer3) = AsyncObserver.CombineLatest(observer, selector);
  97. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  98. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  99. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  100. await Task.WhenAll(sub1, sub2, sub3).ConfigureAwait(false);
  101. return d;
  102. });
  103. }
  104. 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)
  105. {
  106. if (source1 == null)
  107. throw new ArgumentNullException(nameof(source1));
  108. if (source2 == null)
  109. throw new ArgumentNullException(nameof(source2));
  110. if (source3 == null)
  111. throw new ArgumentNullException(nameof(source3));
  112. if (selector == null)
  113. throw new ArgumentNullException(nameof(selector));
  114. return Create<TResult>(async observer =>
  115. {
  116. var d = new CompositeAsyncDisposable();
  117. var (observer1, observer2, observer3) = AsyncObserver.CombineLatest(observer, selector);
  118. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  119. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  120. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  121. await Task.WhenAll(sub1, sub2, sub3).ConfigureAwait(false);
  122. return d;
  123. });
  124. }
  125. 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)
  126. {
  127. if (source1 == null)
  128. throw new ArgumentNullException(nameof(source1));
  129. if (source2 == null)
  130. throw new ArgumentNullException(nameof(source2));
  131. if (source3 == null)
  132. throw new ArgumentNullException(nameof(source3));
  133. if (source4 == null)
  134. throw new ArgumentNullException(nameof(source4));
  135. return Create<(T1, T2, T3, T4)>(async observer =>
  136. {
  137. var d = new CompositeAsyncDisposable();
  138. var (observer1, observer2, observer3, observer4) = AsyncObserver.CombineLatest(observer);
  139. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  140. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  141. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  142. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  143. await Task.WhenAll(sub1, sub2, sub3, sub4).ConfigureAwait(false);
  144. return d;
  145. });
  146. }
  147. 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)
  148. {
  149. if (source1 == null)
  150. throw new ArgumentNullException(nameof(source1));
  151. if (source2 == null)
  152. throw new ArgumentNullException(nameof(source2));
  153. if (source3 == null)
  154. throw new ArgumentNullException(nameof(source3));
  155. if (source4 == null)
  156. throw new ArgumentNullException(nameof(source4));
  157. if (selector == null)
  158. throw new ArgumentNullException(nameof(selector));
  159. return Create<TResult>(async observer =>
  160. {
  161. var d = new CompositeAsyncDisposable();
  162. var (observer1, observer2, observer3, observer4) = AsyncObserver.CombineLatest(observer, selector);
  163. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  164. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  165. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  166. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  167. await Task.WhenAll(sub1, sub2, sub3, sub4).ConfigureAwait(false);
  168. return d;
  169. });
  170. }
  171. 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)
  172. {
  173. if (source1 == null)
  174. throw new ArgumentNullException(nameof(source1));
  175. if (source2 == null)
  176. throw new ArgumentNullException(nameof(source2));
  177. if (source3 == null)
  178. throw new ArgumentNullException(nameof(source3));
  179. if (source4 == null)
  180. throw new ArgumentNullException(nameof(source4));
  181. if (selector == null)
  182. throw new ArgumentNullException(nameof(selector));
  183. return Create<TResult>(async observer =>
  184. {
  185. var d = new CompositeAsyncDisposable();
  186. var (observer1, observer2, observer3, observer4) = AsyncObserver.CombineLatest(observer, selector);
  187. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  188. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  189. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  190. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  191. await Task.WhenAll(sub1, sub2, sub3, sub4).ConfigureAwait(false);
  192. return d;
  193. });
  194. }
  195. 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)
  196. {
  197. if (source1 == null)
  198. throw new ArgumentNullException(nameof(source1));
  199. if (source2 == null)
  200. throw new ArgumentNullException(nameof(source2));
  201. if (source3 == null)
  202. throw new ArgumentNullException(nameof(source3));
  203. if (source4 == null)
  204. throw new ArgumentNullException(nameof(source4));
  205. if (source5 == null)
  206. throw new ArgumentNullException(nameof(source5));
  207. return Create<(T1, T2, T3, T4, T5)>(async observer =>
  208. {
  209. var d = new CompositeAsyncDisposable();
  210. var (observer1, observer2, observer3, observer4, observer5) = AsyncObserver.CombineLatest(observer);
  211. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  212. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  213. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  214. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  215. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  216. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5).ConfigureAwait(false);
  217. return d;
  218. });
  219. }
  220. 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)
  221. {
  222. if (source1 == null)
  223. throw new ArgumentNullException(nameof(source1));
  224. if (source2 == null)
  225. throw new ArgumentNullException(nameof(source2));
  226. if (source3 == null)
  227. throw new ArgumentNullException(nameof(source3));
  228. if (source4 == null)
  229. throw new ArgumentNullException(nameof(source4));
  230. if (source5 == null)
  231. throw new ArgumentNullException(nameof(source5));
  232. if (selector == null)
  233. throw new ArgumentNullException(nameof(selector));
  234. return Create<TResult>(async observer =>
  235. {
  236. var d = new CompositeAsyncDisposable();
  237. var (observer1, observer2, observer3, observer4, observer5) = AsyncObserver.CombineLatest(observer, selector);
  238. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  239. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  240. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  241. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  242. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  243. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5).ConfigureAwait(false);
  244. return d;
  245. });
  246. }
  247. 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)
  248. {
  249. if (source1 == null)
  250. throw new ArgumentNullException(nameof(source1));
  251. if (source2 == null)
  252. throw new ArgumentNullException(nameof(source2));
  253. if (source3 == null)
  254. throw new ArgumentNullException(nameof(source3));
  255. if (source4 == null)
  256. throw new ArgumentNullException(nameof(source4));
  257. if (source5 == null)
  258. throw new ArgumentNullException(nameof(source5));
  259. if (selector == null)
  260. throw new ArgumentNullException(nameof(selector));
  261. return Create<TResult>(async observer =>
  262. {
  263. var d = new CompositeAsyncDisposable();
  264. var (observer1, observer2, observer3, observer4, observer5) = AsyncObserver.CombineLatest(observer, selector);
  265. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  266. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  267. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  268. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  269. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  270. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5).ConfigureAwait(false);
  271. return d;
  272. });
  273. }
  274. 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)
  275. {
  276. if (source1 == null)
  277. throw new ArgumentNullException(nameof(source1));
  278. if (source2 == null)
  279. throw new ArgumentNullException(nameof(source2));
  280. if (source3 == null)
  281. throw new ArgumentNullException(nameof(source3));
  282. if (source4 == null)
  283. throw new ArgumentNullException(nameof(source4));
  284. if (source5 == null)
  285. throw new ArgumentNullException(nameof(source5));
  286. if (source6 == null)
  287. throw new ArgumentNullException(nameof(source6));
  288. return Create<(T1, T2, T3, T4, T5, T6)>(async observer =>
  289. {
  290. var d = new CompositeAsyncDisposable();
  291. var (observer1, observer2, observer3, observer4, observer5, observer6) = AsyncObserver.CombineLatest(observer);
  292. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  293. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  294. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  295. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  296. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  297. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  298. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6).ConfigureAwait(false);
  299. return d;
  300. });
  301. }
  302. 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)
  303. {
  304. if (source1 == null)
  305. throw new ArgumentNullException(nameof(source1));
  306. if (source2 == null)
  307. throw new ArgumentNullException(nameof(source2));
  308. if (source3 == null)
  309. throw new ArgumentNullException(nameof(source3));
  310. if (source4 == null)
  311. throw new ArgumentNullException(nameof(source4));
  312. if (source5 == null)
  313. throw new ArgumentNullException(nameof(source5));
  314. if (source6 == null)
  315. throw new ArgumentNullException(nameof(source6));
  316. if (selector == null)
  317. throw new ArgumentNullException(nameof(selector));
  318. return Create<TResult>(async observer =>
  319. {
  320. var d = new CompositeAsyncDisposable();
  321. var (observer1, observer2, observer3, observer4, observer5, observer6) = AsyncObserver.CombineLatest(observer, selector);
  322. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  323. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  324. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  325. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  326. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  327. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  328. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6).ConfigureAwait(false);
  329. return d;
  330. });
  331. }
  332. 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)
  333. {
  334. if (source1 == null)
  335. throw new ArgumentNullException(nameof(source1));
  336. if (source2 == null)
  337. throw new ArgumentNullException(nameof(source2));
  338. if (source3 == null)
  339. throw new ArgumentNullException(nameof(source3));
  340. if (source4 == null)
  341. throw new ArgumentNullException(nameof(source4));
  342. if (source5 == null)
  343. throw new ArgumentNullException(nameof(source5));
  344. if (source6 == null)
  345. throw new ArgumentNullException(nameof(source6));
  346. if (selector == null)
  347. throw new ArgumentNullException(nameof(selector));
  348. return Create<TResult>(async observer =>
  349. {
  350. var d = new CompositeAsyncDisposable();
  351. var (observer1, observer2, observer3, observer4, observer5, observer6) = AsyncObserver.CombineLatest(observer, selector);
  352. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  353. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  354. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  355. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  356. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  357. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  358. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6).ConfigureAwait(false);
  359. return d;
  360. });
  361. }
  362. 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)
  363. {
  364. if (source1 == null)
  365. throw new ArgumentNullException(nameof(source1));
  366. if (source2 == null)
  367. throw new ArgumentNullException(nameof(source2));
  368. if (source3 == null)
  369. throw new ArgumentNullException(nameof(source3));
  370. if (source4 == null)
  371. throw new ArgumentNullException(nameof(source4));
  372. if (source5 == null)
  373. throw new ArgumentNullException(nameof(source5));
  374. if (source6 == null)
  375. throw new ArgumentNullException(nameof(source6));
  376. if (source7 == null)
  377. throw new ArgumentNullException(nameof(source7));
  378. return Create<(T1, T2, T3, T4, T5, T6, T7)>(async observer =>
  379. {
  380. var d = new CompositeAsyncDisposable();
  381. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7) = AsyncObserver.CombineLatest(observer);
  382. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  383. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  384. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  385. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  386. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  387. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  388. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  389. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7).ConfigureAwait(false);
  390. return d;
  391. });
  392. }
  393. 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)
  394. {
  395. if (source1 == null)
  396. throw new ArgumentNullException(nameof(source1));
  397. if (source2 == null)
  398. throw new ArgumentNullException(nameof(source2));
  399. if (source3 == null)
  400. throw new ArgumentNullException(nameof(source3));
  401. if (source4 == null)
  402. throw new ArgumentNullException(nameof(source4));
  403. if (source5 == null)
  404. throw new ArgumentNullException(nameof(source5));
  405. if (source6 == null)
  406. throw new ArgumentNullException(nameof(source6));
  407. if (source7 == null)
  408. throw new ArgumentNullException(nameof(source7));
  409. if (selector == null)
  410. throw new ArgumentNullException(nameof(selector));
  411. return Create<TResult>(async observer =>
  412. {
  413. var d = new CompositeAsyncDisposable();
  414. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7) = AsyncObserver.CombineLatest(observer, selector);
  415. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  416. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  417. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  418. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  419. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  420. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  421. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  422. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7).ConfigureAwait(false);
  423. return d;
  424. });
  425. }
  426. 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)
  427. {
  428. if (source1 == null)
  429. throw new ArgumentNullException(nameof(source1));
  430. if (source2 == null)
  431. throw new ArgumentNullException(nameof(source2));
  432. if (source3 == null)
  433. throw new ArgumentNullException(nameof(source3));
  434. if (source4 == null)
  435. throw new ArgumentNullException(nameof(source4));
  436. if (source5 == null)
  437. throw new ArgumentNullException(nameof(source5));
  438. if (source6 == null)
  439. throw new ArgumentNullException(nameof(source6));
  440. if (source7 == null)
  441. throw new ArgumentNullException(nameof(source7));
  442. if (selector == null)
  443. throw new ArgumentNullException(nameof(selector));
  444. return Create<TResult>(async observer =>
  445. {
  446. var d = new CompositeAsyncDisposable();
  447. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7) = AsyncObserver.CombineLatest(observer, selector);
  448. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  449. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  450. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  451. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  452. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  453. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  454. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  455. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7).ConfigureAwait(false);
  456. return d;
  457. });
  458. }
  459. 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)
  460. {
  461. if (source1 == null)
  462. throw new ArgumentNullException(nameof(source1));
  463. if (source2 == null)
  464. throw new ArgumentNullException(nameof(source2));
  465. if (source3 == null)
  466. throw new ArgumentNullException(nameof(source3));
  467. if (source4 == null)
  468. throw new ArgumentNullException(nameof(source4));
  469. if (source5 == null)
  470. throw new ArgumentNullException(nameof(source5));
  471. if (source6 == null)
  472. throw new ArgumentNullException(nameof(source6));
  473. if (source7 == null)
  474. throw new ArgumentNullException(nameof(source7));
  475. if (source8 == null)
  476. throw new ArgumentNullException(nameof(source8));
  477. return Create<(T1, T2, T3, T4, T5, T6, T7, T8)>(async observer =>
  478. {
  479. var d = new CompositeAsyncDisposable();
  480. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8) = AsyncObserver.CombineLatest(observer);
  481. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  482. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  483. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  484. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  485. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  486. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  487. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  488. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  489. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8).ConfigureAwait(false);
  490. return d;
  491. });
  492. }
  493. 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)
  494. {
  495. if (source1 == null)
  496. throw new ArgumentNullException(nameof(source1));
  497. if (source2 == null)
  498. throw new ArgumentNullException(nameof(source2));
  499. if (source3 == null)
  500. throw new ArgumentNullException(nameof(source3));
  501. if (source4 == null)
  502. throw new ArgumentNullException(nameof(source4));
  503. if (source5 == null)
  504. throw new ArgumentNullException(nameof(source5));
  505. if (source6 == null)
  506. throw new ArgumentNullException(nameof(source6));
  507. if (source7 == null)
  508. throw new ArgumentNullException(nameof(source7));
  509. if (source8 == null)
  510. throw new ArgumentNullException(nameof(source8));
  511. if (selector == null)
  512. throw new ArgumentNullException(nameof(selector));
  513. return Create<TResult>(async observer =>
  514. {
  515. var d = new CompositeAsyncDisposable();
  516. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8) = AsyncObserver.CombineLatest(observer, selector);
  517. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  518. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  519. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  520. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  521. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  522. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  523. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  524. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  525. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8).ConfigureAwait(false);
  526. return d;
  527. });
  528. }
  529. 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)
  530. {
  531. if (source1 == null)
  532. throw new ArgumentNullException(nameof(source1));
  533. if (source2 == null)
  534. throw new ArgumentNullException(nameof(source2));
  535. if (source3 == null)
  536. throw new ArgumentNullException(nameof(source3));
  537. if (source4 == null)
  538. throw new ArgumentNullException(nameof(source4));
  539. if (source5 == null)
  540. throw new ArgumentNullException(nameof(source5));
  541. if (source6 == null)
  542. throw new ArgumentNullException(nameof(source6));
  543. if (source7 == null)
  544. throw new ArgumentNullException(nameof(source7));
  545. if (source8 == null)
  546. throw new ArgumentNullException(nameof(source8));
  547. if (selector == null)
  548. throw new ArgumentNullException(nameof(selector));
  549. return Create<TResult>(async observer =>
  550. {
  551. var d = new CompositeAsyncDisposable();
  552. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8) = AsyncObserver.CombineLatest(observer, selector);
  553. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  554. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  555. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  556. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  557. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  558. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  559. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  560. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  561. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8).ConfigureAwait(false);
  562. return d;
  563. });
  564. }
  565. 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)
  566. {
  567. if (source1 == null)
  568. throw new ArgumentNullException(nameof(source1));
  569. if (source2 == null)
  570. throw new ArgumentNullException(nameof(source2));
  571. if (source3 == null)
  572. throw new ArgumentNullException(nameof(source3));
  573. if (source4 == null)
  574. throw new ArgumentNullException(nameof(source4));
  575. if (source5 == null)
  576. throw new ArgumentNullException(nameof(source5));
  577. if (source6 == null)
  578. throw new ArgumentNullException(nameof(source6));
  579. if (source7 == null)
  580. throw new ArgumentNullException(nameof(source7));
  581. if (source8 == null)
  582. throw new ArgumentNullException(nameof(source8));
  583. if (source9 == null)
  584. throw new ArgumentNullException(nameof(source9));
  585. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9)>(async observer =>
  586. {
  587. var d = new CompositeAsyncDisposable();
  588. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9) = AsyncObserver.CombineLatest(observer);
  589. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  590. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  591. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  592. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  593. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  594. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  595. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  596. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  597. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  598. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9).ConfigureAwait(false);
  599. return d;
  600. });
  601. }
  602. 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)
  603. {
  604. if (source1 == null)
  605. throw new ArgumentNullException(nameof(source1));
  606. if (source2 == null)
  607. throw new ArgumentNullException(nameof(source2));
  608. if (source3 == null)
  609. throw new ArgumentNullException(nameof(source3));
  610. if (source4 == null)
  611. throw new ArgumentNullException(nameof(source4));
  612. if (source5 == null)
  613. throw new ArgumentNullException(nameof(source5));
  614. if (source6 == null)
  615. throw new ArgumentNullException(nameof(source6));
  616. if (source7 == null)
  617. throw new ArgumentNullException(nameof(source7));
  618. if (source8 == null)
  619. throw new ArgumentNullException(nameof(source8));
  620. if (source9 == null)
  621. throw new ArgumentNullException(nameof(source9));
  622. if (selector == null)
  623. throw new ArgumentNullException(nameof(selector));
  624. return Create<TResult>(async observer =>
  625. {
  626. var d = new CompositeAsyncDisposable();
  627. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9) = AsyncObserver.CombineLatest(observer, selector);
  628. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  629. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  630. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  631. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  632. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  633. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  634. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  635. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  636. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  637. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9).ConfigureAwait(false);
  638. return d;
  639. });
  640. }
  641. 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)
  642. {
  643. if (source1 == null)
  644. throw new ArgumentNullException(nameof(source1));
  645. if (source2 == null)
  646. throw new ArgumentNullException(nameof(source2));
  647. if (source3 == null)
  648. throw new ArgumentNullException(nameof(source3));
  649. if (source4 == null)
  650. throw new ArgumentNullException(nameof(source4));
  651. if (source5 == null)
  652. throw new ArgumentNullException(nameof(source5));
  653. if (source6 == null)
  654. throw new ArgumentNullException(nameof(source6));
  655. if (source7 == null)
  656. throw new ArgumentNullException(nameof(source7));
  657. if (source8 == null)
  658. throw new ArgumentNullException(nameof(source8));
  659. if (source9 == null)
  660. throw new ArgumentNullException(nameof(source9));
  661. if (selector == null)
  662. throw new ArgumentNullException(nameof(selector));
  663. return Create<TResult>(async observer =>
  664. {
  665. var d = new CompositeAsyncDisposable();
  666. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9) = AsyncObserver.CombineLatest(observer, selector);
  667. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  668. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  669. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  670. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  671. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  672. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  673. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  674. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  675. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  676. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9).ConfigureAwait(false);
  677. return d;
  678. });
  679. }
  680. 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)
  681. {
  682. if (source1 == null)
  683. throw new ArgumentNullException(nameof(source1));
  684. if (source2 == null)
  685. throw new ArgumentNullException(nameof(source2));
  686. if (source3 == null)
  687. throw new ArgumentNullException(nameof(source3));
  688. if (source4 == null)
  689. throw new ArgumentNullException(nameof(source4));
  690. if (source5 == null)
  691. throw new ArgumentNullException(nameof(source5));
  692. if (source6 == null)
  693. throw new ArgumentNullException(nameof(source6));
  694. if (source7 == null)
  695. throw new ArgumentNullException(nameof(source7));
  696. if (source8 == null)
  697. throw new ArgumentNullException(nameof(source8));
  698. if (source9 == null)
  699. throw new ArgumentNullException(nameof(source9));
  700. if (source10 == null)
  701. throw new ArgumentNullException(nameof(source10));
  702. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)>(async observer =>
  703. {
  704. var d = new CompositeAsyncDisposable();
  705. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10) = AsyncObserver.CombineLatest(observer);
  706. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  707. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  708. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  709. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  710. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  711. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  712. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  713. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  714. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  715. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  716. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10).ConfigureAwait(false);
  717. return d;
  718. });
  719. }
  720. 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)
  721. {
  722. if (source1 == null)
  723. throw new ArgumentNullException(nameof(source1));
  724. if (source2 == null)
  725. throw new ArgumentNullException(nameof(source2));
  726. if (source3 == null)
  727. throw new ArgumentNullException(nameof(source3));
  728. if (source4 == null)
  729. throw new ArgumentNullException(nameof(source4));
  730. if (source5 == null)
  731. throw new ArgumentNullException(nameof(source5));
  732. if (source6 == null)
  733. throw new ArgumentNullException(nameof(source6));
  734. if (source7 == null)
  735. throw new ArgumentNullException(nameof(source7));
  736. if (source8 == null)
  737. throw new ArgumentNullException(nameof(source8));
  738. if (source9 == null)
  739. throw new ArgumentNullException(nameof(source9));
  740. if (source10 == null)
  741. throw new ArgumentNullException(nameof(source10));
  742. if (selector == null)
  743. throw new ArgumentNullException(nameof(selector));
  744. return Create<TResult>(async observer =>
  745. {
  746. var d = new CompositeAsyncDisposable();
  747. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10) = AsyncObserver.CombineLatest(observer, selector);
  748. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  749. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  750. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  751. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  752. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  753. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  754. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  755. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  756. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  757. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  758. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10).ConfigureAwait(false);
  759. return d;
  760. });
  761. }
  762. 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)
  763. {
  764. if (source1 == null)
  765. throw new ArgumentNullException(nameof(source1));
  766. if (source2 == null)
  767. throw new ArgumentNullException(nameof(source2));
  768. if (source3 == null)
  769. throw new ArgumentNullException(nameof(source3));
  770. if (source4 == null)
  771. throw new ArgumentNullException(nameof(source4));
  772. if (source5 == null)
  773. throw new ArgumentNullException(nameof(source5));
  774. if (source6 == null)
  775. throw new ArgumentNullException(nameof(source6));
  776. if (source7 == null)
  777. throw new ArgumentNullException(nameof(source7));
  778. if (source8 == null)
  779. throw new ArgumentNullException(nameof(source8));
  780. if (source9 == null)
  781. throw new ArgumentNullException(nameof(source9));
  782. if (source10 == null)
  783. throw new ArgumentNullException(nameof(source10));
  784. if (selector == null)
  785. throw new ArgumentNullException(nameof(selector));
  786. return Create<TResult>(async observer =>
  787. {
  788. var d = new CompositeAsyncDisposable();
  789. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10) = AsyncObserver.CombineLatest(observer, selector);
  790. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  791. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  792. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  793. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  794. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  795. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  796. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  797. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  798. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  799. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  800. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10).ConfigureAwait(false);
  801. return d;
  802. });
  803. }
  804. 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)
  805. {
  806. if (source1 == null)
  807. throw new ArgumentNullException(nameof(source1));
  808. if (source2 == null)
  809. throw new ArgumentNullException(nameof(source2));
  810. if (source3 == null)
  811. throw new ArgumentNullException(nameof(source3));
  812. if (source4 == null)
  813. throw new ArgumentNullException(nameof(source4));
  814. if (source5 == null)
  815. throw new ArgumentNullException(nameof(source5));
  816. if (source6 == null)
  817. throw new ArgumentNullException(nameof(source6));
  818. if (source7 == null)
  819. throw new ArgumentNullException(nameof(source7));
  820. if (source8 == null)
  821. throw new ArgumentNullException(nameof(source8));
  822. if (source9 == null)
  823. throw new ArgumentNullException(nameof(source9));
  824. if (source10 == null)
  825. throw new ArgumentNullException(nameof(source10));
  826. if (source11 == null)
  827. throw new ArgumentNullException(nameof(source11));
  828. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11)>(async observer =>
  829. {
  830. var d = new CompositeAsyncDisposable();
  831. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11) = AsyncObserver.CombineLatest(observer);
  832. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  833. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  834. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  835. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  836. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  837. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  838. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  839. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  840. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  841. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  842. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  843. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11).ConfigureAwait(false);
  844. return d;
  845. });
  846. }
  847. 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)
  848. {
  849. if (source1 == null)
  850. throw new ArgumentNullException(nameof(source1));
  851. if (source2 == null)
  852. throw new ArgumentNullException(nameof(source2));
  853. if (source3 == null)
  854. throw new ArgumentNullException(nameof(source3));
  855. if (source4 == null)
  856. throw new ArgumentNullException(nameof(source4));
  857. if (source5 == null)
  858. throw new ArgumentNullException(nameof(source5));
  859. if (source6 == null)
  860. throw new ArgumentNullException(nameof(source6));
  861. if (source7 == null)
  862. throw new ArgumentNullException(nameof(source7));
  863. if (source8 == null)
  864. throw new ArgumentNullException(nameof(source8));
  865. if (source9 == null)
  866. throw new ArgumentNullException(nameof(source9));
  867. if (source10 == null)
  868. throw new ArgumentNullException(nameof(source10));
  869. if (source11 == null)
  870. throw new ArgumentNullException(nameof(source11));
  871. if (selector == null)
  872. throw new ArgumentNullException(nameof(selector));
  873. return Create<TResult>(async observer =>
  874. {
  875. var d = new CompositeAsyncDisposable();
  876. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11) = AsyncObserver.CombineLatest(observer, selector);
  877. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  878. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  879. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  880. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  881. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  882. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  883. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  884. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  885. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  886. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  887. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  888. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11).ConfigureAwait(false);
  889. return d;
  890. });
  891. }
  892. 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)
  893. {
  894. if (source1 == null)
  895. throw new ArgumentNullException(nameof(source1));
  896. if (source2 == null)
  897. throw new ArgumentNullException(nameof(source2));
  898. if (source3 == null)
  899. throw new ArgumentNullException(nameof(source3));
  900. if (source4 == null)
  901. throw new ArgumentNullException(nameof(source4));
  902. if (source5 == null)
  903. throw new ArgumentNullException(nameof(source5));
  904. if (source6 == null)
  905. throw new ArgumentNullException(nameof(source6));
  906. if (source7 == null)
  907. throw new ArgumentNullException(nameof(source7));
  908. if (source8 == null)
  909. throw new ArgumentNullException(nameof(source8));
  910. if (source9 == null)
  911. throw new ArgumentNullException(nameof(source9));
  912. if (source10 == null)
  913. throw new ArgumentNullException(nameof(source10));
  914. if (source11 == null)
  915. throw new ArgumentNullException(nameof(source11));
  916. if (selector == null)
  917. throw new ArgumentNullException(nameof(selector));
  918. return Create<TResult>(async observer =>
  919. {
  920. var d = new CompositeAsyncDisposable();
  921. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11) = AsyncObserver.CombineLatest(observer, selector);
  922. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  923. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  924. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  925. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  926. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  927. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  928. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  929. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  930. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  931. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  932. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  933. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11).ConfigureAwait(false);
  934. return d;
  935. });
  936. }
  937. 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)
  938. {
  939. if (source1 == null)
  940. throw new ArgumentNullException(nameof(source1));
  941. if (source2 == null)
  942. throw new ArgumentNullException(nameof(source2));
  943. if (source3 == null)
  944. throw new ArgumentNullException(nameof(source3));
  945. if (source4 == null)
  946. throw new ArgumentNullException(nameof(source4));
  947. if (source5 == null)
  948. throw new ArgumentNullException(nameof(source5));
  949. if (source6 == null)
  950. throw new ArgumentNullException(nameof(source6));
  951. if (source7 == null)
  952. throw new ArgumentNullException(nameof(source7));
  953. if (source8 == null)
  954. throw new ArgumentNullException(nameof(source8));
  955. if (source9 == null)
  956. throw new ArgumentNullException(nameof(source9));
  957. if (source10 == null)
  958. throw new ArgumentNullException(nameof(source10));
  959. if (source11 == null)
  960. throw new ArgumentNullException(nameof(source11));
  961. if (source12 == null)
  962. throw new ArgumentNullException(nameof(source12));
  963. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12)>(async observer =>
  964. {
  965. var d = new CompositeAsyncDisposable();
  966. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12) = AsyncObserver.CombineLatest(observer);
  967. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  968. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  969. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  970. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  971. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  972. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  973. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  974. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  975. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  976. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  977. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  978. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  979. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12).ConfigureAwait(false);
  980. return d;
  981. });
  982. }
  983. 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)
  984. {
  985. if (source1 == null)
  986. throw new ArgumentNullException(nameof(source1));
  987. if (source2 == null)
  988. throw new ArgumentNullException(nameof(source2));
  989. if (source3 == null)
  990. throw new ArgumentNullException(nameof(source3));
  991. if (source4 == null)
  992. throw new ArgumentNullException(nameof(source4));
  993. if (source5 == null)
  994. throw new ArgumentNullException(nameof(source5));
  995. if (source6 == null)
  996. throw new ArgumentNullException(nameof(source6));
  997. if (source7 == null)
  998. throw new ArgumentNullException(nameof(source7));
  999. if (source8 == null)
  1000. throw new ArgumentNullException(nameof(source8));
  1001. if (source9 == null)
  1002. throw new ArgumentNullException(nameof(source9));
  1003. if (source10 == null)
  1004. throw new ArgumentNullException(nameof(source10));
  1005. if (source11 == null)
  1006. throw new ArgumentNullException(nameof(source11));
  1007. if (source12 == null)
  1008. throw new ArgumentNullException(nameof(source12));
  1009. if (selector == null)
  1010. throw new ArgumentNullException(nameof(selector));
  1011. return Create<TResult>(async observer =>
  1012. {
  1013. var d = new CompositeAsyncDisposable();
  1014. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12) = AsyncObserver.CombineLatest(observer, selector);
  1015. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1016. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1017. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1018. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1019. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1020. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1021. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1022. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1023. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1024. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1025. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1026. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1027. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12).ConfigureAwait(false);
  1028. return d;
  1029. });
  1030. }
  1031. 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)
  1032. {
  1033. if (source1 == null)
  1034. throw new ArgumentNullException(nameof(source1));
  1035. if (source2 == null)
  1036. throw new ArgumentNullException(nameof(source2));
  1037. if (source3 == null)
  1038. throw new ArgumentNullException(nameof(source3));
  1039. if (source4 == null)
  1040. throw new ArgumentNullException(nameof(source4));
  1041. if (source5 == null)
  1042. throw new ArgumentNullException(nameof(source5));
  1043. if (source6 == null)
  1044. throw new ArgumentNullException(nameof(source6));
  1045. if (source7 == null)
  1046. throw new ArgumentNullException(nameof(source7));
  1047. if (source8 == null)
  1048. throw new ArgumentNullException(nameof(source8));
  1049. if (source9 == null)
  1050. throw new ArgumentNullException(nameof(source9));
  1051. if (source10 == null)
  1052. throw new ArgumentNullException(nameof(source10));
  1053. if (source11 == null)
  1054. throw new ArgumentNullException(nameof(source11));
  1055. if (source12 == null)
  1056. throw new ArgumentNullException(nameof(source12));
  1057. if (selector == null)
  1058. throw new ArgumentNullException(nameof(selector));
  1059. return Create<TResult>(async observer =>
  1060. {
  1061. var d = new CompositeAsyncDisposable();
  1062. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12) = AsyncObserver.CombineLatest(observer, selector);
  1063. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1064. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1065. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1066. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1067. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1068. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1069. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1070. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1071. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1072. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1073. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1074. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1075. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12).ConfigureAwait(false);
  1076. return d;
  1077. });
  1078. }
  1079. 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)
  1080. {
  1081. if (source1 == null)
  1082. throw new ArgumentNullException(nameof(source1));
  1083. if (source2 == null)
  1084. throw new ArgumentNullException(nameof(source2));
  1085. if (source3 == null)
  1086. throw new ArgumentNullException(nameof(source3));
  1087. if (source4 == null)
  1088. throw new ArgumentNullException(nameof(source4));
  1089. if (source5 == null)
  1090. throw new ArgumentNullException(nameof(source5));
  1091. if (source6 == null)
  1092. throw new ArgumentNullException(nameof(source6));
  1093. if (source7 == null)
  1094. throw new ArgumentNullException(nameof(source7));
  1095. if (source8 == null)
  1096. throw new ArgumentNullException(nameof(source8));
  1097. if (source9 == null)
  1098. throw new ArgumentNullException(nameof(source9));
  1099. if (source10 == null)
  1100. throw new ArgumentNullException(nameof(source10));
  1101. if (source11 == null)
  1102. throw new ArgumentNullException(nameof(source11));
  1103. if (source12 == null)
  1104. throw new ArgumentNullException(nameof(source12));
  1105. if (source13 == null)
  1106. throw new ArgumentNullException(nameof(source13));
  1107. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13)>(async observer =>
  1108. {
  1109. var d = new CompositeAsyncDisposable();
  1110. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13) = AsyncObserver.CombineLatest(observer);
  1111. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1112. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1113. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1114. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1115. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1116. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1117. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1118. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1119. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1120. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1121. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1122. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1123. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1124. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13).ConfigureAwait(false);
  1125. return d;
  1126. });
  1127. }
  1128. 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)
  1129. {
  1130. if (source1 == null)
  1131. throw new ArgumentNullException(nameof(source1));
  1132. if (source2 == null)
  1133. throw new ArgumentNullException(nameof(source2));
  1134. if (source3 == null)
  1135. throw new ArgumentNullException(nameof(source3));
  1136. if (source4 == null)
  1137. throw new ArgumentNullException(nameof(source4));
  1138. if (source5 == null)
  1139. throw new ArgumentNullException(nameof(source5));
  1140. if (source6 == null)
  1141. throw new ArgumentNullException(nameof(source6));
  1142. if (source7 == null)
  1143. throw new ArgumentNullException(nameof(source7));
  1144. if (source8 == null)
  1145. throw new ArgumentNullException(nameof(source8));
  1146. if (source9 == null)
  1147. throw new ArgumentNullException(nameof(source9));
  1148. if (source10 == null)
  1149. throw new ArgumentNullException(nameof(source10));
  1150. if (source11 == null)
  1151. throw new ArgumentNullException(nameof(source11));
  1152. if (source12 == null)
  1153. throw new ArgumentNullException(nameof(source12));
  1154. if (source13 == null)
  1155. throw new ArgumentNullException(nameof(source13));
  1156. if (selector == null)
  1157. throw new ArgumentNullException(nameof(selector));
  1158. return Create<TResult>(async observer =>
  1159. {
  1160. var d = new CompositeAsyncDisposable();
  1161. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13) = AsyncObserver.CombineLatest(observer, selector);
  1162. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1163. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1164. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1165. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1166. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1167. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1168. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1169. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1170. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1171. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1172. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1173. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1174. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1175. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13).ConfigureAwait(false);
  1176. return d;
  1177. });
  1178. }
  1179. 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)
  1180. {
  1181. if (source1 == null)
  1182. throw new ArgumentNullException(nameof(source1));
  1183. if (source2 == null)
  1184. throw new ArgumentNullException(nameof(source2));
  1185. if (source3 == null)
  1186. throw new ArgumentNullException(nameof(source3));
  1187. if (source4 == null)
  1188. throw new ArgumentNullException(nameof(source4));
  1189. if (source5 == null)
  1190. throw new ArgumentNullException(nameof(source5));
  1191. if (source6 == null)
  1192. throw new ArgumentNullException(nameof(source6));
  1193. if (source7 == null)
  1194. throw new ArgumentNullException(nameof(source7));
  1195. if (source8 == null)
  1196. throw new ArgumentNullException(nameof(source8));
  1197. if (source9 == null)
  1198. throw new ArgumentNullException(nameof(source9));
  1199. if (source10 == null)
  1200. throw new ArgumentNullException(nameof(source10));
  1201. if (source11 == null)
  1202. throw new ArgumentNullException(nameof(source11));
  1203. if (source12 == null)
  1204. throw new ArgumentNullException(nameof(source12));
  1205. if (source13 == null)
  1206. throw new ArgumentNullException(nameof(source13));
  1207. if (selector == null)
  1208. throw new ArgumentNullException(nameof(selector));
  1209. return Create<TResult>(async observer =>
  1210. {
  1211. var d = new CompositeAsyncDisposable();
  1212. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13) = AsyncObserver.CombineLatest(observer, selector);
  1213. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1214. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1215. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1216. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1217. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1218. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1219. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1220. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1221. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1222. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1223. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1224. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1225. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1226. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13).ConfigureAwait(false);
  1227. return d;
  1228. });
  1229. }
  1230. 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)
  1231. {
  1232. if (source1 == null)
  1233. throw new ArgumentNullException(nameof(source1));
  1234. if (source2 == null)
  1235. throw new ArgumentNullException(nameof(source2));
  1236. if (source3 == null)
  1237. throw new ArgumentNullException(nameof(source3));
  1238. if (source4 == null)
  1239. throw new ArgumentNullException(nameof(source4));
  1240. if (source5 == null)
  1241. throw new ArgumentNullException(nameof(source5));
  1242. if (source6 == null)
  1243. throw new ArgumentNullException(nameof(source6));
  1244. if (source7 == null)
  1245. throw new ArgumentNullException(nameof(source7));
  1246. if (source8 == null)
  1247. throw new ArgumentNullException(nameof(source8));
  1248. if (source9 == null)
  1249. throw new ArgumentNullException(nameof(source9));
  1250. if (source10 == null)
  1251. throw new ArgumentNullException(nameof(source10));
  1252. if (source11 == null)
  1253. throw new ArgumentNullException(nameof(source11));
  1254. if (source12 == null)
  1255. throw new ArgumentNullException(nameof(source12));
  1256. if (source13 == null)
  1257. throw new ArgumentNullException(nameof(source13));
  1258. if (source14 == null)
  1259. throw new ArgumentNullException(nameof(source14));
  1260. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14)>(async observer =>
  1261. {
  1262. var d = new CompositeAsyncDisposable();
  1263. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14) = AsyncObserver.CombineLatest(observer);
  1264. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1265. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1266. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1267. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1268. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1269. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1270. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1271. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1272. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1273. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1274. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1275. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1276. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1277. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1278. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14).ConfigureAwait(false);
  1279. return d;
  1280. });
  1281. }
  1282. 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)
  1283. {
  1284. if (source1 == null)
  1285. throw new ArgumentNullException(nameof(source1));
  1286. if (source2 == null)
  1287. throw new ArgumentNullException(nameof(source2));
  1288. if (source3 == null)
  1289. throw new ArgumentNullException(nameof(source3));
  1290. if (source4 == null)
  1291. throw new ArgumentNullException(nameof(source4));
  1292. if (source5 == null)
  1293. throw new ArgumentNullException(nameof(source5));
  1294. if (source6 == null)
  1295. throw new ArgumentNullException(nameof(source6));
  1296. if (source7 == null)
  1297. throw new ArgumentNullException(nameof(source7));
  1298. if (source8 == null)
  1299. throw new ArgumentNullException(nameof(source8));
  1300. if (source9 == null)
  1301. throw new ArgumentNullException(nameof(source9));
  1302. if (source10 == null)
  1303. throw new ArgumentNullException(nameof(source10));
  1304. if (source11 == null)
  1305. throw new ArgumentNullException(nameof(source11));
  1306. if (source12 == null)
  1307. throw new ArgumentNullException(nameof(source12));
  1308. if (source13 == null)
  1309. throw new ArgumentNullException(nameof(source13));
  1310. if (source14 == null)
  1311. throw new ArgumentNullException(nameof(source14));
  1312. if (selector == null)
  1313. throw new ArgumentNullException(nameof(selector));
  1314. return Create<TResult>(async observer =>
  1315. {
  1316. var d = new CompositeAsyncDisposable();
  1317. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14) = AsyncObserver.CombineLatest(observer, selector);
  1318. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1319. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1320. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1321. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1322. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1323. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1324. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1325. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1326. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1327. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1328. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1329. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1330. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1331. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1332. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14).ConfigureAwait(false);
  1333. return d;
  1334. });
  1335. }
  1336. 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)
  1337. {
  1338. if (source1 == null)
  1339. throw new ArgumentNullException(nameof(source1));
  1340. if (source2 == null)
  1341. throw new ArgumentNullException(nameof(source2));
  1342. if (source3 == null)
  1343. throw new ArgumentNullException(nameof(source3));
  1344. if (source4 == null)
  1345. throw new ArgumentNullException(nameof(source4));
  1346. if (source5 == null)
  1347. throw new ArgumentNullException(nameof(source5));
  1348. if (source6 == null)
  1349. throw new ArgumentNullException(nameof(source6));
  1350. if (source7 == null)
  1351. throw new ArgumentNullException(nameof(source7));
  1352. if (source8 == null)
  1353. throw new ArgumentNullException(nameof(source8));
  1354. if (source9 == null)
  1355. throw new ArgumentNullException(nameof(source9));
  1356. if (source10 == null)
  1357. throw new ArgumentNullException(nameof(source10));
  1358. if (source11 == null)
  1359. throw new ArgumentNullException(nameof(source11));
  1360. if (source12 == null)
  1361. throw new ArgumentNullException(nameof(source12));
  1362. if (source13 == null)
  1363. throw new ArgumentNullException(nameof(source13));
  1364. if (source14 == null)
  1365. throw new ArgumentNullException(nameof(source14));
  1366. if (selector == null)
  1367. throw new ArgumentNullException(nameof(selector));
  1368. return Create<TResult>(async observer =>
  1369. {
  1370. var d = new CompositeAsyncDisposable();
  1371. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14) = AsyncObserver.CombineLatest(observer, selector);
  1372. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1373. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1374. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1375. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1376. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1377. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1378. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1379. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1380. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1381. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1382. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1383. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1384. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1385. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1386. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14).ConfigureAwait(false);
  1387. return d;
  1388. });
  1389. }
  1390. 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)
  1391. {
  1392. if (source1 == null)
  1393. throw new ArgumentNullException(nameof(source1));
  1394. if (source2 == null)
  1395. throw new ArgumentNullException(nameof(source2));
  1396. if (source3 == null)
  1397. throw new ArgumentNullException(nameof(source3));
  1398. if (source4 == null)
  1399. throw new ArgumentNullException(nameof(source4));
  1400. if (source5 == null)
  1401. throw new ArgumentNullException(nameof(source5));
  1402. if (source6 == null)
  1403. throw new ArgumentNullException(nameof(source6));
  1404. if (source7 == null)
  1405. throw new ArgumentNullException(nameof(source7));
  1406. if (source8 == null)
  1407. throw new ArgumentNullException(nameof(source8));
  1408. if (source9 == null)
  1409. throw new ArgumentNullException(nameof(source9));
  1410. if (source10 == null)
  1411. throw new ArgumentNullException(nameof(source10));
  1412. if (source11 == null)
  1413. throw new ArgumentNullException(nameof(source11));
  1414. if (source12 == null)
  1415. throw new ArgumentNullException(nameof(source12));
  1416. if (source13 == null)
  1417. throw new ArgumentNullException(nameof(source13));
  1418. if (source14 == null)
  1419. throw new ArgumentNullException(nameof(source14));
  1420. if (source15 == null)
  1421. throw new ArgumentNullException(nameof(source15));
  1422. return Create<(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15)>(async observer =>
  1423. {
  1424. var d = new CompositeAsyncDisposable();
  1425. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14, observer15) = AsyncObserver.CombineLatest(observer);
  1426. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1427. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1428. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1429. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1430. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1431. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1432. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1433. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1434. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1435. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1436. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1437. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1438. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1439. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1440. var sub15 = source15.SubscribeSafeAsync(observer15).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1441. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14, sub15).ConfigureAwait(false);
  1442. return d;
  1443. });
  1444. }
  1445. 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)
  1446. {
  1447. if (source1 == null)
  1448. throw new ArgumentNullException(nameof(source1));
  1449. if (source2 == null)
  1450. throw new ArgumentNullException(nameof(source2));
  1451. if (source3 == null)
  1452. throw new ArgumentNullException(nameof(source3));
  1453. if (source4 == null)
  1454. throw new ArgumentNullException(nameof(source4));
  1455. if (source5 == null)
  1456. throw new ArgumentNullException(nameof(source5));
  1457. if (source6 == null)
  1458. throw new ArgumentNullException(nameof(source6));
  1459. if (source7 == null)
  1460. throw new ArgumentNullException(nameof(source7));
  1461. if (source8 == null)
  1462. throw new ArgumentNullException(nameof(source8));
  1463. if (source9 == null)
  1464. throw new ArgumentNullException(nameof(source9));
  1465. if (source10 == null)
  1466. throw new ArgumentNullException(nameof(source10));
  1467. if (source11 == null)
  1468. throw new ArgumentNullException(nameof(source11));
  1469. if (source12 == null)
  1470. throw new ArgumentNullException(nameof(source12));
  1471. if (source13 == null)
  1472. throw new ArgumentNullException(nameof(source13));
  1473. if (source14 == null)
  1474. throw new ArgumentNullException(nameof(source14));
  1475. if (source15 == null)
  1476. throw new ArgumentNullException(nameof(source15));
  1477. if (selector == null)
  1478. throw new ArgumentNullException(nameof(selector));
  1479. return Create<TResult>(async observer =>
  1480. {
  1481. var d = new CompositeAsyncDisposable();
  1482. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14, observer15) = AsyncObserver.CombineLatest(observer, selector);
  1483. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1484. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1485. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1486. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1487. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1488. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1489. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1490. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1491. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1492. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1493. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1494. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1495. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1496. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1497. var sub15 = source15.SubscribeSafeAsync(observer15).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1498. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14, sub15).ConfigureAwait(false);
  1499. return d;
  1500. });
  1501. }
  1502. 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)
  1503. {
  1504. if (source1 == null)
  1505. throw new ArgumentNullException(nameof(source1));
  1506. if (source2 == null)
  1507. throw new ArgumentNullException(nameof(source2));
  1508. if (source3 == null)
  1509. throw new ArgumentNullException(nameof(source3));
  1510. if (source4 == null)
  1511. throw new ArgumentNullException(nameof(source4));
  1512. if (source5 == null)
  1513. throw new ArgumentNullException(nameof(source5));
  1514. if (source6 == null)
  1515. throw new ArgumentNullException(nameof(source6));
  1516. if (source7 == null)
  1517. throw new ArgumentNullException(nameof(source7));
  1518. if (source8 == null)
  1519. throw new ArgumentNullException(nameof(source8));
  1520. if (source9 == null)
  1521. throw new ArgumentNullException(nameof(source9));
  1522. if (source10 == null)
  1523. throw new ArgumentNullException(nameof(source10));
  1524. if (source11 == null)
  1525. throw new ArgumentNullException(nameof(source11));
  1526. if (source12 == null)
  1527. throw new ArgumentNullException(nameof(source12));
  1528. if (source13 == null)
  1529. throw new ArgumentNullException(nameof(source13));
  1530. if (source14 == null)
  1531. throw new ArgumentNullException(nameof(source14));
  1532. if (source15 == null)
  1533. throw new ArgumentNullException(nameof(source15));
  1534. if (selector == null)
  1535. throw new ArgumentNullException(nameof(selector));
  1536. return Create<TResult>(async observer =>
  1537. {
  1538. var d = new CompositeAsyncDisposable();
  1539. var (observer1, observer2, observer3, observer4, observer5, observer6, observer7, observer8, observer9, observer10, observer11, observer12, observer13, observer14, observer15) = AsyncObserver.CombineLatest(observer, selector);
  1540. var sub1 = source1.SubscribeSafeAsync(observer1).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1541. var sub2 = source2.SubscribeSafeAsync(observer2).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1542. var sub3 = source3.SubscribeSafeAsync(observer3).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1543. var sub4 = source4.SubscribeSafeAsync(observer4).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1544. var sub5 = source5.SubscribeSafeAsync(observer5).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1545. var sub6 = source6.SubscribeSafeAsync(observer6).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1546. var sub7 = source7.SubscribeSafeAsync(observer7).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1547. var sub8 = source8.SubscribeSafeAsync(observer8).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1548. var sub9 = source9.SubscribeSafeAsync(observer9).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1549. var sub10 = source10.SubscribeSafeAsync(observer10).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1550. var sub11 = source11.SubscribeSafeAsync(observer11).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1551. var sub12 = source12.SubscribeSafeAsync(observer12).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1552. var sub13 = source13.SubscribeSafeAsync(observer13).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1553. var sub14 = source14.SubscribeSafeAsync(observer14).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1554. var sub15 = source15.SubscribeSafeAsync(observer15).AsTask().ContinueWith(disposable => d.AddAsync(disposable.Result).AsTask()).Unwrap();
  1555. await Task.WhenAll(sub1, sub2, sub3, sub4, sub5, sub6, sub7, sub8, sub9, sub10, sub11, sub12, sub13, sub14, sub15).ConfigureAwait(false);
  1556. return d;
  1557. });
  1558. }
  1559. }
  1560. public partial class AsyncObserver
  1561. {
  1562. public static (IAsyncObserver<T1>, IAsyncObserver<T2>) CombineLatest<T1, T2>(IAsyncObserver<(T1, T2)> observer)
  1563. {
  1564. if (observer == null)
  1565. throw new ArgumentNullException(nameof(observer));
  1566. bool allHasValue = false;
  1567. bool hasValue1 = false;
  1568. bool isDone1 = false;
  1569. T1 latestValue1 = default(T1);
  1570. bool hasValue2 = false;
  1571. bool isDone2 = false;
  1572. T2 latestValue2 = default(T2);
  1573. var gate = AsyncGate.Create();
  1574. return
  1575. (
  1576. Create<T1>(
  1577. async x =>
  1578. {
  1579. using (await gate.LockAsync().ConfigureAwait(false))
  1580. {
  1581. if (!hasValue1)
  1582. {
  1583. hasValue1 = true;
  1584. allHasValue = hasValue1 && hasValue2;
  1585. }
  1586. latestValue1 = x;
  1587. if (allHasValue)
  1588. {
  1589. await observer.OnNextAsync((latestValue1, latestValue2)).ConfigureAwait(false);
  1590. }
  1591. else if (isDone2)
  1592. {
  1593. await observer.OnCompletedAsync().ConfigureAwait(false);
  1594. }
  1595. }
  1596. },
  1597. async ex =>
  1598. {
  1599. using (await gate.LockAsync().ConfigureAwait(false))
  1600. {
  1601. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1602. }
  1603. },
  1604. async () =>
  1605. {
  1606. using (await gate.LockAsync().ConfigureAwait(false))
  1607. {
  1608. isDone1 = true;
  1609. if (isDone1 && isDone2)
  1610. {
  1611. await observer.OnCompletedAsync().ConfigureAwait(false);
  1612. }
  1613. }
  1614. }
  1615. ),
  1616. Create<T2>(
  1617. async x =>
  1618. {
  1619. using (await gate.LockAsync().ConfigureAwait(false))
  1620. {
  1621. if (!hasValue2)
  1622. {
  1623. hasValue2 = true;
  1624. allHasValue = hasValue1 && hasValue2;
  1625. }
  1626. latestValue2 = x;
  1627. if (allHasValue)
  1628. {
  1629. await observer.OnNextAsync((latestValue1, latestValue2)).ConfigureAwait(false);
  1630. }
  1631. else if (isDone1)
  1632. {
  1633. await observer.OnCompletedAsync().ConfigureAwait(false);
  1634. }
  1635. }
  1636. },
  1637. async ex =>
  1638. {
  1639. using (await gate.LockAsync().ConfigureAwait(false))
  1640. {
  1641. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1642. }
  1643. },
  1644. async () =>
  1645. {
  1646. using (await gate.LockAsync().ConfigureAwait(false))
  1647. {
  1648. isDone2 = true;
  1649. if (isDone1 && isDone2)
  1650. {
  1651. await observer.OnCompletedAsync().ConfigureAwait(false);
  1652. }
  1653. }
  1654. }
  1655. )
  1656. );
  1657. }
  1658. public static (IAsyncObserver<T1>, IAsyncObserver<T2>) CombineLatest<T1, T2, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, TResult> selector)
  1659. {
  1660. if (observer == null)
  1661. throw new ArgumentNullException(nameof(observer));
  1662. if (selector == null)
  1663. throw new ArgumentNullException(nameof(selector));
  1664. return CombineLatest<T1, T2, TResult>(observer, (x1, x2) => new ValueTask<TResult>(selector(x1, x2)));
  1665. }
  1666. public static (IAsyncObserver<T1>, IAsyncObserver<T2>) CombineLatest<T1, T2, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, ValueTask<TResult>> selector)
  1667. {
  1668. if (observer == null)
  1669. throw new ArgumentNullException(nameof(observer));
  1670. if (selector == null)
  1671. throw new ArgumentNullException(nameof(selector));
  1672. bool allHasValue = false;
  1673. bool hasValue1 = false;
  1674. bool isDone1 = false;
  1675. T1 latestValue1 = default(T1);
  1676. bool hasValue2 = false;
  1677. bool isDone2 = false;
  1678. T2 latestValue2 = default(T2);
  1679. var gate = AsyncGate.Create();
  1680. return
  1681. (
  1682. Create<T1>(
  1683. async x =>
  1684. {
  1685. using (await gate.LockAsync().ConfigureAwait(false))
  1686. {
  1687. if (!hasValue1)
  1688. {
  1689. hasValue1 = true;
  1690. allHasValue = hasValue1 && hasValue2;
  1691. }
  1692. latestValue1 = x;
  1693. if (allHasValue)
  1694. {
  1695. TResult res;
  1696. try
  1697. {
  1698. res = await selector(latestValue1, latestValue2).ConfigureAwait(false);
  1699. }
  1700. catch (Exception ex)
  1701. {
  1702. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1703. return;
  1704. }
  1705. await observer.OnNextAsync(res).ConfigureAwait(false);
  1706. }
  1707. else if (isDone2)
  1708. {
  1709. await observer.OnCompletedAsync().ConfigureAwait(false);
  1710. }
  1711. }
  1712. },
  1713. async ex =>
  1714. {
  1715. using (await gate.LockAsync().ConfigureAwait(false))
  1716. {
  1717. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1718. }
  1719. },
  1720. async () =>
  1721. {
  1722. using (await gate.LockAsync().ConfigureAwait(false))
  1723. {
  1724. isDone1 = true;
  1725. if (isDone1 && isDone2)
  1726. {
  1727. await observer.OnCompletedAsync().ConfigureAwait(false);
  1728. }
  1729. }
  1730. }
  1731. ),
  1732. Create<T2>(
  1733. async x =>
  1734. {
  1735. using (await gate.LockAsync().ConfigureAwait(false))
  1736. {
  1737. if (!hasValue2)
  1738. {
  1739. hasValue2 = true;
  1740. allHasValue = hasValue1 && hasValue2;
  1741. }
  1742. latestValue2 = x;
  1743. if (allHasValue)
  1744. {
  1745. TResult res;
  1746. try
  1747. {
  1748. res = await selector(latestValue1, latestValue2).ConfigureAwait(false);
  1749. }
  1750. catch (Exception ex)
  1751. {
  1752. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1753. return;
  1754. }
  1755. await observer.OnNextAsync(res).ConfigureAwait(false);
  1756. }
  1757. else if (isDone1)
  1758. {
  1759. await observer.OnCompletedAsync().ConfigureAwait(false);
  1760. }
  1761. }
  1762. },
  1763. async ex =>
  1764. {
  1765. using (await gate.LockAsync().ConfigureAwait(false))
  1766. {
  1767. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1768. }
  1769. },
  1770. async () =>
  1771. {
  1772. using (await gate.LockAsync().ConfigureAwait(false))
  1773. {
  1774. isDone2 = true;
  1775. if (isDone1 && isDone2)
  1776. {
  1777. await observer.OnCompletedAsync().ConfigureAwait(false);
  1778. }
  1779. }
  1780. }
  1781. )
  1782. );
  1783. }
  1784. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>) CombineLatest<T1, T2, T3>(IAsyncObserver<(T1, T2, T3)> observer)
  1785. {
  1786. if (observer == null)
  1787. throw new ArgumentNullException(nameof(observer));
  1788. bool allHasValue = false;
  1789. bool hasValue1 = false;
  1790. bool isDone1 = false;
  1791. T1 latestValue1 = default(T1);
  1792. bool hasValue2 = false;
  1793. bool isDone2 = false;
  1794. T2 latestValue2 = default(T2);
  1795. bool hasValue3 = false;
  1796. bool isDone3 = false;
  1797. T3 latestValue3 = default(T3);
  1798. var gate = AsyncGate.Create();
  1799. return
  1800. (
  1801. Create<T1>(
  1802. async x =>
  1803. {
  1804. using (await gate.LockAsync().ConfigureAwait(false))
  1805. {
  1806. if (!hasValue1)
  1807. {
  1808. hasValue1 = true;
  1809. allHasValue = hasValue1 && hasValue2 && hasValue3;
  1810. }
  1811. latestValue1 = x;
  1812. if (allHasValue)
  1813. {
  1814. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3)).ConfigureAwait(false);
  1815. }
  1816. else if (isDone2 && isDone3)
  1817. {
  1818. await observer.OnCompletedAsync().ConfigureAwait(false);
  1819. }
  1820. }
  1821. },
  1822. async ex =>
  1823. {
  1824. using (await gate.LockAsync().ConfigureAwait(false))
  1825. {
  1826. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1827. }
  1828. },
  1829. async () =>
  1830. {
  1831. using (await gate.LockAsync().ConfigureAwait(false))
  1832. {
  1833. isDone1 = true;
  1834. if (isDone1 && isDone2 && isDone3)
  1835. {
  1836. await observer.OnCompletedAsync().ConfigureAwait(false);
  1837. }
  1838. }
  1839. }
  1840. ),
  1841. Create<T2>(
  1842. async x =>
  1843. {
  1844. using (await gate.LockAsync().ConfigureAwait(false))
  1845. {
  1846. if (!hasValue2)
  1847. {
  1848. hasValue2 = true;
  1849. allHasValue = hasValue1 && hasValue2 && hasValue3;
  1850. }
  1851. latestValue2 = x;
  1852. if (allHasValue)
  1853. {
  1854. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3)).ConfigureAwait(false);
  1855. }
  1856. else if (isDone1 && isDone3)
  1857. {
  1858. await observer.OnCompletedAsync().ConfigureAwait(false);
  1859. }
  1860. }
  1861. },
  1862. async ex =>
  1863. {
  1864. using (await gate.LockAsync().ConfigureAwait(false))
  1865. {
  1866. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1867. }
  1868. },
  1869. async () =>
  1870. {
  1871. using (await gate.LockAsync().ConfigureAwait(false))
  1872. {
  1873. isDone2 = true;
  1874. if (isDone1 && isDone2 && isDone3)
  1875. {
  1876. await observer.OnCompletedAsync().ConfigureAwait(false);
  1877. }
  1878. }
  1879. }
  1880. ),
  1881. Create<T3>(
  1882. async x =>
  1883. {
  1884. using (await gate.LockAsync().ConfigureAwait(false))
  1885. {
  1886. if (!hasValue3)
  1887. {
  1888. hasValue3 = true;
  1889. allHasValue = hasValue1 && hasValue2 && hasValue3;
  1890. }
  1891. latestValue3 = x;
  1892. if (allHasValue)
  1893. {
  1894. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3)).ConfigureAwait(false);
  1895. }
  1896. else if (isDone1 && isDone2)
  1897. {
  1898. await observer.OnCompletedAsync().ConfigureAwait(false);
  1899. }
  1900. }
  1901. },
  1902. async ex =>
  1903. {
  1904. using (await gate.LockAsync().ConfigureAwait(false))
  1905. {
  1906. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1907. }
  1908. },
  1909. async () =>
  1910. {
  1911. using (await gate.LockAsync().ConfigureAwait(false))
  1912. {
  1913. isDone3 = true;
  1914. if (isDone1 && isDone2 && isDone3)
  1915. {
  1916. await observer.OnCompletedAsync().ConfigureAwait(false);
  1917. }
  1918. }
  1919. }
  1920. )
  1921. );
  1922. }
  1923. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>) CombineLatest<T1, T2, T3, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, TResult> selector)
  1924. {
  1925. if (observer == null)
  1926. throw new ArgumentNullException(nameof(observer));
  1927. if (selector == null)
  1928. throw new ArgumentNullException(nameof(selector));
  1929. return CombineLatest<T1, T2, T3, TResult>(observer, (x1, x2, x3) => new ValueTask<TResult>(selector(x1, x2, x3)));
  1930. }
  1931. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>) CombineLatest<T1, T2, T3, TResult>(IAsyncObserver<TResult> observer, Func<T1, T2, T3, ValueTask<TResult>> selector)
  1932. {
  1933. if (observer == null)
  1934. throw new ArgumentNullException(nameof(observer));
  1935. if (selector == null)
  1936. throw new ArgumentNullException(nameof(selector));
  1937. bool allHasValue = false;
  1938. bool hasValue1 = false;
  1939. bool isDone1 = false;
  1940. T1 latestValue1 = default(T1);
  1941. bool hasValue2 = false;
  1942. bool isDone2 = false;
  1943. T2 latestValue2 = default(T2);
  1944. bool hasValue3 = false;
  1945. bool isDone3 = false;
  1946. T3 latestValue3 = default(T3);
  1947. var gate = AsyncGate.Create();
  1948. return
  1949. (
  1950. Create<T1>(
  1951. async x =>
  1952. {
  1953. using (await gate.LockAsync().ConfigureAwait(false))
  1954. {
  1955. if (!hasValue1)
  1956. {
  1957. hasValue1 = true;
  1958. allHasValue = hasValue1 && hasValue2 && hasValue3;
  1959. }
  1960. latestValue1 = x;
  1961. if (allHasValue)
  1962. {
  1963. TResult res;
  1964. try
  1965. {
  1966. res = await selector(latestValue1, latestValue2, latestValue3).ConfigureAwait(false);
  1967. }
  1968. catch (Exception ex)
  1969. {
  1970. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1971. return;
  1972. }
  1973. await observer.OnNextAsync(res).ConfigureAwait(false);
  1974. }
  1975. else if (isDone2 && isDone3)
  1976. {
  1977. await observer.OnCompletedAsync().ConfigureAwait(false);
  1978. }
  1979. }
  1980. },
  1981. async ex =>
  1982. {
  1983. using (await gate.LockAsync().ConfigureAwait(false))
  1984. {
  1985. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  1986. }
  1987. },
  1988. async () =>
  1989. {
  1990. using (await gate.LockAsync().ConfigureAwait(false))
  1991. {
  1992. isDone1 = true;
  1993. if (isDone1 && isDone2 && isDone3)
  1994. {
  1995. await observer.OnCompletedAsync().ConfigureAwait(false);
  1996. }
  1997. }
  1998. }
  1999. ),
  2000. Create<T2>(
  2001. async x =>
  2002. {
  2003. using (await gate.LockAsync().ConfigureAwait(false))
  2004. {
  2005. if (!hasValue2)
  2006. {
  2007. hasValue2 = true;
  2008. allHasValue = hasValue1 && hasValue2 && hasValue3;
  2009. }
  2010. latestValue2 = x;
  2011. if (allHasValue)
  2012. {
  2013. TResult res;
  2014. try
  2015. {
  2016. res = await selector(latestValue1, latestValue2, latestValue3).ConfigureAwait(false);
  2017. }
  2018. catch (Exception ex)
  2019. {
  2020. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2021. return;
  2022. }
  2023. await observer.OnNextAsync(res).ConfigureAwait(false);
  2024. }
  2025. else if (isDone1 && isDone3)
  2026. {
  2027. await observer.OnCompletedAsync().ConfigureAwait(false);
  2028. }
  2029. }
  2030. },
  2031. async ex =>
  2032. {
  2033. using (await gate.LockAsync().ConfigureAwait(false))
  2034. {
  2035. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2036. }
  2037. },
  2038. async () =>
  2039. {
  2040. using (await gate.LockAsync().ConfigureAwait(false))
  2041. {
  2042. isDone2 = true;
  2043. if (isDone1 && isDone2 && isDone3)
  2044. {
  2045. await observer.OnCompletedAsync().ConfigureAwait(false);
  2046. }
  2047. }
  2048. }
  2049. ),
  2050. Create<T3>(
  2051. async x =>
  2052. {
  2053. using (await gate.LockAsync().ConfigureAwait(false))
  2054. {
  2055. if (!hasValue3)
  2056. {
  2057. hasValue3 = true;
  2058. allHasValue = hasValue1 && hasValue2 && hasValue3;
  2059. }
  2060. latestValue3 = x;
  2061. if (allHasValue)
  2062. {
  2063. TResult res;
  2064. try
  2065. {
  2066. res = await selector(latestValue1, latestValue2, latestValue3).ConfigureAwait(false);
  2067. }
  2068. catch (Exception ex)
  2069. {
  2070. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2071. return;
  2072. }
  2073. await observer.OnNextAsync(res).ConfigureAwait(false);
  2074. }
  2075. else if (isDone1 && isDone2)
  2076. {
  2077. await observer.OnCompletedAsync().ConfigureAwait(false);
  2078. }
  2079. }
  2080. },
  2081. async ex =>
  2082. {
  2083. using (await gate.LockAsync().ConfigureAwait(false))
  2084. {
  2085. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2086. }
  2087. },
  2088. async () =>
  2089. {
  2090. using (await gate.LockAsync().ConfigureAwait(false))
  2091. {
  2092. isDone3 = true;
  2093. if (isDone1 && isDone2 && isDone3)
  2094. {
  2095. await observer.OnCompletedAsync().ConfigureAwait(false);
  2096. }
  2097. }
  2098. }
  2099. )
  2100. );
  2101. }
  2102. public static (IAsyncObserver<T1>, IAsyncObserver<T2>, IAsyncObserver<T3>, IAsyncObserver<T4>) CombineLatest<T1, T2, T3, T4>(IAsyncObserver<(T1, T2, T3, T4)> observer)
  2103. {
  2104. if (observer == null)
  2105. throw new ArgumentNullException(nameof(observer));
  2106. bool allHasValue = false;
  2107. bool hasValue1 = false;
  2108. bool isDone1 = false;
  2109. T1 latestValue1 = default(T1);
  2110. bool hasValue2 = false;
  2111. bool isDone2 = false;
  2112. T2 latestValue2 = default(T2);
  2113. bool hasValue3 = false;
  2114. bool isDone3 = false;
  2115. T3 latestValue3 = default(T3);
  2116. bool hasValue4 = false;
  2117. bool isDone4 = false;
  2118. T4 latestValue4 = default(T4);
  2119. var gate = AsyncGate.Create();
  2120. return
  2121. (
  2122. Create<T1>(
  2123. async x =>
  2124. {
  2125. using (await gate.LockAsync().ConfigureAwait(false))
  2126. {
  2127. if (!hasValue1)
  2128. {
  2129. hasValue1 = true;
  2130. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2131. }
  2132. latestValue1 = x;
  2133. if (allHasValue)
  2134. {
  2135. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4)).ConfigureAwait(false);
  2136. }
  2137. else if (isDone2 && isDone3 && isDone4)
  2138. {
  2139. await observer.OnCompletedAsync().ConfigureAwait(false);
  2140. }
  2141. }
  2142. },
  2143. async ex =>
  2144. {
  2145. using (await gate.LockAsync().ConfigureAwait(false))
  2146. {
  2147. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2148. }
  2149. },
  2150. async () =>
  2151. {
  2152. using (await gate.LockAsync().ConfigureAwait(false))
  2153. {
  2154. isDone1 = true;
  2155. if (isDone1 && isDone2 && isDone3 && isDone4)
  2156. {
  2157. await observer.OnCompletedAsync().ConfigureAwait(false);
  2158. }
  2159. }
  2160. }
  2161. ),
  2162. Create<T2>(
  2163. async x =>
  2164. {
  2165. using (await gate.LockAsync().ConfigureAwait(false))
  2166. {
  2167. if (!hasValue2)
  2168. {
  2169. hasValue2 = true;
  2170. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2171. }
  2172. latestValue2 = x;
  2173. if (allHasValue)
  2174. {
  2175. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4)).ConfigureAwait(false);
  2176. }
  2177. else if (isDone1 && isDone3 && isDone4)
  2178. {
  2179. await observer.OnCompletedAsync().ConfigureAwait(false);
  2180. }
  2181. }
  2182. },
  2183. async ex =>
  2184. {
  2185. using (await gate.LockAsync().ConfigureAwait(false))
  2186. {
  2187. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2188. }
  2189. },
  2190. async () =>
  2191. {
  2192. using (await gate.LockAsync().ConfigureAwait(false))
  2193. {
  2194. isDone2 = true;
  2195. if (isDone1 && isDone2 && isDone3 && isDone4)
  2196. {
  2197. await observer.OnCompletedAsync().ConfigureAwait(false);
  2198. }
  2199. }
  2200. }
  2201. ),
  2202. Create<T3>(
  2203. async x =>
  2204. {
  2205. using (await gate.LockAsync().ConfigureAwait(false))
  2206. {
  2207. if (!hasValue3)
  2208. {
  2209. hasValue3 = true;
  2210. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2211. }
  2212. latestValue3 = x;
  2213. if (allHasValue)
  2214. {
  2215. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4)).ConfigureAwait(false);
  2216. }
  2217. else if (isDone1 && isDone2 && isDone4)
  2218. {
  2219. await observer.OnCompletedAsync().ConfigureAwait(false);
  2220. }
  2221. }
  2222. },
  2223. async ex =>
  2224. {
  2225. using (await gate.LockAsync().ConfigureAwait(false))
  2226. {
  2227. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2228. }
  2229. },
  2230. async () =>
  2231. {
  2232. using (await gate.LockAsync().ConfigureAwait(false))
  2233. {
  2234. isDone3 = true;
  2235. if (isDone1 && isDone2 && isDone3 && isDone4)
  2236. {
  2237. await observer.OnCompletedAsync().ConfigureAwait(false);
  2238. }
  2239. }
  2240. }
  2241. ),
  2242. Create<T4>(
  2243. async x =>
  2244. {
  2245. using (await gate.LockAsync().ConfigureAwait(false))
  2246. {
  2247. if (!hasValue4)
  2248. {
  2249. hasValue4 = true;
  2250. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2251. }
  2252. latestValue4 = x;
  2253. if (allHasValue)
  2254. {
  2255. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4)).ConfigureAwait(false);
  2256. }
  2257. else if (isDone1 && isDone2 && isDone3)
  2258. {
  2259. await observer.OnCompletedAsync().ConfigureAwait(false);
  2260. }
  2261. }
  2262. },
  2263. async ex =>
  2264. {
  2265. using (await gate.LockAsync().ConfigureAwait(false))
  2266. {
  2267. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2268. }
  2269. },
  2270. async () =>
  2271. {
  2272. using (await gate.LockAsync().ConfigureAwait(false))
  2273. {
  2274. isDone4 = true;
  2275. if (isDone1 && isDone2 && isDone3 && isDone4)
  2276. {
  2277. await observer.OnCompletedAsync().ConfigureAwait(false);
  2278. }
  2279. }
  2280. }
  2281. )
  2282. );
  2283. }
  2284. 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)
  2285. {
  2286. if (observer == null)
  2287. throw new ArgumentNullException(nameof(observer));
  2288. if (selector == null)
  2289. throw new ArgumentNullException(nameof(selector));
  2290. return CombineLatest<T1, T2, T3, T4, TResult>(observer, (x1, x2, x3, x4) => new ValueTask<TResult>(selector(x1, x2, x3, x4)));
  2291. }
  2292. 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)
  2293. {
  2294. if (observer == null)
  2295. throw new ArgumentNullException(nameof(observer));
  2296. if (selector == null)
  2297. throw new ArgumentNullException(nameof(selector));
  2298. bool allHasValue = false;
  2299. bool hasValue1 = false;
  2300. bool isDone1 = false;
  2301. T1 latestValue1 = default(T1);
  2302. bool hasValue2 = false;
  2303. bool isDone2 = false;
  2304. T2 latestValue2 = default(T2);
  2305. bool hasValue3 = false;
  2306. bool isDone3 = false;
  2307. T3 latestValue3 = default(T3);
  2308. bool hasValue4 = false;
  2309. bool isDone4 = false;
  2310. T4 latestValue4 = default(T4);
  2311. var gate = AsyncGate.Create();
  2312. return
  2313. (
  2314. Create<T1>(
  2315. async x =>
  2316. {
  2317. using (await gate.LockAsync().ConfigureAwait(false))
  2318. {
  2319. if (!hasValue1)
  2320. {
  2321. hasValue1 = true;
  2322. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2323. }
  2324. latestValue1 = x;
  2325. if (allHasValue)
  2326. {
  2327. TResult res;
  2328. try
  2329. {
  2330. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4).ConfigureAwait(false);
  2331. }
  2332. catch (Exception ex)
  2333. {
  2334. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2335. return;
  2336. }
  2337. await observer.OnNextAsync(res).ConfigureAwait(false);
  2338. }
  2339. else if (isDone2 && isDone3 && isDone4)
  2340. {
  2341. await observer.OnCompletedAsync().ConfigureAwait(false);
  2342. }
  2343. }
  2344. },
  2345. async ex =>
  2346. {
  2347. using (await gate.LockAsync().ConfigureAwait(false))
  2348. {
  2349. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2350. }
  2351. },
  2352. async () =>
  2353. {
  2354. using (await gate.LockAsync().ConfigureAwait(false))
  2355. {
  2356. isDone1 = true;
  2357. if (isDone1 && isDone2 && isDone3 && isDone4)
  2358. {
  2359. await observer.OnCompletedAsync().ConfigureAwait(false);
  2360. }
  2361. }
  2362. }
  2363. ),
  2364. Create<T2>(
  2365. async x =>
  2366. {
  2367. using (await gate.LockAsync().ConfigureAwait(false))
  2368. {
  2369. if (!hasValue2)
  2370. {
  2371. hasValue2 = true;
  2372. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2373. }
  2374. latestValue2 = x;
  2375. if (allHasValue)
  2376. {
  2377. TResult res;
  2378. try
  2379. {
  2380. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4).ConfigureAwait(false);
  2381. }
  2382. catch (Exception ex)
  2383. {
  2384. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2385. return;
  2386. }
  2387. await observer.OnNextAsync(res).ConfigureAwait(false);
  2388. }
  2389. else if (isDone1 && isDone3 && isDone4)
  2390. {
  2391. await observer.OnCompletedAsync().ConfigureAwait(false);
  2392. }
  2393. }
  2394. },
  2395. async ex =>
  2396. {
  2397. using (await gate.LockAsync().ConfigureAwait(false))
  2398. {
  2399. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2400. }
  2401. },
  2402. async () =>
  2403. {
  2404. using (await gate.LockAsync().ConfigureAwait(false))
  2405. {
  2406. isDone2 = true;
  2407. if (isDone1 && isDone2 && isDone3 && isDone4)
  2408. {
  2409. await observer.OnCompletedAsync().ConfigureAwait(false);
  2410. }
  2411. }
  2412. }
  2413. ),
  2414. Create<T3>(
  2415. async x =>
  2416. {
  2417. using (await gate.LockAsync().ConfigureAwait(false))
  2418. {
  2419. if (!hasValue3)
  2420. {
  2421. hasValue3 = true;
  2422. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2423. }
  2424. latestValue3 = x;
  2425. if (allHasValue)
  2426. {
  2427. TResult res;
  2428. try
  2429. {
  2430. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4).ConfigureAwait(false);
  2431. }
  2432. catch (Exception ex)
  2433. {
  2434. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2435. return;
  2436. }
  2437. await observer.OnNextAsync(res).ConfigureAwait(false);
  2438. }
  2439. else if (isDone1 && isDone2 && isDone4)
  2440. {
  2441. await observer.OnCompletedAsync().ConfigureAwait(false);
  2442. }
  2443. }
  2444. },
  2445. async ex =>
  2446. {
  2447. using (await gate.LockAsync().ConfigureAwait(false))
  2448. {
  2449. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2450. }
  2451. },
  2452. async () =>
  2453. {
  2454. using (await gate.LockAsync().ConfigureAwait(false))
  2455. {
  2456. isDone3 = true;
  2457. if (isDone1 && isDone2 && isDone3 && isDone4)
  2458. {
  2459. await observer.OnCompletedAsync().ConfigureAwait(false);
  2460. }
  2461. }
  2462. }
  2463. ),
  2464. Create<T4>(
  2465. async x =>
  2466. {
  2467. using (await gate.LockAsync().ConfigureAwait(false))
  2468. {
  2469. if (!hasValue4)
  2470. {
  2471. hasValue4 = true;
  2472. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4;
  2473. }
  2474. latestValue4 = x;
  2475. if (allHasValue)
  2476. {
  2477. TResult res;
  2478. try
  2479. {
  2480. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4).ConfigureAwait(false);
  2481. }
  2482. catch (Exception ex)
  2483. {
  2484. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2485. return;
  2486. }
  2487. await observer.OnNextAsync(res).ConfigureAwait(false);
  2488. }
  2489. else if (isDone1 && isDone2 && isDone3)
  2490. {
  2491. await observer.OnCompletedAsync().ConfigureAwait(false);
  2492. }
  2493. }
  2494. },
  2495. async ex =>
  2496. {
  2497. using (await gate.LockAsync().ConfigureAwait(false))
  2498. {
  2499. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2500. }
  2501. },
  2502. async () =>
  2503. {
  2504. using (await gate.LockAsync().ConfigureAwait(false))
  2505. {
  2506. isDone4 = true;
  2507. if (isDone1 && isDone2 && isDone3 && isDone4)
  2508. {
  2509. await observer.OnCompletedAsync().ConfigureAwait(false);
  2510. }
  2511. }
  2512. }
  2513. )
  2514. );
  2515. }
  2516. 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)
  2517. {
  2518. if (observer == null)
  2519. throw new ArgumentNullException(nameof(observer));
  2520. bool allHasValue = false;
  2521. bool hasValue1 = false;
  2522. bool isDone1 = false;
  2523. T1 latestValue1 = default(T1);
  2524. bool hasValue2 = false;
  2525. bool isDone2 = false;
  2526. T2 latestValue2 = default(T2);
  2527. bool hasValue3 = false;
  2528. bool isDone3 = false;
  2529. T3 latestValue3 = default(T3);
  2530. bool hasValue4 = false;
  2531. bool isDone4 = false;
  2532. T4 latestValue4 = default(T4);
  2533. bool hasValue5 = false;
  2534. bool isDone5 = false;
  2535. T5 latestValue5 = default(T5);
  2536. var gate = AsyncGate.Create();
  2537. return
  2538. (
  2539. Create<T1>(
  2540. async x =>
  2541. {
  2542. using (await gate.LockAsync().ConfigureAwait(false))
  2543. {
  2544. if (!hasValue1)
  2545. {
  2546. hasValue1 = true;
  2547. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2548. }
  2549. latestValue1 = x;
  2550. if (allHasValue)
  2551. {
  2552. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5)).ConfigureAwait(false);
  2553. }
  2554. else if (isDone2 && isDone3 && isDone4 && isDone5)
  2555. {
  2556. await observer.OnCompletedAsync().ConfigureAwait(false);
  2557. }
  2558. }
  2559. },
  2560. async ex =>
  2561. {
  2562. using (await gate.LockAsync().ConfigureAwait(false))
  2563. {
  2564. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2565. }
  2566. },
  2567. async () =>
  2568. {
  2569. using (await gate.LockAsync().ConfigureAwait(false))
  2570. {
  2571. isDone1 = true;
  2572. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2573. {
  2574. await observer.OnCompletedAsync().ConfigureAwait(false);
  2575. }
  2576. }
  2577. }
  2578. ),
  2579. Create<T2>(
  2580. async x =>
  2581. {
  2582. using (await gate.LockAsync().ConfigureAwait(false))
  2583. {
  2584. if (!hasValue2)
  2585. {
  2586. hasValue2 = true;
  2587. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2588. }
  2589. latestValue2 = x;
  2590. if (allHasValue)
  2591. {
  2592. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5)).ConfigureAwait(false);
  2593. }
  2594. else if (isDone1 && isDone3 && isDone4 && isDone5)
  2595. {
  2596. await observer.OnCompletedAsync().ConfigureAwait(false);
  2597. }
  2598. }
  2599. },
  2600. async ex =>
  2601. {
  2602. using (await gate.LockAsync().ConfigureAwait(false))
  2603. {
  2604. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2605. }
  2606. },
  2607. async () =>
  2608. {
  2609. using (await gate.LockAsync().ConfigureAwait(false))
  2610. {
  2611. isDone2 = true;
  2612. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2613. {
  2614. await observer.OnCompletedAsync().ConfigureAwait(false);
  2615. }
  2616. }
  2617. }
  2618. ),
  2619. Create<T3>(
  2620. async x =>
  2621. {
  2622. using (await gate.LockAsync().ConfigureAwait(false))
  2623. {
  2624. if (!hasValue3)
  2625. {
  2626. hasValue3 = true;
  2627. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2628. }
  2629. latestValue3 = x;
  2630. if (allHasValue)
  2631. {
  2632. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5)).ConfigureAwait(false);
  2633. }
  2634. else if (isDone1 && isDone2 && isDone4 && isDone5)
  2635. {
  2636. await observer.OnCompletedAsync().ConfigureAwait(false);
  2637. }
  2638. }
  2639. },
  2640. async ex =>
  2641. {
  2642. using (await gate.LockAsync().ConfigureAwait(false))
  2643. {
  2644. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2645. }
  2646. },
  2647. async () =>
  2648. {
  2649. using (await gate.LockAsync().ConfigureAwait(false))
  2650. {
  2651. isDone3 = true;
  2652. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2653. {
  2654. await observer.OnCompletedAsync().ConfigureAwait(false);
  2655. }
  2656. }
  2657. }
  2658. ),
  2659. Create<T4>(
  2660. async x =>
  2661. {
  2662. using (await gate.LockAsync().ConfigureAwait(false))
  2663. {
  2664. if (!hasValue4)
  2665. {
  2666. hasValue4 = true;
  2667. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2668. }
  2669. latestValue4 = x;
  2670. if (allHasValue)
  2671. {
  2672. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5)).ConfigureAwait(false);
  2673. }
  2674. else if (isDone1 && isDone2 && isDone3 && isDone5)
  2675. {
  2676. await observer.OnCompletedAsync().ConfigureAwait(false);
  2677. }
  2678. }
  2679. },
  2680. async ex =>
  2681. {
  2682. using (await gate.LockAsync().ConfigureAwait(false))
  2683. {
  2684. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2685. }
  2686. },
  2687. async () =>
  2688. {
  2689. using (await gate.LockAsync().ConfigureAwait(false))
  2690. {
  2691. isDone4 = true;
  2692. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2693. {
  2694. await observer.OnCompletedAsync().ConfigureAwait(false);
  2695. }
  2696. }
  2697. }
  2698. ),
  2699. Create<T5>(
  2700. async x =>
  2701. {
  2702. using (await gate.LockAsync().ConfigureAwait(false))
  2703. {
  2704. if (!hasValue5)
  2705. {
  2706. hasValue5 = true;
  2707. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2708. }
  2709. latestValue5 = x;
  2710. if (allHasValue)
  2711. {
  2712. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5)).ConfigureAwait(false);
  2713. }
  2714. else if (isDone1 && isDone2 && isDone3 && isDone4)
  2715. {
  2716. await observer.OnCompletedAsync().ConfigureAwait(false);
  2717. }
  2718. }
  2719. },
  2720. async ex =>
  2721. {
  2722. using (await gate.LockAsync().ConfigureAwait(false))
  2723. {
  2724. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2725. }
  2726. },
  2727. async () =>
  2728. {
  2729. using (await gate.LockAsync().ConfigureAwait(false))
  2730. {
  2731. isDone5 = true;
  2732. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2733. {
  2734. await observer.OnCompletedAsync().ConfigureAwait(false);
  2735. }
  2736. }
  2737. }
  2738. )
  2739. );
  2740. }
  2741. 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)
  2742. {
  2743. if (observer == null)
  2744. throw new ArgumentNullException(nameof(observer));
  2745. if (selector == null)
  2746. throw new ArgumentNullException(nameof(selector));
  2747. return CombineLatest<T1, T2, T3, T4, T5, TResult>(observer, (x1, x2, x3, x4, x5) => new ValueTask<TResult>(selector(x1, x2, x3, x4, x5)));
  2748. }
  2749. 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)
  2750. {
  2751. if (observer == null)
  2752. throw new ArgumentNullException(nameof(observer));
  2753. if (selector == null)
  2754. throw new ArgumentNullException(nameof(selector));
  2755. bool allHasValue = false;
  2756. bool hasValue1 = false;
  2757. bool isDone1 = false;
  2758. T1 latestValue1 = default(T1);
  2759. bool hasValue2 = false;
  2760. bool isDone2 = false;
  2761. T2 latestValue2 = default(T2);
  2762. bool hasValue3 = false;
  2763. bool isDone3 = false;
  2764. T3 latestValue3 = default(T3);
  2765. bool hasValue4 = false;
  2766. bool isDone4 = false;
  2767. T4 latestValue4 = default(T4);
  2768. bool hasValue5 = false;
  2769. bool isDone5 = false;
  2770. T5 latestValue5 = default(T5);
  2771. var gate = AsyncGate.Create();
  2772. return
  2773. (
  2774. Create<T1>(
  2775. async x =>
  2776. {
  2777. using (await gate.LockAsync().ConfigureAwait(false))
  2778. {
  2779. if (!hasValue1)
  2780. {
  2781. hasValue1 = true;
  2782. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2783. }
  2784. latestValue1 = x;
  2785. if (allHasValue)
  2786. {
  2787. TResult res;
  2788. try
  2789. {
  2790. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5).ConfigureAwait(false);
  2791. }
  2792. catch (Exception ex)
  2793. {
  2794. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2795. return;
  2796. }
  2797. await observer.OnNextAsync(res).ConfigureAwait(false);
  2798. }
  2799. else if (isDone2 && isDone3 && isDone4 && isDone5)
  2800. {
  2801. await observer.OnCompletedAsync().ConfigureAwait(false);
  2802. }
  2803. }
  2804. },
  2805. async ex =>
  2806. {
  2807. using (await gate.LockAsync().ConfigureAwait(false))
  2808. {
  2809. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2810. }
  2811. },
  2812. async () =>
  2813. {
  2814. using (await gate.LockAsync().ConfigureAwait(false))
  2815. {
  2816. isDone1 = true;
  2817. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2818. {
  2819. await observer.OnCompletedAsync().ConfigureAwait(false);
  2820. }
  2821. }
  2822. }
  2823. ),
  2824. Create<T2>(
  2825. async x =>
  2826. {
  2827. using (await gate.LockAsync().ConfigureAwait(false))
  2828. {
  2829. if (!hasValue2)
  2830. {
  2831. hasValue2 = true;
  2832. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2833. }
  2834. latestValue2 = x;
  2835. if (allHasValue)
  2836. {
  2837. TResult res;
  2838. try
  2839. {
  2840. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5).ConfigureAwait(false);
  2841. }
  2842. catch (Exception ex)
  2843. {
  2844. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2845. return;
  2846. }
  2847. await observer.OnNextAsync(res).ConfigureAwait(false);
  2848. }
  2849. else if (isDone1 && isDone3 && isDone4 && isDone5)
  2850. {
  2851. await observer.OnCompletedAsync().ConfigureAwait(false);
  2852. }
  2853. }
  2854. },
  2855. async ex =>
  2856. {
  2857. using (await gate.LockAsync().ConfigureAwait(false))
  2858. {
  2859. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2860. }
  2861. },
  2862. async () =>
  2863. {
  2864. using (await gate.LockAsync().ConfigureAwait(false))
  2865. {
  2866. isDone2 = true;
  2867. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2868. {
  2869. await observer.OnCompletedAsync().ConfigureAwait(false);
  2870. }
  2871. }
  2872. }
  2873. ),
  2874. Create<T3>(
  2875. async x =>
  2876. {
  2877. using (await gate.LockAsync().ConfigureAwait(false))
  2878. {
  2879. if (!hasValue3)
  2880. {
  2881. hasValue3 = true;
  2882. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2883. }
  2884. latestValue3 = x;
  2885. if (allHasValue)
  2886. {
  2887. TResult res;
  2888. try
  2889. {
  2890. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5).ConfigureAwait(false);
  2891. }
  2892. catch (Exception ex)
  2893. {
  2894. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2895. return;
  2896. }
  2897. await observer.OnNextAsync(res).ConfigureAwait(false);
  2898. }
  2899. else if (isDone1 && isDone2 && isDone4 && isDone5)
  2900. {
  2901. await observer.OnCompletedAsync().ConfigureAwait(false);
  2902. }
  2903. }
  2904. },
  2905. async ex =>
  2906. {
  2907. using (await gate.LockAsync().ConfigureAwait(false))
  2908. {
  2909. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2910. }
  2911. },
  2912. async () =>
  2913. {
  2914. using (await gate.LockAsync().ConfigureAwait(false))
  2915. {
  2916. isDone3 = true;
  2917. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2918. {
  2919. await observer.OnCompletedAsync().ConfigureAwait(false);
  2920. }
  2921. }
  2922. }
  2923. ),
  2924. Create<T4>(
  2925. async x =>
  2926. {
  2927. using (await gate.LockAsync().ConfigureAwait(false))
  2928. {
  2929. if (!hasValue4)
  2930. {
  2931. hasValue4 = true;
  2932. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2933. }
  2934. latestValue4 = x;
  2935. if (allHasValue)
  2936. {
  2937. TResult res;
  2938. try
  2939. {
  2940. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5).ConfigureAwait(false);
  2941. }
  2942. catch (Exception ex)
  2943. {
  2944. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2945. return;
  2946. }
  2947. await observer.OnNextAsync(res).ConfigureAwait(false);
  2948. }
  2949. else if (isDone1 && isDone2 && isDone3 && isDone5)
  2950. {
  2951. await observer.OnCompletedAsync().ConfigureAwait(false);
  2952. }
  2953. }
  2954. },
  2955. async ex =>
  2956. {
  2957. using (await gate.LockAsync().ConfigureAwait(false))
  2958. {
  2959. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2960. }
  2961. },
  2962. async () =>
  2963. {
  2964. using (await gate.LockAsync().ConfigureAwait(false))
  2965. {
  2966. isDone4 = true;
  2967. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  2968. {
  2969. await observer.OnCompletedAsync().ConfigureAwait(false);
  2970. }
  2971. }
  2972. }
  2973. ),
  2974. Create<T5>(
  2975. async x =>
  2976. {
  2977. using (await gate.LockAsync().ConfigureAwait(false))
  2978. {
  2979. if (!hasValue5)
  2980. {
  2981. hasValue5 = true;
  2982. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5;
  2983. }
  2984. latestValue5 = x;
  2985. if (allHasValue)
  2986. {
  2987. TResult res;
  2988. try
  2989. {
  2990. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5).ConfigureAwait(false);
  2991. }
  2992. catch (Exception ex)
  2993. {
  2994. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  2995. return;
  2996. }
  2997. await observer.OnNextAsync(res).ConfigureAwait(false);
  2998. }
  2999. else if (isDone1 && isDone2 && isDone3 && isDone4)
  3000. {
  3001. await observer.OnCompletedAsync().ConfigureAwait(false);
  3002. }
  3003. }
  3004. },
  3005. async ex =>
  3006. {
  3007. using (await gate.LockAsync().ConfigureAwait(false))
  3008. {
  3009. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3010. }
  3011. },
  3012. async () =>
  3013. {
  3014. using (await gate.LockAsync().ConfigureAwait(false))
  3015. {
  3016. isDone5 = true;
  3017. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  3018. {
  3019. await observer.OnCompletedAsync().ConfigureAwait(false);
  3020. }
  3021. }
  3022. }
  3023. )
  3024. );
  3025. }
  3026. 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)
  3027. {
  3028. if (observer == null)
  3029. throw new ArgumentNullException(nameof(observer));
  3030. bool allHasValue = false;
  3031. bool hasValue1 = false;
  3032. bool isDone1 = false;
  3033. T1 latestValue1 = default(T1);
  3034. bool hasValue2 = false;
  3035. bool isDone2 = false;
  3036. T2 latestValue2 = default(T2);
  3037. bool hasValue3 = false;
  3038. bool isDone3 = false;
  3039. T3 latestValue3 = default(T3);
  3040. bool hasValue4 = false;
  3041. bool isDone4 = false;
  3042. T4 latestValue4 = default(T4);
  3043. bool hasValue5 = false;
  3044. bool isDone5 = false;
  3045. T5 latestValue5 = default(T5);
  3046. bool hasValue6 = false;
  3047. bool isDone6 = false;
  3048. T6 latestValue6 = default(T6);
  3049. var gate = AsyncGate.Create();
  3050. return
  3051. (
  3052. Create<T1>(
  3053. async x =>
  3054. {
  3055. using (await gate.LockAsync().ConfigureAwait(false))
  3056. {
  3057. if (!hasValue1)
  3058. {
  3059. hasValue1 = true;
  3060. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3061. }
  3062. latestValue1 = x;
  3063. if (allHasValue)
  3064. {
  3065. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3066. }
  3067. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3068. {
  3069. await observer.OnCompletedAsync().ConfigureAwait(false);
  3070. }
  3071. }
  3072. },
  3073. async ex =>
  3074. {
  3075. using (await gate.LockAsync().ConfigureAwait(false))
  3076. {
  3077. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3078. }
  3079. },
  3080. async () =>
  3081. {
  3082. using (await gate.LockAsync().ConfigureAwait(false))
  3083. {
  3084. isDone1 = true;
  3085. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3086. {
  3087. await observer.OnCompletedAsync().ConfigureAwait(false);
  3088. }
  3089. }
  3090. }
  3091. ),
  3092. Create<T2>(
  3093. async x =>
  3094. {
  3095. using (await gate.LockAsync().ConfigureAwait(false))
  3096. {
  3097. if (!hasValue2)
  3098. {
  3099. hasValue2 = true;
  3100. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3101. }
  3102. latestValue2 = x;
  3103. if (allHasValue)
  3104. {
  3105. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3106. }
  3107. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6)
  3108. {
  3109. await observer.OnCompletedAsync().ConfigureAwait(false);
  3110. }
  3111. }
  3112. },
  3113. async ex =>
  3114. {
  3115. using (await gate.LockAsync().ConfigureAwait(false))
  3116. {
  3117. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3118. }
  3119. },
  3120. async () =>
  3121. {
  3122. using (await gate.LockAsync().ConfigureAwait(false))
  3123. {
  3124. isDone2 = true;
  3125. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3126. {
  3127. await observer.OnCompletedAsync().ConfigureAwait(false);
  3128. }
  3129. }
  3130. }
  3131. ),
  3132. Create<T3>(
  3133. async x =>
  3134. {
  3135. using (await gate.LockAsync().ConfigureAwait(false))
  3136. {
  3137. if (!hasValue3)
  3138. {
  3139. hasValue3 = true;
  3140. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3141. }
  3142. latestValue3 = x;
  3143. if (allHasValue)
  3144. {
  3145. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3146. }
  3147. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6)
  3148. {
  3149. await observer.OnCompletedAsync().ConfigureAwait(false);
  3150. }
  3151. }
  3152. },
  3153. async ex =>
  3154. {
  3155. using (await gate.LockAsync().ConfigureAwait(false))
  3156. {
  3157. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3158. }
  3159. },
  3160. async () =>
  3161. {
  3162. using (await gate.LockAsync().ConfigureAwait(false))
  3163. {
  3164. isDone3 = true;
  3165. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3166. {
  3167. await observer.OnCompletedAsync().ConfigureAwait(false);
  3168. }
  3169. }
  3170. }
  3171. ),
  3172. Create<T4>(
  3173. async x =>
  3174. {
  3175. using (await gate.LockAsync().ConfigureAwait(false))
  3176. {
  3177. if (!hasValue4)
  3178. {
  3179. hasValue4 = true;
  3180. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3181. }
  3182. latestValue4 = x;
  3183. if (allHasValue)
  3184. {
  3185. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3186. }
  3187. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6)
  3188. {
  3189. await observer.OnCompletedAsync().ConfigureAwait(false);
  3190. }
  3191. }
  3192. },
  3193. async ex =>
  3194. {
  3195. using (await gate.LockAsync().ConfigureAwait(false))
  3196. {
  3197. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3198. }
  3199. },
  3200. async () =>
  3201. {
  3202. using (await gate.LockAsync().ConfigureAwait(false))
  3203. {
  3204. isDone4 = true;
  3205. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3206. {
  3207. await observer.OnCompletedAsync().ConfigureAwait(false);
  3208. }
  3209. }
  3210. }
  3211. ),
  3212. Create<T5>(
  3213. async x =>
  3214. {
  3215. using (await gate.LockAsync().ConfigureAwait(false))
  3216. {
  3217. if (!hasValue5)
  3218. {
  3219. hasValue5 = true;
  3220. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3221. }
  3222. latestValue5 = x;
  3223. if (allHasValue)
  3224. {
  3225. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3226. }
  3227. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6)
  3228. {
  3229. await observer.OnCompletedAsync().ConfigureAwait(false);
  3230. }
  3231. }
  3232. },
  3233. async ex =>
  3234. {
  3235. using (await gate.LockAsync().ConfigureAwait(false))
  3236. {
  3237. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3238. }
  3239. },
  3240. async () =>
  3241. {
  3242. using (await gate.LockAsync().ConfigureAwait(false))
  3243. {
  3244. isDone5 = true;
  3245. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3246. {
  3247. await observer.OnCompletedAsync().ConfigureAwait(false);
  3248. }
  3249. }
  3250. }
  3251. ),
  3252. Create<T6>(
  3253. async x =>
  3254. {
  3255. using (await gate.LockAsync().ConfigureAwait(false))
  3256. {
  3257. if (!hasValue6)
  3258. {
  3259. hasValue6 = true;
  3260. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3261. }
  3262. latestValue6 = x;
  3263. if (allHasValue)
  3264. {
  3265. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6)).ConfigureAwait(false);
  3266. }
  3267. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  3268. {
  3269. await observer.OnCompletedAsync().ConfigureAwait(false);
  3270. }
  3271. }
  3272. },
  3273. async ex =>
  3274. {
  3275. using (await gate.LockAsync().ConfigureAwait(false))
  3276. {
  3277. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3278. }
  3279. },
  3280. async () =>
  3281. {
  3282. using (await gate.LockAsync().ConfigureAwait(false))
  3283. {
  3284. isDone6 = true;
  3285. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3286. {
  3287. await observer.OnCompletedAsync().ConfigureAwait(false);
  3288. }
  3289. }
  3290. }
  3291. )
  3292. );
  3293. }
  3294. 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)
  3295. {
  3296. if (observer == null)
  3297. throw new ArgumentNullException(nameof(observer));
  3298. if (selector == null)
  3299. throw new ArgumentNullException(nameof(selector));
  3300. 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)));
  3301. }
  3302. 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)
  3303. {
  3304. if (observer == null)
  3305. throw new ArgumentNullException(nameof(observer));
  3306. if (selector == null)
  3307. throw new ArgumentNullException(nameof(selector));
  3308. bool allHasValue = false;
  3309. bool hasValue1 = false;
  3310. bool isDone1 = false;
  3311. T1 latestValue1 = default(T1);
  3312. bool hasValue2 = false;
  3313. bool isDone2 = false;
  3314. T2 latestValue2 = default(T2);
  3315. bool hasValue3 = false;
  3316. bool isDone3 = false;
  3317. T3 latestValue3 = default(T3);
  3318. bool hasValue4 = false;
  3319. bool isDone4 = false;
  3320. T4 latestValue4 = default(T4);
  3321. bool hasValue5 = false;
  3322. bool isDone5 = false;
  3323. T5 latestValue5 = default(T5);
  3324. bool hasValue6 = false;
  3325. bool isDone6 = false;
  3326. T6 latestValue6 = default(T6);
  3327. var gate = AsyncGate.Create();
  3328. return
  3329. (
  3330. Create<T1>(
  3331. async x =>
  3332. {
  3333. using (await gate.LockAsync().ConfigureAwait(false))
  3334. {
  3335. if (!hasValue1)
  3336. {
  3337. hasValue1 = true;
  3338. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3339. }
  3340. latestValue1 = x;
  3341. if (allHasValue)
  3342. {
  3343. TResult res;
  3344. try
  3345. {
  3346. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3347. }
  3348. catch (Exception ex)
  3349. {
  3350. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3351. return;
  3352. }
  3353. await observer.OnNextAsync(res).ConfigureAwait(false);
  3354. }
  3355. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3356. {
  3357. await observer.OnCompletedAsync().ConfigureAwait(false);
  3358. }
  3359. }
  3360. },
  3361. async ex =>
  3362. {
  3363. using (await gate.LockAsync().ConfigureAwait(false))
  3364. {
  3365. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3366. }
  3367. },
  3368. async () =>
  3369. {
  3370. using (await gate.LockAsync().ConfigureAwait(false))
  3371. {
  3372. isDone1 = true;
  3373. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3374. {
  3375. await observer.OnCompletedAsync().ConfigureAwait(false);
  3376. }
  3377. }
  3378. }
  3379. ),
  3380. Create<T2>(
  3381. async x =>
  3382. {
  3383. using (await gate.LockAsync().ConfigureAwait(false))
  3384. {
  3385. if (!hasValue2)
  3386. {
  3387. hasValue2 = true;
  3388. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3389. }
  3390. latestValue2 = x;
  3391. if (allHasValue)
  3392. {
  3393. TResult res;
  3394. try
  3395. {
  3396. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3397. }
  3398. catch (Exception ex)
  3399. {
  3400. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3401. return;
  3402. }
  3403. await observer.OnNextAsync(res).ConfigureAwait(false);
  3404. }
  3405. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6)
  3406. {
  3407. await observer.OnCompletedAsync().ConfigureAwait(false);
  3408. }
  3409. }
  3410. },
  3411. async ex =>
  3412. {
  3413. using (await gate.LockAsync().ConfigureAwait(false))
  3414. {
  3415. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3416. }
  3417. },
  3418. async () =>
  3419. {
  3420. using (await gate.LockAsync().ConfigureAwait(false))
  3421. {
  3422. isDone2 = true;
  3423. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3424. {
  3425. await observer.OnCompletedAsync().ConfigureAwait(false);
  3426. }
  3427. }
  3428. }
  3429. ),
  3430. Create<T3>(
  3431. async x =>
  3432. {
  3433. using (await gate.LockAsync().ConfigureAwait(false))
  3434. {
  3435. if (!hasValue3)
  3436. {
  3437. hasValue3 = true;
  3438. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3439. }
  3440. latestValue3 = x;
  3441. if (allHasValue)
  3442. {
  3443. TResult res;
  3444. try
  3445. {
  3446. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3447. }
  3448. catch (Exception ex)
  3449. {
  3450. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3451. return;
  3452. }
  3453. await observer.OnNextAsync(res).ConfigureAwait(false);
  3454. }
  3455. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6)
  3456. {
  3457. await observer.OnCompletedAsync().ConfigureAwait(false);
  3458. }
  3459. }
  3460. },
  3461. async ex =>
  3462. {
  3463. using (await gate.LockAsync().ConfigureAwait(false))
  3464. {
  3465. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3466. }
  3467. },
  3468. async () =>
  3469. {
  3470. using (await gate.LockAsync().ConfigureAwait(false))
  3471. {
  3472. isDone3 = true;
  3473. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3474. {
  3475. await observer.OnCompletedAsync().ConfigureAwait(false);
  3476. }
  3477. }
  3478. }
  3479. ),
  3480. Create<T4>(
  3481. async x =>
  3482. {
  3483. using (await gate.LockAsync().ConfigureAwait(false))
  3484. {
  3485. if (!hasValue4)
  3486. {
  3487. hasValue4 = true;
  3488. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3489. }
  3490. latestValue4 = x;
  3491. if (allHasValue)
  3492. {
  3493. TResult res;
  3494. try
  3495. {
  3496. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3497. }
  3498. catch (Exception ex)
  3499. {
  3500. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3501. return;
  3502. }
  3503. await observer.OnNextAsync(res).ConfigureAwait(false);
  3504. }
  3505. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6)
  3506. {
  3507. await observer.OnCompletedAsync().ConfigureAwait(false);
  3508. }
  3509. }
  3510. },
  3511. async ex =>
  3512. {
  3513. using (await gate.LockAsync().ConfigureAwait(false))
  3514. {
  3515. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3516. }
  3517. },
  3518. async () =>
  3519. {
  3520. using (await gate.LockAsync().ConfigureAwait(false))
  3521. {
  3522. isDone4 = true;
  3523. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3524. {
  3525. await observer.OnCompletedAsync().ConfigureAwait(false);
  3526. }
  3527. }
  3528. }
  3529. ),
  3530. Create<T5>(
  3531. async x =>
  3532. {
  3533. using (await gate.LockAsync().ConfigureAwait(false))
  3534. {
  3535. if (!hasValue5)
  3536. {
  3537. hasValue5 = true;
  3538. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3539. }
  3540. latestValue5 = x;
  3541. if (allHasValue)
  3542. {
  3543. TResult res;
  3544. try
  3545. {
  3546. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3547. }
  3548. catch (Exception ex)
  3549. {
  3550. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3551. return;
  3552. }
  3553. await observer.OnNextAsync(res).ConfigureAwait(false);
  3554. }
  3555. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6)
  3556. {
  3557. await observer.OnCompletedAsync().ConfigureAwait(false);
  3558. }
  3559. }
  3560. },
  3561. async ex =>
  3562. {
  3563. using (await gate.LockAsync().ConfigureAwait(false))
  3564. {
  3565. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3566. }
  3567. },
  3568. async () =>
  3569. {
  3570. using (await gate.LockAsync().ConfigureAwait(false))
  3571. {
  3572. isDone5 = true;
  3573. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3574. {
  3575. await observer.OnCompletedAsync().ConfigureAwait(false);
  3576. }
  3577. }
  3578. }
  3579. ),
  3580. Create<T6>(
  3581. async x =>
  3582. {
  3583. using (await gate.LockAsync().ConfigureAwait(false))
  3584. {
  3585. if (!hasValue6)
  3586. {
  3587. hasValue6 = true;
  3588. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6;
  3589. }
  3590. latestValue6 = x;
  3591. if (allHasValue)
  3592. {
  3593. TResult res;
  3594. try
  3595. {
  3596. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6).ConfigureAwait(false);
  3597. }
  3598. catch (Exception ex)
  3599. {
  3600. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3601. return;
  3602. }
  3603. await observer.OnNextAsync(res).ConfigureAwait(false);
  3604. }
  3605. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5)
  3606. {
  3607. await observer.OnCompletedAsync().ConfigureAwait(false);
  3608. }
  3609. }
  3610. },
  3611. async ex =>
  3612. {
  3613. using (await gate.LockAsync().ConfigureAwait(false))
  3614. {
  3615. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3616. }
  3617. },
  3618. async () =>
  3619. {
  3620. using (await gate.LockAsync().ConfigureAwait(false))
  3621. {
  3622. isDone6 = true;
  3623. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3624. {
  3625. await observer.OnCompletedAsync().ConfigureAwait(false);
  3626. }
  3627. }
  3628. }
  3629. )
  3630. );
  3631. }
  3632. 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)
  3633. {
  3634. if (observer == null)
  3635. throw new ArgumentNullException(nameof(observer));
  3636. bool allHasValue = false;
  3637. bool hasValue1 = false;
  3638. bool isDone1 = false;
  3639. T1 latestValue1 = default(T1);
  3640. bool hasValue2 = false;
  3641. bool isDone2 = false;
  3642. T2 latestValue2 = default(T2);
  3643. bool hasValue3 = false;
  3644. bool isDone3 = false;
  3645. T3 latestValue3 = default(T3);
  3646. bool hasValue4 = false;
  3647. bool isDone4 = false;
  3648. T4 latestValue4 = default(T4);
  3649. bool hasValue5 = false;
  3650. bool isDone5 = false;
  3651. T5 latestValue5 = default(T5);
  3652. bool hasValue6 = false;
  3653. bool isDone6 = false;
  3654. T6 latestValue6 = default(T6);
  3655. bool hasValue7 = false;
  3656. bool isDone7 = false;
  3657. T7 latestValue7 = default(T7);
  3658. var gate = AsyncGate.Create();
  3659. return
  3660. (
  3661. Create<T1>(
  3662. async x =>
  3663. {
  3664. using (await gate.LockAsync().ConfigureAwait(false))
  3665. {
  3666. if (!hasValue1)
  3667. {
  3668. hasValue1 = true;
  3669. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3670. }
  3671. latestValue1 = x;
  3672. if (allHasValue)
  3673. {
  3674. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3675. }
  3676. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3677. {
  3678. await observer.OnCompletedAsync().ConfigureAwait(false);
  3679. }
  3680. }
  3681. },
  3682. async ex =>
  3683. {
  3684. using (await gate.LockAsync().ConfigureAwait(false))
  3685. {
  3686. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3687. }
  3688. },
  3689. async () =>
  3690. {
  3691. using (await gate.LockAsync().ConfigureAwait(false))
  3692. {
  3693. isDone1 = true;
  3694. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3695. {
  3696. await observer.OnCompletedAsync().ConfigureAwait(false);
  3697. }
  3698. }
  3699. }
  3700. ),
  3701. Create<T2>(
  3702. async x =>
  3703. {
  3704. using (await gate.LockAsync().ConfigureAwait(false))
  3705. {
  3706. if (!hasValue2)
  3707. {
  3708. hasValue2 = true;
  3709. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3710. }
  3711. latestValue2 = x;
  3712. if (allHasValue)
  3713. {
  3714. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3715. }
  3716. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3717. {
  3718. await observer.OnCompletedAsync().ConfigureAwait(false);
  3719. }
  3720. }
  3721. },
  3722. async ex =>
  3723. {
  3724. using (await gate.LockAsync().ConfigureAwait(false))
  3725. {
  3726. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3727. }
  3728. },
  3729. async () =>
  3730. {
  3731. using (await gate.LockAsync().ConfigureAwait(false))
  3732. {
  3733. isDone2 = true;
  3734. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3735. {
  3736. await observer.OnCompletedAsync().ConfigureAwait(false);
  3737. }
  3738. }
  3739. }
  3740. ),
  3741. Create<T3>(
  3742. async x =>
  3743. {
  3744. using (await gate.LockAsync().ConfigureAwait(false))
  3745. {
  3746. if (!hasValue3)
  3747. {
  3748. hasValue3 = true;
  3749. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3750. }
  3751. latestValue3 = x;
  3752. if (allHasValue)
  3753. {
  3754. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3755. }
  3756. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7)
  3757. {
  3758. await observer.OnCompletedAsync().ConfigureAwait(false);
  3759. }
  3760. }
  3761. },
  3762. async ex =>
  3763. {
  3764. using (await gate.LockAsync().ConfigureAwait(false))
  3765. {
  3766. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3767. }
  3768. },
  3769. async () =>
  3770. {
  3771. using (await gate.LockAsync().ConfigureAwait(false))
  3772. {
  3773. isDone3 = true;
  3774. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3775. {
  3776. await observer.OnCompletedAsync().ConfigureAwait(false);
  3777. }
  3778. }
  3779. }
  3780. ),
  3781. Create<T4>(
  3782. async x =>
  3783. {
  3784. using (await gate.LockAsync().ConfigureAwait(false))
  3785. {
  3786. if (!hasValue4)
  3787. {
  3788. hasValue4 = true;
  3789. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3790. }
  3791. latestValue4 = x;
  3792. if (allHasValue)
  3793. {
  3794. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3795. }
  3796. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7)
  3797. {
  3798. await observer.OnCompletedAsync().ConfigureAwait(false);
  3799. }
  3800. }
  3801. },
  3802. async ex =>
  3803. {
  3804. using (await gate.LockAsync().ConfigureAwait(false))
  3805. {
  3806. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3807. }
  3808. },
  3809. async () =>
  3810. {
  3811. using (await gate.LockAsync().ConfigureAwait(false))
  3812. {
  3813. isDone4 = true;
  3814. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3815. {
  3816. await observer.OnCompletedAsync().ConfigureAwait(false);
  3817. }
  3818. }
  3819. }
  3820. ),
  3821. Create<T5>(
  3822. async x =>
  3823. {
  3824. using (await gate.LockAsync().ConfigureAwait(false))
  3825. {
  3826. if (!hasValue5)
  3827. {
  3828. hasValue5 = true;
  3829. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3830. }
  3831. latestValue5 = x;
  3832. if (allHasValue)
  3833. {
  3834. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3835. }
  3836. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7)
  3837. {
  3838. await observer.OnCompletedAsync().ConfigureAwait(false);
  3839. }
  3840. }
  3841. },
  3842. async ex =>
  3843. {
  3844. using (await gate.LockAsync().ConfigureAwait(false))
  3845. {
  3846. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3847. }
  3848. },
  3849. async () =>
  3850. {
  3851. using (await gate.LockAsync().ConfigureAwait(false))
  3852. {
  3853. isDone5 = true;
  3854. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3855. {
  3856. await observer.OnCompletedAsync().ConfigureAwait(false);
  3857. }
  3858. }
  3859. }
  3860. ),
  3861. Create<T6>(
  3862. async x =>
  3863. {
  3864. using (await gate.LockAsync().ConfigureAwait(false))
  3865. {
  3866. if (!hasValue6)
  3867. {
  3868. hasValue6 = true;
  3869. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3870. }
  3871. latestValue6 = x;
  3872. if (allHasValue)
  3873. {
  3874. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3875. }
  3876. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7)
  3877. {
  3878. await observer.OnCompletedAsync().ConfigureAwait(false);
  3879. }
  3880. }
  3881. },
  3882. async ex =>
  3883. {
  3884. using (await gate.LockAsync().ConfigureAwait(false))
  3885. {
  3886. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3887. }
  3888. },
  3889. async () =>
  3890. {
  3891. using (await gate.LockAsync().ConfigureAwait(false))
  3892. {
  3893. isDone6 = true;
  3894. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3895. {
  3896. await observer.OnCompletedAsync().ConfigureAwait(false);
  3897. }
  3898. }
  3899. }
  3900. ),
  3901. Create<T7>(
  3902. async x =>
  3903. {
  3904. using (await gate.LockAsync().ConfigureAwait(false))
  3905. {
  3906. if (!hasValue7)
  3907. {
  3908. hasValue7 = true;
  3909. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3910. }
  3911. latestValue7 = x;
  3912. if (allHasValue)
  3913. {
  3914. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7)).ConfigureAwait(false);
  3915. }
  3916. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  3917. {
  3918. await observer.OnCompletedAsync().ConfigureAwait(false);
  3919. }
  3920. }
  3921. },
  3922. async ex =>
  3923. {
  3924. using (await gate.LockAsync().ConfigureAwait(false))
  3925. {
  3926. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  3927. }
  3928. },
  3929. async () =>
  3930. {
  3931. using (await gate.LockAsync().ConfigureAwait(false))
  3932. {
  3933. isDone7 = true;
  3934. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  3935. {
  3936. await observer.OnCompletedAsync().ConfigureAwait(false);
  3937. }
  3938. }
  3939. }
  3940. )
  3941. );
  3942. }
  3943. 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)
  3944. {
  3945. if (observer == null)
  3946. throw new ArgumentNullException(nameof(observer));
  3947. if (selector == null)
  3948. throw new ArgumentNullException(nameof(selector));
  3949. 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)));
  3950. }
  3951. 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)
  3952. {
  3953. if (observer == null)
  3954. throw new ArgumentNullException(nameof(observer));
  3955. if (selector == null)
  3956. throw new ArgumentNullException(nameof(selector));
  3957. bool allHasValue = false;
  3958. bool hasValue1 = false;
  3959. bool isDone1 = false;
  3960. T1 latestValue1 = default(T1);
  3961. bool hasValue2 = false;
  3962. bool isDone2 = false;
  3963. T2 latestValue2 = default(T2);
  3964. bool hasValue3 = false;
  3965. bool isDone3 = false;
  3966. T3 latestValue3 = default(T3);
  3967. bool hasValue4 = false;
  3968. bool isDone4 = false;
  3969. T4 latestValue4 = default(T4);
  3970. bool hasValue5 = false;
  3971. bool isDone5 = false;
  3972. T5 latestValue5 = default(T5);
  3973. bool hasValue6 = false;
  3974. bool isDone6 = false;
  3975. T6 latestValue6 = default(T6);
  3976. bool hasValue7 = false;
  3977. bool isDone7 = false;
  3978. T7 latestValue7 = default(T7);
  3979. var gate = AsyncGate.Create();
  3980. return
  3981. (
  3982. Create<T1>(
  3983. async x =>
  3984. {
  3985. using (await gate.LockAsync().ConfigureAwait(false))
  3986. {
  3987. if (!hasValue1)
  3988. {
  3989. hasValue1 = true;
  3990. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  3991. }
  3992. latestValue1 = x;
  3993. if (allHasValue)
  3994. {
  3995. TResult res;
  3996. try
  3997. {
  3998. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  3999. }
  4000. catch (Exception ex)
  4001. {
  4002. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4003. return;
  4004. }
  4005. await observer.OnNextAsync(res).ConfigureAwait(false);
  4006. }
  4007. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4008. {
  4009. await observer.OnCompletedAsync().ConfigureAwait(false);
  4010. }
  4011. }
  4012. },
  4013. async ex =>
  4014. {
  4015. using (await gate.LockAsync().ConfigureAwait(false))
  4016. {
  4017. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4018. }
  4019. },
  4020. async () =>
  4021. {
  4022. using (await gate.LockAsync().ConfigureAwait(false))
  4023. {
  4024. isDone1 = true;
  4025. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4026. {
  4027. await observer.OnCompletedAsync().ConfigureAwait(false);
  4028. }
  4029. }
  4030. }
  4031. ),
  4032. Create<T2>(
  4033. async x =>
  4034. {
  4035. using (await gate.LockAsync().ConfigureAwait(false))
  4036. {
  4037. if (!hasValue2)
  4038. {
  4039. hasValue2 = true;
  4040. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4041. }
  4042. latestValue2 = x;
  4043. if (allHasValue)
  4044. {
  4045. TResult res;
  4046. try
  4047. {
  4048. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4049. }
  4050. catch (Exception ex)
  4051. {
  4052. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4053. return;
  4054. }
  4055. await observer.OnNextAsync(res).ConfigureAwait(false);
  4056. }
  4057. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4058. {
  4059. await observer.OnCompletedAsync().ConfigureAwait(false);
  4060. }
  4061. }
  4062. },
  4063. async ex =>
  4064. {
  4065. using (await gate.LockAsync().ConfigureAwait(false))
  4066. {
  4067. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4068. }
  4069. },
  4070. async () =>
  4071. {
  4072. using (await gate.LockAsync().ConfigureAwait(false))
  4073. {
  4074. isDone2 = true;
  4075. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4076. {
  4077. await observer.OnCompletedAsync().ConfigureAwait(false);
  4078. }
  4079. }
  4080. }
  4081. ),
  4082. Create<T3>(
  4083. async x =>
  4084. {
  4085. using (await gate.LockAsync().ConfigureAwait(false))
  4086. {
  4087. if (!hasValue3)
  4088. {
  4089. hasValue3 = true;
  4090. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4091. }
  4092. latestValue3 = x;
  4093. if (allHasValue)
  4094. {
  4095. TResult res;
  4096. try
  4097. {
  4098. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4099. }
  4100. catch (Exception ex)
  4101. {
  4102. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4103. return;
  4104. }
  4105. await observer.OnNextAsync(res).ConfigureAwait(false);
  4106. }
  4107. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7)
  4108. {
  4109. await observer.OnCompletedAsync().ConfigureAwait(false);
  4110. }
  4111. }
  4112. },
  4113. async ex =>
  4114. {
  4115. using (await gate.LockAsync().ConfigureAwait(false))
  4116. {
  4117. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4118. }
  4119. },
  4120. async () =>
  4121. {
  4122. using (await gate.LockAsync().ConfigureAwait(false))
  4123. {
  4124. isDone3 = true;
  4125. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4126. {
  4127. await observer.OnCompletedAsync().ConfigureAwait(false);
  4128. }
  4129. }
  4130. }
  4131. ),
  4132. Create<T4>(
  4133. async x =>
  4134. {
  4135. using (await gate.LockAsync().ConfigureAwait(false))
  4136. {
  4137. if (!hasValue4)
  4138. {
  4139. hasValue4 = true;
  4140. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4141. }
  4142. latestValue4 = x;
  4143. if (allHasValue)
  4144. {
  4145. TResult res;
  4146. try
  4147. {
  4148. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4149. }
  4150. catch (Exception ex)
  4151. {
  4152. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4153. return;
  4154. }
  4155. await observer.OnNextAsync(res).ConfigureAwait(false);
  4156. }
  4157. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7)
  4158. {
  4159. await observer.OnCompletedAsync().ConfigureAwait(false);
  4160. }
  4161. }
  4162. },
  4163. async ex =>
  4164. {
  4165. using (await gate.LockAsync().ConfigureAwait(false))
  4166. {
  4167. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4168. }
  4169. },
  4170. async () =>
  4171. {
  4172. using (await gate.LockAsync().ConfigureAwait(false))
  4173. {
  4174. isDone4 = true;
  4175. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4176. {
  4177. await observer.OnCompletedAsync().ConfigureAwait(false);
  4178. }
  4179. }
  4180. }
  4181. ),
  4182. Create<T5>(
  4183. async x =>
  4184. {
  4185. using (await gate.LockAsync().ConfigureAwait(false))
  4186. {
  4187. if (!hasValue5)
  4188. {
  4189. hasValue5 = true;
  4190. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4191. }
  4192. latestValue5 = x;
  4193. if (allHasValue)
  4194. {
  4195. TResult res;
  4196. try
  4197. {
  4198. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4199. }
  4200. catch (Exception ex)
  4201. {
  4202. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4203. return;
  4204. }
  4205. await observer.OnNextAsync(res).ConfigureAwait(false);
  4206. }
  4207. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7)
  4208. {
  4209. await observer.OnCompletedAsync().ConfigureAwait(false);
  4210. }
  4211. }
  4212. },
  4213. async ex =>
  4214. {
  4215. using (await gate.LockAsync().ConfigureAwait(false))
  4216. {
  4217. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4218. }
  4219. },
  4220. async () =>
  4221. {
  4222. using (await gate.LockAsync().ConfigureAwait(false))
  4223. {
  4224. isDone5 = true;
  4225. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4226. {
  4227. await observer.OnCompletedAsync().ConfigureAwait(false);
  4228. }
  4229. }
  4230. }
  4231. ),
  4232. Create<T6>(
  4233. async x =>
  4234. {
  4235. using (await gate.LockAsync().ConfigureAwait(false))
  4236. {
  4237. if (!hasValue6)
  4238. {
  4239. hasValue6 = true;
  4240. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4241. }
  4242. latestValue6 = x;
  4243. if (allHasValue)
  4244. {
  4245. TResult res;
  4246. try
  4247. {
  4248. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4249. }
  4250. catch (Exception ex)
  4251. {
  4252. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4253. return;
  4254. }
  4255. await observer.OnNextAsync(res).ConfigureAwait(false);
  4256. }
  4257. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7)
  4258. {
  4259. await observer.OnCompletedAsync().ConfigureAwait(false);
  4260. }
  4261. }
  4262. },
  4263. async ex =>
  4264. {
  4265. using (await gate.LockAsync().ConfigureAwait(false))
  4266. {
  4267. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4268. }
  4269. },
  4270. async () =>
  4271. {
  4272. using (await gate.LockAsync().ConfigureAwait(false))
  4273. {
  4274. isDone6 = true;
  4275. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4276. {
  4277. await observer.OnCompletedAsync().ConfigureAwait(false);
  4278. }
  4279. }
  4280. }
  4281. ),
  4282. Create<T7>(
  4283. async x =>
  4284. {
  4285. using (await gate.LockAsync().ConfigureAwait(false))
  4286. {
  4287. if (!hasValue7)
  4288. {
  4289. hasValue7 = true;
  4290. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7;
  4291. }
  4292. latestValue7 = x;
  4293. if (allHasValue)
  4294. {
  4295. TResult res;
  4296. try
  4297. {
  4298. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7).ConfigureAwait(false);
  4299. }
  4300. catch (Exception ex)
  4301. {
  4302. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4303. return;
  4304. }
  4305. await observer.OnNextAsync(res).ConfigureAwait(false);
  4306. }
  4307. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6)
  4308. {
  4309. await observer.OnCompletedAsync().ConfigureAwait(false);
  4310. }
  4311. }
  4312. },
  4313. async ex =>
  4314. {
  4315. using (await gate.LockAsync().ConfigureAwait(false))
  4316. {
  4317. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4318. }
  4319. },
  4320. async () =>
  4321. {
  4322. using (await gate.LockAsync().ConfigureAwait(false))
  4323. {
  4324. isDone7 = true;
  4325. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4326. {
  4327. await observer.OnCompletedAsync().ConfigureAwait(false);
  4328. }
  4329. }
  4330. }
  4331. )
  4332. );
  4333. }
  4334. 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)
  4335. {
  4336. if (observer == null)
  4337. throw new ArgumentNullException(nameof(observer));
  4338. bool allHasValue = false;
  4339. bool hasValue1 = false;
  4340. bool isDone1 = false;
  4341. T1 latestValue1 = default(T1);
  4342. bool hasValue2 = false;
  4343. bool isDone2 = false;
  4344. T2 latestValue2 = default(T2);
  4345. bool hasValue3 = false;
  4346. bool isDone3 = false;
  4347. T3 latestValue3 = default(T3);
  4348. bool hasValue4 = false;
  4349. bool isDone4 = false;
  4350. T4 latestValue4 = default(T4);
  4351. bool hasValue5 = false;
  4352. bool isDone5 = false;
  4353. T5 latestValue5 = default(T5);
  4354. bool hasValue6 = false;
  4355. bool isDone6 = false;
  4356. T6 latestValue6 = default(T6);
  4357. bool hasValue7 = false;
  4358. bool isDone7 = false;
  4359. T7 latestValue7 = default(T7);
  4360. bool hasValue8 = false;
  4361. bool isDone8 = false;
  4362. T8 latestValue8 = default(T8);
  4363. var gate = AsyncGate.Create();
  4364. return
  4365. (
  4366. Create<T1>(
  4367. async x =>
  4368. {
  4369. using (await gate.LockAsync().ConfigureAwait(false))
  4370. {
  4371. if (!hasValue1)
  4372. {
  4373. hasValue1 = true;
  4374. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4375. }
  4376. latestValue1 = x;
  4377. if (allHasValue)
  4378. {
  4379. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4380. }
  4381. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4382. {
  4383. await observer.OnCompletedAsync().ConfigureAwait(false);
  4384. }
  4385. }
  4386. },
  4387. async ex =>
  4388. {
  4389. using (await gate.LockAsync().ConfigureAwait(false))
  4390. {
  4391. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4392. }
  4393. },
  4394. async () =>
  4395. {
  4396. using (await gate.LockAsync().ConfigureAwait(false))
  4397. {
  4398. isDone1 = true;
  4399. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4400. {
  4401. await observer.OnCompletedAsync().ConfigureAwait(false);
  4402. }
  4403. }
  4404. }
  4405. ),
  4406. Create<T2>(
  4407. async x =>
  4408. {
  4409. using (await gate.LockAsync().ConfigureAwait(false))
  4410. {
  4411. if (!hasValue2)
  4412. {
  4413. hasValue2 = true;
  4414. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4415. }
  4416. latestValue2 = x;
  4417. if (allHasValue)
  4418. {
  4419. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4420. }
  4421. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4422. {
  4423. await observer.OnCompletedAsync().ConfigureAwait(false);
  4424. }
  4425. }
  4426. },
  4427. async ex =>
  4428. {
  4429. using (await gate.LockAsync().ConfigureAwait(false))
  4430. {
  4431. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4432. }
  4433. },
  4434. async () =>
  4435. {
  4436. using (await gate.LockAsync().ConfigureAwait(false))
  4437. {
  4438. isDone2 = true;
  4439. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4440. {
  4441. await observer.OnCompletedAsync().ConfigureAwait(false);
  4442. }
  4443. }
  4444. }
  4445. ),
  4446. Create<T3>(
  4447. async x =>
  4448. {
  4449. using (await gate.LockAsync().ConfigureAwait(false))
  4450. {
  4451. if (!hasValue3)
  4452. {
  4453. hasValue3 = true;
  4454. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4455. }
  4456. latestValue3 = x;
  4457. if (allHasValue)
  4458. {
  4459. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4460. }
  4461. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4462. {
  4463. await observer.OnCompletedAsync().ConfigureAwait(false);
  4464. }
  4465. }
  4466. },
  4467. async ex =>
  4468. {
  4469. using (await gate.LockAsync().ConfigureAwait(false))
  4470. {
  4471. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4472. }
  4473. },
  4474. async () =>
  4475. {
  4476. using (await gate.LockAsync().ConfigureAwait(false))
  4477. {
  4478. isDone3 = true;
  4479. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4480. {
  4481. await observer.OnCompletedAsync().ConfigureAwait(false);
  4482. }
  4483. }
  4484. }
  4485. ),
  4486. Create<T4>(
  4487. async x =>
  4488. {
  4489. using (await gate.LockAsync().ConfigureAwait(false))
  4490. {
  4491. if (!hasValue4)
  4492. {
  4493. hasValue4 = true;
  4494. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4495. }
  4496. latestValue4 = x;
  4497. if (allHasValue)
  4498. {
  4499. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4500. }
  4501. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8)
  4502. {
  4503. await observer.OnCompletedAsync().ConfigureAwait(false);
  4504. }
  4505. }
  4506. },
  4507. async ex =>
  4508. {
  4509. using (await gate.LockAsync().ConfigureAwait(false))
  4510. {
  4511. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4512. }
  4513. },
  4514. async () =>
  4515. {
  4516. using (await gate.LockAsync().ConfigureAwait(false))
  4517. {
  4518. isDone4 = true;
  4519. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4520. {
  4521. await observer.OnCompletedAsync().ConfigureAwait(false);
  4522. }
  4523. }
  4524. }
  4525. ),
  4526. Create<T5>(
  4527. async x =>
  4528. {
  4529. using (await gate.LockAsync().ConfigureAwait(false))
  4530. {
  4531. if (!hasValue5)
  4532. {
  4533. hasValue5 = true;
  4534. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4535. }
  4536. latestValue5 = x;
  4537. if (allHasValue)
  4538. {
  4539. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4540. }
  4541. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8)
  4542. {
  4543. await observer.OnCompletedAsync().ConfigureAwait(false);
  4544. }
  4545. }
  4546. },
  4547. async ex =>
  4548. {
  4549. using (await gate.LockAsync().ConfigureAwait(false))
  4550. {
  4551. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4552. }
  4553. },
  4554. async () =>
  4555. {
  4556. using (await gate.LockAsync().ConfigureAwait(false))
  4557. {
  4558. isDone5 = true;
  4559. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4560. {
  4561. await observer.OnCompletedAsync().ConfigureAwait(false);
  4562. }
  4563. }
  4564. }
  4565. ),
  4566. Create<T6>(
  4567. async x =>
  4568. {
  4569. using (await gate.LockAsync().ConfigureAwait(false))
  4570. {
  4571. if (!hasValue6)
  4572. {
  4573. hasValue6 = true;
  4574. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4575. }
  4576. latestValue6 = x;
  4577. if (allHasValue)
  4578. {
  4579. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4580. }
  4581. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8)
  4582. {
  4583. await observer.OnCompletedAsync().ConfigureAwait(false);
  4584. }
  4585. }
  4586. },
  4587. async ex =>
  4588. {
  4589. using (await gate.LockAsync().ConfigureAwait(false))
  4590. {
  4591. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4592. }
  4593. },
  4594. async () =>
  4595. {
  4596. using (await gate.LockAsync().ConfigureAwait(false))
  4597. {
  4598. isDone6 = true;
  4599. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4600. {
  4601. await observer.OnCompletedAsync().ConfigureAwait(false);
  4602. }
  4603. }
  4604. }
  4605. ),
  4606. Create<T7>(
  4607. async x =>
  4608. {
  4609. using (await gate.LockAsync().ConfigureAwait(false))
  4610. {
  4611. if (!hasValue7)
  4612. {
  4613. hasValue7 = true;
  4614. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4615. }
  4616. latestValue7 = x;
  4617. if (allHasValue)
  4618. {
  4619. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4620. }
  4621. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8)
  4622. {
  4623. await observer.OnCompletedAsync().ConfigureAwait(false);
  4624. }
  4625. }
  4626. },
  4627. async ex =>
  4628. {
  4629. using (await gate.LockAsync().ConfigureAwait(false))
  4630. {
  4631. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4632. }
  4633. },
  4634. async () =>
  4635. {
  4636. using (await gate.LockAsync().ConfigureAwait(false))
  4637. {
  4638. isDone7 = true;
  4639. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4640. {
  4641. await observer.OnCompletedAsync().ConfigureAwait(false);
  4642. }
  4643. }
  4644. }
  4645. ),
  4646. Create<T8>(
  4647. async x =>
  4648. {
  4649. using (await gate.LockAsync().ConfigureAwait(false))
  4650. {
  4651. if (!hasValue8)
  4652. {
  4653. hasValue8 = true;
  4654. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4655. }
  4656. latestValue8 = x;
  4657. if (allHasValue)
  4658. {
  4659. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8)).ConfigureAwait(false);
  4660. }
  4661. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  4662. {
  4663. await observer.OnCompletedAsync().ConfigureAwait(false);
  4664. }
  4665. }
  4666. },
  4667. async ex =>
  4668. {
  4669. using (await gate.LockAsync().ConfigureAwait(false))
  4670. {
  4671. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4672. }
  4673. },
  4674. async () =>
  4675. {
  4676. using (await gate.LockAsync().ConfigureAwait(false))
  4677. {
  4678. isDone8 = true;
  4679. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4680. {
  4681. await observer.OnCompletedAsync().ConfigureAwait(false);
  4682. }
  4683. }
  4684. }
  4685. )
  4686. );
  4687. }
  4688. 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)
  4689. {
  4690. if (observer == null)
  4691. throw new ArgumentNullException(nameof(observer));
  4692. if (selector == null)
  4693. throw new ArgumentNullException(nameof(selector));
  4694. 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)));
  4695. }
  4696. 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)
  4697. {
  4698. if (observer == null)
  4699. throw new ArgumentNullException(nameof(observer));
  4700. if (selector == null)
  4701. throw new ArgumentNullException(nameof(selector));
  4702. bool allHasValue = false;
  4703. bool hasValue1 = false;
  4704. bool isDone1 = false;
  4705. T1 latestValue1 = default(T1);
  4706. bool hasValue2 = false;
  4707. bool isDone2 = false;
  4708. T2 latestValue2 = default(T2);
  4709. bool hasValue3 = false;
  4710. bool isDone3 = false;
  4711. T3 latestValue3 = default(T3);
  4712. bool hasValue4 = false;
  4713. bool isDone4 = false;
  4714. T4 latestValue4 = default(T4);
  4715. bool hasValue5 = false;
  4716. bool isDone5 = false;
  4717. T5 latestValue5 = default(T5);
  4718. bool hasValue6 = false;
  4719. bool isDone6 = false;
  4720. T6 latestValue6 = default(T6);
  4721. bool hasValue7 = false;
  4722. bool isDone7 = false;
  4723. T7 latestValue7 = default(T7);
  4724. bool hasValue8 = false;
  4725. bool isDone8 = false;
  4726. T8 latestValue8 = default(T8);
  4727. var gate = AsyncGate.Create();
  4728. return
  4729. (
  4730. Create<T1>(
  4731. async x =>
  4732. {
  4733. using (await gate.LockAsync().ConfigureAwait(false))
  4734. {
  4735. if (!hasValue1)
  4736. {
  4737. hasValue1 = true;
  4738. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4739. }
  4740. latestValue1 = x;
  4741. if (allHasValue)
  4742. {
  4743. TResult res;
  4744. try
  4745. {
  4746. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4747. }
  4748. catch (Exception ex)
  4749. {
  4750. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4751. return;
  4752. }
  4753. await observer.OnNextAsync(res).ConfigureAwait(false);
  4754. }
  4755. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4756. {
  4757. await observer.OnCompletedAsync().ConfigureAwait(false);
  4758. }
  4759. }
  4760. },
  4761. async ex =>
  4762. {
  4763. using (await gate.LockAsync().ConfigureAwait(false))
  4764. {
  4765. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4766. }
  4767. },
  4768. async () =>
  4769. {
  4770. using (await gate.LockAsync().ConfigureAwait(false))
  4771. {
  4772. isDone1 = true;
  4773. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4774. {
  4775. await observer.OnCompletedAsync().ConfigureAwait(false);
  4776. }
  4777. }
  4778. }
  4779. ),
  4780. Create<T2>(
  4781. async x =>
  4782. {
  4783. using (await gate.LockAsync().ConfigureAwait(false))
  4784. {
  4785. if (!hasValue2)
  4786. {
  4787. hasValue2 = true;
  4788. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4789. }
  4790. latestValue2 = x;
  4791. if (allHasValue)
  4792. {
  4793. TResult res;
  4794. try
  4795. {
  4796. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4797. }
  4798. catch (Exception ex)
  4799. {
  4800. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4801. return;
  4802. }
  4803. await observer.OnNextAsync(res).ConfigureAwait(false);
  4804. }
  4805. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4806. {
  4807. await observer.OnCompletedAsync().ConfigureAwait(false);
  4808. }
  4809. }
  4810. },
  4811. async ex =>
  4812. {
  4813. using (await gate.LockAsync().ConfigureAwait(false))
  4814. {
  4815. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4816. }
  4817. },
  4818. async () =>
  4819. {
  4820. using (await gate.LockAsync().ConfigureAwait(false))
  4821. {
  4822. isDone2 = true;
  4823. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4824. {
  4825. await observer.OnCompletedAsync().ConfigureAwait(false);
  4826. }
  4827. }
  4828. }
  4829. ),
  4830. Create<T3>(
  4831. async x =>
  4832. {
  4833. using (await gate.LockAsync().ConfigureAwait(false))
  4834. {
  4835. if (!hasValue3)
  4836. {
  4837. hasValue3 = true;
  4838. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4839. }
  4840. latestValue3 = x;
  4841. if (allHasValue)
  4842. {
  4843. TResult res;
  4844. try
  4845. {
  4846. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4847. }
  4848. catch (Exception ex)
  4849. {
  4850. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4851. return;
  4852. }
  4853. await observer.OnNextAsync(res).ConfigureAwait(false);
  4854. }
  4855. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4856. {
  4857. await observer.OnCompletedAsync().ConfigureAwait(false);
  4858. }
  4859. }
  4860. },
  4861. async ex =>
  4862. {
  4863. using (await gate.LockAsync().ConfigureAwait(false))
  4864. {
  4865. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4866. }
  4867. },
  4868. async () =>
  4869. {
  4870. using (await gate.LockAsync().ConfigureAwait(false))
  4871. {
  4872. isDone3 = true;
  4873. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4874. {
  4875. await observer.OnCompletedAsync().ConfigureAwait(false);
  4876. }
  4877. }
  4878. }
  4879. ),
  4880. Create<T4>(
  4881. async x =>
  4882. {
  4883. using (await gate.LockAsync().ConfigureAwait(false))
  4884. {
  4885. if (!hasValue4)
  4886. {
  4887. hasValue4 = true;
  4888. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4889. }
  4890. latestValue4 = x;
  4891. if (allHasValue)
  4892. {
  4893. TResult res;
  4894. try
  4895. {
  4896. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4897. }
  4898. catch (Exception ex)
  4899. {
  4900. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4901. return;
  4902. }
  4903. await observer.OnNextAsync(res).ConfigureAwait(false);
  4904. }
  4905. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8)
  4906. {
  4907. await observer.OnCompletedAsync().ConfigureAwait(false);
  4908. }
  4909. }
  4910. },
  4911. async ex =>
  4912. {
  4913. using (await gate.LockAsync().ConfigureAwait(false))
  4914. {
  4915. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4916. }
  4917. },
  4918. async () =>
  4919. {
  4920. using (await gate.LockAsync().ConfigureAwait(false))
  4921. {
  4922. isDone4 = true;
  4923. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4924. {
  4925. await observer.OnCompletedAsync().ConfigureAwait(false);
  4926. }
  4927. }
  4928. }
  4929. ),
  4930. Create<T5>(
  4931. async x =>
  4932. {
  4933. using (await gate.LockAsync().ConfigureAwait(false))
  4934. {
  4935. if (!hasValue5)
  4936. {
  4937. hasValue5 = true;
  4938. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4939. }
  4940. latestValue5 = x;
  4941. if (allHasValue)
  4942. {
  4943. TResult res;
  4944. try
  4945. {
  4946. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4947. }
  4948. catch (Exception ex)
  4949. {
  4950. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4951. return;
  4952. }
  4953. await observer.OnNextAsync(res).ConfigureAwait(false);
  4954. }
  4955. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8)
  4956. {
  4957. await observer.OnCompletedAsync().ConfigureAwait(false);
  4958. }
  4959. }
  4960. },
  4961. async ex =>
  4962. {
  4963. using (await gate.LockAsync().ConfigureAwait(false))
  4964. {
  4965. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  4966. }
  4967. },
  4968. async () =>
  4969. {
  4970. using (await gate.LockAsync().ConfigureAwait(false))
  4971. {
  4972. isDone5 = true;
  4973. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  4974. {
  4975. await observer.OnCompletedAsync().ConfigureAwait(false);
  4976. }
  4977. }
  4978. }
  4979. ),
  4980. Create<T6>(
  4981. async x =>
  4982. {
  4983. using (await gate.LockAsync().ConfigureAwait(false))
  4984. {
  4985. if (!hasValue6)
  4986. {
  4987. hasValue6 = true;
  4988. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  4989. }
  4990. latestValue6 = x;
  4991. if (allHasValue)
  4992. {
  4993. TResult res;
  4994. try
  4995. {
  4996. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  4997. }
  4998. catch (Exception ex)
  4999. {
  5000. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5001. return;
  5002. }
  5003. await observer.OnNextAsync(res).ConfigureAwait(false);
  5004. }
  5005. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8)
  5006. {
  5007. await observer.OnCompletedAsync().ConfigureAwait(false);
  5008. }
  5009. }
  5010. },
  5011. async ex =>
  5012. {
  5013. using (await gate.LockAsync().ConfigureAwait(false))
  5014. {
  5015. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5016. }
  5017. },
  5018. async () =>
  5019. {
  5020. using (await gate.LockAsync().ConfigureAwait(false))
  5021. {
  5022. isDone6 = true;
  5023. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  5024. {
  5025. await observer.OnCompletedAsync().ConfigureAwait(false);
  5026. }
  5027. }
  5028. }
  5029. ),
  5030. Create<T7>(
  5031. async x =>
  5032. {
  5033. using (await gate.LockAsync().ConfigureAwait(false))
  5034. {
  5035. if (!hasValue7)
  5036. {
  5037. hasValue7 = true;
  5038. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  5039. }
  5040. latestValue7 = x;
  5041. if (allHasValue)
  5042. {
  5043. TResult res;
  5044. try
  5045. {
  5046. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  5047. }
  5048. catch (Exception ex)
  5049. {
  5050. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5051. return;
  5052. }
  5053. await observer.OnNextAsync(res).ConfigureAwait(false);
  5054. }
  5055. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8)
  5056. {
  5057. await observer.OnCompletedAsync().ConfigureAwait(false);
  5058. }
  5059. }
  5060. },
  5061. async ex =>
  5062. {
  5063. using (await gate.LockAsync().ConfigureAwait(false))
  5064. {
  5065. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5066. }
  5067. },
  5068. async () =>
  5069. {
  5070. using (await gate.LockAsync().ConfigureAwait(false))
  5071. {
  5072. isDone7 = true;
  5073. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  5074. {
  5075. await observer.OnCompletedAsync().ConfigureAwait(false);
  5076. }
  5077. }
  5078. }
  5079. ),
  5080. Create<T8>(
  5081. async x =>
  5082. {
  5083. using (await gate.LockAsync().ConfigureAwait(false))
  5084. {
  5085. if (!hasValue8)
  5086. {
  5087. hasValue8 = true;
  5088. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8;
  5089. }
  5090. latestValue8 = x;
  5091. if (allHasValue)
  5092. {
  5093. TResult res;
  5094. try
  5095. {
  5096. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8).ConfigureAwait(false);
  5097. }
  5098. catch (Exception ex)
  5099. {
  5100. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5101. return;
  5102. }
  5103. await observer.OnNextAsync(res).ConfigureAwait(false);
  5104. }
  5105. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7)
  5106. {
  5107. await observer.OnCompletedAsync().ConfigureAwait(false);
  5108. }
  5109. }
  5110. },
  5111. async ex =>
  5112. {
  5113. using (await gate.LockAsync().ConfigureAwait(false))
  5114. {
  5115. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5116. }
  5117. },
  5118. async () =>
  5119. {
  5120. using (await gate.LockAsync().ConfigureAwait(false))
  5121. {
  5122. isDone8 = true;
  5123. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  5124. {
  5125. await observer.OnCompletedAsync().ConfigureAwait(false);
  5126. }
  5127. }
  5128. }
  5129. )
  5130. );
  5131. }
  5132. 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)
  5133. {
  5134. if (observer == null)
  5135. throw new ArgumentNullException(nameof(observer));
  5136. bool allHasValue = false;
  5137. bool hasValue1 = false;
  5138. bool isDone1 = false;
  5139. T1 latestValue1 = default(T1);
  5140. bool hasValue2 = false;
  5141. bool isDone2 = false;
  5142. T2 latestValue2 = default(T2);
  5143. bool hasValue3 = false;
  5144. bool isDone3 = false;
  5145. T3 latestValue3 = default(T3);
  5146. bool hasValue4 = false;
  5147. bool isDone4 = false;
  5148. T4 latestValue4 = default(T4);
  5149. bool hasValue5 = false;
  5150. bool isDone5 = false;
  5151. T5 latestValue5 = default(T5);
  5152. bool hasValue6 = false;
  5153. bool isDone6 = false;
  5154. T6 latestValue6 = default(T6);
  5155. bool hasValue7 = false;
  5156. bool isDone7 = false;
  5157. T7 latestValue7 = default(T7);
  5158. bool hasValue8 = false;
  5159. bool isDone8 = false;
  5160. T8 latestValue8 = default(T8);
  5161. bool hasValue9 = false;
  5162. bool isDone9 = false;
  5163. T9 latestValue9 = default(T9);
  5164. var gate = AsyncGate.Create();
  5165. return
  5166. (
  5167. Create<T1>(
  5168. async x =>
  5169. {
  5170. using (await gate.LockAsync().ConfigureAwait(false))
  5171. {
  5172. if (!hasValue1)
  5173. {
  5174. hasValue1 = true;
  5175. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5176. }
  5177. latestValue1 = x;
  5178. if (allHasValue)
  5179. {
  5180. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5181. }
  5182. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5183. {
  5184. await observer.OnCompletedAsync().ConfigureAwait(false);
  5185. }
  5186. }
  5187. },
  5188. async ex =>
  5189. {
  5190. using (await gate.LockAsync().ConfigureAwait(false))
  5191. {
  5192. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5193. }
  5194. },
  5195. async () =>
  5196. {
  5197. using (await gate.LockAsync().ConfigureAwait(false))
  5198. {
  5199. isDone1 = true;
  5200. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5201. {
  5202. await observer.OnCompletedAsync().ConfigureAwait(false);
  5203. }
  5204. }
  5205. }
  5206. ),
  5207. Create<T2>(
  5208. async x =>
  5209. {
  5210. using (await gate.LockAsync().ConfigureAwait(false))
  5211. {
  5212. if (!hasValue2)
  5213. {
  5214. hasValue2 = true;
  5215. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5216. }
  5217. latestValue2 = x;
  5218. if (allHasValue)
  5219. {
  5220. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5221. }
  5222. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5223. {
  5224. await observer.OnCompletedAsync().ConfigureAwait(false);
  5225. }
  5226. }
  5227. },
  5228. async ex =>
  5229. {
  5230. using (await gate.LockAsync().ConfigureAwait(false))
  5231. {
  5232. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5233. }
  5234. },
  5235. async () =>
  5236. {
  5237. using (await gate.LockAsync().ConfigureAwait(false))
  5238. {
  5239. isDone2 = true;
  5240. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5241. {
  5242. await observer.OnCompletedAsync().ConfigureAwait(false);
  5243. }
  5244. }
  5245. }
  5246. ),
  5247. Create<T3>(
  5248. async x =>
  5249. {
  5250. using (await gate.LockAsync().ConfigureAwait(false))
  5251. {
  5252. if (!hasValue3)
  5253. {
  5254. hasValue3 = true;
  5255. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5256. }
  5257. latestValue3 = x;
  5258. if (allHasValue)
  5259. {
  5260. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5261. }
  5262. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5263. {
  5264. await observer.OnCompletedAsync().ConfigureAwait(false);
  5265. }
  5266. }
  5267. },
  5268. async ex =>
  5269. {
  5270. using (await gate.LockAsync().ConfigureAwait(false))
  5271. {
  5272. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5273. }
  5274. },
  5275. async () =>
  5276. {
  5277. using (await gate.LockAsync().ConfigureAwait(false))
  5278. {
  5279. isDone3 = true;
  5280. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5281. {
  5282. await observer.OnCompletedAsync().ConfigureAwait(false);
  5283. }
  5284. }
  5285. }
  5286. ),
  5287. Create<T4>(
  5288. async x =>
  5289. {
  5290. using (await gate.LockAsync().ConfigureAwait(false))
  5291. {
  5292. if (!hasValue4)
  5293. {
  5294. hasValue4 = true;
  5295. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5296. }
  5297. latestValue4 = x;
  5298. if (allHasValue)
  5299. {
  5300. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5301. }
  5302. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5303. {
  5304. await observer.OnCompletedAsync().ConfigureAwait(false);
  5305. }
  5306. }
  5307. },
  5308. async ex =>
  5309. {
  5310. using (await gate.LockAsync().ConfigureAwait(false))
  5311. {
  5312. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5313. }
  5314. },
  5315. async () =>
  5316. {
  5317. using (await gate.LockAsync().ConfigureAwait(false))
  5318. {
  5319. isDone4 = true;
  5320. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5321. {
  5322. await observer.OnCompletedAsync().ConfigureAwait(false);
  5323. }
  5324. }
  5325. }
  5326. ),
  5327. Create<T5>(
  5328. async x =>
  5329. {
  5330. using (await gate.LockAsync().ConfigureAwait(false))
  5331. {
  5332. if (!hasValue5)
  5333. {
  5334. hasValue5 = true;
  5335. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5336. }
  5337. latestValue5 = x;
  5338. if (allHasValue)
  5339. {
  5340. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5341. }
  5342. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9)
  5343. {
  5344. await observer.OnCompletedAsync().ConfigureAwait(false);
  5345. }
  5346. }
  5347. },
  5348. async ex =>
  5349. {
  5350. using (await gate.LockAsync().ConfigureAwait(false))
  5351. {
  5352. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5353. }
  5354. },
  5355. async () =>
  5356. {
  5357. using (await gate.LockAsync().ConfigureAwait(false))
  5358. {
  5359. isDone5 = true;
  5360. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5361. {
  5362. await observer.OnCompletedAsync().ConfigureAwait(false);
  5363. }
  5364. }
  5365. }
  5366. ),
  5367. Create<T6>(
  5368. async x =>
  5369. {
  5370. using (await gate.LockAsync().ConfigureAwait(false))
  5371. {
  5372. if (!hasValue6)
  5373. {
  5374. hasValue6 = true;
  5375. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5376. }
  5377. latestValue6 = x;
  5378. if (allHasValue)
  5379. {
  5380. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5381. }
  5382. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9)
  5383. {
  5384. await observer.OnCompletedAsync().ConfigureAwait(false);
  5385. }
  5386. }
  5387. },
  5388. async ex =>
  5389. {
  5390. using (await gate.LockAsync().ConfigureAwait(false))
  5391. {
  5392. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5393. }
  5394. },
  5395. async () =>
  5396. {
  5397. using (await gate.LockAsync().ConfigureAwait(false))
  5398. {
  5399. isDone6 = true;
  5400. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5401. {
  5402. await observer.OnCompletedAsync().ConfigureAwait(false);
  5403. }
  5404. }
  5405. }
  5406. ),
  5407. Create<T7>(
  5408. async x =>
  5409. {
  5410. using (await gate.LockAsync().ConfigureAwait(false))
  5411. {
  5412. if (!hasValue7)
  5413. {
  5414. hasValue7 = true;
  5415. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5416. }
  5417. latestValue7 = x;
  5418. if (allHasValue)
  5419. {
  5420. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5421. }
  5422. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9)
  5423. {
  5424. await observer.OnCompletedAsync().ConfigureAwait(false);
  5425. }
  5426. }
  5427. },
  5428. async ex =>
  5429. {
  5430. using (await gate.LockAsync().ConfigureAwait(false))
  5431. {
  5432. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5433. }
  5434. },
  5435. async () =>
  5436. {
  5437. using (await gate.LockAsync().ConfigureAwait(false))
  5438. {
  5439. isDone7 = true;
  5440. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5441. {
  5442. await observer.OnCompletedAsync().ConfigureAwait(false);
  5443. }
  5444. }
  5445. }
  5446. ),
  5447. Create<T8>(
  5448. async x =>
  5449. {
  5450. using (await gate.LockAsync().ConfigureAwait(false))
  5451. {
  5452. if (!hasValue8)
  5453. {
  5454. hasValue8 = true;
  5455. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5456. }
  5457. latestValue8 = x;
  5458. if (allHasValue)
  5459. {
  5460. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5461. }
  5462. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9)
  5463. {
  5464. await observer.OnCompletedAsync().ConfigureAwait(false);
  5465. }
  5466. }
  5467. },
  5468. async ex =>
  5469. {
  5470. using (await gate.LockAsync().ConfigureAwait(false))
  5471. {
  5472. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5473. }
  5474. },
  5475. async () =>
  5476. {
  5477. using (await gate.LockAsync().ConfigureAwait(false))
  5478. {
  5479. isDone8 = true;
  5480. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5481. {
  5482. await observer.OnCompletedAsync().ConfigureAwait(false);
  5483. }
  5484. }
  5485. }
  5486. ),
  5487. Create<T9>(
  5488. async x =>
  5489. {
  5490. using (await gate.LockAsync().ConfigureAwait(false))
  5491. {
  5492. if (!hasValue9)
  5493. {
  5494. hasValue9 = true;
  5495. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5496. }
  5497. latestValue9 = x;
  5498. if (allHasValue)
  5499. {
  5500. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9)).ConfigureAwait(false);
  5501. }
  5502. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  5503. {
  5504. await observer.OnCompletedAsync().ConfigureAwait(false);
  5505. }
  5506. }
  5507. },
  5508. async ex =>
  5509. {
  5510. using (await gate.LockAsync().ConfigureAwait(false))
  5511. {
  5512. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5513. }
  5514. },
  5515. async () =>
  5516. {
  5517. using (await gate.LockAsync().ConfigureAwait(false))
  5518. {
  5519. isDone9 = true;
  5520. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5521. {
  5522. await observer.OnCompletedAsync().ConfigureAwait(false);
  5523. }
  5524. }
  5525. }
  5526. )
  5527. );
  5528. }
  5529. 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)
  5530. {
  5531. if (observer == null)
  5532. throw new ArgumentNullException(nameof(observer));
  5533. if (selector == null)
  5534. throw new ArgumentNullException(nameof(selector));
  5535. 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)));
  5536. }
  5537. 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)
  5538. {
  5539. if (observer == null)
  5540. throw new ArgumentNullException(nameof(observer));
  5541. if (selector == null)
  5542. throw new ArgumentNullException(nameof(selector));
  5543. bool allHasValue = false;
  5544. bool hasValue1 = false;
  5545. bool isDone1 = false;
  5546. T1 latestValue1 = default(T1);
  5547. bool hasValue2 = false;
  5548. bool isDone2 = false;
  5549. T2 latestValue2 = default(T2);
  5550. bool hasValue3 = false;
  5551. bool isDone3 = false;
  5552. T3 latestValue3 = default(T3);
  5553. bool hasValue4 = false;
  5554. bool isDone4 = false;
  5555. T4 latestValue4 = default(T4);
  5556. bool hasValue5 = false;
  5557. bool isDone5 = false;
  5558. T5 latestValue5 = default(T5);
  5559. bool hasValue6 = false;
  5560. bool isDone6 = false;
  5561. T6 latestValue6 = default(T6);
  5562. bool hasValue7 = false;
  5563. bool isDone7 = false;
  5564. T7 latestValue7 = default(T7);
  5565. bool hasValue8 = false;
  5566. bool isDone8 = false;
  5567. T8 latestValue8 = default(T8);
  5568. bool hasValue9 = false;
  5569. bool isDone9 = false;
  5570. T9 latestValue9 = default(T9);
  5571. var gate = AsyncGate.Create();
  5572. return
  5573. (
  5574. Create<T1>(
  5575. async x =>
  5576. {
  5577. using (await gate.LockAsync().ConfigureAwait(false))
  5578. {
  5579. if (!hasValue1)
  5580. {
  5581. hasValue1 = true;
  5582. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5583. }
  5584. latestValue1 = x;
  5585. if (allHasValue)
  5586. {
  5587. TResult res;
  5588. try
  5589. {
  5590. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5591. }
  5592. catch (Exception ex)
  5593. {
  5594. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5595. return;
  5596. }
  5597. await observer.OnNextAsync(res).ConfigureAwait(false);
  5598. }
  5599. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5600. {
  5601. await observer.OnCompletedAsync().ConfigureAwait(false);
  5602. }
  5603. }
  5604. },
  5605. async ex =>
  5606. {
  5607. using (await gate.LockAsync().ConfigureAwait(false))
  5608. {
  5609. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5610. }
  5611. },
  5612. async () =>
  5613. {
  5614. using (await gate.LockAsync().ConfigureAwait(false))
  5615. {
  5616. isDone1 = true;
  5617. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5618. {
  5619. await observer.OnCompletedAsync().ConfigureAwait(false);
  5620. }
  5621. }
  5622. }
  5623. ),
  5624. Create<T2>(
  5625. async x =>
  5626. {
  5627. using (await gate.LockAsync().ConfigureAwait(false))
  5628. {
  5629. if (!hasValue2)
  5630. {
  5631. hasValue2 = true;
  5632. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5633. }
  5634. latestValue2 = x;
  5635. if (allHasValue)
  5636. {
  5637. TResult res;
  5638. try
  5639. {
  5640. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5641. }
  5642. catch (Exception ex)
  5643. {
  5644. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5645. return;
  5646. }
  5647. await observer.OnNextAsync(res).ConfigureAwait(false);
  5648. }
  5649. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5650. {
  5651. await observer.OnCompletedAsync().ConfigureAwait(false);
  5652. }
  5653. }
  5654. },
  5655. async ex =>
  5656. {
  5657. using (await gate.LockAsync().ConfigureAwait(false))
  5658. {
  5659. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5660. }
  5661. },
  5662. async () =>
  5663. {
  5664. using (await gate.LockAsync().ConfigureAwait(false))
  5665. {
  5666. isDone2 = true;
  5667. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5668. {
  5669. await observer.OnCompletedAsync().ConfigureAwait(false);
  5670. }
  5671. }
  5672. }
  5673. ),
  5674. Create<T3>(
  5675. async x =>
  5676. {
  5677. using (await gate.LockAsync().ConfigureAwait(false))
  5678. {
  5679. if (!hasValue3)
  5680. {
  5681. hasValue3 = true;
  5682. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5683. }
  5684. latestValue3 = x;
  5685. if (allHasValue)
  5686. {
  5687. TResult res;
  5688. try
  5689. {
  5690. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5691. }
  5692. catch (Exception ex)
  5693. {
  5694. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5695. return;
  5696. }
  5697. await observer.OnNextAsync(res).ConfigureAwait(false);
  5698. }
  5699. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5700. {
  5701. await observer.OnCompletedAsync().ConfigureAwait(false);
  5702. }
  5703. }
  5704. },
  5705. async ex =>
  5706. {
  5707. using (await gate.LockAsync().ConfigureAwait(false))
  5708. {
  5709. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5710. }
  5711. },
  5712. async () =>
  5713. {
  5714. using (await gate.LockAsync().ConfigureAwait(false))
  5715. {
  5716. isDone3 = true;
  5717. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5718. {
  5719. await observer.OnCompletedAsync().ConfigureAwait(false);
  5720. }
  5721. }
  5722. }
  5723. ),
  5724. Create<T4>(
  5725. async x =>
  5726. {
  5727. using (await gate.LockAsync().ConfigureAwait(false))
  5728. {
  5729. if (!hasValue4)
  5730. {
  5731. hasValue4 = true;
  5732. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5733. }
  5734. latestValue4 = x;
  5735. if (allHasValue)
  5736. {
  5737. TResult res;
  5738. try
  5739. {
  5740. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5741. }
  5742. catch (Exception ex)
  5743. {
  5744. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5745. return;
  5746. }
  5747. await observer.OnNextAsync(res).ConfigureAwait(false);
  5748. }
  5749. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5750. {
  5751. await observer.OnCompletedAsync().ConfigureAwait(false);
  5752. }
  5753. }
  5754. },
  5755. async ex =>
  5756. {
  5757. using (await gate.LockAsync().ConfigureAwait(false))
  5758. {
  5759. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5760. }
  5761. },
  5762. async () =>
  5763. {
  5764. using (await gate.LockAsync().ConfigureAwait(false))
  5765. {
  5766. isDone4 = true;
  5767. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5768. {
  5769. await observer.OnCompletedAsync().ConfigureAwait(false);
  5770. }
  5771. }
  5772. }
  5773. ),
  5774. Create<T5>(
  5775. async x =>
  5776. {
  5777. using (await gate.LockAsync().ConfigureAwait(false))
  5778. {
  5779. if (!hasValue5)
  5780. {
  5781. hasValue5 = true;
  5782. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5783. }
  5784. latestValue5 = x;
  5785. if (allHasValue)
  5786. {
  5787. TResult res;
  5788. try
  5789. {
  5790. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5791. }
  5792. catch (Exception ex)
  5793. {
  5794. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5795. return;
  5796. }
  5797. await observer.OnNextAsync(res).ConfigureAwait(false);
  5798. }
  5799. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9)
  5800. {
  5801. await observer.OnCompletedAsync().ConfigureAwait(false);
  5802. }
  5803. }
  5804. },
  5805. async ex =>
  5806. {
  5807. using (await gate.LockAsync().ConfigureAwait(false))
  5808. {
  5809. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5810. }
  5811. },
  5812. async () =>
  5813. {
  5814. using (await gate.LockAsync().ConfigureAwait(false))
  5815. {
  5816. isDone5 = true;
  5817. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5818. {
  5819. await observer.OnCompletedAsync().ConfigureAwait(false);
  5820. }
  5821. }
  5822. }
  5823. ),
  5824. Create<T6>(
  5825. async x =>
  5826. {
  5827. using (await gate.LockAsync().ConfigureAwait(false))
  5828. {
  5829. if (!hasValue6)
  5830. {
  5831. hasValue6 = true;
  5832. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5833. }
  5834. latestValue6 = x;
  5835. if (allHasValue)
  5836. {
  5837. TResult res;
  5838. try
  5839. {
  5840. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5841. }
  5842. catch (Exception ex)
  5843. {
  5844. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5845. return;
  5846. }
  5847. await observer.OnNextAsync(res).ConfigureAwait(false);
  5848. }
  5849. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9)
  5850. {
  5851. await observer.OnCompletedAsync().ConfigureAwait(false);
  5852. }
  5853. }
  5854. },
  5855. async ex =>
  5856. {
  5857. using (await gate.LockAsync().ConfigureAwait(false))
  5858. {
  5859. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5860. }
  5861. },
  5862. async () =>
  5863. {
  5864. using (await gate.LockAsync().ConfigureAwait(false))
  5865. {
  5866. isDone6 = true;
  5867. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5868. {
  5869. await observer.OnCompletedAsync().ConfigureAwait(false);
  5870. }
  5871. }
  5872. }
  5873. ),
  5874. Create<T7>(
  5875. async x =>
  5876. {
  5877. using (await gate.LockAsync().ConfigureAwait(false))
  5878. {
  5879. if (!hasValue7)
  5880. {
  5881. hasValue7 = true;
  5882. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5883. }
  5884. latestValue7 = x;
  5885. if (allHasValue)
  5886. {
  5887. TResult res;
  5888. try
  5889. {
  5890. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5891. }
  5892. catch (Exception ex)
  5893. {
  5894. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5895. return;
  5896. }
  5897. await observer.OnNextAsync(res).ConfigureAwait(false);
  5898. }
  5899. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9)
  5900. {
  5901. await observer.OnCompletedAsync().ConfigureAwait(false);
  5902. }
  5903. }
  5904. },
  5905. async ex =>
  5906. {
  5907. using (await gate.LockAsync().ConfigureAwait(false))
  5908. {
  5909. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5910. }
  5911. },
  5912. async () =>
  5913. {
  5914. using (await gate.LockAsync().ConfigureAwait(false))
  5915. {
  5916. isDone7 = true;
  5917. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5918. {
  5919. await observer.OnCompletedAsync().ConfigureAwait(false);
  5920. }
  5921. }
  5922. }
  5923. ),
  5924. Create<T8>(
  5925. async x =>
  5926. {
  5927. using (await gate.LockAsync().ConfigureAwait(false))
  5928. {
  5929. if (!hasValue8)
  5930. {
  5931. hasValue8 = true;
  5932. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5933. }
  5934. latestValue8 = x;
  5935. if (allHasValue)
  5936. {
  5937. TResult res;
  5938. try
  5939. {
  5940. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5941. }
  5942. catch (Exception ex)
  5943. {
  5944. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5945. return;
  5946. }
  5947. await observer.OnNextAsync(res).ConfigureAwait(false);
  5948. }
  5949. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9)
  5950. {
  5951. await observer.OnCompletedAsync().ConfigureAwait(false);
  5952. }
  5953. }
  5954. },
  5955. async ex =>
  5956. {
  5957. using (await gate.LockAsync().ConfigureAwait(false))
  5958. {
  5959. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5960. }
  5961. },
  5962. async () =>
  5963. {
  5964. using (await gate.LockAsync().ConfigureAwait(false))
  5965. {
  5966. isDone8 = true;
  5967. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  5968. {
  5969. await observer.OnCompletedAsync().ConfigureAwait(false);
  5970. }
  5971. }
  5972. }
  5973. ),
  5974. Create<T9>(
  5975. async x =>
  5976. {
  5977. using (await gate.LockAsync().ConfigureAwait(false))
  5978. {
  5979. if (!hasValue9)
  5980. {
  5981. hasValue9 = true;
  5982. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9;
  5983. }
  5984. latestValue9 = x;
  5985. if (allHasValue)
  5986. {
  5987. TResult res;
  5988. try
  5989. {
  5990. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9).ConfigureAwait(false);
  5991. }
  5992. catch (Exception ex)
  5993. {
  5994. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  5995. return;
  5996. }
  5997. await observer.OnNextAsync(res).ConfigureAwait(false);
  5998. }
  5999. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8)
  6000. {
  6001. await observer.OnCompletedAsync().ConfigureAwait(false);
  6002. }
  6003. }
  6004. },
  6005. async ex =>
  6006. {
  6007. using (await gate.LockAsync().ConfigureAwait(false))
  6008. {
  6009. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6010. }
  6011. },
  6012. async () =>
  6013. {
  6014. using (await gate.LockAsync().ConfigureAwait(false))
  6015. {
  6016. isDone9 = true;
  6017. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  6018. {
  6019. await observer.OnCompletedAsync().ConfigureAwait(false);
  6020. }
  6021. }
  6022. }
  6023. )
  6024. );
  6025. }
  6026. 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)
  6027. {
  6028. if (observer == null)
  6029. throw new ArgumentNullException(nameof(observer));
  6030. bool allHasValue = false;
  6031. bool hasValue1 = false;
  6032. bool isDone1 = false;
  6033. T1 latestValue1 = default(T1);
  6034. bool hasValue2 = false;
  6035. bool isDone2 = false;
  6036. T2 latestValue2 = default(T2);
  6037. bool hasValue3 = false;
  6038. bool isDone3 = false;
  6039. T3 latestValue3 = default(T3);
  6040. bool hasValue4 = false;
  6041. bool isDone4 = false;
  6042. T4 latestValue4 = default(T4);
  6043. bool hasValue5 = false;
  6044. bool isDone5 = false;
  6045. T5 latestValue5 = default(T5);
  6046. bool hasValue6 = false;
  6047. bool isDone6 = false;
  6048. T6 latestValue6 = default(T6);
  6049. bool hasValue7 = false;
  6050. bool isDone7 = false;
  6051. T7 latestValue7 = default(T7);
  6052. bool hasValue8 = false;
  6053. bool isDone8 = false;
  6054. T8 latestValue8 = default(T8);
  6055. bool hasValue9 = false;
  6056. bool isDone9 = false;
  6057. T9 latestValue9 = default(T9);
  6058. bool hasValue10 = false;
  6059. bool isDone10 = false;
  6060. T10 latestValue10 = default(T10);
  6061. var gate = AsyncGate.Create();
  6062. return
  6063. (
  6064. Create<T1>(
  6065. async x =>
  6066. {
  6067. using (await gate.LockAsync().ConfigureAwait(false))
  6068. {
  6069. if (!hasValue1)
  6070. {
  6071. hasValue1 = true;
  6072. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6073. }
  6074. latestValue1 = x;
  6075. if (allHasValue)
  6076. {
  6077. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6078. }
  6079. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6080. {
  6081. await observer.OnCompletedAsync().ConfigureAwait(false);
  6082. }
  6083. }
  6084. },
  6085. async ex =>
  6086. {
  6087. using (await gate.LockAsync().ConfigureAwait(false))
  6088. {
  6089. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6090. }
  6091. },
  6092. async () =>
  6093. {
  6094. using (await gate.LockAsync().ConfigureAwait(false))
  6095. {
  6096. isDone1 = true;
  6097. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6098. {
  6099. await observer.OnCompletedAsync().ConfigureAwait(false);
  6100. }
  6101. }
  6102. }
  6103. ),
  6104. Create<T2>(
  6105. async x =>
  6106. {
  6107. using (await gate.LockAsync().ConfigureAwait(false))
  6108. {
  6109. if (!hasValue2)
  6110. {
  6111. hasValue2 = true;
  6112. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6113. }
  6114. latestValue2 = x;
  6115. if (allHasValue)
  6116. {
  6117. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6118. }
  6119. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6120. {
  6121. await observer.OnCompletedAsync().ConfigureAwait(false);
  6122. }
  6123. }
  6124. },
  6125. async ex =>
  6126. {
  6127. using (await gate.LockAsync().ConfigureAwait(false))
  6128. {
  6129. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6130. }
  6131. },
  6132. async () =>
  6133. {
  6134. using (await gate.LockAsync().ConfigureAwait(false))
  6135. {
  6136. isDone2 = true;
  6137. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6138. {
  6139. await observer.OnCompletedAsync().ConfigureAwait(false);
  6140. }
  6141. }
  6142. }
  6143. ),
  6144. Create<T3>(
  6145. async x =>
  6146. {
  6147. using (await gate.LockAsync().ConfigureAwait(false))
  6148. {
  6149. if (!hasValue3)
  6150. {
  6151. hasValue3 = true;
  6152. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6153. }
  6154. latestValue3 = x;
  6155. if (allHasValue)
  6156. {
  6157. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6158. }
  6159. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6160. {
  6161. await observer.OnCompletedAsync().ConfigureAwait(false);
  6162. }
  6163. }
  6164. },
  6165. async ex =>
  6166. {
  6167. using (await gate.LockAsync().ConfigureAwait(false))
  6168. {
  6169. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6170. }
  6171. },
  6172. async () =>
  6173. {
  6174. using (await gate.LockAsync().ConfigureAwait(false))
  6175. {
  6176. isDone3 = true;
  6177. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6178. {
  6179. await observer.OnCompletedAsync().ConfigureAwait(false);
  6180. }
  6181. }
  6182. }
  6183. ),
  6184. Create<T4>(
  6185. async x =>
  6186. {
  6187. using (await gate.LockAsync().ConfigureAwait(false))
  6188. {
  6189. if (!hasValue4)
  6190. {
  6191. hasValue4 = true;
  6192. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6193. }
  6194. latestValue4 = x;
  6195. if (allHasValue)
  6196. {
  6197. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6198. }
  6199. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6200. {
  6201. await observer.OnCompletedAsync().ConfigureAwait(false);
  6202. }
  6203. }
  6204. },
  6205. async ex =>
  6206. {
  6207. using (await gate.LockAsync().ConfigureAwait(false))
  6208. {
  6209. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6210. }
  6211. },
  6212. async () =>
  6213. {
  6214. using (await gate.LockAsync().ConfigureAwait(false))
  6215. {
  6216. isDone4 = true;
  6217. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6218. {
  6219. await observer.OnCompletedAsync().ConfigureAwait(false);
  6220. }
  6221. }
  6222. }
  6223. ),
  6224. Create<T5>(
  6225. async x =>
  6226. {
  6227. using (await gate.LockAsync().ConfigureAwait(false))
  6228. {
  6229. if (!hasValue5)
  6230. {
  6231. hasValue5 = true;
  6232. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6233. }
  6234. latestValue5 = x;
  6235. if (allHasValue)
  6236. {
  6237. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6238. }
  6239. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6240. {
  6241. await observer.OnCompletedAsync().ConfigureAwait(false);
  6242. }
  6243. }
  6244. },
  6245. async ex =>
  6246. {
  6247. using (await gate.LockAsync().ConfigureAwait(false))
  6248. {
  6249. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6250. }
  6251. },
  6252. async () =>
  6253. {
  6254. using (await gate.LockAsync().ConfigureAwait(false))
  6255. {
  6256. isDone5 = true;
  6257. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6258. {
  6259. await observer.OnCompletedAsync().ConfigureAwait(false);
  6260. }
  6261. }
  6262. }
  6263. ),
  6264. Create<T6>(
  6265. async x =>
  6266. {
  6267. using (await gate.LockAsync().ConfigureAwait(false))
  6268. {
  6269. if (!hasValue6)
  6270. {
  6271. hasValue6 = true;
  6272. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6273. }
  6274. latestValue6 = x;
  6275. if (allHasValue)
  6276. {
  6277. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6278. }
  6279. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10)
  6280. {
  6281. await observer.OnCompletedAsync().ConfigureAwait(false);
  6282. }
  6283. }
  6284. },
  6285. async ex =>
  6286. {
  6287. using (await gate.LockAsync().ConfigureAwait(false))
  6288. {
  6289. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6290. }
  6291. },
  6292. async () =>
  6293. {
  6294. using (await gate.LockAsync().ConfigureAwait(false))
  6295. {
  6296. isDone6 = true;
  6297. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6298. {
  6299. await observer.OnCompletedAsync().ConfigureAwait(false);
  6300. }
  6301. }
  6302. }
  6303. ),
  6304. Create<T7>(
  6305. async x =>
  6306. {
  6307. using (await gate.LockAsync().ConfigureAwait(false))
  6308. {
  6309. if (!hasValue7)
  6310. {
  6311. hasValue7 = true;
  6312. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6313. }
  6314. latestValue7 = x;
  6315. if (allHasValue)
  6316. {
  6317. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6318. }
  6319. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10)
  6320. {
  6321. await observer.OnCompletedAsync().ConfigureAwait(false);
  6322. }
  6323. }
  6324. },
  6325. async ex =>
  6326. {
  6327. using (await gate.LockAsync().ConfigureAwait(false))
  6328. {
  6329. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6330. }
  6331. },
  6332. async () =>
  6333. {
  6334. using (await gate.LockAsync().ConfigureAwait(false))
  6335. {
  6336. isDone7 = true;
  6337. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6338. {
  6339. await observer.OnCompletedAsync().ConfigureAwait(false);
  6340. }
  6341. }
  6342. }
  6343. ),
  6344. Create<T8>(
  6345. async x =>
  6346. {
  6347. using (await gate.LockAsync().ConfigureAwait(false))
  6348. {
  6349. if (!hasValue8)
  6350. {
  6351. hasValue8 = true;
  6352. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6353. }
  6354. latestValue8 = x;
  6355. if (allHasValue)
  6356. {
  6357. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6358. }
  6359. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10)
  6360. {
  6361. await observer.OnCompletedAsync().ConfigureAwait(false);
  6362. }
  6363. }
  6364. },
  6365. async ex =>
  6366. {
  6367. using (await gate.LockAsync().ConfigureAwait(false))
  6368. {
  6369. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6370. }
  6371. },
  6372. async () =>
  6373. {
  6374. using (await gate.LockAsync().ConfigureAwait(false))
  6375. {
  6376. isDone8 = true;
  6377. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6378. {
  6379. await observer.OnCompletedAsync().ConfigureAwait(false);
  6380. }
  6381. }
  6382. }
  6383. ),
  6384. Create<T9>(
  6385. async x =>
  6386. {
  6387. using (await gate.LockAsync().ConfigureAwait(false))
  6388. {
  6389. if (!hasValue9)
  6390. {
  6391. hasValue9 = true;
  6392. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6393. }
  6394. latestValue9 = x;
  6395. if (allHasValue)
  6396. {
  6397. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6398. }
  6399. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10)
  6400. {
  6401. await observer.OnCompletedAsync().ConfigureAwait(false);
  6402. }
  6403. }
  6404. },
  6405. async ex =>
  6406. {
  6407. using (await gate.LockAsync().ConfigureAwait(false))
  6408. {
  6409. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6410. }
  6411. },
  6412. async () =>
  6413. {
  6414. using (await gate.LockAsync().ConfigureAwait(false))
  6415. {
  6416. isDone9 = true;
  6417. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6418. {
  6419. await observer.OnCompletedAsync().ConfigureAwait(false);
  6420. }
  6421. }
  6422. }
  6423. ),
  6424. Create<T10>(
  6425. async x =>
  6426. {
  6427. using (await gate.LockAsync().ConfigureAwait(false))
  6428. {
  6429. if (!hasValue10)
  6430. {
  6431. hasValue10 = true;
  6432. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6433. }
  6434. latestValue10 = x;
  6435. if (allHasValue)
  6436. {
  6437. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10)).ConfigureAwait(false);
  6438. }
  6439. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  6440. {
  6441. await observer.OnCompletedAsync().ConfigureAwait(false);
  6442. }
  6443. }
  6444. },
  6445. async ex =>
  6446. {
  6447. using (await gate.LockAsync().ConfigureAwait(false))
  6448. {
  6449. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6450. }
  6451. },
  6452. async () =>
  6453. {
  6454. using (await gate.LockAsync().ConfigureAwait(false))
  6455. {
  6456. isDone10 = true;
  6457. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6458. {
  6459. await observer.OnCompletedAsync().ConfigureAwait(false);
  6460. }
  6461. }
  6462. }
  6463. )
  6464. );
  6465. }
  6466. 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)
  6467. {
  6468. if (observer == null)
  6469. throw new ArgumentNullException(nameof(observer));
  6470. if (selector == null)
  6471. throw new ArgumentNullException(nameof(selector));
  6472. 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)));
  6473. }
  6474. 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)
  6475. {
  6476. if (observer == null)
  6477. throw new ArgumentNullException(nameof(observer));
  6478. if (selector == null)
  6479. throw new ArgumentNullException(nameof(selector));
  6480. bool allHasValue = false;
  6481. bool hasValue1 = false;
  6482. bool isDone1 = false;
  6483. T1 latestValue1 = default(T1);
  6484. bool hasValue2 = false;
  6485. bool isDone2 = false;
  6486. T2 latestValue2 = default(T2);
  6487. bool hasValue3 = false;
  6488. bool isDone3 = false;
  6489. T3 latestValue3 = default(T3);
  6490. bool hasValue4 = false;
  6491. bool isDone4 = false;
  6492. T4 latestValue4 = default(T4);
  6493. bool hasValue5 = false;
  6494. bool isDone5 = false;
  6495. T5 latestValue5 = default(T5);
  6496. bool hasValue6 = false;
  6497. bool isDone6 = false;
  6498. T6 latestValue6 = default(T6);
  6499. bool hasValue7 = false;
  6500. bool isDone7 = false;
  6501. T7 latestValue7 = default(T7);
  6502. bool hasValue8 = false;
  6503. bool isDone8 = false;
  6504. T8 latestValue8 = default(T8);
  6505. bool hasValue9 = false;
  6506. bool isDone9 = false;
  6507. T9 latestValue9 = default(T9);
  6508. bool hasValue10 = false;
  6509. bool isDone10 = false;
  6510. T10 latestValue10 = default(T10);
  6511. var gate = AsyncGate.Create();
  6512. return
  6513. (
  6514. Create<T1>(
  6515. async x =>
  6516. {
  6517. using (await gate.LockAsync().ConfigureAwait(false))
  6518. {
  6519. if (!hasValue1)
  6520. {
  6521. hasValue1 = true;
  6522. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6523. }
  6524. latestValue1 = x;
  6525. if (allHasValue)
  6526. {
  6527. TResult res;
  6528. try
  6529. {
  6530. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6531. }
  6532. catch (Exception ex)
  6533. {
  6534. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6535. return;
  6536. }
  6537. await observer.OnNextAsync(res).ConfigureAwait(false);
  6538. }
  6539. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6540. {
  6541. await observer.OnCompletedAsync().ConfigureAwait(false);
  6542. }
  6543. }
  6544. },
  6545. async ex =>
  6546. {
  6547. using (await gate.LockAsync().ConfigureAwait(false))
  6548. {
  6549. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6550. }
  6551. },
  6552. async () =>
  6553. {
  6554. using (await gate.LockAsync().ConfigureAwait(false))
  6555. {
  6556. isDone1 = true;
  6557. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6558. {
  6559. await observer.OnCompletedAsync().ConfigureAwait(false);
  6560. }
  6561. }
  6562. }
  6563. ),
  6564. Create<T2>(
  6565. async x =>
  6566. {
  6567. using (await gate.LockAsync().ConfigureAwait(false))
  6568. {
  6569. if (!hasValue2)
  6570. {
  6571. hasValue2 = true;
  6572. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6573. }
  6574. latestValue2 = x;
  6575. if (allHasValue)
  6576. {
  6577. TResult res;
  6578. try
  6579. {
  6580. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6581. }
  6582. catch (Exception ex)
  6583. {
  6584. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6585. return;
  6586. }
  6587. await observer.OnNextAsync(res).ConfigureAwait(false);
  6588. }
  6589. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6590. {
  6591. await observer.OnCompletedAsync().ConfigureAwait(false);
  6592. }
  6593. }
  6594. },
  6595. async ex =>
  6596. {
  6597. using (await gate.LockAsync().ConfigureAwait(false))
  6598. {
  6599. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6600. }
  6601. },
  6602. async () =>
  6603. {
  6604. using (await gate.LockAsync().ConfigureAwait(false))
  6605. {
  6606. isDone2 = true;
  6607. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6608. {
  6609. await observer.OnCompletedAsync().ConfigureAwait(false);
  6610. }
  6611. }
  6612. }
  6613. ),
  6614. Create<T3>(
  6615. async x =>
  6616. {
  6617. using (await gate.LockAsync().ConfigureAwait(false))
  6618. {
  6619. if (!hasValue3)
  6620. {
  6621. hasValue3 = true;
  6622. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6623. }
  6624. latestValue3 = x;
  6625. if (allHasValue)
  6626. {
  6627. TResult res;
  6628. try
  6629. {
  6630. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6631. }
  6632. catch (Exception ex)
  6633. {
  6634. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6635. return;
  6636. }
  6637. await observer.OnNextAsync(res).ConfigureAwait(false);
  6638. }
  6639. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6640. {
  6641. await observer.OnCompletedAsync().ConfigureAwait(false);
  6642. }
  6643. }
  6644. },
  6645. async ex =>
  6646. {
  6647. using (await gate.LockAsync().ConfigureAwait(false))
  6648. {
  6649. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6650. }
  6651. },
  6652. async () =>
  6653. {
  6654. using (await gate.LockAsync().ConfigureAwait(false))
  6655. {
  6656. isDone3 = true;
  6657. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6658. {
  6659. await observer.OnCompletedAsync().ConfigureAwait(false);
  6660. }
  6661. }
  6662. }
  6663. ),
  6664. Create<T4>(
  6665. async x =>
  6666. {
  6667. using (await gate.LockAsync().ConfigureAwait(false))
  6668. {
  6669. if (!hasValue4)
  6670. {
  6671. hasValue4 = true;
  6672. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6673. }
  6674. latestValue4 = x;
  6675. if (allHasValue)
  6676. {
  6677. TResult res;
  6678. try
  6679. {
  6680. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6681. }
  6682. catch (Exception ex)
  6683. {
  6684. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6685. return;
  6686. }
  6687. await observer.OnNextAsync(res).ConfigureAwait(false);
  6688. }
  6689. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6690. {
  6691. await observer.OnCompletedAsync().ConfigureAwait(false);
  6692. }
  6693. }
  6694. },
  6695. async ex =>
  6696. {
  6697. using (await gate.LockAsync().ConfigureAwait(false))
  6698. {
  6699. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6700. }
  6701. },
  6702. async () =>
  6703. {
  6704. using (await gate.LockAsync().ConfigureAwait(false))
  6705. {
  6706. isDone4 = true;
  6707. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6708. {
  6709. await observer.OnCompletedAsync().ConfigureAwait(false);
  6710. }
  6711. }
  6712. }
  6713. ),
  6714. Create<T5>(
  6715. async x =>
  6716. {
  6717. using (await gate.LockAsync().ConfigureAwait(false))
  6718. {
  6719. if (!hasValue5)
  6720. {
  6721. hasValue5 = true;
  6722. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6723. }
  6724. latestValue5 = x;
  6725. if (allHasValue)
  6726. {
  6727. TResult res;
  6728. try
  6729. {
  6730. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6731. }
  6732. catch (Exception ex)
  6733. {
  6734. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6735. return;
  6736. }
  6737. await observer.OnNextAsync(res).ConfigureAwait(false);
  6738. }
  6739. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6740. {
  6741. await observer.OnCompletedAsync().ConfigureAwait(false);
  6742. }
  6743. }
  6744. },
  6745. async ex =>
  6746. {
  6747. using (await gate.LockAsync().ConfigureAwait(false))
  6748. {
  6749. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6750. }
  6751. },
  6752. async () =>
  6753. {
  6754. using (await gate.LockAsync().ConfigureAwait(false))
  6755. {
  6756. isDone5 = true;
  6757. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6758. {
  6759. await observer.OnCompletedAsync().ConfigureAwait(false);
  6760. }
  6761. }
  6762. }
  6763. ),
  6764. Create<T6>(
  6765. async x =>
  6766. {
  6767. using (await gate.LockAsync().ConfigureAwait(false))
  6768. {
  6769. if (!hasValue6)
  6770. {
  6771. hasValue6 = true;
  6772. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6773. }
  6774. latestValue6 = x;
  6775. if (allHasValue)
  6776. {
  6777. TResult res;
  6778. try
  6779. {
  6780. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6781. }
  6782. catch (Exception ex)
  6783. {
  6784. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6785. return;
  6786. }
  6787. await observer.OnNextAsync(res).ConfigureAwait(false);
  6788. }
  6789. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10)
  6790. {
  6791. await observer.OnCompletedAsync().ConfigureAwait(false);
  6792. }
  6793. }
  6794. },
  6795. async ex =>
  6796. {
  6797. using (await gate.LockAsync().ConfigureAwait(false))
  6798. {
  6799. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6800. }
  6801. },
  6802. async () =>
  6803. {
  6804. using (await gate.LockAsync().ConfigureAwait(false))
  6805. {
  6806. isDone6 = true;
  6807. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6808. {
  6809. await observer.OnCompletedAsync().ConfigureAwait(false);
  6810. }
  6811. }
  6812. }
  6813. ),
  6814. Create<T7>(
  6815. async x =>
  6816. {
  6817. using (await gate.LockAsync().ConfigureAwait(false))
  6818. {
  6819. if (!hasValue7)
  6820. {
  6821. hasValue7 = true;
  6822. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6823. }
  6824. latestValue7 = x;
  6825. if (allHasValue)
  6826. {
  6827. TResult res;
  6828. try
  6829. {
  6830. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6831. }
  6832. catch (Exception ex)
  6833. {
  6834. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6835. return;
  6836. }
  6837. await observer.OnNextAsync(res).ConfigureAwait(false);
  6838. }
  6839. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10)
  6840. {
  6841. await observer.OnCompletedAsync().ConfigureAwait(false);
  6842. }
  6843. }
  6844. },
  6845. async ex =>
  6846. {
  6847. using (await gate.LockAsync().ConfigureAwait(false))
  6848. {
  6849. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6850. }
  6851. },
  6852. async () =>
  6853. {
  6854. using (await gate.LockAsync().ConfigureAwait(false))
  6855. {
  6856. isDone7 = true;
  6857. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6858. {
  6859. await observer.OnCompletedAsync().ConfigureAwait(false);
  6860. }
  6861. }
  6862. }
  6863. ),
  6864. Create<T8>(
  6865. async x =>
  6866. {
  6867. using (await gate.LockAsync().ConfigureAwait(false))
  6868. {
  6869. if (!hasValue8)
  6870. {
  6871. hasValue8 = true;
  6872. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6873. }
  6874. latestValue8 = x;
  6875. if (allHasValue)
  6876. {
  6877. TResult res;
  6878. try
  6879. {
  6880. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6881. }
  6882. catch (Exception ex)
  6883. {
  6884. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6885. return;
  6886. }
  6887. await observer.OnNextAsync(res).ConfigureAwait(false);
  6888. }
  6889. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10)
  6890. {
  6891. await observer.OnCompletedAsync().ConfigureAwait(false);
  6892. }
  6893. }
  6894. },
  6895. async ex =>
  6896. {
  6897. using (await gate.LockAsync().ConfigureAwait(false))
  6898. {
  6899. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6900. }
  6901. },
  6902. async () =>
  6903. {
  6904. using (await gate.LockAsync().ConfigureAwait(false))
  6905. {
  6906. isDone8 = true;
  6907. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6908. {
  6909. await observer.OnCompletedAsync().ConfigureAwait(false);
  6910. }
  6911. }
  6912. }
  6913. ),
  6914. Create<T9>(
  6915. async x =>
  6916. {
  6917. using (await gate.LockAsync().ConfigureAwait(false))
  6918. {
  6919. if (!hasValue9)
  6920. {
  6921. hasValue9 = true;
  6922. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6923. }
  6924. latestValue9 = x;
  6925. if (allHasValue)
  6926. {
  6927. TResult res;
  6928. try
  6929. {
  6930. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6931. }
  6932. catch (Exception ex)
  6933. {
  6934. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6935. return;
  6936. }
  6937. await observer.OnNextAsync(res).ConfigureAwait(false);
  6938. }
  6939. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10)
  6940. {
  6941. await observer.OnCompletedAsync().ConfigureAwait(false);
  6942. }
  6943. }
  6944. },
  6945. async ex =>
  6946. {
  6947. using (await gate.LockAsync().ConfigureAwait(false))
  6948. {
  6949. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6950. }
  6951. },
  6952. async () =>
  6953. {
  6954. using (await gate.LockAsync().ConfigureAwait(false))
  6955. {
  6956. isDone9 = true;
  6957. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  6958. {
  6959. await observer.OnCompletedAsync().ConfigureAwait(false);
  6960. }
  6961. }
  6962. }
  6963. ),
  6964. Create<T10>(
  6965. async x =>
  6966. {
  6967. using (await gate.LockAsync().ConfigureAwait(false))
  6968. {
  6969. if (!hasValue10)
  6970. {
  6971. hasValue10 = true;
  6972. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10;
  6973. }
  6974. latestValue10 = x;
  6975. if (allHasValue)
  6976. {
  6977. TResult res;
  6978. try
  6979. {
  6980. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10).ConfigureAwait(false);
  6981. }
  6982. catch (Exception ex)
  6983. {
  6984. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  6985. return;
  6986. }
  6987. await observer.OnNextAsync(res).ConfigureAwait(false);
  6988. }
  6989. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9)
  6990. {
  6991. await observer.OnCompletedAsync().ConfigureAwait(false);
  6992. }
  6993. }
  6994. },
  6995. async ex =>
  6996. {
  6997. using (await gate.LockAsync().ConfigureAwait(false))
  6998. {
  6999. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7000. }
  7001. },
  7002. async () =>
  7003. {
  7004. using (await gate.LockAsync().ConfigureAwait(false))
  7005. {
  7006. isDone10 = true;
  7007. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  7008. {
  7009. await observer.OnCompletedAsync().ConfigureAwait(false);
  7010. }
  7011. }
  7012. }
  7013. )
  7014. );
  7015. }
  7016. 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)
  7017. {
  7018. if (observer == null)
  7019. throw new ArgumentNullException(nameof(observer));
  7020. bool allHasValue = false;
  7021. bool hasValue1 = false;
  7022. bool isDone1 = false;
  7023. T1 latestValue1 = default(T1);
  7024. bool hasValue2 = false;
  7025. bool isDone2 = false;
  7026. T2 latestValue2 = default(T2);
  7027. bool hasValue3 = false;
  7028. bool isDone3 = false;
  7029. T3 latestValue3 = default(T3);
  7030. bool hasValue4 = false;
  7031. bool isDone4 = false;
  7032. T4 latestValue4 = default(T4);
  7033. bool hasValue5 = false;
  7034. bool isDone5 = false;
  7035. T5 latestValue5 = default(T5);
  7036. bool hasValue6 = false;
  7037. bool isDone6 = false;
  7038. T6 latestValue6 = default(T6);
  7039. bool hasValue7 = false;
  7040. bool isDone7 = false;
  7041. T7 latestValue7 = default(T7);
  7042. bool hasValue8 = false;
  7043. bool isDone8 = false;
  7044. T8 latestValue8 = default(T8);
  7045. bool hasValue9 = false;
  7046. bool isDone9 = false;
  7047. T9 latestValue9 = default(T9);
  7048. bool hasValue10 = false;
  7049. bool isDone10 = false;
  7050. T10 latestValue10 = default(T10);
  7051. bool hasValue11 = false;
  7052. bool isDone11 = false;
  7053. T11 latestValue11 = default(T11);
  7054. var gate = AsyncGate.Create();
  7055. return
  7056. (
  7057. Create<T1>(
  7058. async x =>
  7059. {
  7060. using (await gate.LockAsync().ConfigureAwait(false))
  7061. {
  7062. if (!hasValue1)
  7063. {
  7064. hasValue1 = true;
  7065. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7066. }
  7067. latestValue1 = x;
  7068. if (allHasValue)
  7069. {
  7070. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7071. }
  7072. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7073. {
  7074. await observer.OnCompletedAsync().ConfigureAwait(false);
  7075. }
  7076. }
  7077. },
  7078. async ex =>
  7079. {
  7080. using (await gate.LockAsync().ConfigureAwait(false))
  7081. {
  7082. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7083. }
  7084. },
  7085. async () =>
  7086. {
  7087. using (await gate.LockAsync().ConfigureAwait(false))
  7088. {
  7089. isDone1 = true;
  7090. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7091. {
  7092. await observer.OnCompletedAsync().ConfigureAwait(false);
  7093. }
  7094. }
  7095. }
  7096. ),
  7097. Create<T2>(
  7098. async x =>
  7099. {
  7100. using (await gate.LockAsync().ConfigureAwait(false))
  7101. {
  7102. if (!hasValue2)
  7103. {
  7104. hasValue2 = true;
  7105. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7106. }
  7107. latestValue2 = x;
  7108. if (allHasValue)
  7109. {
  7110. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7111. }
  7112. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7113. {
  7114. await observer.OnCompletedAsync().ConfigureAwait(false);
  7115. }
  7116. }
  7117. },
  7118. async ex =>
  7119. {
  7120. using (await gate.LockAsync().ConfigureAwait(false))
  7121. {
  7122. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7123. }
  7124. },
  7125. async () =>
  7126. {
  7127. using (await gate.LockAsync().ConfigureAwait(false))
  7128. {
  7129. isDone2 = true;
  7130. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7131. {
  7132. await observer.OnCompletedAsync().ConfigureAwait(false);
  7133. }
  7134. }
  7135. }
  7136. ),
  7137. Create<T3>(
  7138. async x =>
  7139. {
  7140. using (await gate.LockAsync().ConfigureAwait(false))
  7141. {
  7142. if (!hasValue3)
  7143. {
  7144. hasValue3 = true;
  7145. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7146. }
  7147. latestValue3 = x;
  7148. if (allHasValue)
  7149. {
  7150. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7151. }
  7152. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7153. {
  7154. await observer.OnCompletedAsync().ConfigureAwait(false);
  7155. }
  7156. }
  7157. },
  7158. async ex =>
  7159. {
  7160. using (await gate.LockAsync().ConfigureAwait(false))
  7161. {
  7162. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7163. }
  7164. },
  7165. async () =>
  7166. {
  7167. using (await gate.LockAsync().ConfigureAwait(false))
  7168. {
  7169. isDone3 = true;
  7170. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7171. {
  7172. await observer.OnCompletedAsync().ConfigureAwait(false);
  7173. }
  7174. }
  7175. }
  7176. ),
  7177. Create<T4>(
  7178. async x =>
  7179. {
  7180. using (await gate.LockAsync().ConfigureAwait(false))
  7181. {
  7182. if (!hasValue4)
  7183. {
  7184. hasValue4 = true;
  7185. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7186. }
  7187. latestValue4 = x;
  7188. if (allHasValue)
  7189. {
  7190. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7191. }
  7192. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7193. {
  7194. await observer.OnCompletedAsync().ConfigureAwait(false);
  7195. }
  7196. }
  7197. },
  7198. async ex =>
  7199. {
  7200. using (await gate.LockAsync().ConfigureAwait(false))
  7201. {
  7202. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7203. }
  7204. },
  7205. async () =>
  7206. {
  7207. using (await gate.LockAsync().ConfigureAwait(false))
  7208. {
  7209. isDone4 = true;
  7210. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7211. {
  7212. await observer.OnCompletedAsync().ConfigureAwait(false);
  7213. }
  7214. }
  7215. }
  7216. ),
  7217. Create<T5>(
  7218. async x =>
  7219. {
  7220. using (await gate.LockAsync().ConfigureAwait(false))
  7221. {
  7222. if (!hasValue5)
  7223. {
  7224. hasValue5 = true;
  7225. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7226. }
  7227. latestValue5 = x;
  7228. if (allHasValue)
  7229. {
  7230. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7231. }
  7232. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7233. {
  7234. await observer.OnCompletedAsync().ConfigureAwait(false);
  7235. }
  7236. }
  7237. },
  7238. async ex =>
  7239. {
  7240. using (await gate.LockAsync().ConfigureAwait(false))
  7241. {
  7242. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7243. }
  7244. },
  7245. async () =>
  7246. {
  7247. using (await gate.LockAsync().ConfigureAwait(false))
  7248. {
  7249. isDone5 = true;
  7250. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7251. {
  7252. await observer.OnCompletedAsync().ConfigureAwait(false);
  7253. }
  7254. }
  7255. }
  7256. ),
  7257. Create<T6>(
  7258. async x =>
  7259. {
  7260. using (await gate.LockAsync().ConfigureAwait(false))
  7261. {
  7262. if (!hasValue6)
  7263. {
  7264. hasValue6 = true;
  7265. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7266. }
  7267. latestValue6 = x;
  7268. if (allHasValue)
  7269. {
  7270. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7271. }
  7272. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7273. {
  7274. await observer.OnCompletedAsync().ConfigureAwait(false);
  7275. }
  7276. }
  7277. },
  7278. async ex =>
  7279. {
  7280. using (await gate.LockAsync().ConfigureAwait(false))
  7281. {
  7282. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7283. }
  7284. },
  7285. async () =>
  7286. {
  7287. using (await gate.LockAsync().ConfigureAwait(false))
  7288. {
  7289. isDone6 = true;
  7290. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7291. {
  7292. await observer.OnCompletedAsync().ConfigureAwait(false);
  7293. }
  7294. }
  7295. }
  7296. ),
  7297. Create<T7>(
  7298. async x =>
  7299. {
  7300. using (await gate.LockAsync().ConfigureAwait(false))
  7301. {
  7302. if (!hasValue7)
  7303. {
  7304. hasValue7 = true;
  7305. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7306. }
  7307. latestValue7 = x;
  7308. if (allHasValue)
  7309. {
  7310. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7311. }
  7312. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11)
  7313. {
  7314. await observer.OnCompletedAsync().ConfigureAwait(false);
  7315. }
  7316. }
  7317. },
  7318. async ex =>
  7319. {
  7320. using (await gate.LockAsync().ConfigureAwait(false))
  7321. {
  7322. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7323. }
  7324. },
  7325. async () =>
  7326. {
  7327. using (await gate.LockAsync().ConfigureAwait(false))
  7328. {
  7329. isDone7 = true;
  7330. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7331. {
  7332. await observer.OnCompletedAsync().ConfigureAwait(false);
  7333. }
  7334. }
  7335. }
  7336. ),
  7337. Create<T8>(
  7338. async x =>
  7339. {
  7340. using (await gate.LockAsync().ConfigureAwait(false))
  7341. {
  7342. if (!hasValue8)
  7343. {
  7344. hasValue8 = true;
  7345. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7346. }
  7347. latestValue8 = x;
  7348. if (allHasValue)
  7349. {
  7350. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7351. }
  7352. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11)
  7353. {
  7354. await observer.OnCompletedAsync().ConfigureAwait(false);
  7355. }
  7356. }
  7357. },
  7358. async ex =>
  7359. {
  7360. using (await gate.LockAsync().ConfigureAwait(false))
  7361. {
  7362. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7363. }
  7364. },
  7365. async () =>
  7366. {
  7367. using (await gate.LockAsync().ConfigureAwait(false))
  7368. {
  7369. isDone8 = true;
  7370. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7371. {
  7372. await observer.OnCompletedAsync().ConfigureAwait(false);
  7373. }
  7374. }
  7375. }
  7376. ),
  7377. Create<T9>(
  7378. async x =>
  7379. {
  7380. using (await gate.LockAsync().ConfigureAwait(false))
  7381. {
  7382. if (!hasValue9)
  7383. {
  7384. hasValue9 = true;
  7385. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7386. }
  7387. latestValue9 = x;
  7388. if (allHasValue)
  7389. {
  7390. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7391. }
  7392. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11)
  7393. {
  7394. await observer.OnCompletedAsync().ConfigureAwait(false);
  7395. }
  7396. }
  7397. },
  7398. async ex =>
  7399. {
  7400. using (await gate.LockAsync().ConfigureAwait(false))
  7401. {
  7402. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7403. }
  7404. },
  7405. async () =>
  7406. {
  7407. using (await gate.LockAsync().ConfigureAwait(false))
  7408. {
  7409. isDone9 = true;
  7410. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7411. {
  7412. await observer.OnCompletedAsync().ConfigureAwait(false);
  7413. }
  7414. }
  7415. }
  7416. ),
  7417. Create<T10>(
  7418. async x =>
  7419. {
  7420. using (await gate.LockAsync().ConfigureAwait(false))
  7421. {
  7422. if (!hasValue10)
  7423. {
  7424. hasValue10 = true;
  7425. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7426. }
  7427. latestValue10 = x;
  7428. if (allHasValue)
  7429. {
  7430. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7431. }
  7432. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11)
  7433. {
  7434. await observer.OnCompletedAsync().ConfigureAwait(false);
  7435. }
  7436. }
  7437. },
  7438. async ex =>
  7439. {
  7440. using (await gate.LockAsync().ConfigureAwait(false))
  7441. {
  7442. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7443. }
  7444. },
  7445. async () =>
  7446. {
  7447. using (await gate.LockAsync().ConfigureAwait(false))
  7448. {
  7449. isDone10 = true;
  7450. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7451. {
  7452. await observer.OnCompletedAsync().ConfigureAwait(false);
  7453. }
  7454. }
  7455. }
  7456. ),
  7457. Create<T11>(
  7458. async x =>
  7459. {
  7460. using (await gate.LockAsync().ConfigureAwait(false))
  7461. {
  7462. if (!hasValue11)
  7463. {
  7464. hasValue11 = true;
  7465. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7466. }
  7467. latestValue11 = x;
  7468. if (allHasValue)
  7469. {
  7470. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11)).ConfigureAwait(false);
  7471. }
  7472. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  7473. {
  7474. await observer.OnCompletedAsync().ConfigureAwait(false);
  7475. }
  7476. }
  7477. },
  7478. async ex =>
  7479. {
  7480. using (await gate.LockAsync().ConfigureAwait(false))
  7481. {
  7482. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7483. }
  7484. },
  7485. async () =>
  7486. {
  7487. using (await gate.LockAsync().ConfigureAwait(false))
  7488. {
  7489. isDone11 = true;
  7490. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7491. {
  7492. await observer.OnCompletedAsync().ConfigureAwait(false);
  7493. }
  7494. }
  7495. }
  7496. )
  7497. );
  7498. }
  7499. 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)
  7500. {
  7501. if (observer == null)
  7502. throw new ArgumentNullException(nameof(observer));
  7503. if (selector == null)
  7504. throw new ArgumentNullException(nameof(selector));
  7505. 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)));
  7506. }
  7507. 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)
  7508. {
  7509. if (observer == null)
  7510. throw new ArgumentNullException(nameof(observer));
  7511. if (selector == null)
  7512. throw new ArgumentNullException(nameof(selector));
  7513. bool allHasValue = false;
  7514. bool hasValue1 = false;
  7515. bool isDone1 = false;
  7516. T1 latestValue1 = default(T1);
  7517. bool hasValue2 = false;
  7518. bool isDone2 = false;
  7519. T2 latestValue2 = default(T2);
  7520. bool hasValue3 = false;
  7521. bool isDone3 = false;
  7522. T3 latestValue3 = default(T3);
  7523. bool hasValue4 = false;
  7524. bool isDone4 = false;
  7525. T4 latestValue4 = default(T4);
  7526. bool hasValue5 = false;
  7527. bool isDone5 = false;
  7528. T5 latestValue5 = default(T5);
  7529. bool hasValue6 = false;
  7530. bool isDone6 = false;
  7531. T6 latestValue6 = default(T6);
  7532. bool hasValue7 = false;
  7533. bool isDone7 = false;
  7534. T7 latestValue7 = default(T7);
  7535. bool hasValue8 = false;
  7536. bool isDone8 = false;
  7537. T8 latestValue8 = default(T8);
  7538. bool hasValue9 = false;
  7539. bool isDone9 = false;
  7540. T9 latestValue9 = default(T9);
  7541. bool hasValue10 = false;
  7542. bool isDone10 = false;
  7543. T10 latestValue10 = default(T10);
  7544. bool hasValue11 = false;
  7545. bool isDone11 = false;
  7546. T11 latestValue11 = default(T11);
  7547. var gate = AsyncGate.Create();
  7548. return
  7549. (
  7550. Create<T1>(
  7551. async x =>
  7552. {
  7553. using (await gate.LockAsync().ConfigureAwait(false))
  7554. {
  7555. if (!hasValue1)
  7556. {
  7557. hasValue1 = true;
  7558. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7559. }
  7560. latestValue1 = x;
  7561. if (allHasValue)
  7562. {
  7563. TResult res;
  7564. try
  7565. {
  7566. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7567. }
  7568. catch (Exception ex)
  7569. {
  7570. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7571. return;
  7572. }
  7573. await observer.OnNextAsync(res).ConfigureAwait(false);
  7574. }
  7575. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7576. {
  7577. await observer.OnCompletedAsync().ConfigureAwait(false);
  7578. }
  7579. }
  7580. },
  7581. async ex =>
  7582. {
  7583. using (await gate.LockAsync().ConfigureAwait(false))
  7584. {
  7585. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7586. }
  7587. },
  7588. async () =>
  7589. {
  7590. using (await gate.LockAsync().ConfigureAwait(false))
  7591. {
  7592. isDone1 = true;
  7593. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7594. {
  7595. await observer.OnCompletedAsync().ConfigureAwait(false);
  7596. }
  7597. }
  7598. }
  7599. ),
  7600. Create<T2>(
  7601. async x =>
  7602. {
  7603. using (await gate.LockAsync().ConfigureAwait(false))
  7604. {
  7605. if (!hasValue2)
  7606. {
  7607. hasValue2 = true;
  7608. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7609. }
  7610. latestValue2 = x;
  7611. if (allHasValue)
  7612. {
  7613. TResult res;
  7614. try
  7615. {
  7616. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7617. }
  7618. catch (Exception ex)
  7619. {
  7620. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7621. return;
  7622. }
  7623. await observer.OnNextAsync(res).ConfigureAwait(false);
  7624. }
  7625. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7626. {
  7627. await observer.OnCompletedAsync().ConfigureAwait(false);
  7628. }
  7629. }
  7630. },
  7631. async ex =>
  7632. {
  7633. using (await gate.LockAsync().ConfigureAwait(false))
  7634. {
  7635. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7636. }
  7637. },
  7638. async () =>
  7639. {
  7640. using (await gate.LockAsync().ConfigureAwait(false))
  7641. {
  7642. isDone2 = true;
  7643. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7644. {
  7645. await observer.OnCompletedAsync().ConfigureAwait(false);
  7646. }
  7647. }
  7648. }
  7649. ),
  7650. Create<T3>(
  7651. async x =>
  7652. {
  7653. using (await gate.LockAsync().ConfigureAwait(false))
  7654. {
  7655. if (!hasValue3)
  7656. {
  7657. hasValue3 = true;
  7658. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7659. }
  7660. latestValue3 = x;
  7661. if (allHasValue)
  7662. {
  7663. TResult res;
  7664. try
  7665. {
  7666. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7667. }
  7668. catch (Exception ex)
  7669. {
  7670. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7671. return;
  7672. }
  7673. await observer.OnNextAsync(res).ConfigureAwait(false);
  7674. }
  7675. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7676. {
  7677. await observer.OnCompletedAsync().ConfigureAwait(false);
  7678. }
  7679. }
  7680. },
  7681. async ex =>
  7682. {
  7683. using (await gate.LockAsync().ConfigureAwait(false))
  7684. {
  7685. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7686. }
  7687. },
  7688. async () =>
  7689. {
  7690. using (await gate.LockAsync().ConfigureAwait(false))
  7691. {
  7692. isDone3 = true;
  7693. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7694. {
  7695. await observer.OnCompletedAsync().ConfigureAwait(false);
  7696. }
  7697. }
  7698. }
  7699. ),
  7700. Create<T4>(
  7701. async x =>
  7702. {
  7703. using (await gate.LockAsync().ConfigureAwait(false))
  7704. {
  7705. if (!hasValue4)
  7706. {
  7707. hasValue4 = true;
  7708. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7709. }
  7710. latestValue4 = x;
  7711. if (allHasValue)
  7712. {
  7713. TResult res;
  7714. try
  7715. {
  7716. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7717. }
  7718. catch (Exception ex)
  7719. {
  7720. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7721. return;
  7722. }
  7723. await observer.OnNextAsync(res).ConfigureAwait(false);
  7724. }
  7725. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7726. {
  7727. await observer.OnCompletedAsync().ConfigureAwait(false);
  7728. }
  7729. }
  7730. },
  7731. async ex =>
  7732. {
  7733. using (await gate.LockAsync().ConfigureAwait(false))
  7734. {
  7735. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7736. }
  7737. },
  7738. async () =>
  7739. {
  7740. using (await gate.LockAsync().ConfigureAwait(false))
  7741. {
  7742. isDone4 = true;
  7743. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7744. {
  7745. await observer.OnCompletedAsync().ConfigureAwait(false);
  7746. }
  7747. }
  7748. }
  7749. ),
  7750. Create<T5>(
  7751. async x =>
  7752. {
  7753. using (await gate.LockAsync().ConfigureAwait(false))
  7754. {
  7755. if (!hasValue5)
  7756. {
  7757. hasValue5 = true;
  7758. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7759. }
  7760. latestValue5 = x;
  7761. if (allHasValue)
  7762. {
  7763. TResult res;
  7764. try
  7765. {
  7766. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7767. }
  7768. catch (Exception ex)
  7769. {
  7770. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7771. return;
  7772. }
  7773. await observer.OnNextAsync(res).ConfigureAwait(false);
  7774. }
  7775. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7776. {
  7777. await observer.OnCompletedAsync().ConfigureAwait(false);
  7778. }
  7779. }
  7780. },
  7781. async ex =>
  7782. {
  7783. using (await gate.LockAsync().ConfigureAwait(false))
  7784. {
  7785. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7786. }
  7787. },
  7788. async () =>
  7789. {
  7790. using (await gate.LockAsync().ConfigureAwait(false))
  7791. {
  7792. isDone5 = true;
  7793. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7794. {
  7795. await observer.OnCompletedAsync().ConfigureAwait(false);
  7796. }
  7797. }
  7798. }
  7799. ),
  7800. Create<T6>(
  7801. async x =>
  7802. {
  7803. using (await gate.LockAsync().ConfigureAwait(false))
  7804. {
  7805. if (!hasValue6)
  7806. {
  7807. hasValue6 = true;
  7808. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7809. }
  7810. latestValue6 = x;
  7811. if (allHasValue)
  7812. {
  7813. TResult res;
  7814. try
  7815. {
  7816. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7817. }
  7818. catch (Exception ex)
  7819. {
  7820. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7821. return;
  7822. }
  7823. await observer.OnNextAsync(res).ConfigureAwait(false);
  7824. }
  7825. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7826. {
  7827. await observer.OnCompletedAsync().ConfigureAwait(false);
  7828. }
  7829. }
  7830. },
  7831. async ex =>
  7832. {
  7833. using (await gate.LockAsync().ConfigureAwait(false))
  7834. {
  7835. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7836. }
  7837. },
  7838. async () =>
  7839. {
  7840. using (await gate.LockAsync().ConfigureAwait(false))
  7841. {
  7842. isDone6 = true;
  7843. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7844. {
  7845. await observer.OnCompletedAsync().ConfigureAwait(false);
  7846. }
  7847. }
  7848. }
  7849. ),
  7850. Create<T7>(
  7851. async x =>
  7852. {
  7853. using (await gate.LockAsync().ConfigureAwait(false))
  7854. {
  7855. if (!hasValue7)
  7856. {
  7857. hasValue7 = true;
  7858. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7859. }
  7860. latestValue7 = x;
  7861. if (allHasValue)
  7862. {
  7863. TResult res;
  7864. try
  7865. {
  7866. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7867. }
  7868. catch (Exception ex)
  7869. {
  7870. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7871. return;
  7872. }
  7873. await observer.OnNextAsync(res).ConfigureAwait(false);
  7874. }
  7875. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11)
  7876. {
  7877. await observer.OnCompletedAsync().ConfigureAwait(false);
  7878. }
  7879. }
  7880. },
  7881. async ex =>
  7882. {
  7883. using (await gate.LockAsync().ConfigureAwait(false))
  7884. {
  7885. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7886. }
  7887. },
  7888. async () =>
  7889. {
  7890. using (await gate.LockAsync().ConfigureAwait(false))
  7891. {
  7892. isDone7 = true;
  7893. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7894. {
  7895. await observer.OnCompletedAsync().ConfigureAwait(false);
  7896. }
  7897. }
  7898. }
  7899. ),
  7900. Create<T8>(
  7901. async x =>
  7902. {
  7903. using (await gate.LockAsync().ConfigureAwait(false))
  7904. {
  7905. if (!hasValue8)
  7906. {
  7907. hasValue8 = true;
  7908. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7909. }
  7910. latestValue8 = x;
  7911. if (allHasValue)
  7912. {
  7913. TResult res;
  7914. try
  7915. {
  7916. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7917. }
  7918. catch (Exception ex)
  7919. {
  7920. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7921. return;
  7922. }
  7923. await observer.OnNextAsync(res).ConfigureAwait(false);
  7924. }
  7925. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11)
  7926. {
  7927. await observer.OnCompletedAsync().ConfigureAwait(false);
  7928. }
  7929. }
  7930. },
  7931. async ex =>
  7932. {
  7933. using (await gate.LockAsync().ConfigureAwait(false))
  7934. {
  7935. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7936. }
  7937. },
  7938. async () =>
  7939. {
  7940. using (await gate.LockAsync().ConfigureAwait(false))
  7941. {
  7942. isDone8 = true;
  7943. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7944. {
  7945. await observer.OnCompletedAsync().ConfigureAwait(false);
  7946. }
  7947. }
  7948. }
  7949. ),
  7950. Create<T9>(
  7951. async x =>
  7952. {
  7953. using (await gate.LockAsync().ConfigureAwait(false))
  7954. {
  7955. if (!hasValue9)
  7956. {
  7957. hasValue9 = true;
  7958. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  7959. }
  7960. latestValue9 = x;
  7961. if (allHasValue)
  7962. {
  7963. TResult res;
  7964. try
  7965. {
  7966. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  7967. }
  7968. catch (Exception ex)
  7969. {
  7970. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7971. return;
  7972. }
  7973. await observer.OnNextAsync(res).ConfigureAwait(false);
  7974. }
  7975. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11)
  7976. {
  7977. await observer.OnCompletedAsync().ConfigureAwait(false);
  7978. }
  7979. }
  7980. },
  7981. async ex =>
  7982. {
  7983. using (await gate.LockAsync().ConfigureAwait(false))
  7984. {
  7985. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  7986. }
  7987. },
  7988. async () =>
  7989. {
  7990. using (await gate.LockAsync().ConfigureAwait(false))
  7991. {
  7992. isDone9 = true;
  7993. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  7994. {
  7995. await observer.OnCompletedAsync().ConfigureAwait(false);
  7996. }
  7997. }
  7998. }
  7999. ),
  8000. Create<T10>(
  8001. async x =>
  8002. {
  8003. using (await gate.LockAsync().ConfigureAwait(false))
  8004. {
  8005. if (!hasValue10)
  8006. {
  8007. hasValue10 = true;
  8008. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  8009. }
  8010. latestValue10 = x;
  8011. if (allHasValue)
  8012. {
  8013. TResult res;
  8014. try
  8015. {
  8016. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  8017. }
  8018. catch (Exception ex)
  8019. {
  8020. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8021. return;
  8022. }
  8023. await observer.OnNextAsync(res).ConfigureAwait(false);
  8024. }
  8025. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11)
  8026. {
  8027. await observer.OnCompletedAsync().ConfigureAwait(false);
  8028. }
  8029. }
  8030. },
  8031. async ex =>
  8032. {
  8033. using (await gate.LockAsync().ConfigureAwait(false))
  8034. {
  8035. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8036. }
  8037. },
  8038. async () =>
  8039. {
  8040. using (await gate.LockAsync().ConfigureAwait(false))
  8041. {
  8042. isDone10 = true;
  8043. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  8044. {
  8045. await observer.OnCompletedAsync().ConfigureAwait(false);
  8046. }
  8047. }
  8048. }
  8049. ),
  8050. Create<T11>(
  8051. async x =>
  8052. {
  8053. using (await gate.LockAsync().ConfigureAwait(false))
  8054. {
  8055. if (!hasValue11)
  8056. {
  8057. hasValue11 = true;
  8058. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11;
  8059. }
  8060. latestValue11 = x;
  8061. if (allHasValue)
  8062. {
  8063. TResult res;
  8064. try
  8065. {
  8066. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11).ConfigureAwait(false);
  8067. }
  8068. catch (Exception ex)
  8069. {
  8070. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8071. return;
  8072. }
  8073. await observer.OnNextAsync(res).ConfigureAwait(false);
  8074. }
  8075. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10)
  8076. {
  8077. await observer.OnCompletedAsync().ConfigureAwait(false);
  8078. }
  8079. }
  8080. },
  8081. async ex =>
  8082. {
  8083. using (await gate.LockAsync().ConfigureAwait(false))
  8084. {
  8085. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8086. }
  8087. },
  8088. async () =>
  8089. {
  8090. using (await gate.LockAsync().ConfigureAwait(false))
  8091. {
  8092. isDone11 = true;
  8093. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  8094. {
  8095. await observer.OnCompletedAsync().ConfigureAwait(false);
  8096. }
  8097. }
  8098. }
  8099. )
  8100. );
  8101. }
  8102. 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)
  8103. {
  8104. if (observer == null)
  8105. throw new ArgumentNullException(nameof(observer));
  8106. bool allHasValue = false;
  8107. bool hasValue1 = false;
  8108. bool isDone1 = false;
  8109. T1 latestValue1 = default(T1);
  8110. bool hasValue2 = false;
  8111. bool isDone2 = false;
  8112. T2 latestValue2 = default(T2);
  8113. bool hasValue3 = false;
  8114. bool isDone3 = false;
  8115. T3 latestValue3 = default(T3);
  8116. bool hasValue4 = false;
  8117. bool isDone4 = false;
  8118. T4 latestValue4 = default(T4);
  8119. bool hasValue5 = false;
  8120. bool isDone5 = false;
  8121. T5 latestValue5 = default(T5);
  8122. bool hasValue6 = false;
  8123. bool isDone6 = false;
  8124. T6 latestValue6 = default(T6);
  8125. bool hasValue7 = false;
  8126. bool isDone7 = false;
  8127. T7 latestValue7 = default(T7);
  8128. bool hasValue8 = false;
  8129. bool isDone8 = false;
  8130. T8 latestValue8 = default(T8);
  8131. bool hasValue9 = false;
  8132. bool isDone9 = false;
  8133. T9 latestValue9 = default(T9);
  8134. bool hasValue10 = false;
  8135. bool isDone10 = false;
  8136. T10 latestValue10 = default(T10);
  8137. bool hasValue11 = false;
  8138. bool isDone11 = false;
  8139. T11 latestValue11 = default(T11);
  8140. bool hasValue12 = false;
  8141. bool isDone12 = false;
  8142. T12 latestValue12 = default(T12);
  8143. var gate = AsyncGate.Create();
  8144. return
  8145. (
  8146. Create<T1>(
  8147. async x =>
  8148. {
  8149. using (await gate.LockAsync().ConfigureAwait(false))
  8150. {
  8151. if (!hasValue1)
  8152. {
  8153. hasValue1 = true;
  8154. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8155. }
  8156. latestValue1 = x;
  8157. if (allHasValue)
  8158. {
  8159. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8160. }
  8161. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8162. {
  8163. await observer.OnCompletedAsync().ConfigureAwait(false);
  8164. }
  8165. }
  8166. },
  8167. async ex =>
  8168. {
  8169. using (await gate.LockAsync().ConfigureAwait(false))
  8170. {
  8171. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8172. }
  8173. },
  8174. async () =>
  8175. {
  8176. using (await gate.LockAsync().ConfigureAwait(false))
  8177. {
  8178. isDone1 = true;
  8179. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8180. {
  8181. await observer.OnCompletedAsync().ConfigureAwait(false);
  8182. }
  8183. }
  8184. }
  8185. ),
  8186. Create<T2>(
  8187. async x =>
  8188. {
  8189. using (await gate.LockAsync().ConfigureAwait(false))
  8190. {
  8191. if (!hasValue2)
  8192. {
  8193. hasValue2 = true;
  8194. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8195. }
  8196. latestValue2 = x;
  8197. if (allHasValue)
  8198. {
  8199. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8200. }
  8201. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8202. {
  8203. await observer.OnCompletedAsync().ConfigureAwait(false);
  8204. }
  8205. }
  8206. },
  8207. async ex =>
  8208. {
  8209. using (await gate.LockAsync().ConfigureAwait(false))
  8210. {
  8211. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8212. }
  8213. },
  8214. async () =>
  8215. {
  8216. using (await gate.LockAsync().ConfigureAwait(false))
  8217. {
  8218. isDone2 = true;
  8219. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8220. {
  8221. await observer.OnCompletedAsync().ConfigureAwait(false);
  8222. }
  8223. }
  8224. }
  8225. ),
  8226. Create<T3>(
  8227. async x =>
  8228. {
  8229. using (await gate.LockAsync().ConfigureAwait(false))
  8230. {
  8231. if (!hasValue3)
  8232. {
  8233. hasValue3 = true;
  8234. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8235. }
  8236. latestValue3 = x;
  8237. if (allHasValue)
  8238. {
  8239. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8240. }
  8241. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8242. {
  8243. await observer.OnCompletedAsync().ConfigureAwait(false);
  8244. }
  8245. }
  8246. },
  8247. async ex =>
  8248. {
  8249. using (await gate.LockAsync().ConfigureAwait(false))
  8250. {
  8251. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8252. }
  8253. },
  8254. async () =>
  8255. {
  8256. using (await gate.LockAsync().ConfigureAwait(false))
  8257. {
  8258. isDone3 = true;
  8259. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8260. {
  8261. await observer.OnCompletedAsync().ConfigureAwait(false);
  8262. }
  8263. }
  8264. }
  8265. ),
  8266. Create<T4>(
  8267. async x =>
  8268. {
  8269. using (await gate.LockAsync().ConfigureAwait(false))
  8270. {
  8271. if (!hasValue4)
  8272. {
  8273. hasValue4 = true;
  8274. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8275. }
  8276. latestValue4 = x;
  8277. if (allHasValue)
  8278. {
  8279. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8280. }
  8281. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8282. {
  8283. await observer.OnCompletedAsync().ConfigureAwait(false);
  8284. }
  8285. }
  8286. },
  8287. async ex =>
  8288. {
  8289. using (await gate.LockAsync().ConfigureAwait(false))
  8290. {
  8291. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8292. }
  8293. },
  8294. async () =>
  8295. {
  8296. using (await gate.LockAsync().ConfigureAwait(false))
  8297. {
  8298. isDone4 = true;
  8299. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8300. {
  8301. await observer.OnCompletedAsync().ConfigureAwait(false);
  8302. }
  8303. }
  8304. }
  8305. ),
  8306. Create<T5>(
  8307. async x =>
  8308. {
  8309. using (await gate.LockAsync().ConfigureAwait(false))
  8310. {
  8311. if (!hasValue5)
  8312. {
  8313. hasValue5 = true;
  8314. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8315. }
  8316. latestValue5 = x;
  8317. if (allHasValue)
  8318. {
  8319. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8320. }
  8321. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8322. {
  8323. await observer.OnCompletedAsync().ConfigureAwait(false);
  8324. }
  8325. }
  8326. },
  8327. async ex =>
  8328. {
  8329. using (await gate.LockAsync().ConfigureAwait(false))
  8330. {
  8331. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8332. }
  8333. },
  8334. async () =>
  8335. {
  8336. using (await gate.LockAsync().ConfigureAwait(false))
  8337. {
  8338. isDone5 = true;
  8339. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8340. {
  8341. await observer.OnCompletedAsync().ConfigureAwait(false);
  8342. }
  8343. }
  8344. }
  8345. ),
  8346. Create<T6>(
  8347. async x =>
  8348. {
  8349. using (await gate.LockAsync().ConfigureAwait(false))
  8350. {
  8351. if (!hasValue6)
  8352. {
  8353. hasValue6 = true;
  8354. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8355. }
  8356. latestValue6 = x;
  8357. if (allHasValue)
  8358. {
  8359. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8360. }
  8361. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8362. {
  8363. await observer.OnCompletedAsync().ConfigureAwait(false);
  8364. }
  8365. }
  8366. },
  8367. async ex =>
  8368. {
  8369. using (await gate.LockAsync().ConfigureAwait(false))
  8370. {
  8371. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8372. }
  8373. },
  8374. async () =>
  8375. {
  8376. using (await gate.LockAsync().ConfigureAwait(false))
  8377. {
  8378. isDone6 = true;
  8379. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8380. {
  8381. await observer.OnCompletedAsync().ConfigureAwait(false);
  8382. }
  8383. }
  8384. }
  8385. ),
  8386. Create<T7>(
  8387. async x =>
  8388. {
  8389. using (await gate.LockAsync().ConfigureAwait(false))
  8390. {
  8391. if (!hasValue7)
  8392. {
  8393. hasValue7 = true;
  8394. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8395. }
  8396. latestValue7 = x;
  8397. if (allHasValue)
  8398. {
  8399. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8400. }
  8401. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8402. {
  8403. await observer.OnCompletedAsync().ConfigureAwait(false);
  8404. }
  8405. }
  8406. },
  8407. async ex =>
  8408. {
  8409. using (await gate.LockAsync().ConfigureAwait(false))
  8410. {
  8411. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8412. }
  8413. },
  8414. async () =>
  8415. {
  8416. using (await gate.LockAsync().ConfigureAwait(false))
  8417. {
  8418. isDone7 = true;
  8419. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8420. {
  8421. await observer.OnCompletedAsync().ConfigureAwait(false);
  8422. }
  8423. }
  8424. }
  8425. ),
  8426. Create<T8>(
  8427. async x =>
  8428. {
  8429. using (await gate.LockAsync().ConfigureAwait(false))
  8430. {
  8431. if (!hasValue8)
  8432. {
  8433. hasValue8 = true;
  8434. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8435. }
  8436. latestValue8 = x;
  8437. if (allHasValue)
  8438. {
  8439. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8440. }
  8441. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12)
  8442. {
  8443. await observer.OnCompletedAsync().ConfigureAwait(false);
  8444. }
  8445. }
  8446. },
  8447. async ex =>
  8448. {
  8449. using (await gate.LockAsync().ConfigureAwait(false))
  8450. {
  8451. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8452. }
  8453. },
  8454. async () =>
  8455. {
  8456. using (await gate.LockAsync().ConfigureAwait(false))
  8457. {
  8458. isDone8 = true;
  8459. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8460. {
  8461. await observer.OnCompletedAsync().ConfigureAwait(false);
  8462. }
  8463. }
  8464. }
  8465. ),
  8466. Create<T9>(
  8467. async x =>
  8468. {
  8469. using (await gate.LockAsync().ConfigureAwait(false))
  8470. {
  8471. if (!hasValue9)
  8472. {
  8473. hasValue9 = true;
  8474. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8475. }
  8476. latestValue9 = x;
  8477. if (allHasValue)
  8478. {
  8479. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8480. }
  8481. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12)
  8482. {
  8483. await observer.OnCompletedAsync().ConfigureAwait(false);
  8484. }
  8485. }
  8486. },
  8487. async ex =>
  8488. {
  8489. using (await gate.LockAsync().ConfigureAwait(false))
  8490. {
  8491. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8492. }
  8493. },
  8494. async () =>
  8495. {
  8496. using (await gate.LockAsync().ConfigureAwait(false))
  8497. {
  8498. isDone9 = true;
  8499. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8500. {
  8501. await observer.OnCompletedAsync().ConfigureAwait(false);
  8502. }
  8503. }
  8504. }
  8505. ),
  8506. Create<T10>(
  8507. async x =>
  8508. {
  8509. using (await gate.LockAsync().ConfigureAwait(false))
  8510. {
  8511. if (!hasValue10)
  8512. {
  8513. hasValue10 = true;
  8514. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8515. }
  8516. latestValue10 = x;
  8517. if (allHasValue)
  8518. {
  8519. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8520. }
  8521. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12)
  8522. {
  8523. await observer.OnCompletedAsync().ConfigureAwait(false);
  8524. }
  8525. }
  8526. },
  8527. async ex =>
  8528. {
  8529. using (await gate.LockAsync().ConfigureAwait(false))
  8530. {
  8531. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8532. }
  8533. },
  8534. async () =>
  8535. {
  8536. using (await gate.LockAsync().ConfigureAwait(false))
  8537. {
  8538. isDone10 = true;
  8539. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8540. {
  8541. await observer.OnCompletedAsync().ConfigureAwait(false);
  8542. }
  8543. }
  8544. }
  8545. ),
  8546. Create<T11>(
  8547. async x =>
  8548. {
  8549. using (await gate.LockAsync().ConfigureAwait(false))
  8550. {
  8551. if (!hasValue11)
  8552. {
  8553. hasValue11 = true;
  8554. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8555. }
  8556. latestValue11 = x;
  8557. if (allHasValue)
  8558. {
  8559. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8560. }
  8561. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12)
  8562. {
  8563. await observer.OnCompletedAsync().ConfigureAwait(false);
  8564. }
  8565. }
  8566. },
  8567. async ex =>
  8568. {
  8569. using (await gate.LockAsync().ConfigureAwait(false))
  8570. {
  8571. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8572. }
  8573. },
  8574. async () =>
  8575. {
  8576. using (await gate.LockAsync().ConfigureAwait(false))
  8577. {
  8578. isDone11 = true;
  8579. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8580. {
  8581. await observer.OnCompletedAsync().ConfigureAwait(false);
  8582. }
  8583. }
  8584. }
  8585. ),
  8586. Create<T12>(
  8587. async x =>
  8588. {
  8589. using (await gate.LockAsync().ConfigureAwait(false))
  8590. {
  8591. if (!hasValue12)
  8592. {
  8593. hasValue12 = true;
  8594. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8595. }
  8596. latestValue12 = x;
  8597. if (allHasValue)
  8598. {
  8599. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12)).ConfigureAwait(false);
  8600. }
  8601. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  8602. {
  8603. await observer.OnCompletedAsync().ConfigureAwait(false);
  8604. }
  8605. }
  8606. },
  8607. async ex =>
  8608. {
  8609. using (await gate.LockAsync().ConfigureAwait(false))
  8610. {
  8611. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8612. }
  8613. },
  8614. async () =>
  8615. {
  8616. using (await gate.LockAsync().ConfigureAwait(false))
  8617. {
  8618. isDone12 = true;
  8619. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8620. {
  8621. await observer.OnCompletedAsync().ConfigureAwait(false);
  8622. }
  8623. }
  8624. }
  8625. )
  8626. );
  8627. }
  8628. 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)
  8629. {
  8630. if (observer == null)
  8631. throw new ArgumentNullException(nameof(observer));
  8632. if (selector == null)
  8633. throw new ArgumentNullException(nameof(selector));
  8634. 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)));
  8635. }
  8636. 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)
  8637. {
  8638. if (observer == null)
  8639. throw new ArgumentNullException(nameof(observer));
  8640. if (selector == null)
  8641. throw new ArgumentNullException(nameof(selector));
  8642. bool allHasValue = false;
  8643. bool hasValue1 = false;
  8644. bool isDone1 = false;
  8645. T1 latestValue1 = default(T1);
  8646. bool hasValue2 = false;
  8647. bool isDone2 = false;
  8648. T2 latestValue2 = default(T2);
  8649. bool hasValue3 = false;
  8650. bool isDone3 = false;
  8651. T3 latestValue3 = default(T3);
  8652. bool hasValue4 = false;
  8653. bool isDone4 = false;
  8654. T4 latestValue4 = default(T4);
  8655. bool hasValue5 = false;
  8656. bool isDone5 = false;
  8657. T5 latestValue5 = default(T5);
  8658. bool hasValue6 = false;
  8659. bool isDone6 = false;
  8660. T6 latestValue6 = default(T6);
  8661. bool hasValue7 = false;
  8662. bool isDone7 = false;
  8663. T7 latestValue7 = default(T7);
  8664. bool hasValue8 = false;
  8665. bool isDone8 = false;
  8666. T8 latestValue8 = default(T8);
  8667. bool hasValue9 = false;
  8668. bool isDone9 = false;
  8669. T9 latestValue9 = default(T9);
  8670. bool hasValue10 = false;
  8671. bool isDone10 = false;
  8672. T10 latestValue10 = default(T10);
  8673. bool hasValue11 = false;
  8674. bool isDone11 = false;
  8675. T11 latestValue11 = default(T11);
  8676. bool hasValue12 = false;
  8677. bool isDone12 = false;
  8678. T12 latestValue12 = default(T12);
  8679. var gate = AsyncGate.Create();
  8680. return
  8681. (
  8682. Create<T1>(
  8683. async x =>
  8684. {
  8685. using (await gate.LockAsync().ConfigureAwait(false))
  8686. {
  8687. if (!hasValue1)
  8688. {
  8689. hasValue1 = true;
  8690. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8691. }
  8692. latestValue1 = x;
  8693. if (allHasValue)
  8694. {
  8695. TResult res;
  8696. try
  8697. {
  8698. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8699. }
  8700. catch (Exception ex)
  8701. {
  8702. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8703. return;
  8704. }
  8705. await observer.OnNextAsync(res).ConfigureAwait(false);
  8706. }
  8707. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8708. {
  8709. await observer.OnCompletedAsync().ConfigureAwait(false);
  8710. }
  8711. }
  8712. },
  8713. async ex =>
  8714. {
  8715. using (await gate.LockAsync().ConfigureAwait(false))
  8716. {
  8717. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8718. }
  8719. },
  8720. async () =>
  8721. {
  8722. using (await gate.LockAsync().ConfigureAwait(false))
  8723. {
  8724. isDone1 = true;
  8725. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8726. {
  8727. await observer.OnCompletedAsync().ConfigureAwait(false);
  8728. }
  8729. }
  8730. }
  8731. ),
  8732. Create<T2>(
  8733. async x =>
  8734. {
  8735. using (await gate.LockAsync().ConfigureAwait(false))
  8736. {
  8737. if (!hasValue2)
  8738. {
  8739. hasValue2 = true;
  8740. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8741. }
  8742. latestValue2 = x;
  8743. if (allHasValue)
  8744. {
  8745. TResult res;
  8746. try
  8747. {
  8748. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8749. }
  8750. catch (Exception ex)
  8751. {
  8752. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8753. return;
  8754. }
  8755. await observer.OnNextAsync(res).ConfigureAwait(false);
  8756. }
  8757. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8758. {
  8759. await observer.OnCompletedAsync().ConfigureAwait(false);
  8760. }
  8761. }
  8762. },
  8763. async ex =>
  8764. {
  8765. using (await gate.LockAsync().ConfigureAwait(false))
  8766. {
  8767. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8768. }
  8769. },
  8770. async () =>
  8771. {
  8772. using (await gate.LockAsync().ConfigureAwait(false))
  8773. {
  8774. isDone2 = true;
  8775. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8776. {
  8777. await observer.OnCompletedAsync().ConfigureAwait(false);
  8778. }
  8779. }
  8780. }
  8781. ),
  8782. Create<T3>(
  8783. async x =>
  8784. {
  8785. using (await gate.LockAsync().ConfigureAwait(false))
  8786. {
  8787. if (!hasValue3)
  8788. {
  8789. hasValue3 = true;
  8790. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8791. }
  8792. latestValue3 = x;
  8793. if (allHasValue)
  8794. {
  8795. TResult res;
  8796. try
  8797. {
  8798. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8799. }
  8800. catch (Exception ex)
  8801. {
  8802. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8803. return;
  8804. }
  8805. await observer.OnNextAsync(res).ConfigureAwait(false);
  8806. }
  8807. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8808. {
  8809. await observer.OnCompletedAsync().ConfigureAwait(false);
  8810. }
  8811. }
  8812. },
  8813. async ex =>
  8814. {
  8815. using (await gate.LockAsync().ConfigureAwait(false))
  8816. {
  8817. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8818. }
  8819. },
  8820. async () =>
  8821. {
  8822. using (await gate.LockAsync().ConfigureAwait(false))
  8823. {
  8824. isDone3 = true;
  8825. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8826. {
  8827. await observer.OnCompletedAsync().ConfigureAwait(false);
  8828. }
  8829. }
  8830. }
  8831. ),
  8832. Create<T4>(
  8833. async x =>
  8834. {
  8835. using (await gate.LockAsync().ConfigureAwait(false))
  8836. {
  8837. if (!hasValue4)
  8838. {
  8839. hasValue4 = true;
  8840. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8841. }
  8842. latestValue4 = x;
  8843. if (allHasValue)
  8844. {
  8845. TResult res;
  8846. try
  8847. {
  8848. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8849. }
  8850. catch (Exception ex)
  8851. {
  8852. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8853. return;
  8854. }
  8855. await observer.OnNextAsync(res).ConfigureAwait(false);
  8856. }
  8857. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8858. {
  8859. await observer.OnCompletedAsync().ConfigureAwait(false);
  8860. }
  8861. }
  8862. },
  8863. async ex =>
  8864. {
  8865. using (await gate.LockAsync().ConfigureAwait(false))
  8866. {
  8867. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8868. }
  8869. },
  8870. async () =>
  8871. {
  8872. using (await gate.LockAsync().ConfigureAwait(false))
  8873. {
  8874. isDone4 = true;
  8875. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8876. {
  8877. await observer.OnCompletedAsync().ConfigureAwait(false);
  8878. }
  8879. }
  8880. }
  8881. ),
  8882. Create<T5>(
  8883. async x =>
  8884. {
  8885. using (await gate.LockAsync().ConfigureAwait(false))
  8886. {
  8887. if (!hasValue5)
  8888. {
  8889. hasValue5 = true;
  8890. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8891. }
  8892. latestValue5 = x;
  8893. if (allHasValue)
  8894. {
  8895. TResult res;
  8896. try
  8897. {
  8898. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8899. }
  8900. catch (Exception ex)
  8901. {
  8902. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8903. return;
  8904. }
  8905. await observer.OnNextAsync(res).ConfigureAwait(false);
  8906. }
  8907. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8908. {
  8909. await observer.OnCompletedAsync().ConfigureAwait(false);
  8910. }
  8911. }
  8912. },
  8913. async ex =>
  8914. {
  8915. using (await gate.LockAsync().ConfigureAwait(false))
  8916. {
  8917. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8918. }
  8919. },
  8920. async () =>
  8921. {
  8922. using (await gate.LockAsync().ConfigureAwait(false))
  8923. {
  8924. isDone5 = true;
  8925. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8926. {
  8927. await observer.OnCompletedAsync().ConfigureAwait(false);
  8928. }
  8929. }
  8930. }
  8931. ),
  8932. Create<T6>(
  8933. async x =>
  8934. {
  8935. using (await gate.LockAsync().ConfigureAwait(false))
  8936. {
  8937. if (!hasValue6)
  8938. {
  8939. hasValue6 = true;
  8940. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8941. }
  8942. latestValue6 = x;
  8943. if (allHasValue)
  8944. {
  8945. TResult res;
  8946. try
  8947. {
  8948. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8949. }
  8950. catch (Exception ex)
  8951. {
  8952. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8953. return;
  8954. }
  8955. await observer.OnNextAsync(res).ConfigureAwait(false);
  8956. }
  8957. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8958. {
  8959. await observer.OnCompletedAsync().ConfigureAwait(false);
  8960. }
  8961. }
  8962. },
  8963. async ex =>
  8964. {
  8965. using (await gate.LockAsync().ConfigureAwait(false))
  8966. {
  8967. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  8968. }
  8969. },
  8970. async () =>
  8971. {
  8972. using (await gate.LockAsync().ConfigureAwait(false))
  8973. {
  8974. isDone6 = true;
  8975. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  8976. {
  8977. await observer.OnCompletedAsync().ConfigureAwait(false);
  8978. }
  8979. }
  8980. }
  8981. ),
  8982. Create<T7>(
  8983. async x =>
  8984. {
  8985. using (await gate.LockAsync().ConfigureAwait(false))
  8986. {
  8987. if (!hasValue7)
  8988. {
  8989. hasValue7 = true;
  8990. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  8991. }
  8992. latestValue7 = x;
  8993. if (allHasValue)
  8994. {
  8995. TResult res;
  8996. try
  8997. {
  8998. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  8999. }
  9000. catch (Exception ex)
  9001. {
  9002. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9003. return;
  9004. }
  9005. await observer.OnNextAsync(res).ConfigureAwait(false);
  9006. }
  9007. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9008. {
  9009. await observer.OnCompletedAsync().ConfigureAwait(false);
  9010. }
  9011. }
  9012. },
  9013. async ex =>
  9014. {
  9015. using (await gate.LockAsync().ConfigureAwait(false))
  9016. {
  9017. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9018. }
  9019. },
  9020. async () =>
  9021. {
  9022. using (await gate.LockAsync().ConfigureAwait(false))
  9023. {
  9024. isDone7 = true;
  9025. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9026. {
  9027. await observer.OnCompletedAsync().ConfigureAwait(false);
  9028. }
  9029. }
  9030. }
  9031. ),
  9032. Create<T8>(
  9033. async x =>
  9034. {
  9035. using (await gate.LockAsync().ConfigureAwait(false))
  9036. {
  9037. if (!hasValue8)
  9038. {
  9039. hasValue8 = true;
  9040. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  9041. }
  9042. latestValue8 = x;
  9043. if (allHasValue)
  9044. {
  9045. TResult res;
  9046. try
  9047. {
  9048. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  9049. }
  9050. catch (Exception ex)
  9051. {
  9052. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9053. return;
  9054. }
  9055. await observer.OnNextAsync(res).ConfigureAwait(false);
  9056. }
  9057. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12)
  9058. {
  9059. await observer.OnCompletedAsync().ConfigureAwait(false);
  9060. }
  9061. }
  9062. },
  9063. async ex =>
  9064. {
  9065. using (await gate.LockAsync().ConfigureAwait(false))
  9066. {
  9067. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9068. }
  9069. },
  9070. async () =>
  9071. {
  9072. using (await gate.LockAsync().ConfigureAwait(false))
  9073. {
  9074. isDone8 = true;
  9075. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9076. {
  9077. await observer.OnCompletedAsync().ConfigureAwait(false);
  9078. }
  9079. }
  9080. }
  9081. ),
  9082. Create<T9>(
  9083. async x =>
  9084. {
  9085. using (await gate.LockAsync().ConfigureAwait(false))
  9086. {
  9087. if (!hasValue9)
  9088. {
  9089. hasValue9 = true;
  9090. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  9091. }
  9092. latestValue9 = x;
  9093. if (allHasValue)
  9094. {
  9095. TResult res;
  9096. try
  9097. {
  9098. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  9099. }
  9100. catch (Exception ex)
  9101. {
  9102. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9103. return;
  9104. }
  9105. await observer.OnNextAsync(res).ConfigureAwait(false);
  9106. }
  9107. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12)
  9108. {
  9109. await observer.OnCompletedAsync().ConfigureAwait(false);
  9110. }
  9111. }
  9112. },
  9113. async ex =>
  9114. {
  9115. using (await gate.LockAsync().ConfigureAwait(false))
  9116. {
  9117. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9118. }
  9119. },
  9120. async () =>
  9121. {
  9122. using (await gate.LockAsync().ConfigureAwait(false))
  9123. {
  9124. isDone9 = true;
  9125. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9126. {
  9127. await observer.OnCompletedAsync().ConfigureAwait(false);
  9128. }
  9129. }
  9130. }
  9131. ),
  9132. Create<T10>(
  9133. async x =>
  9134. {
  9135. using (await gate.LockAsync().ConfigureAwait(false))
  9136. {
  9137. if (!hasValue10)
  9138. {
  9139. hasValue10 = true;
  9140. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  9141. }
  9142. latestValue10 = x;
  9143. if (allHasValue)
  9144. {
  9145. TResult res;
  9146. try
  9147. {
  9148. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  9149. }
  9150. catch (Exception ex)
  9151. {
  9152. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9153. return;
  9154. }
  9155. await observer.OnNextAsync(res).ConfigureAwait(false);
  9156. }
  9157. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12)
  9158. {
  9159. await observer.OnCompletedAsync().ConfigureAwait(false);
  9160. }
  9161. }
  9162. },
  9163. async ex =>
  9164. {
  9165. using (await gate.LockAsync().ConfigureAwait(false))
  9166. {
  9167. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9168. }
  9169. },
  9170. async () =>
  9171. {
  9172. using (await gate.LockAsync().ConfigureAwait(false))
  9173. {
  9174. isDone10 = true;
  9175. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9176. {
  9177. await observer.OnCompletedAsync().ConfigureAwait(false);
  9178. }
  9179. }
  9180. }
  9181. ),
  9182. Create<T11>(
  9183. async x =>
  9184. {
  9185. using (await gate.LockAsync().ConfigureAwait(false))
  9186. {
  9187. if (!hasValue11)
  9188. {
  9189. hasValue11 = true;
  9190. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  9191. }
  9192. latestValue11 = x;
  9193. if (allHasValue)
  9194. {
  9195. TResult res;
  9196. try
  9197. {
  9198. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  9199. }
  9200. catch (Exception ex)
  9201. {
  9202. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9203. return;
  9204. }
  9205. await observer.OnNextAsync(res).ConfigureAwait(false);
  9206. }
  9207. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12)
  9208. {
  9209. await observer.OnCompletedAsync().ConfigureAwait(false);
  9210. }
  9211. }
  9212. },
  9213. async ex =>
  9214. {
  9215. using (await gate.LockAsync().ConfigureAwait(false))
  9216. {
  9217. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9218. }
  9219. },
  9220. async () =>
  9221. {
  9222. using (await gate.LockAsync().ConfigureAwait(false))
  9223. {
  9224. isDone11 = true;
  9225. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9226. {
  9227. await observer.OnCompletedAsync().ConfigureAwait(false);
  9228. }
  9229. }
  9230. }
  9231. ),
  9232. Create<T12>(
  9233. async x =>
  9234. {
  9235. using (await gate.LockAsync().ConfigureAwait(false))
  9236. {
  9237. if (!hasValue12)
  9238. {
  9239. hasValue12 = true;
  9240. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12;
  9241. }
  9242. latestValue12 = x;
  9243. if (allHasValue)
  9244. {
  9245. TResult res;
  9246. try
  9247. {
  9248. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12).ConfigureAwait(false);
  9249. }
  9250. catch (Exception ex)
  9251. {
  9252. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9253. return;
  9254. }
  9255. await observer.OnNextAsync(res).ConfigureAwait(false);
  9256. }
  9257. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11)
  9258. {
  9259. await observer.OnCompletedAsync().ConfigureAwait(false);
  9260. }
  9261. }
  9262. },
  9263. async ex =>
  9264. {
  9265. using (await gate.LockAsync().ConfigureAwait(false))
  9266. {
  9267. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9268. }
  9269. },
  9270. async () =>
  9271. {
  9272. using (await gate.LockAsync().ConfigureAwait(false))
  9273. {
  9274. isDone12 = true;
  9275. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9276. {
  9277. await observer.OnCompletedAsync().ConfigureAwait(false);
  9278. }
  9279. }
  9280. }
  9281. )
  9282. );
  9283. }
  9284. 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)
  9285. {
  9286. if (observer == null)
  9287. throw new ArgumentNullException(nameof(observer));
  9288. bool allHasValue = false;
  9289. bool hasValue1 = false;
  9290. bool isDone1 = false;
  9291. T1 latestValue1 = default(T1);
  9292. bool hasValue2 = false;
  9293. bool isDone2 = false;
  9294. T2 latestValue2 = default(T2);
  9295. bool hasValue3 = false;
  9296. bool isDone3 = false;
  9297. T3 latestValue3 = default(T3);
  9298. bool hasValue4 = false;
  9299. bool isDone4 = false;
  9300. T4 latestValue4 = default(T4);
  9301. bool hasValue5 = false;
  9302. bool isDone5 = false;
  9303. T5 latestValue5 = default(T5);
  9304. bool hasValue6 = false;
  9305. bool isDone6 = false;
  9306. T6 latestValue6 = default(T6);
  9307. bool hasValue7 = false;
  9308. bool isDone7 = false;
  9309. T7 latestValue7 = default(T7);
  9310. bool hasValue8 = false;
  9311. bool isDone8 = false;
  9312. T8 latestValue8 = default(T8);
  9313. bool hasValue9 = false;
  9314. bool isDone9 = false;
  9315. T9 latestValue9 = default(T9);
  9316. bool hasValue10 = false;
  9317. bool isDone10 = false;
  9318. T10 latestValue10 = default(T10);
  9319. bool hasValue11 = false;
  9320. bool isDone11 = false;
  9321. T11 latestValue11 = default(T11);
  9322. bool hasValue12 = false;
  9323. bool isDone12 = false;
  9324. T12 latestValue12 = default(T12);
  9325. bool hasValue13 = false;
  9326. bool isDone13 = false;
  9327. T13 latestValue13 = default(T13);
  9328. var gate = AsyncGate.Create();
  9329. return
  9330. (
  9331. Create<T1>(
  9332. async x =>
  9333. {
  9334. using (await gate.LockAsync().ConfigureAwait(false))
  9335. {
  9336. if (!hasValue1)
  9337. {
  9338. hasValue1 = true;
  9339. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9340. }
  9341. latestValue1 = x;
  9342. if (allHasValue)
  9343. {
  9344. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9345. }
  9346. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9347. {
  9348. await observer.OnCompletedAsync().ConfigureAwait(false);
  9349. }
  9350. }
  9351. },
  9352. async ex =>
  9353. {
  9354. using (await gate.LockAsync().ConfigureAwait(false))
  9355. {
  9356. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9357. }
  9358. },
  9359. async () =>
  9360. {
  9361. using (await gate.LockAsync().ConfigureAwait(false))
  9362. {
  9363. isDone1 = true;
  9364. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9365. {
  9366. await observer.OnCompletedAsync().ConfigureAwait(false);
  9367. }
  9368. }
  9369. }
  9370. ),
  9371. Create<T2>(
  9372. async x =>
  9373. {
  9374. using (await gate.LockAsync().ConfigureAwait(false))
  9375. {
  9376. if (!hasValue2)
  9377. {
  9378. hasValue2 = true;
  9379. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9380. }
  9381. latestValue2 = x;
  9382. if (allHasValue)
  9383. {
  9384. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9385. }
  9386. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9387. {
  9388. await observer.OnCompletedAsync().ConfigureAwait(false);
  9389. }
  9390. }
  9391. },
  9392. async ex =>
  9393. {
  9394. using (await gate.LockAsync().ConfigureAwait(false))
  9395. {
  9396. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9397. }
  9398. },
  9399. async () =>
  9400. {
  9401. using (await gate.LockAsync().ConfigureAwait(false))
  9402. {
  9403. isDone2 = true;
  9404. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9405. {
  9406. await observer.OnCompletedAsync().ConfigureAwait(false);
  9407. }
  9408. }
  9409. }
  9410. ),
  9411. Create<T3>(
  9412. async x =>
  9413. {
  9414. using (await gate.LockAsync().ConfigureAwait(false))
  9415. {
  9416. if (!hasValue3)
  9417. {
  9418. hasValue3 = true;
  9419. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9420. }
  9421. latestValue3 = x;
  9422. if (allHasValue)
  9423. {
  9424. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9425. }
  9426. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9427. {
  9428. await observer.OnCompletedAsync().ConfigureAwait(false);
  9429. }
  9430. }
  9431. },
  9432. async ex =>
  9433. {
  9434. using (await gate.LockAsync().ConfigureAwait(false))
  9435. {
  9436. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9437. }
  9438. },
  9439. async () =>
  9440. {
  9441. using (await gate.LockAsync().ConfigureAwait(false))
  9442. {
  9443. isDone3 = true;
  9444. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9445. {
  9446. await observer.OnCompletedAsync().ConfigureAwait(false);
  9447. }
  9448. }
  9449. }
  9450. ),
  9451. Create<T4>(
  9452. async x =>
  9453. {
  9454. using (await gate.LockAsync().ConfigureAwait(false))
  9455. {
  9456. if (!hasValue4)
  9457. {
  9458. hasValue4 = true;
  9459. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9460. }
  9461. latestValue4 = x;
  9462. if (allHasValue)
  9463. {
  9464. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9465. }
  9466. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9467. {
  9468. await observer.OnCompletedAsync().ConfigureAwait(false);
  9469. }
  9470. }
  9471. },
  9472. async ex =>
  9473. {
  9474. using (await gate.LockAsync().ConfigureAwait(false))
  9475. {
  9476. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9477. }
  9478. },
  9479. async () =>
  9480. {
  9481. using (await gate.LockAsync().ConfigureAwait(false))
  9482. {
  9483. isDone4 = true;
  9484. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9485. {
  9486. await observer.OnCompletedAsync().ConfigureAwait(false);
  9487. }
  9488. }
  9489. }
  9490. ),
  9491. Create<T5>(
  9492. async x =>
  9493. {
  9494. using (await gate.LockAsync().ConfigureAwait(false))
  9495. {
  9496. if (!hasValue5)
  9497. {
  9498. hasValue5 = true;
  9499. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9500. }
  9501. latestValue5 = x;
  9502. if (allHasValue)
  9503. {
  9504. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9505. }
  9506. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9507. {
  9508. await observer.OnCompletedAsync().ConfigureAwait(false);
  9509. }
  9510. }
  9511. },
  9512. async ex =>
  9513. {
  9514. using (await gate.LockAsync().ConfigureAwait(false))
  9515. {
  9516. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9517. }
  9518. },
  9519. async () =>
  9520. {
  9521. using (await gate.LockAsync().ConfigureAwait(false))
  9522. {
  9523. isDone5 = true;
  9524. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9525. {
  9526. await observer.OnCompletedAsync().ConfigureAwait(false);
  9527. }
  9528. }
  9529. }
  9530. ),
  9531. Create<T6>(
  9532. async x =>
  9533. {
  9534. using (await gate.LockAsync().ConfigureAwait(false))
  9535. {
  9536. if (!hasValue6)
  9537. {
  9538. hasValue6 = true;
  9539. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9540. }
  9541. latestValue6 = x;
  9542. if (allHasValue)
  9543. {
  9544. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9545. }
  9546. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9547. {
  9548. await observer.OnCompletedAsync().ConfigureAwait(false);
  9549. }
  9550. }
  9551. },
  9552. async ex =>
  9553. {
  9554. using (await gate.LockAsync().ConfigureAwait(false))
  9555. {
  9556. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9557. }
  9558. },
  9559. async () =>
  9560. {
  9561. using (await gate.LockAsync().ConfigureAwait(false))
  9562. {
  9563. isDone6 = true;
  9564. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9565. {
  9566. await observer.OnCompletedAsync().ConfigureAwait(false);
  9567. }
  9568. }
  9569. }
  9570. ),
  9571. Create<T7>(
  9572. async x =>
  9573. {
  9574. using (await gate.LockAsync().ConfigureAwait(false))
  9575. {
  9576. if (!hasValue7)
  9577. {
  9578. hasValue7 = true;
  9579. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9580. }
  9581. latestValue7 = x;
  9582. if (allHasValue)
  9583. {
  9584. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9585. }
  9586. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9587. {
  9588. await observer.OnCompletedAsync().ConfigureAwait(false);
  9589. }
  9590. }
  9591. },
  9592. async ex =>
  9593. {
  9594. using (await gate.LockAsync().ConfigureAwait(false))
  9595. {
  9596. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9597. }
  9598. },
  9599. async () =>
  9600. {
  9601. using (await gate.LockAsync().ConfigureAwait(false))
  9602. {
  9603. isDone7 = true;
  9604. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9605. {
  9606. await observer.OnCompletedAsync().ConfigureAwait(false);
  9607. }
  9608. }
  9609. }
  9610. ),
  9611. Create<T8>(
  9612. async x =>
  9613. {
  9614. using (await gate.LockAsync().ConfigureAwait(false))
  9615. {
  9616. if (!hasValue8)
  9617. {
  9618. hasValue8 = true;
  9619. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9620. }
  9621. latestValue8 = x;
  9622. if (allHasValue)
  9623. {
  9624. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9625. }
  9626. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9627. {
  9628. await observer.OnCompletedAsync().ConfigureAwait(false);
  9629. }
  9630. }
  9631. },
  9632. async ex =>
  9633. {
  9634. using (await gate.LockAsync().ConfigureAwait(false))
  9635. {
  9636. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9637. }
  9638. },
  9639. async () =>
  9640. {
  9641. using (await gate.LockAsync().ConfigureAwait(false))
  9642. {
  9643. isDone8 = true;
  9644. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9645. {
  9646. await observer.OnCompletedAsync().ConfigureAwait(false);
  9647. }
  9648. }
  9649. }
  9650. ),
  9651. Create<T9>(
  9652. async x =>
  9653. {
  9654. using (await gate.LockAsync().ConfigureAwait(false))
  9655. {
  9656. if (!hasValue9)
  9657. {
  9658. hasValue9 = true;
  9659. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9660. }
  9661. latestValue9 = x;
  9662. if (allHasValue)
  9663. {
  9664. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9665. }
  9666. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13)
  9667. {
  9668. await observer.OnCompletedAsync().ConfigureAwait(false);
  9669. }
  9670. }
  9671. },
  9672. async ex =>
  9673. {
  9674. using (await gate.LockAsync().ConfigureAwait(false))
  9675. {
  9676. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9677. }
  9678. },
  9679. async () =>
  9680. {
  9681. using (await gate.LockAsync().ConfigureAwait(false))
  9682. {
  9683. isDone9 = true;
  9684. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9685. {
  9686. await observer.OnCompletedAsync().ConfigureAwait(false);
  9687. }
  9688. }
  9689. }
  9690. ),
  9691. Create<T10>(
  9692. async x =>
  9693. {
  9694. using (await gate.LockAsync().ConfigureAwait(false))
  9695. {
  9696. if (!hasValue10)
  9697. {
  9698. hasValue10 = true;
  9699. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9700. }
  9701. latestValue10 = x;
  9702. if (allHasValue)
  9703. {
  9704. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9705. }
  9706. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13)
  9707. {
  9708. await observer.OnCompletedAsync().ConfigureAwait(false);
  9709. }
  9710. }
  9711. },
  9712. async ex =>
  9713. {
  9714. using (await gate.LockAsync().ConfigureAwait(false))
  9715. {
  9716. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9717. }
  9718. },
  9719. async () =>
  9720. {
  9721. using (await gate.LockAsync().ConfigureAwait(false))
  9722. {
  9723. isDone10 = true;
  9724. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9725. {
  9726. await observer.OnCompletedAsync().ConfigureAwait(false);
  9727. }
  9728. }
  9729. }
  9730. ),
  9731. Create<T11>(
  9732. async x =>
  9733. {
  9734. using (await gate.LockAsync().ConfigureAwait(false))
  9735. {
  9736. if (!hasValue11)
  9737. {
  9738. hasValue11 = true;
  9739. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9740. }
  9741. latestValue11 = x;
  9742. if (allHasValue)
  9743. {
  9744. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9745. }
  9746. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13)
  9747. {
  9748. await observer.OnCompletedAsync().ConfigureAwait(false);
  9749. }
  9750. }
  9751. },
  9752. async ex =>
  9753. {
  9754. using (await gate.LockAsync().ConfigureAwait(false))
  9755. {
  9756. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9757. }
  9758. },
  9759. async () =>
  9760. {
  9761. using (await gate.LockAsync().ConfigureAwait(false))
  9762. {
  9763. isDone11 = true;
  9764. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9765. {
  9766. await observer.OnCompletedAsync().ConfigureAwait(false);
  9767. }
  9768. }
  9769. }
  9770. ),
  9771. Create<T12>(
  9772. async x =>
  9773. {
  9774. using (await gate.LockAsync().ConfigureAwait(false))
  9775. {
  9776. if (!hasValue12)
  9777. {
  9778. hasValue12 = true;
  9779. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9780. }
  9781. latestValue12 = x;
  9782. if (allHasValue)
  9783. {
  9784. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9785. }
  9786. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13)
  9787. {
  9788. await observer.OnCompletedAsync().ConfigureAwait(false);
  9789. }
  9790. }
  9791. },
  9792. async ex =>
  9793. {
  9794. using (await gate.LockAsync().ConfigureAwait(false))
  9795. {
  9796. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9797. }
  9798. },
  9799. async () =>
  9800. {
  9801. using (await gate.LockAsync().ConfigureAwait(false))
  9802. {
  9803. isDone12 = true;
  9804. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9805. {
  9806. await observer.OnCompletedAsync().ConfigureAwait(false);
  9807. }
  9808. }
  9809. }
  9810. ),
  9811. Create<T13>(
  9812. async x =>
  9813. {
  9814. using (await gate.LockAsync().ConfigureAwait(false))
  9815. {
  9816. if (!hasValue13)
  9817. {
  9818. hasValue13 = true;
  9819. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9820. }
  9821. latestValue13 = x;
  9822. if (allHasValue)
  9823. {
  9824. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13)).ConfigureAwait(false);
  9825. }
  9826. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  9827. {
  9828. await observer.OnCompletedAsync().ConfigureAwait(false);
  9829. }
  9830. }
  9831. },
  9832. async ex =>
  9833. {
  9834. using (await gate.LockAsync().ConfigureAwait(false))
  9835. {
  9836. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9837. }
  9838. },
  9839. async () =>
  9840. {
  9841. using (await gate.LockAsync().ConfigureAwait(false))
  9842. {
  9843. isDone13 = true;
  9844. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9845. {
  9846. await observer.OnCompletedAsync().ConfigureAwait(false);
  9847. }
  9848. }
  9849. }
  9850. )
  9851. );
  9852. }
  9853. 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)
  9854. {
  9855. if (observer == null)
  9856. throw new ArgumentNullException(nameof(observer));
  9857. if (selector == null)
  9858. throw new ArgumentNullException(nameof(selector));
  9859. 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)));
  9860. }
  9861. 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)
  9862. {
  9863. if (observer == null)
  9864. throw new ArgumentNullException(nameof(observer));
  9865. if (selector == null)
  9866. throw new ArgumentNullException(nameof(selector));
  9867. bool allHasValue = false;
  9868. bool hasValue1 = false;
  9869. bool isDone1 = false;
  9870. T1 latestValue1 = default(T1);
  9871. bool hasValue2 = false;
  9872. bool isDone2 = false;
  9873. T2 latestValue2 = default(T2);
  9874. bool hasValue3 = false;
  9875. bool isDone3 = false;
  9876. T3 latestValue3 = default(T3);
  9877. bool hasValue4 = false;
  9878. bool isDone4 = false;
  9879. T4 latestValue4 = default(T4);
  9880. bool hasValue5 = false;
  9881. bool isDone5 = false;
  9882. T5 latestValue5 = default(T5);
  9883. bool hasValue6 = false;
  9884. bool isDone6 = false;
  9885. T6 latestValue6 = default(T6);
  9886. bool hasValue7 = false;
  9887. bool isDone7 = false;
  9888. T7 latestValue7 = default(T7);
  9889. bool hasValue8 = false;
  9890. bool isDone8 = false;
  9891. T8 latestValue8 = default(T8);
  9892. bool hasValue9 = false;
  9893. bool isDone9 = false;
  9894. T9 latestValue9 = default(T9);
  9895. bool hasValue10 = false;
  9896. bool isDone10 = false;
  9897. T10 latestValue10 = default(T10);
  9898. bool hasValue11 = false;
  9899. bool isDone11 = false;
  9900. T11 latestValue11 = default(T11);
  9901. bool hasValue12 = false;
  9902. bool isDone12 = false;
  9903. T12 latestValue12 = default(T12);
  9904. bool hasValue13 = false;
  9905. bool isDone13 = false;
  9906. T13 latestValue13 = default(T13);
  9907. var gate = AsyncGate.Create();
  9908. return
  9909. (
  9910. Create<T1>(
  9911. async x =>
  9912. {
  9913. using (await gate.LockAsync().ConfigureAwait(false))
  9914. {
  9915. if (!hasValue1)
  9916. {
  9917. hasValue1 = true;
  9918. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9919. }
  9920. latestValue1 = x;
  9921. if (allHasValue)
  9922. {
  9923. TResult res;
  9924. try
  9925. {
  9926. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  9927. }
  9928. catch (Exception ex)
  9929. {
  9930. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9931. return;
  9932. }
  9933. await observer.OnNextAsync(res).ConfigureAwait(false);
  9934. }
  9935. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9936. {
  9937. await observer.OnCompletedAsync().ConfigureAwait(false);
  9938. }
  9939. }
  9940. },
  9941. async ex =>
  9942. {
  9943. using (await gate.LockAsync().ConfigureAwait(false))
  9944. {
  9945. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9946. }
  9947. },
  9948. async () =>
  9949. {
  9950. using (await gate.LockAsync().ConfigureAwait(false))
  9951. {
  9952. isDone1 = true;
  9953. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9954. {
  9955. await observer.OnCompletedAsync().ConfigureAwait(false);
  9956. }
  9957. }
  9958. }
  9959. ),
  9960. Create<T2>(
  9961. async x =>
  9962. {
  9963. using (await gate.LockAsync().ConfigureAwait(false))
  9964. {
  9965. if (!hasValue2)
  9966. {
  9967. hasValue2 = true;
  9968. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  9969. }
  9970. latestValue2 = x;
  9971. if (allHasValue)
  9972. {
  9973. TResult res;
  9974. try
  9975. {
  9976. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  9977. }
  9978. catch (Exception ex)
  9979. {
  9980. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9981. return;
  9982. }
  9983. await observer.OnNextAsync(res).ConfigureAwait(false);
  9984. }
  9985. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  9986. {
  9987. await observer.OnCompletedAsync().ConfigureAwait(false);
  9988. }
  9989. }
  9990. },
  9991. async ex =>
  9992. {
  9993. using (await gate.LockAsync().ConfigureAwait(false))
  9994. {
  9995. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  9996. }
  9997. },
  9998. async () =>
  9999. {
  10000. using (await gate.LockAsync().ConfigureAwait(false))
  10001. {
  10002. isDone2 = true;
  10003. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10004. {
  10005. await observer.OnCompletedAsync().ConfigureAwait(false);
  10006. }
  10007. }
  10008. }
  10009. ),
  10010. Create<T3>(
  10011. async x =>
  10012. {
  10013. using (await gate.LockAsync().ConfigureAwait(false))
  10014. {
  10015. if (!hasValue3)
  10016. {
  10017. hasValue3 = true;
  10018. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10019. }
  10020. latestValue3 = x;
  10021. if (allHasValue)
  10022. {
  10023. TResult res;
  10024. try
  10025. {
  10026. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10027. }
  10028. catch (Exception ex)
  10029. {
  10030. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10031. return;
  10032. }
  10033. await observer.OnNextAsync(res).ConfigureAwait(false);
  10034. }
  10035. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10036. {
  10037. await observer.OnCompletedAsync().ConfigureAwait(false);
  10038. }
  10039. }
  10040. },
  10041. async ex =>
  10042. {
  10043. using (await gate.LockAsync().ConfigureAwait(false))
  10044. {
  10045. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10046. }
  10047. },
  10048. async () =>
  10049. {
  10050. using (await gate.LockAsync().ConfigureAwait(false))
  10051. {
  10052. isDone3 = true;
  10053. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10054. {
  10055. await observer.OnCompletedAsync().ConfigureAwait(false);
  10056. }
  10057. }
  10058. }
  10059. ),
  10060. Create<T4>(
  10061. async x =>
  10062. {
  10063. using (await gate.LockAsync().ConfigureAwait(false))
  10064. {
  10065. if (!hasValue4)
  10066. {
  10067. hasValue4 = true;
  10068. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10069. }
  10070. latestValue4 = x;
  10071. if (allHasValue)
  10072. {
  10073. TResult res;
  10074. try
  10075. {
  10076. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10077. }
  10078. catch (Exception ex)
  10079. {
  10080. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10081. return;
  10082. }
  10083. await observer.OnNextAsync(res).ConfigureAwait(false);
  10084. }
  10085. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10086. {
  10087. await observer.OnCompletedAsync().ConfigureAwait(false);
  10088. }
  10089. }
  10090. },
  10091. async ex =>
  10092. {
  10093. using (await gate.LockAsync().ConfigureAwait(false))
  10094. {
  10095. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10096. }
  10097. },
  10098. async () =>
  10099. {
  10100. using (await gate.LockAsync().ConfigureAwait(false))
  10101. {
  10102. isDone4 = true;
  10103. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10104. {
  10105. await observer.OnCompletedAsync().ConfigureAwait(false);
  10106. }
  10107. }
  10108. }
  10109. ),
  10110. Create<T5>(
  10111. async x =>
  10112. {
  10113. using (await gate.LockAsync().ConfigureAwait(false))
  10114. {
  10115. if (!hasValue5)
  10116. {
  10117. hasValue5 = true;
  10118. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10119. }
  10120. latestValue5 = x;
  10121. if (allHasValue)
  10122. {
  10123. TResult res;
  10124. try
  10125. {
  10126. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10127. }
  10128. catch (Exception ex)
  10129. {
  10130. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10131. return;
  10132. }
  10133. await observer.OnNextAsync(res).ConfigureAwait(false);
  10134. }
  10135. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10136. {
  10137. await observer.OnCompletedAsync().ConfigureAwait(false);
  10138. }
  10139. }
  10140. },
  10141. async ex =>
  10142. {
  10143. using (await gate.LockAsync().ConfigureAwait(false))
  10144. {
  10145. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10146. }
  10147. },
  10148. async () =>
  10149. {
  10150. using (await gate.LockAsync().ConfigureAwait(false))
  10151. {
  10152. isDone5 = true;
  10153. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10154. {
  10155. await observer.OnCompletedAsync().ConfigureAwait(false);
  10156. }
  10157. }
  10158. }
  10159. ),
  10160. Create<T6>(
  10161. async x =>
  10162. {
  10163. using (await gate.LockAsync().ConfigureAwait(false))
  10164. {
  10165. if (!hasValue6)
  10166. {
  10167. hasValue6 = true;
  10168. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10169. }
  10170. latestValue6 = x;
  10171. if (allHasValue)
  10172. {
  10173. TResult res;
  10174. try
  10175. {
  10176. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10177. }
  10178. catch (Exception ex)
  10179. {
  10180. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10181. return;
  10182. }
  10183. await observer.OnNextAsync(res).ConfigureAwait(false);
  10184. }
  10185. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10186. {
  10187. await observer.OnCompletedAsync().ConfigureAwait(false);
  10188. }
  10189. }
  10190. },
  10191. async ex =>
  10192. {
  10193. using (await gate.LockAsync().ConfigureAwait(false))
  10194. {
  10195. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10196. }
  10197. },
  10198. async () =>
  10199. {
  10200. using (await gate.LockAsync().ConfigureAwait(false))
  10201. {
  10202. isDone6 = true;
  10203. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10204. {
  10205. await observer.OnCompletedAsync().ConfigureAwait(false);
  10206. }
  10207. }
  10208. }
  10209. ),
  10210. Create<T7>(
  10211. async x =>
  10212. {
  10213. using (await gate.LockAsync().ConfigureAwait(false))
  10214. {
  10215. if (!hasValue7)
  10216. {
  10217. hasValue7 = true;
  10218. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10219. }
  10220. latestValue7 = x;
  10221. if (allHasValue)
  10222. {
  10223. TResult res;
  10224. try
  10225. {
  10226. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10227. }
  10228. catch (Exception ex)
  10229. {
  10230. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10231. return;
  10232. }
  10233. await observer.OnNextAsync(res).ConfigureAwait(false);
  10234. }
  10235. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10236. {
  10237. await observer.OnCompletedAsync().ConfigureAwait(false);
  10238. }
  10239. }
  10240. },
  10241. async ex =>
  10242. {
  10243. using (await gate.LockAsync().ConfigureAwait(false))
  10244. {
  10245. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10246. }
  10247. },
  10248. async () =>
  10249. {
  10250. using (await gate.LockAsync().ConfigureAwait(false))
  10251. {
  10252. isDone7 = true;
  10253. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10254. {
  10255. await observer.OnCompletedAsync().ConfigureAwait(false);
  10256. }
  10257. }
  10258. }
  10259. ),
  10260. Create<T8>(
  10261. async x =>
  10262. {
  10263. using (await gate.LockAsync().ConfigureAwait(false))
  10264. {
  10265. if (!hasValue8)
  10266. {
  10267. hasValue8 = true;
  10268. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10269. }
  10270. latestValue8 = x;
  10271. if (allHasValue)
  10272. {
  10273. TResult res;
  10274. try
  10275. {
  10276. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10277. }
  10278. catch (Exception ex)
  10279. {
  10280. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10281. return;
  10282. }
  10283. await observer.OnNextAsync(res).ConfigureAwait(false);
  10284. }
  10285. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10286. {
  10287. await observer.OnCompletedAsync().ConfigureAwait(false);
  10288. }
  10289. }
  10290. },
  10291. async ex =>
  10292. {
  10293. using (await gate.LockAsync().ConfigureAwait(false))
  10294. {
  10295. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10296. }
  10297. },
  10298. async () =>
  10299. {
  10300. using (await gate.LockAsync().ConfigureAwait(false))
  10301. {
  10302. isDone8 = true;
  10303. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10304. {
  10305. await observer.OnCompletedAsync().ConfigureAwait(false);
  10306. }
  10307. }
  10308. }
  10309. ),
  10310. Create<T9>(
  10311. async x =>
  10312. {
  10313. using (await gate.LockAsync().ConfigureAwait(false))
  10314. {
  10315. if (!hasValue9)
  10316. {
  10317. hasValue9 = true;
  10318. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10319. }
  10320. latestValue9 = x;
  10321. if (allHasValue)
  10322. {
  10323. TResult res;
  10324. try
  10325. {
  10326. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10327. }
  10328. catch (Exception ex)
  10329. {
  10330. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10331. return;
  10332. }
  10333. await observer.OnNextAsync(res).ConfigureAwait(false);
  10334. }
  10335. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13)
  10336. {
  10337. await observer.OnCompletedAsync().ConfigureAwait(false);
  10338. }
  10339. }
  10340. },
  10341. async ex =>
  10342. {
  10343. using (await gate.LockAsync().ConfigureAwait(false))
  10344. {
  10345. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10346. }
  10347. },
  10348. async () =>
  10349. {
  10350. using (await gate.LockAsync().ConfigureAwait(false))
  10351. {
  10352. isDone9 = true;
  10353. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10354. {
  10355. await observer.OnCompletedAsync().ConfigureAwait(false);
  10356. }
  10357. }
  10358. }
  10359. ),
  10360. Create<T10>(
  10361. async x =>
  10362. {
  10363. using (await gate.LockAsync().ConfigureAwait(false))
  10364. {
  10365. if (!hasValue10)
  10366. {
  10367. hasValue10 = true;
  10368. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10369. }
  10370. latestValue10 = x;
  10371. if (allHasValue)
  10372. {
  10373. TResult res;
  10374. try
  10375. {
  10376. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10377. }
  10378. catch (Exception ex)
  10379. {
  10380. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10381. return;
  10382. }
  10383. await observer.OnNextAsync(res).ConfigureAwait(false);
  10384. }
  10385. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13)
  10386. {
  10387. await observer.OnCompletedAsync().ConfigureAwait(false);
  10388. }
  10389. }
  10390. },
  10391. async ex =>
  10392. {
  10393. using (await gate.LockAsync().ConfigureAwait(false))
  10394. {
  10395. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10396. }
  10397. },
  10398. async () =>
  10399. {
  10400. using (await gate.LockAsync().ConfigureAwait(false))
  10401. {
  10402. isDone10 = true;
  10403. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10404. {
  10405. await observer.OnCompletedAsync().ConfigureAwait(false);
  10406. }
  10407. }
  10408. }
  10409. ),
  10410. Create<T11>(
  10411. async x =>
  10412. {
  10413. using (await gate.LockAsync().ConfigureAwait(false))
  10414. {
  10415. if (!hasValue11)
  10416. {
  10417. hasValue11 = true;
  10418. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10419. }
  10420. latestValue11 = x;
  10421. if (allHasValue)
  10422. {
  10423. TResult res;
  10424. try
  10425. {
  10426. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10427. }
  10428. catch (Exception ex)
  10429. {
  10430. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10431. return;
  10432. }
  10433. await observer.OnNextAsync(res).ConfigureAwait(false);
  10434. }
  10435. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13)
  10436. {
  10437. await observer.OnCompletedAsync().ConfigureAwait(false);
  10438. }
  10439. }
  10440. },
  10441. async ex =>
  10442. {
  10443. using (await gate.LockAsync().ConfigureAwait(false))
  10444. {
  10445. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10446. }
  10447. },
  10448. async () =>
  10449. {
  10450. using (await gate.LockAsync().ConfigureAwait(false))
  10451. {
  10452. isDone11 = true;
  10453. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10454. {
  10455. await observer.OnCompletedAsync().ConfigureAwait(false);
  10456. }
  10457. }
  10458. }
  10459. ),
  10460. Create<T12>(
  10461. async x =>
  10462. {
  10463. using (await gate.LockAsync().ConfigureAwait(false))
  10464. {
  10465. if (!hasValue12)
  10466. {
  10467. hasValue12 = true;
  10468. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10469. }
  10470. latestValue12 = x;
  10471. if (allHasValue)
  10472. {
  10473. TResult res;
  10474. try
  10475. {
  10476. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10477. }
  10478. catch (Exception ex)
  10479. {
  10480. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10481. return;
  10482. }
  10483. await observer.OnNextAsync(res).ConfigureAwait(false);
  10484. }
  10485. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13)
  10486. {
  10487. await observer.OnCompletedAsync().ConfigureAwait(false);
  10488. }
  10489. }
  10490. },
  10491. async ex =>
  10492. {
  10493. using (await gate.LockAsync().ConfigureAwait(false))
  10494. {
  10495. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10496. }
  10497. },
  10498. async () =>
  10499. {
  10500. using (await gate.LockAsync().ConfigureAwait(false))
  10501. {
  10502. isDone12 = true;
  10503. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10504. {
  10505. await observer.OnCompletedAsync().ConfigureAwait(false);
  10506. }
  10507. }
  10508. }
  10509. ),
  10510. Create<T13>(
  10511. async x =>
  10512. {
  10513. using (await gate.LockAsync().ConfigureAwait(false))
  10514. {
  10515. if (!hasValue13)
  10516. {
  10517. hasValue13 = true;
  10518. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13;
  10519. }
  10520. latestValue13 = x;
  10521. if (allHasValue)
  10522. {
  10523. TResult res;
  10524. try
  10525. {
  10526. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13).ConfigureAwait(false);
  10527. }
  10528. catch (Exception ex)
  10529. {
  10530. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10531. return;
  10532. }
  10533. await observer.OnNextAsync(res).ConfigureAwait(false);
  10534. }
  10535. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12)
  10536. {
  10537. await observer.OnCompletedAsync().ConfigureAwait(false);
  10538. }
  10539. }
  10540. },
  10541. async ex =>
  10542. {
  10543. using (await gate.LockAsync().ConfigureAwait(false))
  10544. {
  10545. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10546. }
  10547. },
  10548. async () =>
  10549. {
  10550. using (await gate.LockAsync().ConfigureAwait(false))
  10551. {
  10552. isDone13 = true;
  10553. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  10554. {
  10555. await observer.OnCompletedAsync().ConfigureAwait(false);
  10556. }
  10557. }
  10558. }
  10559. )
  10560. );
  10561. }
  10562. 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)
  10563. {
  10564. if (observer == null)
  10565. throw new ArgumentNullException(nameof(observer));
  10566. bool allHasValue = false;
  10567. bool hasValue1 = false;
  10568. bool isDone1 = false;
  10569. T1 latestValue1 = default(T1);
  10570. bool hasValue2 = false;
  10571. bool isDone2 = false;
  10572. T2 latestValue2 = default(T2);
  10573. bool hasValue3 = false;
  10574. bool isDone3 = false;
  10575. T3 latestValue3 = default(T3);
  10576. bool hasValue4 = false;
  10577. bool isDone4 = false;
  10578. T4 latestValue4 = default(T4);
  10579. bool hasValue5 = false;
  10580. bool isDone5 = false;
  10581. T5 latestValue5 = default(T5);
  10582. bool hasValue6 = false;
  10583. bool isDone6 = false;
  10584. T6 latestValue6 = default(T6);
  10585. bool hasValue7 = false;
  10586. bool isDone7 = false;
  10587. T7 latestValue7 = default(T7);
  10588. bool hasValue8 = false;
  10589. bool isDone8 = false;
  10590. T8 latestValue8 = default(T8);
  10591. bool hasValue9 = false;
  10592. bool isDone9 = false;
  10593. T9 latestValue9 = default(T9);
  10594. bool hasValue10 = false;
  10595. bool isDone10 = false;
  10596. T10 latestValue10 = default(T10);
  10597. bool hasValue11 = false;
  10598. bool isDone11 = false;
  10599. T11 latestValue11 = default(T11);
  10600. bool hasValue12 = false;
  10601. bool isDone12 = false;
  10602. T12 latestValue12 = default(T12);
  10603. bool hasValue13 = false;
  10604. bool isDone13 = false;
  10605. T13 latestValue13 = default(T13);
  10606. bool hasValue14 = false;
  10607. bool isDone14 = false;
  10608. T14 latestValue14 = default(T14);
  10609. var gate = AsyncGate.Create();
  10610. return
  10611. (
  10612. Create<T1>(
  10613. async x =>
  10614. {
  10615. using (await gate.LockAsync().ConfigureAwait(false))
  10616. {
  10617. if (!hasValue1)
  10618. {
  10619. hasValue1 = true;
  10620. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10621. }
  10622. latestValue1 = x;
  10623. if (allHasValue)
  10624. {
  10625. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10626. }
  10627. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10628. {
  10629. await observer.OnCompletedAsync().ConfigureAwait(false);
  10630. }
  10631. }
  10632. },
  10633. async ex =>
  10634. {
  10635. using (await gate.LockAsync().ConfigureAwait(false))
  10636. {
  10637. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10638. }
  10639. },
  10640. async () =>
  10641. {
  10642. using (await gate.LockAsync().ConfigureAwait(false))
  10643. {
  10644. isDone1 = true;
  10645. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10646. {
  10647. await observer.OnCompletedAsync().ConfigureAwait(false);
  10648. }
  10649. }
  10650. }
  10651. ),
  10652. Create<T2>(
  10653. async x =>
  10654. {
  10655. using (await gate.LockAsync().ConfigureAwait(false))
  10656. {
  10657. if (!hasValue2)
  10658. {
  10659. hasValue2 = true;
  10660. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10661. }
  10662. latestValue2 = x;
  10663. if (allHasValue)
  10664. {
  10665. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10666. }
  10667. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10668. {
  10669. await observer.OnCompletedAsync().ConfigureAwait(false);
  10670. }
  10671. }
  10672. },
  10673. async ex =>
  10674. {
  10675. using (await gate.LockAsync().ConfigureAwait(false))
  10676. {
  10677. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10678. }
  10679. },
  10680. async () =>
  10681. {
  10682. using (await gate.LockAsync().ConfigureAwait(false))
  10683. {
  10684. isDone2 = true;
  10685. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10686. {
  10687. await observer.OnCompletedAsync().ConfigureAwait(false);
  10688. }
  10689. }
  10690. }
  10691. ),
  10692. Create<T3>(
  10693. async x =>
  10694. {
  10695. using (await gate.LockAsync().ConfigureAwait(false))
  10696. {
  10697. if (!hasValue3)
  10698. {
  10699. hasValue3 = true;
  10700. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10701. }
  10702. latestValue3 = x;
  10703. if (allHasValue)
  10704. {
  10705. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10706. }
  10707. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10708. {
  10709. await observer.OnCompletedAsync().ConfigureAwait(false);
  10710. }
  10711. }
  10712. },
  10713. async ex =>
  10714. {
  10715. using (await gate.LockAsync().ConfigureAwait(false))
  10716. {
  10717. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10718. }
  10719. },
  10720. async () =>
  10721. {
  10722. using (await gate.LockAsync().ConfigureAwait(false))
  10723. {
  10724. isDone3 = true;
  10725. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10726. {
  10727. await observer.OnCompletedAsync().ConfigureAwait(false);
  10728. }
  10729. }
  10730. }
  10731. ),
  10732. Create<T4>(
  10733. async x =>
  10734. {
  10735. using (await gate.LockAsync().ConfigureAwait(false))
  10736. {
  10737. if (!hasValue4)
  10738. {
  10739. hasValue4 = true;
  10740. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10741. }
  10742. latestValue4 = x;
  10743. if (allHasValue)
  10744. {
  10745. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10746. }
  10747. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10748. {
  10749. await observer.OnCompletedAsync().ConfigureAwait(false);
  10750. }
  10751. }
  10752. },
  10753. async ex =>
  10754. {
  10755. using (await gate.LockAsync().ConfigureAwait(false))
  10756. {
  10757. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10758. }
  10759. },
  10760. async () =>
  10761. {
  10762. using (await gate.LockAsync().ConfigureAwait(false))
  10763. {
  10764. isDone4 = true;
  10765. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10766. {
  10767. await observer.OnCompletedAsync().ConfigureAwait(false);
  10768. }
  10769. }
  10770. }
  10771. ),
  10772. Create<T5>(
  10773. async x =>
  10774. {
  10775. using (await gate.LockAsync().ConfigureAwait(false))
  10776. {
  10777. if (!hasValue5)
  10778. {
  10779. hasValue5 = true;
  10780. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10781. }
  10782. latestValue5 = x;
  10783. if (allHasValue)
  10784. {
  10785. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10786. }
  10787. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10788. {
  10789. await observer.OnCompletedAsync().ConfigureAwait(false);
  10790. }
  10791. }
  10792. },
  10793. async ex =>
  10794. {
  10795. using (await gate.LockAsync().ConfigureAwait(false))
  10796. {
  10797. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10798. }
  10799. },
  10800. async () =>
  10801. {
  10802. using (await gate.LockAsync().ConfigureAwait(false))
  10803. {
  10804. isDone5 = true;
  10805. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10806. {
  10807. await observer.OnCompletedAsync().ConfigureAwait(false);
  10808. }
  10809. }
  10810. }
  10811. ),
  10812. Create<T6>(
  10813. async x =>
  10814. {
  10815. using (await gate.LockAsync().ConfigureAwait(false))
  10816. {
  10817. if (!hasValue6)
  10818. {
  10819. hasValue6 = true;
  10820. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10821. }
  10822. latestValue6 = x;
  10823. if (allHasValue)
  10824. {
  10825. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10826. }
  10827. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10828. {
  10829. await observer.OnCompletedAsync().ConfigureAwait(false);
  10830. }
  10831. }
  10832. },
  10833. async ex =>
  10834. {
  10835. using (await gate.LockAsync().ConfigureAwait(false))
  10836. {
  10837. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10838. }
  10839. },
  10840. async () =>
  10841. {
  10842. using (await gate.LockAsync().ConfigureAwait(false))
  10843. {
  10844. isDone6 = true;
  10845. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10846. {
  10847. await observer.OnCompletedAsync().ConfigureAwait(false);
  10848. }
  10849. }
  10850. }
  10851. ),
  10852. Create<T7>(
  10853. async x =>
  10854. {
  10855. using (await gate.LockAsync().ConfigureAwait(false))
  10856. {
  10857. if (!hasValue7)
  10858. {
  10859. hasValue7 = true;
  10860. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10861. }
  10862. latestValue7 = x;
  10863. if (allHasValue)
  10864. {
  10865. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10866. }
  10867. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10868. {
  10869. await observer.OnCompletedAsync().ConfigureAwait(false);
  10870. }
  10871. }
  10872. },
  10873. async ex =>
  10874. {
  10875. using (await gate.LockAsync().ConfigureAwait(false))
  10876. {
  10877. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10878. }
  10879. },
  10880. async () =>
  10881. {
  10882. using (await gate.LockAsync().ConfigureAwait(false))
  10883. {
  10884. isDone7 = true;
  10885. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10886. {
  10887. await observer.OnCompletedAsync().ConfigureAwait(false);
  10888. }
  10889. }
  10890. }
  10891. ),
  10892. Create<T8>(
  10893. async x =>
  10894. {
  10895. using (await gate.LockAsync().ConfigureAwait(false))
  10896. {
  10897. if (!hasValue8)
  10898. {
  10899. hasValue8 = true;
  10900. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10901. }
  10902. latestValue8 = x;
  10903. if (allHasValue)
  10904. {
  10905. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10906. }
  10907. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10908. {
  10909. await observer.OnCompletedAsync().ConfigureAwait(false);
  10910. }
  10911. }
  10912. },
  10913. async ex =>
  10914. {
  10915. using (await gate.LockAsync().ConfigureAwait(false))
  10916. {
  10917. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10918. }
  10919. },
  10920. async () =>
  10921. {
  10922. using (await gate.LockAsync().ConfigureAwait(false))
  10923. {
  10924. isDone8 = true;
  10925. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10926. {
  10927. await observer.OnCompletedAsync().ConfigureAwait(false);
  10928. }
  10929. }
  10930. }
  10931. ),
  10932. Create<T9>(
  10933. async x =>
  10934. {
  10935. using (await gate.LockAsync().ConfigureAwait(false))
  10936. {
  10937. if (!hasValue9)
  10938. {
  10939. hasValue9 = true;
  10940. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10941. }
  10942. latestValue9 = x;
  10943. if (allHasValue)
  10944. {
  10945. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10946. }
  10947. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10948. {
  10949. await observer.OnCompletedAsync().ConfigureAwait(false);
  10950. }
  10951. }
  10952. },
  10953. async ex =>
  10954. {
  10955. using (await gate.LockAsync().ConfigureAwait(false))
  10956. {
  10957. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10958. }
  10959. },
  10960. async () =>
  10961. {
  10962. using (await gate.LockAsync().ConfigureAwait(false))
  10963. {
  10964. isDone9 = true;
  10965. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  10966. {
  10967. await observer.OnCompletedAsync().ConfigureAwait(false);
  10968. }
  10969. }
  10970. }
  10971. ),
  10972. Create<T10>(
  10973. async x =>
  10974. {
  10975. using (await gate.LockAsync().ConfigureAwait(false))
  10976. {
  10977. if (!hasValue10)
  10978. {
  10979. hasValue10 = true;
  10980. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  10981. }
  10982. latestValue10 = x;
  10983. if (allHasValue)
  10984. {
  10985. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  10986. }
  10987. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13 && isDone14)
  10988. {
  10989. await observer.OnCompletedAsync().ConfigureAwait(false);
  10990. }
  10991. }
  10992. },
  10993. async ex =>
  10994. {
  10995. using (await gate.LockAsync().ConfigureAwait(false))
  10996. {
  10997. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  10998. }
  10999. },
  11000. async () =>
  11001. {
  11002. using (await gate.LockAsync().ConfigureAwait(false))
  11003. {
  11004. isDone10 = true;
  11005. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11006. {
  11007. await observer.OnCompletedAsync().ConfigureAwait(false);
  11008. }
  11009. }
  11010. }
  11011. ),
  11012. Create<T11>(
  11013. async x =>
  11014. {
  11015. using (await gate.LockAsync().ConfigureAwait(false))
  11016. {
  11017. if (!hasValue11)
  11018. {
  11019. hasValue11 = true;
  11020. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11021. }
  11022. latestValue11 = x;
  11023. if (allHasValue)
  11024. {
  11025. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  11026. }
  11027. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13 && isDone14)
  11028. {
  11029. await observer.OnCompletedAsync().ConfigureAwait(false);
  11030. }
  11031. }
  11032. },
  11033. async ex =>
  11034. {
  11035. using (await gate.LockAsync().ConfigureAwait(false))
  11036. {
  11037. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11038. }
  11039. },
  11040. async () =>
  11041. {
  11042. using (await gate.LockAsync().ConfigureAwait(false))
  11043. {
  11044. isDone11 = true;
  11045. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11046. {
  11047. await observer.OnCompletedAsync().ConfigureAwait(false);
  11048. }
  11049. }
  11050. }
  11051. ),
  11052. Create<T12>(
  11053. async x =>
  11054. {
  11055. using (await gate.LockAsync().ConfigureAwait(false))
  11056. {
  11057. if (!hasValue12)
  11058. {
  11059. hasValue12 = true;
  11060. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11061. }
  11062. latestValue12 = x;
  11063. if (allHasValue)
  11064. {
  11065. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  11066. }
  11067. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13 && isDone14)
  11068. {
  11069. await observer.OnCompletedAsync().ConfigureAwait(false);
  11070. }
  11071. }
  11072. },
  11073. async ex =>
  11074. {
  11075. using (await gate.LockAsync().ConfigureAwait(false))
  11076. {
  11077. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11078. }
  11079. },
  11080. async () =>
  11081. {
  11082. using (await gate.LockAsync().ConfigureAwait(false))
  11083. {
  11084. isDone12 = true;
  11085. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11086. {
  11087. await observer.OnCompletedAsync().ConfigureAwait(false);
  11088. }
  11089. }
  11090. }
  11091. ),
  11092. Create<T13>(
  11093. async x =>
  11094. {
  11095. using (await gate.LockAsync().ConfigureAwait(false))
  11096. {
  11097. if (!hasValue13)
  11098. {
  11099. hasValue13 = true;
  11100. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11101. }
  11102. latestValue13 = x;
  11103. if (allHasValue)
  11104. {
  11105. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  11106. }
  11107. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone14)
  11108. {
  11109. await observer.OnCompletedAsync().ConfigureAwait(false);
  11110. }
  11111. }
  11112. },
  11113. async ex =>
  11114. {
  11115. using (await gate.LockAsync().ConfigureAwait(false))
  11116. {
  11117. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11118. }
  11119. },
  11120. async () =>
  11121. {
  11122. using (await gate.LockAsync().ConfigureAwait(false))
  11123. {
  11124. isDone13 = true;
  11125. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11126. {
  11127. await observer.OnCompletedAsync().ConfigureAwait(false);
  11128. }
  11129. }
  11130. }
  11131. ),
  11132. Create<T14>(
  11133. async x =>
  11134. {
  11135. using (await gate.LockAsync().ConfigureAwait(false))
  11136. {
  11137. if (!hasValue14)
  11138. {
  11139. hasValue14 = true;
  11140. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11141. }
  11142. latestValue14 = x;
  11143. if (allHasValue)
  11144. {
  11145. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14)).ConfigureAwait(false);
  11146. }
  11147. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  11148. {
  11149. await observer.OnCompletedAsync().ConfigureAwait(false);
  11150. }
  11151. }
  11152. },
  11153. async ex =>
  11154. {
  11155. using (await gate.LockAsync().ConfigureAwait(false))
  11156. {
  11157. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11158. }
  11159. },
  11160. async () =>
  11161. {
  11162. using (await gate.LockAsync().ConfigureAwait(false))
  11163. {
  11164. isDone14 = true;
  11165. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11166. {
  11167. await observer.OnCompletedAsync().ConfigureAwait(false);
  11168. }
  11169. }
  11170. }
  11171. )
  11172. );
  11173. }
  11174. 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)
  11175. {
  11176. if (observer == null)
  11177. throw new ArgumentNullException(nameof(observer));
  11178. if (selector == null)
  11179. throw new ArgumentNullException(nameof(selector));
  11180. 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)));
  11181. }
  11182. 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)
  11183. {
  11184. if (observer == null)
  11185. throw new ArgumentNullException(nameof(observer));
  11186. if (selector == null)
  11187. throw new ArgumentNullException(nameof(selector));
  11188. bool allHasValue = false;
  11189. bool hasValue1 = false;
  11190. bool isDone1 = false;
  11191. T1 latestValue1 = default(T1);
  11192. bool hasValue2 = false;
  11193. bool isDone2 = false;
  11194. T2 latestValue2 = default(T2);
  11195. bool hasValue3 = false;
  11196. bool isDone3 = false;
  11197. T3 latestValue3 = default(T3);
  11198. bool hasValue4 = false;
  11199. bool isDone4 = false;
  11200. T4 latestValue4 = default(T4);
  11201. bool hasValue5 = false;
  11202. bool isDone5 = false;
  11203. T5 latestValue5 = default(T5);
  11204. bool hasValue6 = false;
  11205. bool isDone6 = false;
  11206. T6 latestValue6 = default(T6);
  11207. bool hasValue7 = false;
  11208. bool isDone7 = false;
  11209. T7 latestValue7 = default(T7);
  11210. bool hasValue8 = false;
  11211. bool isDone8 = false;
  11212. T8 latestValue8 = default(T8);
  11213. bool hasValue9 = false;
  11214. bool isDone9 = false;
  11215. T9 latestValue9 = default(T9);
  11216. bool hasValue10 = false;
  11217. bool isDone10 = false;
  11218. T10 latestValue10 = default(T10);
  11219. bool hasValue11 = false;
  11220. bool isDone11 = false;
  11221. T11 latestValue11 = default(T11);
  11222. bool hasValue12 = false;
  11223. bool isDone12 = false;
  11224. T12 latestValue12 = default(T12);
  11225. bool hasValue13 = false;
  11226. bool isDone13 = false;
  11227. T13 latestValue13 = default(T13);
  11228. bool hasValue14 = false;
  11229. bool isDone14 = false;
  11230. T14 latestValue14 = default(T14);
  11231. var gate = AsyncGate.Create();
  11232. return
  11233. (
  11234. Create<T1>(
  11235. async x =>
  11236. {
  11237. using (await gate.LockAsync().ConfigureAwait(false))
  11238. {
  11239. if (!hasValue1)
  11240. {
  11241. hasValue1 = true;
  11242. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11243. }
  11244. latestValue1 = x;
  11245. if (allHasValue)
  11246. {
  11247. TResult res;
  11248. try
  11249. {
  11250. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11251. }
  11252. catch (Exception ex)
  11253. {
  11254. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11255. return;
  11256. }
  11257. await observer.OnNextAsync(res).ConfigureAwait(false);
  11258. }
  11259. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11260. {
  11261. await observer.OnCompletedAsync().ConfigureAwait(false);
  11262. }
  11263. }
  11264. },
  11265. async ex =>
  11266. {
  11267. using (await gate.LockAsync().ConfigureAwait(false))
  11268. {
  11269. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11270. }
  11271. },
  11272. async () =>
  11273. {
  11274. using (await gate.LockAsync().ConfigureAwait(false))
  11275. {
  11276. isDone1 = true;
  11277. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11278. {
  11279. await observer.OnCompletedAsync().ConfigureAwait(false);
  11280. }
  11281. }
  11282. }
  11283. ),
  11284. Create<T2>(
  11285. async x =>
  11286. {
  11287. using (await gate.LockAsync().ConfigureAwait(false))
  11288. {
  11289. if (!hasValue2)
  11290. {
  11291. hasValue2 = true;
  11292. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11293. }
  11294. latestValue2 = x;
  11295. if (allHasValue)
  11296. {
  11297. TResult res;
  11298. try
  11299. {
  11300. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11301. }
  11302. catch (Exception ex)
  11303. {
  11304. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11305. return;
  11306. }
  11307. await observer.OnNextAsync(res).ConfigureAwait(false);
  11308. }
  11309. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11310. {
  11311. await observer.OnCompletedAsync().ConfigureAwait(false);
  11312. }
  11313. }
  11314. },
  11315. async ex =>
  11316. {
  11317. using (await gate.LockAsync().ConfigureAwait(false))
  11318. {
  11319. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11320. }
  11321. },
  11322. async () =>
  11323. {
  11324. using (await gate.LockAsync().ConfigureAwait(false))
  11325. {
  11326. isDone2 = true;
  11327. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11328. {
  11329. await observer.OnCompletedAsync().ConfigureAwait(false);
  11330. }
  11331. }
  11332. }
  11333. ),
  11334. Create<T3>(
  11335. async x =>
  11336. {
  11337. using (await gate.LockAsync().ConfigureAwait(false))
  11338. {
  11339. if (!hasValue3)
  11340. {
  11341. hasValue3 = true;
  11342. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11343. }
  11344. latestValue3 = x;
  11345. if (allHasValue)
  11346. {
  11347. TResult res;
  11348. try
  11349. {
  11350. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11351. }
  11352. catch (Exception ex)
  11353. {
  11354. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11355. return;
  11356. }
  11357. await observer.OnNextAsync(res).ConfigureAwait(false);
  11358. }
  11359. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11360. {
  11361. await observer.OnCompletedAsync().ConfigureAwait(false);
  11362. }
  11363. }
  11364. },
  11365. async ex =>
  11366. {
  11367. using (await gate.LockAsync().ConfigureAwait(false))
  11368. {
  11369. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11370. }
  11371. },
  11372. async () =>
  11373. {
  11374. using (await gate.LockAsync().ConfigureAwait(false))
  11375. {
  11376. isDone3 = true;
  11377. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11378. {
  11379. await observer.OnCompletedAsync().ConfigureAwait(false);
  11380. }
  11381. }
  11382. }
  11383. ),
  11384. Create<T4>(
  11385. async x =>
  11386. {
  11387. using (await gate.LockAsync().ConfigureAwait(false))
  11388. {
  11389. if (!hasValue4)
  11390. {
  11391. hasValue4 = true;
  11392. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11393. }
  11394. latestValue4 = x;
  11395. if (allHasValue)
  11396. {
  11397. TResult res;
  11398. try
  11399. {
  11400. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11401. }
  11402. catch (Exception ex)
  11403. {
  11404. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11405. return;
  11406. }
  11407. await observer.OnNextAsync(res).ConfigureAwait(false);
  11408. }
  11409. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11410. {
  11411. await observer.OnCompletedAsync().ConfigureAwait(false);
  11412. }
  11413. }
  11414. },
  11415. async ex =>
  11416. {
  11417. using (await gate.LockAsync().ConfigureAwait(false))
  11418. {
  11419. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11420. }
  11421. },
  11422. async () =>
  11423. {
  11424. using (await gate.LockAsync().ConfigureAwait(false))
  11425. {
  11426. isDone4 = true;
  11427. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11428. {
  11429. await observer.OnCompletedAsync().ConfigureAwait(false);
  11430. }
  11431. }
  11432. }
  11433. ),
  11434. Create<T5>(
  11435. async x =>
  11436. {
  11437. using (await gate.LockAsync().ConfigureAwait(false))
  11438. {
  11439. if (!hasValue5)
  11440. {
  11441. hasValue5 = true;
  11442. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11443. }
  11444. latestValue5 = x;
  11445. if (allHasValue)
  11446. {
  11447. TResult res;
  11448. try
  11449. {
  11450. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11451. }
  11452. catch (Exception ex)
  11453. {
  11454. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11455. return;
  11456. }
  11457. await observer.OnNextAsync(res).ConfigureAwait(false);
  11458. }
  11459. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11460. {
  11461. await observer.OnCompletedAsync().ConfigureAwait(false);
  11462. }
  11463. }
  11464. },
  11465. async ex =>
  11466. {
  11467. using (await gate.LockAsync().ConfigureAwait(false))
  11468. {
  11469. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11470. }
  11471. },
  11472. async () =>
  11473. {
  11474. using (await gate.LockAsync().ConfigureAwait(false))
  11475. {
  11476. isDone5 = true;
  11477. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11478. {
  11479. await observer.OnCompletedAsync().ConfigureAwait(false);
  11480. }
  11481. }
  11482. }
  11483. ),
  11484. Create<T6>(
  11485. async x =>
  11486. {
  11487. using (await gate.LockAsync().ConfigureAwait(false))
  11488. {
  11489. if (!hasValue6)
  11490. {
  11491. hasValue6 = true;
  11492. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11493. }
  11494. latestValue6 = x;
  11495. if (allHasValue)
  11496. {
  11497. TResult res;
  11498. try
  11499. {
  11500. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11501. }
  11502. catch (Exception ex)
  11503. {
  11504. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11505. return;
  11506. }
  11507. await observer.OnNextAsync(res).ConfigureAwait(false);
  11508. }
  11509. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11510. {
  11511. await observer.OnCompletedAsync().ConfigureAwait(false);
  11512. }
  11513. }
  11514. },
  11515. async ex =>
  11516. {
  11517. using (await gate.LockAsync().ConfigureAwait(false))
  11518. {
  11519. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11520. }
  11521. },
  11522. async () =>
  11523. {
  11524. using (await gate.LockAsync().ConfigureAwait(false))
  11525. {
  11526. isDone6 = true;
  11527. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11528. {
  11529. await observer.OnCompletedAsync().ConfigureAwait(false);
  11530. }
  11531. }
  11532. }
  11533. ),
  11534. Create<T7>(
  11535. async x =>
  11536. {
  11537. using (await gate.LockAsync().ConfigureAwait(false))
  11538. {
  11539. if (!hasValue7)
  11540. {
  11541. hasValue7 = true;
  11542. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11543. }
  11544. latestValue7 = x;
  11545. if (allHasValue)
  11546. {
  11547. TResult res;
  11548. try
  11549. {
  11550. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11551. }
  11552. catch (Exception ex)
  11553. {
  11554. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11555. return;
  11556. }
  11557. await observer.OnNextAsync(res).ConfigureAwait(false);
  11558. }
  11559. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11560. {
  11561. await observer.OnCompletedAsync().ConfigureAwait(false);
  11562. }
  11563. }
  11564. },
  11565. async ex =>
  11566. {
  11567. using (await gate.LockAsync().ConfigureAwait(false))
  11568. {
  11569. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11570. }
  11571. },
  11572. async () =>
  11573. {
  11574. using (await gate.LockAsync().ConfigureAwait(false))
  11575. {
  11576. isDone7 = true;
  11577. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11578. {
  11579. await observer.OnCompletedAsync().ConfigureAwait(false);
  11580. }
  11581. }
  11582. }
  11583. ),
  11584. Create<T8>(
  11585. async x =>
  11586. {
  11587. using (await gate.LockAsync().ConfigureAwait(false))
  11588. {
  11589. if (!hasValue8)
  11590. {
  11591. hasValue8 = true;
  11592. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11593. }
  11594. latestValue8 = x;
  11595. if (allHasValue)
  11596. {
  11597. TResult res;
  11598. try
  11599. {
  11600. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11601. }
  11602. catch (Exception ex)
  11603. {
  11604. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11605. return;
  11606. }
  11607. await observer.OnNextAsync(res).ConfigureAwait(false);
  11608. }
  11609. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11610. {
  11611. await observer.OnCompletedAsync().ConfigureAwait(false);
  11612. }
  11613. }
  11614. },
  11615. async ex =>
  11616. {
  11617. using (await gate.LockAsync().ConfigureAwait(false))
  11618. {
  11619. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11620. }
  11621. },
  11622. async () =>
  11623. {
  11624. using (await gate.LockAsync().ConfigureAwait(false))
  11625. {
  11626. isDone8 = true;
  11627. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11628. {
  11629. await observer.OnCompletedAsync().ConfigureAwait(false);
  11630. }
  11631. }
  11632. }
  11633. ),
  11634. Create<T9>(
  11635. async x =>
  11636. {
  11637. using (await gate.LockAsync().ConfigureAwait(false))
  11638. {
  11639. if (!hasValue9)
  11640. {
  11641. hasValue9 = true;
  11642. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11643. }
  11644. latestValue9 = x;
  11645. if (allHasValue)
  11646. {
  11647. TResult res;
  11648. try
  11649. {
  11650. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11651. }
  11652. catch (Exception ex)
  11653. {
  11654. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11655. return;
  11656. }
  11657. await observer.OnNextAsync(res).ConfigureAwait(false);
  11658. }
  11659. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11660. {
  11661. await observer.OnCompletedAsync().ConfigureAwait(false);
  11662. }
  11663. }
  11664. },
  11665. async ex =>
  11666. {
  11667. using (await gate.LockAsync().ConfigureAwait(false))
  11668. {
  11669. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11670. }
  11671. },
  11672. async () =>
  11673. {
  11674. using (await gate.LockAsync().ConfigureAwait(false))
  11675. {
  11676. isDone9 = true;
  11677. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11678. {
  11679. await observer.OnCompletedAsync().ConfigureAwait(false);
  11680. }
  11681. }
  11682. }
  11683. ),
  11684. Create<T10>(
  11685. async x =>
  11686. {
  11687. using (await gate.LockAsync().ConfigureAwait(false))
  11688. {
  11689. if (!hasValue10)
  11690. {
  11691. hasValue10 = true;
  11692. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11693. }
  11694. latestValue10 = x;
  11695. if (allHasValue)
  11696. {
  11697. TResult res;
  11698. try
  11699. {
  11700. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11701. }
  11702. catch (Exception ex)
  11703. {
  11704. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11705. return;
  11706. }
  11707. await observer.OnNextAsync(res).ConfigureAwait(false);
  11708. }
  11709. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13 && isDone14)
  11710. {
  11711. await observer.OnCompletedAsync().ConfigureAwait(false);
  11712. }
  11713. }
  11714. },
  11715. async ex =>
  11716. {
  11717. using (await gate.LockAsync().ConfigureAwait(false))
  11718. {
  11719. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11720. }
  11721. },
  11722. async () =>
  11723. {
  11724. using (await gate.LockAsync().ConfigureAwait(false))
  11725. {
  11726. isDone10 = true;
  11727. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11728. {
  11729. await observer.OnCompletedAsync().ConfigureAwait(false);
  11730. }
  11731. }
  11732. }
  11733. ),
  11734. Create<T11>(
  11735. async x =>
  11736. {
  11737. using (await gate.LockAsync().ConfigureAwait(false))
  11738. {
  11739. if (!hasValue11)
  11740. {
  11741. hasValue11 = true;
  11742. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11743. }
  11744. latestValue11 = x;
  11745. if (allHasValue)
  11746. {
  11747. TResult res;
  11748. try
  11749. {
  11750. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11751. }
  11752. catch (Exception ex)
  11753. {
  11754. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11755. return;
  11756. }
  11757. await observer.OnNextAsync(res).ConfigureAwait(false);
  11758. }
  11759. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13 && isDone14)
  11760. {
  11761. await observer.OnCompletedAsync().ConfigureAwait(false);
  11762. }
  11763. }
  11764. },
  11765. async ex =>
  11766. {
  11767. using (await gate.LockAsync().ConfigureAwait(false))
  11768. {
  11769. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11770. }
  11771. },
  11772. async () =>
  11773. {
  11774. using (await gate.LockAsync().ConfigureAwait(false))
  11775. {
  11776. isDone11 = true;
  11777. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11778. {
  11779. await observer.OnCompletedAsync().ConfigureAwait(false);
  11780. }
  11781. }
  11782. }
  11783. ),
  11784. Create<T12>(
  11785. async x =>
  11786. {
  11787. using (await gate.LockAsync().ConfigureAwait(false))
  11788. {
  11789. if (!hasValue12)
  11790. {
  11791. hasValue12 = true;
  11792. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11793. }
  11794. latestValue12 = x;
  11795. if (allHasValue)
  11796. {
  11797. TResult res;
  11798. try
  11799. {
  11800. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11801. }
  11802. catch (Exception ex)
  11803. {
  11804. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11805. return;
  11806. }
  11807. await observer.OnNextAsync(res).ConfigureAwait(false);
  11808. }
  11809. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13 && isDone14)
  11810. {
  11811. await observer.OnCompletedAsync().ConfigureAwait(false);
  11812. }
  11813. }
  11814. },
  11815. async ex =>
  11816. {
  11817. using (await gate.LockAsync().ConfigureAwait(false))
  11818. {
  11819. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11820. }
  11821. },
  11822. async () =>
  11823. {
  11824. using (await gate.LockAsync().ConfigureAwait(false))
  11825. {
  11826. isDone12 = true;
  11827. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11828. {
  11829. await observer.OnCompletedAsync().ConfigureAwait(false);
  11830. }
  11831. }
  11832. }
  11833. ),
  11834. Create<T13>(
  11835. async x =>
  11836. {
  11837. using (await gate.LockAsync().ConfigureAwait(false))
  11838. {
  11839. if (!hasValue13)
  11840. {
  11841. hasValue13 = true;
  11842. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11843. }
  11844. latestValue13 = x;
  11845. if (allHasValue)
  11846. {
  11847. TResult res;
  11848. try
  11849. {
  11850. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11851. }
  11852. catch (Exception ex)
  11853. {
  11854. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11855. return;
  11856. }
  11857. await observer.OnNextAsync(res).ConfigureAwait(false);
  11858. }
  11859. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone14)
  11860. {
  11861. await observer.OnCompletedAsync().ConfigureAwait(false);
  11862. }
  11863. }
  11864. },
  11865. async ex =>
  11866. {
  11867. using (await gate.LockAsync().ConfigureAwait(false))
  11868. {
  11869. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11870. }
  11871. },
  11872. async () =>
  11873. {
  11874. using (await gate.LockAsync().ConfigureAwait(false))
  11875. {
  11876. isDone13 = true;
  11877. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11878. {
  11879. await observer.OnCompletedAsync().ConfigureAwait(false);
  11880. }
  11881. }
  11882. }
  11883. ),
  11884. Create<T14>(
  11885. async x =>
  11886. {
  11887. using (await gate.LockAsync().ConfigureAwait(false))
  11888. {
  11889. if (!hasValue14)
  11890. {
  11891. hasValue14 = true;
  11892. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14;
  11893. }
  11894. latestValue14 = x;
  11895. if (allHasValue)
  11896. {
  11897. TResult res;
  11898. try
  11899. {
  11900. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14).ConfigureAwait(false);
  11901. }
  11902. catch (Exception ex)
  11903. {
  11904. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11905. return;
  11906. }
  11907. await observer.OnNextAsync(res).ConfigureAwait(false);
  11908. }
  11909. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13)
  11910. {
  11911. await observer.OnCompletedAsync().ConfigureAwait(false);
  11912. }
  11913. }
  11914. },
  11915. async ex =>
  11916. {
  11917. using (await gate.LockAsync().ConfigureAwait(false))
  11918. {
  11919. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  11920. }
  11921. },
  11922. async () =>
  11923. {
  11924. using (await gate.LockAsync().ConfigureAwait(false))
  11925. {
  11926. isDone14 = true;
  11927. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  11928. {
  11929. await observer.OnCompletedAsync().ConfigureAwait(false);
  11930. }
  11931. }
  11932. }
  11933. )
  11934. );
  11935. }
  11936. 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)
  11937. {
  11938. if (observer == null)
  11939. throw new ArgumentNullException(nameof(observer));
  11940. bool allHasValue = false;
  11941. bool hasValue1 = false;
  11942. bool isDone1 = false;
  11943. T1 latestValue1 = default(T1);
  11944. bool hasValue2 = false;
  11945. bool isDone2 = false;
  11946. T2 latestValue2 = default(T2);
  11947. bool hasValue3 = false;
  11948. bool isDone3 = false;
  11949. T3 latestValue3 = default(T3);
  11950. bool hasValue4 = false;
  11951. bool isDone4 = false;
  11952. T4 latestValue4 = default(T4);
  11953. bool hasValue5 = false;
  11954. bool isDone5 = false;
  11955. T5 latestValue5 = default(T5);
  11956. bool hasValue6 = false;
  11957. bool isDone6 = false;
  11958. T6 latestValue6 = default(T6);
  11959. bool hasValue7 = false;
  11960. bool isDone7 = false;
  11961. T7 latestValue7 = default(T7);
  11962. bool hasValue8 = false;
  11963. bool isDone8 = false;
  11964. T8 latestValue8 = default(T8);
  11965. bool hasValue9 = false;
  11966. bool isDone9 = false;
  11967. T9 latestValue9 = default(T9);
  11968. bool hasValue10 = false;
  11969. bool isDone10 = false;
  11970. T10 latestValue10 = default(T10);
  11971. bool hasValue11 = false;
  11972. bool isDone11 = false;
  11973. T11 latestValue11 = default(T11);
  11974. bool hasValue12 = false;
  11975. bool isDone12 = false;
  11976. T12 latestValue12 = default(T12);
  11977. bool hasValue13 = false;
  11978. bool isDone13 = false;
  11979. T13 latestValue13 = default(T13);
  11980. bool hasValue14 = false;
  11981. bool isDone14 = false;
  11982. T14 latestValue14 = default(T14);
  11983. bool hasValue15 = false;
  11984. bool isDone15 = false;
  11985. T15 latestValue15 = default(T15);
  11986. var gate = AsyncGate.Create();
  11987. return
  11988. (
  11989. Create<T1>(
  11990. async x =>
  11991. {
  11992. using (await gate.LockAsync().ConfigureAwait(false))
  11993. {
  11994. if (!hasValue1)
  11995. {
  11996. hasValue1 = true;
  11997. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  11998. }
  11999. latestValue1 = x;
  12000. if (allHasValue)
  12001. {
  12002. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12003. }
  12004. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12005. {
  12006. await observer.OnCompletedAsync().ConfigureAwait(false);
  12007. }
  12008. }
  12009. },
  12010. async ex =>
  12011. {
  12012. using (await gate.LockAsync().ConfigureAwait(false))
  12013. {
  12014. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12015. }
  12016. },
  12017. async () =>
  12018. {
  12019. using (await gate.LockAsync().ConfigureAwait(false))
  12020. {
  12021. isDone1 = true;
  12022. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12023. {
  12024. await observer.OnCompletedAsync().ConfigureAwait(false);
  12025. }
  12026. }
  12027. }
  12028. ),
  12029. Create<T2>(
  12030. async x =>
  12031. {
  12032. using (await gate.LockAsync().ConfigureAwait(false))
  12033. {
  12034. if (!hasValue2)
  12035. {
  12036. hasValue2 = true;
  12037. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12038. }
  12039. latestValue2 = x;
  12040. if (allHasValue)
  12041. {
  12042. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12043. }
  12044. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12045. {
  12046. await observer.OnCompletedAsync().ConfigureAwait(false);
  12047. }
  12048. }
  12049. },
  12050. async ex =>
  12051. {
  12052. using (await gate.LockAsync().ConfigureAwait(false))
  12053. {
  12054. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12055. }
  12056. },
  12057. async () =>
  12058. {
  12059. using (await gate.LockAsync().ConfigureAwait(false))
  12060. {
  12061. isDone2 = true;
  12062. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12063. {
  12064. await observer.OnCompletedAsync().ConfigureAwait(false);
  12065. }
  12066. }
  12067. }
  12068. ),
  12069. Create<T3>(
  12070. async x =>
  12071. {
  12072. using (await gate.LockAsync().ConfigureAwait(false))
  12073. {
  12074. if (!hasValue3)
  12075. {
  12076. hasValue3 = true;
  12077. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12078. }
  12079. latestValue3 = x;
  12080. if (allHasValue)
  12081. {
  12082. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12083. }
  12084. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12085. {
  12086. await observer.OnCompletedAsync().ConfigureAwait(false);
  12087. }
  12088. }
  12089. },
  12090. async ex =>
  12091. {
  12092. using (await gate.LockAsync().ConfigureAwait(false))
  12093. {
  12094. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12095. }
  12096. },
  12097. async () =>
  12098. {
  12099. using (await gate.LockAsync().ConfigureAwait(false))
  12100. {
  12101. isDone3 = true;
  12102. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12103. {
  12104. await observer.OnCompletedAsync().ConfigureAwait(false);
  12105. }
  12106. }
  12107. }
  12108. ),
  12109. Create<T4>(
  12110. async x =>
  12111. {
  12112. using (await gate.LockAsync().ConfigureAwait(false))
  12113. {
  12114. if (!hasValue4)
  12115. {
  12116. hasValue4 = true;
  12117. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12118. }
  12119. latestValue4 = x;
  12120. if (allHasValue)
  12121. {
  12122. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12123. }
  12124. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12125. {
  12126. await observer.OnCompletedAsync().ConfigureAwait(false);
  12127. }
  12128. }
  12129. },
  12130. async ex =>
  12131. {
  12132. using (await gate.LockAsync().ConfigureAwait(false))
  12133. {
  12134. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12135. }
  12136. },
  12137. async () =>
  12138. {
  12139. using (await gate.LockAsync().ConfigureAwait(false))
  12140. {
  12141. isDone4 = true;
  12142. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12143. {
  12144. await observer.OnCompletedAsync().ConfigureAwait(false);
  12145. }
  12146. }
  12147. }
  12148. ),
  12149. Create<T5>(
  12150. async x =>
  12151. {
  12152. using (await gate.LockAsync().ConfigureAwait(false))
  12153. {
  12154. if (!hasValue5)
  12155. {
  12156. hasValue5 = true;
  12157. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12158. }
  12159. latestValue5 = x;
  12160. if (allHasValue)
  12161. {
  12162. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12163. }
  12164. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12165. {
  12166. await observer.OnCompletedAsync().ConfigureAwait(false);
  12167. }
  12168. }
  12169. },
  12170. async ex =>
  12171. {
  12172. using (await gate.LockAsync().ConfigureAwait(false))
  12173. {
  12174. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12175. }
  12176. },
  12177. async () =>
  12178. {
  12179. using (await gate.LockAsync().ConfigureAwait(false))
  12180. {
  12181. isDone5 = true;
  12182. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12183. {
  12184. await observer.OnCompletedAsync().ConfigureAwait(false);
  12185. }
  12186. }
  12187. }
  12188. ),
  12189. Create<T6>(
  12190. async x =>
  12191. {
  12192. using (await gate.LockAsync().ConfigureAwait(false))
  12193. {
  12194. if (!hasValue6)
  12195. {
  12196. hasValue6 = true;
  12197. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12198. }
  12199. latestValue6 = x;
  12200. if (allHasValue)
  12201. {
  12202. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12203. }
  12204. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12205. {
  12206. await observer.OnCompletedAsync().ConfigureAwait(false);
  12207. }
  12208. }
  12209. },
  12210. async ex =>
  12211. {
  12212. using (await gate.LockAsync().ConfigureAwait(false))
  12213. {
  12214. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12215. }
  12216. },
  12217. async () =>
  12218. {
  12219. using (await gate.LockAsync().ConfigureAwait(false))
  12220. {
  12221. isDone6 = true;
  12222. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12223. {
  12224. await observer.OnCompletedAsync().ConfigureAwait(false);
  12225. }
  12226. }
  12227. }
  12228. ),
  12229. Create<T7>(
  12230. async x =>
  12231. {
  12232. using (await gate.LockAsync().ConfigureAwait(false))
  12233. {
  12234. if (!hasValue7)
  12235. {
  12236. hasValue7 = true;
  12237. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12238. }
  12239. latestValue7 = x;
  12240. if (allHasValue)
  12241. {
  12242. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12243. }
  12244. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12245. {
  12246. await observer.OnCompletedAsync().ConfigureAwait(false);
  12247. }
  12248. }
  12249. },
  12250. async ex =>
  12251. {
  12252. using (await gate.LockAsync().ConfigureAwait(false))
  12253. {
  12254. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12255. }
  12256. },
  12257. async () =>
  12258. {
  12259. using (await gate.LockAsync().ConfigureAwait(false))
  12260. {
  12261. isDone7 = true;
  12262. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12263. {
  12264. await observer.OnCompletedAsync().ConfigureAwait(false);
  12265. }
  12266. }
  12267. }
  12268. ),
  12269. Create<T8>(
  12270. async x =>
  12271. {
  12272. using (await gate.LockAsync().ConfigureAwait(false))
  12273. {
  12274. if (!hasValue8)
  12275. {
  12276. hasValue8 = true;
  12277. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12278. }
  12279. latestValue8 = x;
  12280. if (allHasValue)
  12281. {
  12282. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12283. }
  12284. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12285. {
  12286. await observer.OnCompletedAsync().ConfigureAwait(false);
  12287. }
  12288. }
  12289. },
  12290. async ex =>
  12291. {
  12292. using (await gate.LockAsync().ConfigureAwait(false))
  12293. {
  12294. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12295. }
  12296. },
  12297. async () =>
  12298. {
  12299. using (await gate.LockAsync().ConfigureAwait(false))
  12300. {
  12301. isDone8 = true;
  12302. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12303. {
  12304. await observer.OnCompletedAsync().ConfigureAwait(false);
  12305. }
  12306. }
  12307. }
  12308. ),
  12309. Create<T9>(
  12310. async x =>
  12311. {
  12312. using (await gate.LockAsync().ConfigureAwait(false))
  12313. {
  12314. if (!hasValue9)
  12315. {
  12316. hasValue9 = true;
  12317. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12318. }
  12319. latestValue9 = x;
  12320. if (allHasValue)
  12321. {
  12322. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12323. }
  12324. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12325. {
  12326. await observer.OnCompletedAsync().ConfigureAwait(false);
  12327. }
  12328. }
  12329. },
  12330. async ex =>
  12331. {
  12332. using (await gate.LockAsync().ConfigureAwait(false))
  12333. {
  12334. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12335. }
  12336. },
  12337. async () =>
  12338. {
  12339. using (await gate.LockAsync().ConfigureAwait(false))
  12340. {
  12341. isDone9 = true;
  12342. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12343. {
  12344. await observer.OnCompletedAsync().ConfigureAwait(false);
  12345. }
  12346. }
  12347. }
  12348. ),
  12349. Create<T10>(
  12350. async x =>
  12351. {
  12352. using (await gate.LockAsync().ConfigureAwait(false))
  12353. {
  12354. if (!hasValue10)
  12355. {
  12356. hasValue10 = true;
  12357. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12358. }
  12359. latestValue10 = x;
  12360. if (allHasValue)
  12361. {
  12362. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12363. }
  12364. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12365. {
  12366. await observer.OnCompletedAsync().ConfigureAwait(false);
  12367. }
  12368. }
  12369. },
  12370. async ex =>
  12371. {
  12372. using (await gate.LockAsync().ConfigureAwait(false))
  12373. {
  12374. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12375. }
  12376. },
  12377. async () =>
  12378. {
  12379. using (await gate.LockAsync().ConfigureAwait(false))
  12380. {
  12381. isDone10 = true;
  12382. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12383. {
  12384. await observer.OnCompletedAsync().ConfigureAwait(false);
  12385. }
  12386. }
  12387. }
  12388. ),
  12389. Create<T11>(
  12390. async x =>
  12391. {
  12392. using (await gate.LockAsync().ConfigureAwait(false))
  12393. {
  12394. if (!hasValue11)
  12395. {
  12396. hasValue11 = true;
  12397. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12398. }
  12399. latestValue11 = x;
  12400. if (allHasValue)
  12401. {
  12402. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12403. }
  12404. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13 && isDone14 && isDone15)
  12405. {
  12406. await observer.OnCompletedAsync().ConfigureAwait(false);
  12407. }
  12408. }
  12409. },
  12410. async ex =>
  12411. {
  12412. using (await gate.LockAsync().ConfigureAwait(false))
  12413. {
  12414. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12415. }
  12416. },
  12417. async () =>
  12418. {
  12419. using (await gate.LockAsync().ConfigureAwait(false))
  12420. {
  12421. isDone11 = true;
  12422. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12423. {
  12424. await observer.OnCompletedAsync().ConfigureAwait(false);
  12425. }
  12426. }
  12427. }
  12428. ),
  12429. Create<T12>(
  12430. async x =>
  12431. {
  12432. using (await gate.LockAsync().ConfigureAwait(false))
  12433. {
  12434. if (!hasValue12)
  12435. {
  12436. hasValue12 = true;
  12437. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12438. }
  12439. latestValue12 = x;
  12440. if (allHasValue)
  12441. {
  12442. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12443. }
  12444. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13 && isDone14 && isDone15)
  12445. {
  12446. await observer.OnCompletedAsync().ConfigureAwait(false);
  12447. }
  12448. }
  12449. },
  12450. async ex =>
  12451. {
  12452. using (await gate.LockAsync().ConfigureAwait(false))
  12453. {
  12454. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12455. }
  12456. },
  12457. async () =>
  12458. {
  12459. using (await gate.LockAsync().ConfigureAwait(false))
  12460. {
  12461. isDone12 = true;
  12462. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12463. {
  12464. await observer.OnCompletedAsync().ConfigureAwait(false);
  12465. }
  12466. }
  12467. }
  12468. ),
  12469. Create<T13>(
  12470. async x =>
  12471. {
  12472. using (await gate.LockAsync().ConfigureAwait(false))
  12473. {
  12474. if (!hasValue13)
  12475. {
  12476. hasValue13 = true;
  12477. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12478. }
  12479. latestValue13 = x;
  12480. if (allHasValue)
  12481. {
  12482. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12483. }
  12484. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone14 && isDone15)
  12485. {
  12486. await observer.OnCompletedAsync().ConfigureAwait(false);
  12487. }
  12488. }
  12489. },
  12490. async ex =>
  12491. {
  12492. using (await gate.LockAsync().ConfigureAwait(false))
  12493. {
  12494. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12495. }
  12496. },
  12497. async () =>
  12498. {
  12499. using (await gate.LockAsync().ConfigureAwait(false))
  12500. {
  12501. isDone13 = true;
  12502. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12503. {
  12504. await observer.OnCompletedAsync().ConfigureAwait(false);
  12505. }
  12506. }
  12507. }
  12508. ),
  12509. Create<T14>(
  12510. async x =>
  12511. {
  12512. using (await gate.LockAsync().ConfigureAwait(false))
  12513. {
  12514. if (!hasValue14)
  12515. {
  12516. hasValue14 = true;
  12517. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12518. }
  12519. latestValue14 = x;
  12520. if (allHasValue)
  12521. {
  12522. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12523. }
  12524. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone15)
  12525. {
  12526. await observer.OnCompletedAsync().ConfigureAwait(false);
  12527. }
  12528. }
  12529. },
  12530. async ex =>
  12531. {
  12532. using (await gate.LockAsync().ConfigureAwait(false))
  12533. {
  12534. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12535. }
  12536. },
  12537. async () =>
  12538. {
  12539. using (await gate.LockAsync().ConfigureAwait(false))
  12540. {
  12541. isDone14 = true;
  12542. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12543. {
  12544. await observer.OnCompletedAsync().ConfigureAwait(false);
  12545. }
  12546. }
  12547. }
  12548. ),
  12549. Create<T15>(
  12550. async x =>
  12551. {
  12552. using (await gate.LockAsync().ConfigureAwait(false))
  12553. {
  12554. if (!hasValue15)
  12555. {
  12556. hasValue15 = true;
  12557. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12558. }
  12559. latestValue15 = x;
  12560. if (allHasValue)
  12561. {
  12562. await observer.OnNextAsync((latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15)).ConfigureAwait(false);
  12563. }
  12564. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  12565. {
  12566. await observer.OnCompletedAsync().ConfigureAwait(false);
  12567. }
  12568. }
  12569. },
  12570. async ex =>
  12571. {
  12572. using (await gate.LockAsync().ConfigureAwait(false))
  12573. {
  12574. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12575. }
  12576. },
  12577. async () =>
  12578. {
  12579. using (await gate.LockAsync().ConfigureAwait(false))
  12580. {
  12581. isDone15 = true;
  12582. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12583. {
  12584. await observer.OnCompletedAsync().ConfigureAwait(false);
  12585. }
  12586. }
  12587. }
  12588. )
  12589. );
  12590. }
  12591. 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)
  12592. {
  12593. if (observer == null)
  12594. throw new ArgumentNullException(nameof(observer));
  12595. if (selector == null)
  12596. throw new ArgumentNullException(nameof(selector));
  12597. 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)));
  12598. }
  12599. 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)
  12600. {
  12601. if (observer == null)
  12602. throw new ArgumentNullException(nameof(observer));
  12603. if (selector == null)
  12604. throw new ArgumentNullException(nameof(selector));
  12605. bool allHasValue = false;
  12606. bool hasValue1 = false;
  12607. bool isDone1 = false;
  12608. T1 latestValue1 = default(T1);
  12609. bool hasValue2 = false;
  12610. bool isDone2 = false;
  12611. T2 latestValue2 = default(T2);
  12612. bool hasValue3 = false;
  12613. bool isDone3 = false;
  12614. T3 latestValue3 = default(T3);
  12615. bool hasValue4 = false;
  12616. bool isDone4 = false;
  12617. T4 latestValue4 = default(T4);
  12618. bool hasValue5 = false;
  12619. bool isDone5 = false;
  12620. T5 latestValue5 = default(T5);
  12621. bool hasValue6 = false;
  12622. bool isDone6 = false;
  12623. T6 latestValue6 = default(T6);
  12624. bool hasValue7 = false;
  12625. bool isDone7 = false;
  12626. T7 latestValue7 = default(T7);
  12627. bool hasValue8 = false;
  12628. bool isDone8 = false;
  12629. T8 latestValue8 = default(T8);
  12630. bool hasValue9 = false;
  12631. bool isDone9 = false;
  12632. T9 latestValue9 = default(T9);
  12633. bool hasValue10 = false;
  12634. bool isDone10 = false;
  12635. T10 latestValue10 = default(T10);
  12636. bool hasValue11 = false;
  12637. bool isDone11 = false;
  12638. T11 latestValue11 = default(T11);
  12639. bool hasValue12 = false;
  12640. bool isDone12 = false;
  12641. T12 latestValue12 = default(T12);
  12642. bool hasValue13 = false;
  12643. bool isDone13 = false;
  12644. T13 latestValue13 = default(T13);
  12645. bool hasValue14 = false;
  12646. bool isDone14 = false;
  12647. T14 latestValue14 = default(T14);
  12648. bool hasValue15 = false;
  12649. bool isDone15 = false;
  12650. T15 latestValue15 = default(T15);
  12651. var gate = AsyncGate.Create();
  12652. return
  12653. (
  12654. Create<T1>(
  12655. async x =>
  12656. {
  12657. using (await gate.LockAsync().ConfigureAwait(false))
  12658. {
  12659. if (!hasValue1)
  12660. {
  12661. hasValue1 = true;
  12662. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12663. }
  12664. latestValue1 = x;
  12665. if (allHasValue)
  12666. {
  12667. TResult res;
  12668. try
  12669. {
  12670. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12671. }
  12672. catch (Exception ex)
  12673. {
  12674. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12675. return;
  12676. }
  12677. await observer.OnNextAsync(res).ConfigureAwait(false);
  12678. }
  12679. else if (isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12680. {
  12681. await observer.OnCompletedAsync().ConfigureAwait(false);
  12682. }
  12683. }
  12684. },
  12685. async ex =>
  12686. {
  12687. using (await gate.LockAsync().ConfigureAwait(false))
  12688. {
  12689. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12690. }
  12691. },
  12692. async () =>
  12693. {
  12694. using (await gate.LockAsync().ConfigureAwait(false))
  12695. {
  12696. isDone1 = true;
  12697. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12698. {
  12699. await observer.OnCompletedAsync().ConfigureAwait(false);
  12700. }
  12701. }
  12702. }
  12703. ),
  12704. Create<T2>(
  12705. async x =>
  12706. {
  12707. using (await gate.LockAsync().ConfigureAwait(false))
  12708. {
  12709. if (!hasValue2)
  12710. {
  12711. hasValue2 = true;
  12712. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12713. }
  12714. latestValue2 = x;
  12715. if (allHasValue)
  12716. {
  12717. TResult res;
  12718. try
  12719. {
  12720. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12721. }
  12722. catch (Exception ex)
  12723. {
  12724. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12725. return;
  12726. }
  12727. await observer.OnNextAsync(res).ConfigureAwait(false);
  12728. }
  12729. else if (isDone1 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12730. {
  12731. await observer.OnCompletedAsync().ConfigureAwait(false);
  12732. }
  12733. }
  12734. },
  12735. async ex =>
  12736. {
  12737. using (await gate.LockAsync().ConfigureAwait(false))
  12738. {
  12739. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12740. }
  12741. },
  12742. async () =>
  12743. {
  12744. using (await gate.LockAsync().ConfigureAwait(false))
  12745. {
  12746. isDone2 = true;
  12747. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12748. {
  12749. await observer.OnCompletedAsync().ConfigureAwait(false);
  12750. }
  12751. }
  12752. }
  12753. ),
  12754. Create<T3>(
  12755. async x =>
  12756. {
  12757. using (await gate.LockAsync().ConfigureAwait(false))
  12758. {
  12759. if (!hasValue3)
  12760. {
  12761. hasValue3 = true;
  12762. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12763. }
  12764. latestValue3 = x;
  12765. if (allHasValue)
  12766. {
  12767. TResult res;
  12768. try
  12769. {
  12770. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12771. }
  12772. catch (Exception ex)
  12773. {
  12774. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12775. return;
  12776. }
  12777. await observer.OnNextAsync(res).ConfigureAwait(false);
  12778. }
  12779. else if (isDone1 && isDone2 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12780. {
  12781. await observer.OnCompletedAsync().ConfigureAwait(false);
  12782. }
  12783. }
  12784. },
  12785. async ex =>
  12786. {
  12787. using (await gate.LockAsync().ConfigureAwait(false))
  12788. {
  12789. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12790. }
  12791. },
  12792. async () =>
  12793. {
  12794. using (await gate.LockAsync().ConfigureAwait(false))
  12795. {
  12796. isDone3 = true;
  12797. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12798. {
  12799. await observer.OnCompletedAsync().ConfigureAwait(false);
  12800. }
  12801. }
  12802. }
  12803. ),
  12804. Create<T4>(
  12805. async x =>
  12806. {
  12807. using (await gate.LockAsync().ConfigureAwait(false))
  12808. {
  12809. if (!hasValue4)
  12810. {
  12811. hasValue4 = true;
  12812. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12813. }
  12814. latestValue4 = x;
  12815. if (allHasValue)
  12816. {
  12817. TResult res;
  12818. try
  12819. {
  12820. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12821. }
  12822. catch (Exception ex)
  12823. {
  12824. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12825. return;
  12826. }
  12827. await observer.OnNextAsync(res).ConfigureAwait(false);
  12828. }
  12829. else if (isDone1 && isDone2 && isDone3 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12830. {
  12831. await observer.OnCompletedAsync().ConfigureAwait(false);
  12832. }
  12833. }
  12834. },
  12835. async ex =>
  12836. {
  12837. using (await gate.LockAsync().ConfigureAwait(false))
  12838. {
  12839. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12840. }
  12841. },
  12842. async () =>
  12843. {
  12844. using (await gate.LockAsync().ConfigureAwait(false))
  12845. {
  12846. isDone4 = true;
  12847. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12848. {
  12849. await observer.OnCompletedAsync().ConfigureAwait(false);
  12850. }
  12851. }
  12852. }
  12853. ),
  12854. Create<T5>(
  12855. async x =>
  12856. {
  12857. using (await gate.LockAsync().ConfigureAwait(false))
  12858. {
  12859. if (!hasValue5)
  12860. {
  12861. hasValue5 = true;
  12862. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12863. }
  12864. latestValue5 = x;
  12865. if (allHasValue)
  12866. {
  12867. TResult res;
  12868. try
  12869. {
  12870. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12871. }
  12872. catch (Exception ex)
  12873. {
  12874. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12875. return;
  12876. }
  12877. await observer.OnNextAsync(res).ConfigureAwait(false);
  12878. }
  12879. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12880. {
  12881. await observer.OnCompletedAsync().ConfigureAwait(false);
  12882. }
  12883. }
  12884. },
  12885. async ex =>
  12886. {
  12887. using (await gate.LockAsync().ConfigureAwait(false))
  12888. {
  12889. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12890. }
  12891. },
  12892. async () =>
  12893. {
  12894. using (await gate.LockAsync().ConfigureAwait(false))
  12895. {
  12896. isDone5 = true;
  12897. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12898. {
  12899. await observer.OnCompletedAsync().ConfigureAwait(false);
  12900. }
  12901. }
  12902. }
  12903. ),
  12904. Create<T6>(
  12905. async x =>
  12906. {
  12907. using (await gate.LockAsync().ConfigureAwait(false))
  12908. {
  12909. if (!hasValue6)
  12910. {
  12911. hasValue6 = true;
  12912. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12913. }
  12914. latestValue6 = x;
  12915. if (allHasValue)
  12916. {
  12917. TResult res;
  12918. try
  12919. {
  12920. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12921. }
  12922. catch (Exception ex)
  12923. {
  12924. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12925. return;
  12926. }
  12927. await observer.OnNextAsync(res).ConfigureAwait(false);
  12928. }
  12929. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12930. {
  12931. await observer.OnCompletedAsync().ConfigureAwait(false);
  12932. }
  12933. }
  12934. },
  12935. async ex =>
  12936. {
  12937. using (await gate.LockAsync().ConfigureAwait(false))
  12938. {
  12939. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12940. }
  12941. },
  12942. async () =>
  12943. {
  12944. using (await gate.LockAsync().ConfigureAwait(false))
  12945. {
  12946. isDone6 = true;
  12947. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12948. {
  12949. await observer.OnCompletedAsync().ConfigureAwait(false);
  12950. }
  12951. }
  12952. }
  12953. ),
  12954. Create<T7>(
  12955. async x =>
  12956. {
  12957. using (await gate.LockAsync().ConfigureAwait(false))
  12958. {
  12959. if (!hasValue7)
  12960. {
  12961. hasValue7 = true;
  12962. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  12963. }
  12964. latestValue7 = x;
  12965. if (allHasValue)
  12966. {
  12967. TResult res;
  12968. try
  12969. {
  12970. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  12971. }
  12972. catch (Exception ex)
  12973. {
  12974. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12975. return;
  12976. }
  12977. await observer.OnNextAsync(res).ConfigureAwait(false);
  12978. }
  12979. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12980. {
  12981. await observer.OnCompletedAsync().ConfigureAwait(false);
  12982. }
  12983. }
  12984. },
  12985. async ex =>
  12986. {
  12987. using (await gate.LockAsync().ConfigureAwait(false))
  12988. {
  12989. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  12990. }
  12991. },
  12992. async () =>
  12993. {
  12994. using (await gate.LockAsync().ConfigureAwait(false))
  12995. {
  12996. isDone7 = true;
  12997. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  12998. {
  12999. await observer.OnCompletedAsync().ConfigureAwait(false);
  13000. }
  13001. }
  13002. }
  13003. ),
  13004. Create<T8>(
  13005. async x =>
  13006. {
  13007. using (await gate.LockAsync().ConfigureAwait(false))
  13008. {
  13009. if (!hasValue8)
  13010. {
  13011. hasValue8 = true;
  13012. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13013. }
  13014. latestValue8 = x;
  13015. if (allHasValue)
  13016. {
  13017. TResult res;
  13018. try
  13019. {
  13020. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13021. }
  13022. catch (Exception ex)
  13023. {
  13024. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13025. return;
  13026. }
  13027. await observer.OnNextAsync(res).ConfigureAwait(false);
  13028. }
  13029. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13030. {
  13031. await observer.OnCompletedAsync().ConfigureAwait(false);
  13032. }
  13033. }
  13034. },
  13035. async ex =>
  13036. {
  13037. using (await gate.LockAsync().ConfigureAwait(false))
  13038. {
  13039. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13040. }
  13041. },
  13042. async () =>
  13043. {
  13044. using (await gate.LockAsync().ConfigureAwait(false))
  13045. {
  13046. isDone8 = true;
  13047. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13048. {
  13049. await observer.OnCompletedAsync().ConfigureAwait(false);
  13050. }
  13051. }
  13052. }
  13053. ),
  13054. Create<T9>(
  13055. async x =>
  13056. {
  13057. using (await gate.LockAsync().ConfigureAwait(false))
  13058. {
  13059. if (!hasValue9)
  13060. {
  13061. hasValue9 = true;
  13062. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13063. }
  13064. latestValue9 = x;
  13065. if (allHasValue)
  13066. {
  13067. TResult res;
  13068. try
  13069. {
  13070. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13071. }
  13072. catch (Exception ex)
  13073. {
  13074. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13075. return;
  13076. }
  13077. await observer.OnNextAsync(res).ConfigureAwait(false);
  13078. }
  13079. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13080. {
  13081. await observer.OnCompletedAsync().ConfigureAwait(false);
  13082. }
  13083. }
  13084. },
  13085. async ex =>
  13086. {
  13087. using (await gate.LockAsync().ConfigureAwait(false))
  13088. {
  13089. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13090. }
  13091. },
  13092. async () =>
  13093. {
  13094. using (await gate.LockAsync().ConfigureAwait(false))
  13095. {
  13096. isDone9 = true;
  13097. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13098. {
  13099. await observer.OnCompletedAsync().ConfigureAwait(false);
  13100. }
  13101. }
  13102. }
  13103. ),
  13104. Create<T10>(
  13105. async x =>
  13106. {
  13107. using (await gate.LockAsync().ConfigureAwait(false))
  13108. {
  13109. if (!hasValue10)
  13110. {
  13111. hasValue10 = true;
  13112. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13113. }
  13114. latestValue10 = x;
  13115. if (allHasValue)
  13116. {
  13117. TResult res;
  13118. try
  13119. {
  13120. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13121. }
  13122. catch (Exception ex)
  13123. {
  13124. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13125. return;
  13126. }
  13127. await observer.OnNextAsync(res).ConfigureAwait(false);
  13128. }
  13129. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13130. {
  13131. await observer.OnCompletedAsync().ConfigureAwait(false);
  13132. }
  13133. }
  13134. },
  13135. async ex =>
  13136. {
  13137. using (await gate.LockAsync().ConfigureAwait(false))
  13138. {
  13139. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13140. }
  13141. },
  13142. async () =>
  13143. {
  13144. using (await gate.LockAsync().ConfigureAwait(false))
  13145. {
  13146. isDone10 = true;
  13147. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13148. {
  13149. await observer.OnCompletedAsync().ConfigureAwait(false);
  13150. }
  13151. }
  13152. }
  13153. ),
  13154. Create<T11>(
  13155. async x =>
  13156. {
  13157. using (await gate.LockAsync().ConfigureAwait(false))
  13158. {
  13159. if (!hasValue11)
  13160. {
  13161. hasValue11 = true;
  13162. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13163. }
  13164. latestValue11 = x;
  13165. if (allHasValue)
  13166. {
  13167. TResult res;
  13168. try
  13169. {
  13170. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13171. }
  13172. catch (Exception ex)
  13173. {
  13174. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13175. return;
  13176. }
  13177. await observer.OnNextAsync(res).ConfigureAwait(false);
  13178. }
  13179. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone12 && isDone13 && isDone14 && isDone15)
  13180. {
  13181. await observer.OnCompletedAsync().ConfigureAwait(false);
  13182. }
  13183. }
  13184. },
  13185. async ex =>
  13186. {
  13187. using (await gate.LockAsync().ConfigureAwait(false))
  13188. {
  13189. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13190. }
  13191. },
  13192. async () =>
  13193. {
  13194. using (await gate.LockAsync().ConfigureAwait(false))
  13195. {
  13196. isDone11 = true;
  13197. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13198. {
  13199. await observer.OnCompletedAsync().ConfigureAwait(false);
  13200. }
  13201. }
  13202. }
  13203. ),
  13204. Create<T12>(
  13205. async x =>
  13206. {
  13207. using (await gate.LockAsync().ConfigureAwait(false))
  13208. {
  13209. if (!hasValue12)
  13210. {
  13211. hasValue12 = true;
  13212. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13213. }
  13214. latestValue12 = x;
  13215. if (allHasValue)
  13216. {
  13217. TResult res;
  13218. try
  13219. {
  13220. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13221. }
  13222. catch (Exception ex)
  13223. {
  13224. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13225. return;
  13226. }
  13227. await observer.OnNextAsync(res).ConfigureAwait(false);
  13228. }
  13229. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone13 && isDone14 && isDone15)
  13230. {
  13231. await observer.OnCompletedAsync().ConfigureAwait(false);
  13232. }
  13233. }
  13234. },
  13235. async ex =>
  13236. {
  13237. using (await gate.LockAsync().ConfigureAwait(false))
  13238. {
  13239. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13240. }
  13241. },
  13242. async () =>
  13243. {
  13244. using (await gate.LockAsync().ConfigureAwait(false))
  13245. {
  13246. isDone12 = true;
  13247. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13248. {
  13249. await observer.OnCompletedAsync().ConfigureAwait(false);
  13250. }
  13251. }
  13252. }
  13253. ),
  13254. Create<T13>(
  13255. async x =>
  13256. {
  13257. using (await gate.LockAsync().ConfigureAwait(false))
  13258. {
  13259. if (!hasValue13)
  13260. {
  13261. hasValue13 = true;
  13262. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13263. }
  13264. latestValue13 = x;
  13265. if (allHasValue)
  13266. {
  13267. TResult res;
  13268. try
  13269. {
  13270. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13271. }
  13272. catch (Exception ex)
  13273. {
  13274. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13275. return;
  13276. }
  13277. await observer.OnNextAsync(res).ConfigureAwait(false);
  13278. }
  13279. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone14 && isDone15)
  13280. {
  13281. await observer.OnCompletedAsync().ConfigureAwait(false);
  13282. }
  13283. }
  13284. },
  13285. async ex =>
  13286. {
  13287. using (await gate.LockAsync().ConfigureAwait(false))
  13288. {
  13289. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13290. }
  13291. },
  13292. async () =>
  13293. {
  13294. using (await gate.LockAsync().ConfigureAwait(false))
  13295. {
  13296. isDone13 = true;
  13297. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13298. {
  13299. await observer.OnCompletedAsync().ConfigureAwait(false);
  13300. }
  13301. }
  13302. }
  13303. ),
  13304. Create<T14>(
  13305. async x =>
  13306. {
  13307. using (await gate.LockAsync().ConfigureAwait(false))
  13308. {
  13309. if (!hasValue14)
  13310. {
  13311. hasValue14 = true;
  13312. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13313. }
  13314. latestValue14 = x;
  13315. if (allHasValue)
  13316. {
  13317. TResult res;
  13318. try
  13319. {
  13320. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13321. }
  13322. catch (Exception ex)
  13323. {
  13324. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13325. return;
  13326. }
  13327. await observer.OnNextAsync(res).ConfigureAwait(false);
  13328. }
  13329. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone15)
  13330. {
  13331. await observer.OnCompletedAsync().ConfigureAwait(false);
  13332. }
  13333. }
  13334. },
  13335. async ex =>
  13336. {
  13337. using (await gate.LockAsync().ConfigureAwait(false))
  13338. {
  13339. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13340. }
  13341. },
  13342. async () =>
  13343. {
  13344. using (await gate.LockAsync().ConfigureAwait(false))
  13345. {
  13346. isDone14 = true;
  13347. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13348. {
  13349. await observer.OnCompletedAsync().ConfigureAwait(false);
  13350. }
  13351. }
  13352. }
  13353. ),
  13354. Create<T15>(
  13355. async x =>
  13356. {
  13357. using (await gate.LockAsync().ConfigureAwait(false))
  13358. {
  13359. if (!hasValue15)
  13360. {
  13361. hasValue15 = true;
  13362. allHasValue = hasValue1 && hasValue2 && hasValue3 && hasValue4 && hasValue5 && hasValue6 && hasValue7 && hasValue8 && hasValue9 && hasValue10 && hasValue11 && hasValue12 && hasValue13 && hasValue14 && hasValue15;
  13363. }
  13364. latestValue15 = x;
  13365. if (allHasValue)
  13366. {
  13367. TResult res;
  13368. try
  13369. {
  13370. res = await selector(latestValue1, latestValue2, latestValue3, latestValue4, latestValue5, latestValue6, latestValue7, latestValue8, latestValue9, latestValue10, latestValue11, latestValue12, latestValue13, latestValue14, latestValue15).ConfigureAwait(false);
  13371. }
  13372. catch (Exception ex)
  13373. {
  13374. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13375. return;
  13376. }
  13377. await observer.OnNextAsync(res).ConfigureAwait(false);
  13378. }
  13379. else if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14)
  13380. {
  13381. await observer.OnCompletedAsync().ConfigureAwait(false);
  13382. }
  13383. }
  13384. },
  13385. async ex =>
  13386. {
  13387. using (await gate.LockAsync().ConfigureAwait(false))
  13388. {
  13389. await observer.OnErrorAsync(ex).ConfigureAwait(false);
  13390. }
  13391. },
  13392. async () =>
  13393. {
  13394. using (await gate.LockAsync().ConfigureAwait(false))
  13395. {
  13396. isDone15 = true;
  13397. if (isDone1 && isDone2 && isDone3 && isDone4 && isDone5 && isDone6 && isDone7 && isDone8 && isDone9 && isDone10 && isDone11 && isDone12 && isDone13 && isDone14 && isDone15)
  13398. {
  13399. await observer.OnCompletedAsync().ConfigureAwait(false);
  13400. }
  13401. }
  13402. }
  13403. )
  13404. );
  13405. }
  13406. }
  13407. }