Qbservable.Generated.cs 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546
  1. /*
  2. * WARNING: Auto-generated file (merged on 06/13/2018)
  3. * Run Rx's auto-homoiconizer tool to generate this file (in the HomoIcon directory).
  4. */
  5. #pragma warning disable 1591
  6. using System.Collections.Generic;
  7. using System.Diagnostics.CodeAnalysis;
  8. using System.Linq;
  9. using System.Linq.Expressions;
  10. using System.Reactive.Concurrency;
  11. using System.Reactive.Subjects;
  12. #if !CRIPPLED_REFLECTION
  13. using System.Reflection;
  14. #endif
  15. using System.Threading;
  16. using System.Threading.Tasks;
  17. namespace System.Reactive.Linq
  18. {
  19. [ExcludeFromCodeCoverage]
  20. public static partial class Qbservable
  21. {
  22. /// <summary>
  23. /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence.
  24. /// For aggregation behavior with incremental intermediate results, see <see cref="M:System.Reactive.Linq.Observable.Scan``1(System.IObservable{``0},System.Func{``0,``0,``0})" />.
  25. /// </summary>
  26. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  27. /// <param name="source">An observable sequence to aggregate over.</param>
  28. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  29. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  30. /// <exception cref="ArgumentNullException">
  31. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  32. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  33. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  34. public static IQbservable<TSource> Aggregate<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  35. {
  36. if (source == null)
  37. throw new ArgumentNullException(nameof(source));
  38. if (accumulator == null)
  39. throw new ArgumentNullException(nameof(accumulator));
  40. return source.Provider.CreateQuery<TSource>(
  41. Expression.Call(
  42. null,
  43. #if CRIPPLED_REFLECTION
  44. InfoOf(() => Qbservable.Aggregate<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  45. #else
  46. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  47. #endif
  48. source.Expression,
  49. accumulator
  50. )
  51. );
  52. }
  53. /// <summary>
  54. /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value.
  55. /// For aggregation behavior with incremental intermediate results, see <see cref="M:System.Reactive.Linq.Observable.Scan``2(System.IObservable{``0},``1,System.Func{``1,``0,``1})" />.
  56. /// </summary>
  57. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  58. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  59. /// <param name="source">An observable sequence to aggregate over.</param>
  60. /// <param name="seed">The initial accumulator value.</param>
  61. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  62. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  63. /// <exception cref="ArgumentNullException">
  64. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  65. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  66. public static IQbservable<TAccumulate> Aggregate<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  67. {
  68. if (source == null)
  69. throw new ArgumentNullException(nameof(source));
  70. if (accumulator == null)
  71. throw new ArgumentNullException(nameof(accumulator));
  72. return source.Provider.CreateQuery<TAccumulate>(
  73. Expression.Call(
  74. null,
  75. #if CRIPPLED_REFLECTION
  76. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  77. #else
  78. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  79. #endif
  80. source.Expression,
  81. Expression.Constant(seed, typeof(TAccumulate)),
  82. accumulator
  83. )
  84. );
  85. }
  86. /// <summary>
  87. /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified seed value is used as the initial accumulator value,
  88. /// and the specified result selector function is used to select the result value.
  89. /// </summary>
  90. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  91. /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam>
  92. /// <typeparam name="TResult">The type of the resulting value.</typeparam>
  93. /// <param name="source">An observable sequence to aggregate over.</param>
  94. /// <param name="seed">The initial accumulator value.</param>
  95. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  96. /// <param name="resultSelector">A function to transform the final accumulator value into the result value.</param>
  97. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  98. /// <exception cref="ArgumentNullException">
  99. /// <paramref name="source" /> or <paramref name="accumulator" /> or <paramref name="resultSelector" /> is null.</exception>
  100. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  101. public static IQbservable<TResult> Aggregate<TSource, TAccumulate, TResult>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator, Expression<Func<TAccumulate, TResult>> resultSelector)
  102. {
  103. if (source == null)
  104. throw new ArgumentNullException(nameof(source));
  105. if (accumulator == null)
  106. throw new ArgumentNullException(nameof(accumulator));
  107. if (resultSelector == null)
  108. throw new ArgumentNullException(nameof(resultSelector));
  109. return source.Provider.CreateQuery<TResult>(
  110. Expression.Call(
  111. null,
  112. #if CRIPPLED_REFLECTION
  113. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate, TResult>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>), default(Expression<Func<TAccumulate, TResult>>))),
  114. #else
  115. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)),
  116. #endif
  117. source.Expression,
  118. Expression.Constant(seed, typeof(TAccumulate)),
  119. accumulator,
  120. resultSelector
  121. )
  122. );
  123. }
  124. /// <summary>
  125. /// Determines whether all elements of an observable sequence satisfy a condition.
  126. /// </summary>
  127. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  128. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  129. /// <param name="predicate">A function to test each element for a condition.</param>
  130. /// <returns>An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.</returns>
  131. /// <exception cref="ArgumentNullException">
  132. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  133. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  134. public static IQbservable<bool> All<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  135. {
  136. if (source == null)
  137. throw new ArgumentNullException(nameof(source));
  138. if (predicate == null)
  139. throw new ArgumentNullException(nameof(predicate));
  140. return source.Provider.CreateQuery<bool>(
  141. Expression.Call(
  142. null,
  143. #if CRIPPLED_REFLECTION
  144. InfoOf(() => Qbservable.All<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  145. #else
  146. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  147. #endif
  148. source.Expression,
  149. predicate
  150. )
  151. );
  152. }
  153. /// <summary>
  154. /// Propagates the observable sequence that reacts first.
  155. /// </summary>
  156. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  157. /// <param name="first">First observable sequence.</param>
  158. /// <param name="second">Second observable sequence.</param>
  159. /// <returns>An observable sequence that surfaces either of the given sequences, whichever reacted first.</returns>
  160. /// <exception cref="ArgumentNullException">
  161. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  162. public static IQbservable<TSource> Amb<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  163. {
  164. if (first == null)
  165. throw new ArgumentNullException(nameof(first));
  166. if (second == null)
  167. throw new ArgumentNullException(nameof(second));
  168. return first.Provider.CreateQuery<TSource>(
  169. Expression.Call(
  170. null,
  171. #if CRIPPLED_REFLECTION
  172. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  173. #else
  174. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  175. #endif
  176. first.Expression,
  177. GetSourceExpression(second)
  178. )
  179. );
  180. }
  181. /// <summary>
  182. /// Propagates the observable sequence that reacts first.
  183. /// </summary>
  184. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  185. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  186. /// <param name="sources">Observable sources competing to react first.</param>
  187. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  188. /// <exception cref="ArgumentNullException">
  189. /// <paramref name="sources" /> is null.</exception>
  190. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  191. {
  192. if (provider == null)
  193. throw new ArgumentNullException(nameof(provider));
  194. if (sources == null)
  195. throw new ArgumentNullException(nameof(sources));
  196. return provider.CreateQuery<TSource>(
  197. Expression.Call(
  198. null,
  199. #if CRIPPLED_REFLECTION
  200. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  201. #else
  202. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  203. #endif
  204. Expression.Constant(provider, typeof(IQbservableProvider)),
  205. GetSourceExpression(sources)
  206. )
  207. );
  208. }
  209. /// <summary>
  210. /// Propagates the observable sequence that reacts first.
  211. /// </summary>
  212. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  213. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  214. /// <param name="sources">Observable sources competing to react first.</param>
  215. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  216. /// <exception cref="ArgumentNullException">
  217. /// <paramref name="sources" /> is null.</exception>
  218. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  219. {
  220. if (provider == null)
  221. throw new ArgumentNullException(nameof(provider));
  222. if (sources == null)
  223. throw new ArgumentNullException(nameof(sources));
  224. return provider.CreateQuery<TSource>(
  225. Expression.Call(
  226. null,
  227. #if CRIPPLED_REFLECTION
  228. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  229. #else
  230. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  231. #endif
  232. Expression.Constant(provider, typeof(IQbservableProvider)),
  233. GetSourceExpression(sources)
  234. )
  235. );
  236. }
  237. /// <summary>
  238. /// Determines whether an observable sequence contains any elements.
  239. /// </summary>
  240. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  241. /// <param name="source">An observable sequence to check for non-emptiness.</param>
  242. /// <returns>An observable sequence containing a single element determining whether the source sequence contains any elements.</returns>
  243. /// <exception cref="ArgumentNullException">
  244. /// <paramref name="source" /> is null.</exception>
  245. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  246. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source)
  247. {
  248. if (source == null)
  249. throw new ArgumentNullException(nameof(source));
  250. return source.Provider.CreateQuery<bool>(
  251. Expression.Call(
  252. null,
  253. #if CRIPPLED_REFLECTION
  254. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>))),
  255. #else
  256. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  257. #endif
  258. source.Expression
  259. )
  260. );
  261. }
  262. /// <summary>
  263. /// Determines whether any element of an observable sequence satisfies a condition.
  264. /// </summary>
  265. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  266. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  267. /// <param name="predicate">A function to test each element for a condition.</param>
  268. /// <returns>An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate.</returns>
  269. /// <exception cref="ArgumentNullException">
  270. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  271. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  272. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  273. {
  274. if (source == null)
  275. throw new ArgumentNullException(nameof(source));
  276. if (predicate == null)
  277. throw new ArgumentNullException(nameof(predicate));
  278. return source.Provider.CreateQuery<bool>(
  279. Expression.Call(
  280. null,
  281. #if CRIPPLED_REFLECTION
  282. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  283. #else
  284. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  285. #endif
  286. source.Expression,
  287. predicate
  288. )
  289. );
  290. }
  291. /// <summary>
  292. /// Append a value to an observable sequence.
  293. /// </summary>
  294. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  295. /// <param name="source">Source sequence to append the value to.</param>
  296. /// <param name="value">Value to append to the specified sequence.</param>
  297. /// <returns>The source sequence appended with the specified value.</returns>
  298. /// <exception cref="ArgumentNullException">
  299. /// <paramref name="source" /> is null.</exception>
  300. public static IQbservable<TSource> Append<TSource>(this IQbservable<TSource> source, TSource value)
  301. {
  302. if (source == null)
  303. throw new ArgumentNullException(nameof(source));
  304. return source.Provider.CreateQuery<TSource>(
  305. Expression.Call(
  306. null,
  307. #if CRIPPLED_REFLECTION
  308. InfoOf(() => Qbservable.Append<TSource>(default(IQbservable<TSource>), default(TSource))),
  309. #else
  310. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  311. #endif
  312. source.Expression,
  313. Expression.Constant(value, typeof(TSource))
  314. )
  315. );
  316. }
  317. /// <summary>
  318. /// Append a value to an observable sequence.
  319. /// </summary>
  320. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  321. /// <param name="source">Source sequence to append the value to.</param>
  322. /// <param name="value">Value to append to the specified sequence.</param>
  323. /// <param name="scheduler">Scheduler to emit the append values on.</param>
  324. /// <returns>The source sequence appended with the specified value.</returns>
  325. /// <exception cref="ArgumentNullException">
  326. /// <paramref name="source" /> is null.</exception>
  327. public static IQbservable<TSource> Append<TSource>(this IQbservable<TSource> source, TSource value, IScheduler scheduler)
  328. {
  329. if (source == null)
  330. throw new ArgumentNullException(nameof(source));
  331. if (scheduler == null)
  332. throw new ArgumentNullException(nameof(scheduler));
  333. return source.Provider.CreateQuery<TSource>(
  334. Expression.Call(
  335. null,
  336. #if CRIPPLED_REFLECTION
  337. InfoOf(() => Qbservable.Append<TSource>(default(IQbservable<TSource>), default(TSource), default(IScheduler))),
  338. #else
  339. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  340. #endif
  341. source.Expression,
  342. Expression.Constant(value, typeof(TSource)),
  343. Expression.Constant(scheduler, typeof(IScheduler))
  344. )
  345. );
  346. }
  347. /// <summary>
  348. /// Automatically connect the upstream IConnectableObservable at most once when the
  349. /// specified number of IObservers have subscribed to this IObservable.
  350. /// </summary>
  351. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  352. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  353. /// <param name="source">Connectable observable sequence.</param>
  354. /// <param name="minObservers">The number of observers required to subscribe before the connection to source happens, non-positive value will trigger an immediate subscription.</param>
  355. /// <param name="onConnect">If not null, the connection's IDisposable is provided to it.</param>
  356. /// <returns>An observable sequence that connects to the source at most once when the given number of observers have subscribed to it.</returns>
  357. /// <exception cref="ArgumentNullException">
  358. /// <paramref name="source" /> is null.</exception>
  359. public static IQbservable<TSource> AutoConnect<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, int minObservers, Expression<Action<IDisposable>> onConnect)
  360. {
  361. if (provider == null)
  362. throw new ArgumentNullException(nameof(provider));
  363. if (source == null)
  364. throw new ArgumentNullException(nameof(source));
  365. if (onConnect == null)
  366. throw new ArgumentNullException(nameof(onConnect));
  367. return provider.CreateQuery<TSource>(
  368. Expression.Call(
  369. null,
  370. #if CRIPPLED_REFLECTION
  371. InfoOf(() => Qbservable.AutoConnect<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(int), default(Expression<Action<IDisposable>>))),
  372. #else
  373. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  374. #endif
  375. Expression.Constant(provider, typeof(IQbservableProvider)),
  376. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  377. Expression.Constant(minObservers, typeof(int)),
  378. onConnect
  379. )
  380. );
  381. }
  382. /// <summary>
  383. /// Computes the average of an observable sequence of <see cref="Decimal" /> values.
  384. /// </summary>
  385. /// <param name="source">A sequence of <see cref="Decimal" /> values to calculate the average of.</param>
  386. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  387. /// <exception cref="ArgumentNullException">
  388. /// <paramref name="source" /> is null.</exception>
  389. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  390. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  391. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  392. public static IQbservable<decimal> Average(this IQbservable<decimal> source)
  393. {
  394. if (source == null)
  395. throw new ArgumentNullException(nameof(source));
  396. return source.Provider.CreateQuery<decimal>(
  397. Expression.Call(
  398. null,
  399. #if CRIPPLED_REFLECTION
  400. InfoOf(() => Qbservable.Average(default(IQbservable<decimal>))),
  401. #else
  402. (MethodInfo)MethodInfo.GetCurrentMethod(),
  403. #endif
  404. source.Expression
  405. )
  406. );
  407. }
  408. /// <summary>
  409. /// Computes the average of an observable sequence of <see cref="double" /> values.
  410. /// </summary>
  411. /// <param name="source">A sequence of <see cref="double" /> values to calculate the average of.</param>
  412. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  413. /// <exception cref="ArgumentNullException">
  414. /// <paramref name="source" /> is null.</exception>
  415. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  416. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  417. public static IQbservable<double> Average(this IQbservable<double> source)
  418. {
  419. if (source == null)
  420. throw new ArgumentNullException(nameof(source));
  421. return source.Provider.CreateQuery<double>(
  422. Expression.Call(
  423. null,
  424. #if CRIPPLED_REFLECTION
  425. InfoOf(() => Qbservable.Average(default(IQbservable<double>))),
  426. #else
  427. (MethodInfo)MethodInfo.GetCurrentMethod(),
  428. #endif
  429. source.Expression
  430. )
  431. );
  432. }
  433. /// <summary>
  434. /// Computes the average of an observable sequence of <see cref="int" /> values.
  435. /// </summary>
  436. /// <param name="source">A sequence of <see cref="int" /> values to calculate the average of.</param>
  437. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  438. /// <exception cref="ArgumentNullException">
  439. /// <paramref name="source" /> is null.</exception>
  440. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  441. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  442. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  443. public static IQbservable<double> Average(this IQbservable<int> source)
  444. {
  445. if (source == null)
  446. throw new ArgumentNullException(nameof(source));
  447. return source.Provider.CreateQuery<double>(
  448. Expression.Call(
  449. null,
  450. #if CRIPPLED_REFLECTION
  451. InfoOf(() => Qbservable.Average(default(IQbservable<int>))),
  452. #else
  453. (MethodInfo)MethodInfo.GetCurrentMethod(),
  454. #endif
  455. source.Expression
  456. )
  457. );
  458. }
  459. /// <summary>
  460. /// Computes the average of an observable sequence of <see cref="long" /> values.
  461. /// </summary>
  462. /// <param name="source">A sequence of <see cref="long" /> values to calculate the average of.</param>
  463. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  464. /// <exception cref="ArgumentNullException">
  465. /// <paramref name="source" /> is null.</exception>
  466. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  467. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  468. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  469. public static IQbservable<double> Average(this IQbservable<long> source)
  470. {
  471. if (source == null)
  472. throw new ArgumentNullException(nameof(source));
  473. return source.Provider.CreateQuery<double>(
  474. Expression.Call(
  475. null,
  476. #if CRIPPLED_REFLECTION
  477. InfoOf(() => Qbservable.Average(default(IQbservable<long>))),
  478. #else
  479. (MethodInfo)MethodInfo.GetCurrentMethod(),
  480. #endif
  481. source.Expression
  482. )
  483. );
  484. }
  485. /// <summary>
  486. /// Computes the average of an observable sequence of nullable <see cref="Decimal" /> values.
  487. /// </summary>
  488. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to calculate the average of.</param>
  489. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  490. /// <exception cref="ArgumentNullException">
  491. /// <paramref name="source" /> is null.</exception>
  492. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  493. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  494. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  495. public static IQbservable<decimal?> Average(this IQbservable<decimal?> source)
  496. {
  497. if (source == null)
  498. throw new ArgumentNullException(nameof(source));
  499. return source.Provider.CreateQuery<decimal?>(
  500. Expression.Call(
  501. null,
  502. #if CRIPPLED_REFLECTION
  503. InfoOf(() => Qbservable.Average(default(IQbservable<decimal?>))),
  504. #else
  505. (MethodInfo)MethodInfo.GetCurrentMethod(),
  506. #endif
  507. source.Expression
  508. )
  509. );
  510. }
  511. /// <summary>
  512. /// Computes the average of an observable sequence of nullable <see cref="double" /> values.
  513. /// </summary>
  514. /// <param name="source">A sequence of nullable <see cref="double" /> values to calculate the average of.</param>
  515. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  516. /// <exception cref="ArgumentNullException">
  517. /// <paramref name="source" /> is null.</exception>
  518. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  519. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  520. public static IQbservable<double?> Average(this IQbservable<double?> source)
  521. {
  522. if (source == null)
  523. throw new ArgumentNullException(nameof(source));
  524. return source.Provider.CreateQuery<double?>(
  525. Expression.Call(
  526. null,
  527. #if CRIPPLED_REFLECTION
  528. InfoOf(() => Qbservable.Average(default(IQbservable<double?>))),
  529. #else
  530. (MethodInfo)MethodInfo.GetCurrentMethod(),
  531. #endif
  532. source.Expression
  533. )
  534. );
  535. }
  536. /// <summary>
  537. /// Computes the average of an observable sequence of nullable <see cref="int" /> values.
  538. /// </summary>
  539. /// <param name="source">A sequence of nullable <see cref="int" /> values to calculate the average of.</param>
  540. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  541. /// <exception cref="ArgumentNullException">
  542. /// <paramref name="source" /> is null.</exception>
  543. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  544. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  545. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  546. public static IQbservable<double?> Average(this IQbservable<int?> source)
  547. {
  548. if (source == null)
  549. throw new ArgumentNullException(nameof(source));
  550. return source.Provider.CreateQuery<double?>(
  551. Expression.Call(
  552. null,
  553. #if CRIPPLED_REFLECTION
  554. InfoOf(() => Qbservable.Average(default(IQbservable<int?>))),
  555. #else
  556. (MethodInfo)MethodInfo.GetCurrentMethod(),
  557. #endif
  558. source.Expression
  559. )
  560. );
  561. }
  562. /// <summary>
  563. /// Computes the average of an observable sequence of nullable <see cref="long" /> values.
  564. /// </summary>
  565. /// <param name="source">A sequence of nullable <see cref="long" /> values to calculate the average of.</param>
  566. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  567. /// <exception cref="ArgumentNullException">
  568. /// <paramref name="source" /> is null.</exception>
  569. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  570. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  571. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  572. public static IQbservable<double?> Average(this IQbservable<long?> source)
  573. {
  574. if (source == null)
  575. throw new ArgumentNullException(nameof(source));
  576. return source.Provider.CreateQuery<double?>(
  577. Expression.Call(
  578. null,
  579. #if CRIPPLED_REFLECTION
  580. InfoOf(() => Qbservable.Average(default(IQbservable<long?>))),
  581. #else
  582. (MethodInfo)MethodInfo.GetCurrentMethod(),
  583. #endif
  584. source.Expression
  585. )
  586. );
  587. }
  588. /// <summary>
  589. /// Computes the average of an observable sequence of nullable <see cref="Single" /> values.
  590. /// </summary>
  591. /// <param name="source">A sequence of nullable <see cref="Single" /> values to calculate the average of.</param>
  592. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  593. /// <exception cref="ArgumentNullException">
  594. /// <paramref name="source" /> is null.</exception>
  595. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  596. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  597. public static IQbservable<float?> Average(this IQbservable<float?> source)
  598. {
  599. if (source == null)
  600. throw new ArgumentNullException(nameof(source));
  601. return source.Provider.CreateQuery<float?>(
  602. Expression.Call(
  603. null,
  604. #if CRIPPLED_REFLECTION
  605. InfoOf(() => Qbservable.Average(default(IQbservable<float?>))),
  606. #else
  607. (MethodInfo)MethodInfo.GetCurrentMethod(),
  608. #endif
  609. source.Expression
  610. )
  611. );
  612. }
  613. /// <summary>
  614. /// Computes the average of an observable sequence of <see cref="Single" /> values.
  615. /// </summary>
  616. /// <param name="source">A sequence of <see cref="Single" /> values to calculate the average of.</param>
  617. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  618. /// <exception cref="ArgumentNullException">
  619. /// <paramref name="source" /> is null.</exception>
  620. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  621. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  622. public static IQbservable<float> Average(this IQbservable<float> source)
  623. {
  624. if (source == null)
  625. throw new ArgumentNullException(nameof(source));
  626. return source.Provider.CreateQuery<float>(
  627. Expression.Call(
  628. null,
  629. #if CRIPPLED_REFLECTION
  630. InfoOf(() => Qbservable.Average(default(IQbservable<float>))),
  631. #else
  632. (MethodInfo)MethodInfo.GetCurrentMethod(),
  633. #endif
  634. source.Expression
  635. )
  636. );
  637. }
  638. /// <summary>
  639. /// Computes the average of an observable sequence of <see cref="Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
  640. /// </summary>
  641. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  642. /// <param name="source">A sequence of values to calculate the average of.</param>
  643. /// <param name="selector">A transform function to apply to each element.</param>
  644. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  645. /// <exception cref="ArgumentNullException">
  646. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  647. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  648. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  649. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  650. public static IQbservable<decimal> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  651. {
  652. if (source == null)
  653. throw new ArgumentNullException(nameof(source));
  654. if (selector == null)
  655. throw new ArgumentNullException(nameof(selector));
  656. return source.Provider.CreateQuery<decimal>(
  657. Expression.Call(
  658. null,
  659. #if CRIPPLED_REFLECTION
  660. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  661. #else
  662. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  663. #endif
  664. source.Expression,
  665. selector
  666. )
  667. );
  668. }
  669. /// <summary>
  670. /// Computes the average of an observable sequence of <see cref="double" /> values that are obtained by invoking a transform function on each element of the input sequence.
  671. /// </summary>
  672. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  673. /// <param name="source">A sequence of values to calculate the average of.</param>
  674. /// <param name="selector">A transform function to apply to each element.</param>
  675. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  676. /// <exception cref="ArgumentNullException">
  677. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  678. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  679. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  680. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  681. {
  682. if (source == null)
  683. throw new ArgumentNullException(nameof(source));
  684. if (selector == null)
  685. throw new ArgumentNullException(nameof(selector));
  686. return source.Provider.CreateQuery<double>(
  687. Expression.Call(
  688. null,
  689. #if CRIPPLED_REFLECTION
  690. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  691. #else
  692. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  693. #endif
  694. source.Expression,
  695. selector
  696. )
  697. );
  698. }
  699. /// <summary>
  700. /// Computes the average of an observable sequence of <see cref="Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
  701. /// </summary>
  702. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  703. /// <param name="source">A sequence of values to calculate the average of.</param>
  704. /// <param name="selector">A transform function to apply to each element.</param>
  705. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  706. /// <exception cref="ArgumentNullException">
  707. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  708. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  709. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  710. public static IQbservable<float> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  711. {
  712. if (source == null)
  713. throw new ArgumentNullException(nameof(source));
  714. if (selector == null)
  715. throw new ArgumentNullException(nameof(selector));
  716. return source.Provider.CreateQuery<float>(
  717. Expression.Call(
  718. null,
  719. #if CRIPPLED_REFLECTION
  720. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  721. #else
  722. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  723. #endif
  724. source.Expression,
  725. selector
  726. )
  727. );
  728. }
  729. /// <summary>
  730. /// Computes the average of an observable sequence of <see cref="int" /> values that are obtained by invoking a transform function on each element of the input sequence.
  731. /// </summary>
  732. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  733. /// <param name="source">A sequence of values to calculate the average of.</param>
  734. /// <param name="selector">A transform function to apply to each element.</param>
  735. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  736. /// <exception cref="ArgumentNullException">
  737. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  738. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  739. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  740. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  741. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  742. {
  743. if (source == null)
  744. throw new ArgumentNullException(nameof(source));
  745. if (selector == null)
  746. throw new ArgumentNullException(nameof(selector));
  747. return source.Provider.CreateQuery<double>(
  748. Expression.Call(
  749. null,
  750. #if CRIPPLED_REFLECTION
  751. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  752. #else
  753. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  754. #endif
  755. source.Expression,
  756. selector
  757. )
  758. );
  759. }
  760. /// <summary>
  761. /// Computes the average of an observable sequence of <see cref="long" /> values that are obtained by invoking a transform function on each element of the input sequence.
  762. /// </summary>
  763. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  764. /// <param name="source">A sequence of values to calculate the average of.</param>
  765. /// <param name="selector">A transform function to apply to each element.</param>
  766. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  767. /// <exception cref="ArgumentNullException">
  768. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  769. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  770. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  771. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  772. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  773. {
  774. if (source == null)
  775. throw new ArgumentNullException(nameof(source));
  776. if (selector == null)
  777. throw new ArgumentNullException(nameof(selector));
  778. return source.Provider.CreateQuery<double>(
  779. Expression.Call(
  780. null,
  781. #if CRIPPLED_REFLECTION
  782. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  783. #else
  784. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  785. #endif
  786. source.Expression,
  787. selector
  788. )
  789. );
  790. }
  791. /// <summary>
  792. /// Computes the average of an observable sequence of nullable <see cref="Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
  793. /// </summary>
  794. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  795. /// <param name="source">A sequence of values to calculate the average of.</param>
  796. /// <param name="selector">A transform function to apply to each element.</param>
  797. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  798. /// <exception cref="ArgumentNullException">
  799. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  800. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  801. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  802. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  803. public static IQbservable<decimal?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  804. {
  805. if (source == null)
  806. throw new ArgumentNullException(nameof(source));
  807. if (selector == null)
  808. throw new ArgumentNullException(nameof(selector));
  809. return source.Provider.CreateQuery<decimal?>(
  810. Expression.Call(
  811. null,
  812. #if CRIPPLED_REFLECTION
  813. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  814. #else
  815. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  816. #endif
  817. source.Expression,
  818. selector
  819. )
  820. );
  821. }
  822. /// <summary>
  823. /// Computes the average of an observable sequence of nullable <see cref="double" /> values that are obtained by invoking a transform function on each element of the input sequence.
  824. /// </summary>
  825. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  826. /// <param name="source">A sequence of values to calculate the average of.</param>
  827. /// <param name="selector">A transform function to apply to each element.</param>
  828. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  829. /// <exception cref="ArgumentNullException">
  830. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  831. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  832. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  833. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  834. {
  835. if (source == null)
  836. throw new ArgumentNullException(nameof(source));
  837. if (selector == null)
  838. throw new ArgumentNullException(nameof(selector));
  839. return source.Provider.CreateQuery<double?>(
  840. Expression.Call(
  841. null,
  842. #if CRIPPLED_REFLECTION
  843. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  844. #else
  845. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  846. #endif
  847. source.Expression,
  848. selector
  849. )
  850. );
  851. }
  852. /// <summary>
  853. /// Computes the average of an observable sequence of nullable <see cref="Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
  854. /// </summary>
  855. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  856. /// <param name="source">A sequence of values to calculate the average of.</param>
  857. /// <param name="selector">A transform function to apply to each element.</param>
  858. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  859. /// <exception cref="ArgumentNullException">
  860. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  861. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  862. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  863. public static IQbservable<float?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  864. {
  865. if (source == null)
  866. throw new ArgumentNullException(nameof(source));
  867. if (selector == null)
  868. throw new ArgumentNullException(nameof(selector));
  869. return source.Provider.CreateQuery<float?>(
  870. Expression.Call(
  871. null,
  872. #if CRIPPLED_REFLECTION
  873. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  874. #else
  875. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  876. #endif
  877. source.Expression,
  878. selector
  879. )
  880. );
  881. }
  882. /// <summary>
  883. /// Computes the average of an observable sequence of nullable <see cref="int" /> values that are obtained by invoking a transform function on each element of the input sequence.
  884. /// </summary>
  885. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  886. /// <param name="source">A sequence of values to calculate the average of.</param>
  887. /// <param name="selector">A transform function to apply to each element.</param>
  888. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  889. /// <exception cref="ArgumentNullException">
  890. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  891. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  892. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  893. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  894. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  895. {
  896. if (source == null)
  897. throw new ArgumentNullException(nameof(source));
  898. if (selector == null)
  899. throw new ArgumentNullException(nameof(selector));
  900. return source.Provider.CreateQuery<double?>(
  901. Expression.Call(
  902. null,
  903. #if CRIPPLED_REFLECTION
  904. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  905. #else
  906. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  907. #endif
  908. source.Expression,
  909. selector
  910. )
  911. );
  912. }
  913. /// <summary>
  914. /// Computes the average of an observable sequence of nullable <see cref="long" /> values that are obtained by invoking a transform function on each element of the input sequence.
  915. /// </summary>
  916. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  917. /// <param name="source">A sequence of values to calculate the average of.</param>
  918. /// <param name="selector">A transform function to apply to each element.</param>
  919. /// <returns>An observable sequence containing a single element with the average of the sequence of values, or null if the source sequence is empty or contains only values that are null.</returns>
  920. /// <exception cref="ArgumentNullException">
  921. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  922. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  923. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  924. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  925. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  926. {
  927. if (source == null)
  928. throw new ArgumentNullException(nameof(source));
  929. if (selector == null)
  930. throw new ArgumentNullException(nameof(selector));
  931. return source.Provider.CreateQuery<double?>(
  932. Expression.Call(
  933. null,
  934. #if CRIPPLED_REFLECTION
  935. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  936. #else
  937. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  938. #endif
  939. source.Expression,
  940. selector
  941. )
  942. );
  943. }
  944. /// <summary>
  945. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on element count information.
  946. /// </summary>
  947. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  948. /// <param name="source">Source sequence to produce buffers over.</param>
  949. /// <param name="count">Length of each buffer.</param>
  950. /// <returns>An observable sequence of buffers.</returns>
  951. /// <exception cref="ArgumentNullException">
  952. /// <paramref name="source" /> is null.</exception>
  953. /// <exception cref="ArgumentOutOfRangeException">
  954. /// <paramref name="count" /> is less than or equal to zero.</exception>
  955. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count)
  956. {
  957. if (source == null)
  958. throw new ArgumentNullException(nameof(source));
  959. return source.Provider.CreateQuery<IList<TSource>>(
  960. Expression.Call(
  961. null,
  962. #if CRIPPLED_REFLECTION
  963. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int))),
  964. #else
  965. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  966. #endif
  967. source.Expression,
  968. Expression.Constant(count, typeof(int))
  969. )
  970. );
  971. }
  972. /// <summary>
  973. /// Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
  974. /// </summary>
  975. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  976. /// <param name="source">Source sequence to produce buffers over.</param>
  977. /// <param name="count">Length of each buffer.</param>
  978. /// <param name="skip">Number of elements to skip between creation of consecutive buffers.</param>
  979. /// <returns>An observable sequence of buffers.</returns>
  980. /// <exception cref="ArgumentNullException">
  981. /// <paramref name="source" /> is null.</exception>
  982. /// <exception cref="ArgumentOutOfRangeException">
  983. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  984. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count, int skip)
  985. {
  986. if (source == null)
  987. throw new ArgumentNullException(nameof(source));
  988. return source.Provider.CreateQuery<IList<TSource>>(
  989. Expression.Call(
  990. null,
  991. #if CRIPPLED_REFLECTION
  992. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  993. #else
  994. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  995. #endif
  996. source.Expression,
  997. Expression.Constant(count, typeof(int)),
  998. Expression.Constant(skip, typeof(int))
  999. )
  1000. );
  1001. }
  1002. /// <summary>
  1003. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information.
  1004. /// </summary>
  1005. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1006. /// <param name="source">Source sequence to produce buffers over.</param>
  1007. /// <param name="timeSpan">Length of each buffer.</param>
  1008. /// <returns>An observable sequence of buffers.</returns>
  1009. /// <exception cref="ArgumentNullException">
  1010. /// <paramref name="source" /> is null.</exception>
  1011. /// <exception cref="ArgumentOutOfRangeException">
  1012. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1013. /// <remarks>
  1014. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  1015. /// Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
  1016. /// by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1017. /// </remarks>
  1018. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  1019. {
  1020. if (source == null)
  1021. throw new ArgumentNullException(nameof(source));
  1022. return source.Provider.CreateQuery<IList<TSource>>(
  1023. Expression.Call(
  1024. null,
  1025. #if CRIPPLED_REFLECTION
  1026. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  1027. #else
  1028. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1029. #endif
  1030. source.Expression,
  1031. Expression.Constant(timeSpan, typeof(TimeSpan))
  1032. )
  1033. );
  1034. }
  1035. /// <summary>
  1036. /// Projects each element of an observable sequence into a buffer that's sent out when either it's full or a given amount of time has elapsed.
  1037. /// A useful real-world analogy of this overload is the behavior of a ferry leaving the dock when all seats are taken, or at the scheduled time of departure, whichever event occurs first.
  1038. /// </summary>
  1039. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1040. /// <param name="source">Source sequence to produce buffers over.</param>
  1041. /// <param name="timeSpan">Maximum time length of a window.</param>
  1042. /// <param name="count">Maximum element count of a window.</param>
  1043. /// <returns>An observable sequence of buffers.</returns>
  1044. /// <exception cref="ArgumentNullException">
  1045. /// <paramref name="source" /> is null.</exception>
  1046. /// <exception cref="ArgumentOutOfRangeException">
  1047. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  1048. /// <remarks>
  1049. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  1050. /// Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
  1051. /// by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1052. /// </remarks>
  1053. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  1054. {
  1055. if (source == null)
  1056. throw new ArgumentNullException(nameof(source));
  1057. return source.Provider.CreateQuery<IList<TSource>>(
  1058. Expression.Call(
  1059. null,
  1060. #if CRIPPLED_REFLECTION
  1061. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  1062. #else
  1063. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1064. #endif
  1065. source.Expression,
  1066. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1067. Expression.Constant(count, typeof(int))
  1068. )
  1069. );
  1070. }
  1071. /// <summary>
  1072. /// Projects each element of an observable sequence into a buffer that's sent out when either it's full or a given amount of time has elapsed, using the specified scheduler to run timers.
  1073. /// A useful real-world analogy of this overload is the behavior of a ferry leaving the dock when all seats are taken, or at the scheduled time of departure, whichever event occurs first.
  1074. /// </summary>
  1075. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1076. /// <param name="source">Source sequence to produce buffers over.</param>
  1077. /// <param name="timeSpan">Maximum time length of a buffer.</param>
  1078. /// <param name="count">Maximum element count of a buffer.</param>
  1079. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1080. /// <returns>An observable sequence of buffers.</returns>
  1081. /// <exception cref="ArgumentNullException">
  1082. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1083. /// <exception cref="ArgumentOutOfRangeException">
  1084. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  1085. /// <remarks>
  1086. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  1087. /// Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
  1088. /// by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1089. /// </remarks>
  1090. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  1091. {
  1092. if (source == null)
  1093. throw new ArgumentNullException(nameof(source));
  1094. if (scheduler == null)
  1095. throw new ArgumentNullException(nameof(scheduler));
  1096. return source.Provider.CreateQuery<IList<TSource>>(
  1097. Expression.Call(
  1098. null,
  1099. #if CRIPPLED_REFLECTION
  1100. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  1101. #else
  1102. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1103. #endif
  1104. source.Expression,
  1105. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1106. Expression.Constant(count, typeof(int)),
  1107. Expression.Constant(scheduler, typeof(IScheduler))
  1108. )
  1109. );
  1110. }
  1111. /// <summary>
  1112. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information, using the specified scheduler to run timers.
  1113. /// </summary>
  1114. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1115. /// <param name="source">Source sequence to produce buffers over.</param>
  1116. /// <param name="timeSpan">Length of each buffer.</param>
  1117. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1118. /// <returns>An observable sequence of buffers.</returns>
  1119. /// <exception cref="ArgumentNullException">
  1120. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1121. /// <exception cref="ArgumentOutOfRangeException">
  1122. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1123. /// <remarks>
  1124. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  1125. /// Because all source sequence elements end up in one of the buffers, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced
  1126. /// by the scheduler, where the action to close the current buffer and to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1127. /// </remarks>
  1128. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  1129. {
  1130. if (source == null)
  1131. throw new ArgumentNullException(nameof(source));
  1132. if (scheduler == null)
  1133. throw new ArgumentNullException(nameof(scheduler));
  1134. return source.Provider.CreateQuery<IList<TSource>>(
  1135. Expression.Call(
  1136. null,
  1137. #if CRIPPLED_REFLECTION
  1138. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  1139. #else
  1140. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1141. #endif
  1142. source.Expression,
  1143. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1144. Expression.Constant(scheduler, typeof(IScheduler))
  1145. )
  1146. );
  1147. }
  1148. /// <summary>
  1149. /// Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
  1150. /// </summary>
  1151. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1152. /// <param name="source">Source sequence to produce buffers over.</param>
  1153. /// <param name="timeSpan">Length of each buffer.</param>
  1154. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1155. /// <returns>An observable sequence of buffers.</returns>
  1156. /// <exception cref="ArgumentNullException">
  1157. /// <paramref name="source" /> is null.</exception>
  1158. /// <exception cref="ArgumentOutOfRangeException">
  1159. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1160. /// <remarks>
  1161. /// <para>
  1162. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1163. /// length. However, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced by the scheduler, where the action to close the
  1164. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1165. /// </para>
  1166. /// <para>
  1167. /// Specifying a TimeSpan.Zero value for <paramref name="timeShift" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  1168. /// However, this doesn't mean all buffers will start at the beginning of the source sequence. This is a side-effect of the asynchrony introduced by the scheduler,
  1169. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1170. /// </para>
  1171. /// </remarks>
  1172. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  1173. {
  1174. if (source == null)
  1175. throw new ArgumentNullException(nameof(source));
  1176. return source.Provider.CreateQuery<IList<TSource>>(
  1177. Expression.Call(
  1178. null,
  1179. #if CRIPPLED_REFLECTION
  1180. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  1181. #else
  1182. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1183. #endif
  1184. source.Expression,
  1185. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1186. Expression.Constant(timeShift, typeof(TimeSpan))
  1187. )
  1188. );
  1189. }
  1190. /// <summary>
  1191. /// Projects each element of an observable sequence into zero or more buffers which are produced based on timing information, using the specified scheduler to run timers.
  1192. /// </summary>
  1193. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1194. /// <param name="source">Source sequence to produce buffers over.</param>
  1195. /// <param name="timeSpan">Length of each buffer.</param>
  1196. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1197. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1198. /// <returns>An observable sequence of buffers.</returns>
  1199. /// <exception cref="ArgumentNullException">
  1200. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1201. /// <exception cref="ArgumentOutOfRangeException">
  1202. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1203. /// <remarks>
  1204. /// <para>
  1205. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1206. /// length. However, some buffers won't have a zero time span. This is a side-effect of the asynchrony introduced by the scheduler, where the action to close the
  1207. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1208. /// </para>
  1209. /// <para>
  1210. /// Specifying a TimeSpan.Zero value for <paramref name="timeShift" /> is not recommended but supported, causing the scheduler to create buffers as fast as it can.
  1211. /// However, this doesn't mean all buffers will start at the beginning of the source sequence. This is a side-effect of the asynchrony introduced by the scheduler,
  1212. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1213. /// </para>
  1214. /// </remarks>
  1215. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  1216. {
  1217. if (source == null)
  1218. throw new ArgumentNullException(nameof(source));
  1219. if (scheduler == null)
  1220. throw new ArgumentNullException(nameof(scheduler));
  1221. return source.Provider.CreateQuery<IList<TSource>>(
  1222. Expression.Call(
  1223. null,
  1224. #if CRIPPLED_REFLECTION
  1225. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  1226. #else
  1227. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1228. #endif
  1229. source.Expression,
  1230. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1231. Expression.Constant(timeShift, typeof(TimeSpan)),
  1232. Expression.Constant(scheduler, typeof(IScheduler))
  1233. )
  1234. );
  1235. }
  1236. /// <summary>
  1237. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  1238. /// </summary>
  1239. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1240. /// <typeparam name="TBufferBoundary">The type of the elements in the sequences indicating buffer boundary events.</typeparam>
  1241. /// <param name="source">Source sequence to produce buffers over.</param>
  1242. /// <param name="bufferBoundaries">Sequence of buffer boundary markers. The current buffer is closed and a new buffer is opened upon receiving a boundary marker.</param>
  1243. /// <returns>An observable sequence of buffers.</returns>
  1244. /// <exception cref="ArgumentNullException">
  1245. /// <paramref name="source" /> or <paramref name="bufferBoundaries" /> is null.</exception>
  1246. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferBoundary>(this IQbservable<TSource> source, IObservable<TBufferBoundary> bufferBoundaries)
  1247. {
  1248. if (source == null)
  1249. throw new ArgumentNullException(nameof(source));
  1250. if (bufferBoundaries == null)
  1251. throw new ArgumentNullException(nameof(bufferBoundaries));
  1252. return source.Provider.CreateQuery<IList<TSource>>(
  1253. Expression.Call(
  1254. null,
  1255. #if CRIPPLED_REFLECTION
  1256. InfoOf(() => Qbservable.Buffer<TSource, TBufferBoundary>(default(IQbservable<TSource>), default(IObservable<TBufferBoundary>))),
  1257. #else
  1258. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferBoundary)),
  1259. #endif
  1260. source.Expression,
  1261. GetSourceExpression(bufferBoundaries)
  1262. )
  1263. );
  1264. }
  1265. /// <summary>
  1266. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  1267. /// </summary>
  1268. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1269. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1270. /// <param name="source">Source sequence to produce buffers over.</param>
  1271. /// <param name="bufferClosingSelector">A function invoked to define the boundaries of the produced buffers. A new buffer is started when the previous one is closed.</param>
  1272. /// <returns>An observable sequence of buffers.</returns>
  1273. /// <exception cref="ArgumentNullException">
  1274. /// <paramref name="source" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1275. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TBufferClosing>>> bufferClosingSelector)
  1276. {
  1277. if (source == null)
  1278. throw new ArgumentNullException(nameof(source));
  1279. if (bufferClosingSelector == null)
  1280. throw new ArgumentNullException(nameof(bufferClosingSelector));
  1281. return source.Provider.CreateQuery<IList<TSource>>(
  1282. Expression.Call(
  1283. null,
  1284. #if CRIPPLED_REFLECTION
  1285. InfoOf(() => Qbservable.Buffer<TSource, TBufferClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TBufferClosing>>>))),
  1286. #else
  1287. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferClosing)),
  1288. #endif
  1289. source.Expression,
  1290. bufferClosingSelector
  1291. )
  1292. );
  1293. }
  1294. /// <summary>
  1295. /// Projects each element of an observable sequence into zero or more buffers.
  1296. /// </summary>
  1297. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1298. /// <typeparam name="TBufferOpening">The type of the elements in the sequence indicating buffer opening events, also passed to the closing selector to obtain a sequence of buffer closing events.</typeparam>
  1299. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1300. /// <param name="source">Source sequence to produce buffers over.</param>
  1301. /// <param name="bufferOpenings">Observable sequence whose elements denote the creation of new buffers.</param>
  1302. /// <param name="bufferClosingSelector">A function invoked to define the closing of each produced buffer.</param>
  1303. /// <returns>An observable sequence of buffers.</returns>
  1304. /// <exception cref="ArgumentNullException">
  1305. /// <paramref name="source" /> or <paramref name="bufferOpenings" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1306. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferOpening, TBufferClosing>(this IQbservable<TSource> source, IObservable<TBufferOpening> bufferOpenings, Expression<Func<TBufferOpening, IObservable<TBufferClosing>>> bufferClosingSelector)
  1307. {
  1308. if (source == null)
  1309. throw new ArgumentNullException(nameof(source));
  1310. if (bufferOpenings == null)
  1311. throw new ArgumentNullException(nameof(bufferOpenings));
  1312. if (bufferClosingSelector == null)
  1313. throw new ArgumentNullException(nameof(bufferClosingSelector));
  1314. return source.Provider.CreateQuery<IList<TSource>>(
  1315. Expression.Call(
  1316. null,
  1317. #if CRIPPLED_REFLECTION
  1318. InfoOf(() => Qbservable.Buffer<TSource, TBufferOpening, TBufferClosing>(default(IQbservable<TSource>), default(IObservable<TBufferOpening>), default(Expression<Func<TBufferOpening, IObservable<TBufferClosing>>>))),
  1319. #else
  1320. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferOpening), typeof(TBufferClosing)),
  1321. #endif
  1322. source.Expression,
  1323. GetSourceExpression(bufferOpenings),
  1324. bufferClosingSelector
  1325. )
  1326. );
  1327. }
  1328. /// <summary>
  1329. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing an empty sequence if no match is found.
  1330. /// </summary>
  1331. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1332. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1333. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1334. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1335. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1336. /// <returns>The observable sequence retrieved from the <paramref name="sources" /> dictionary based on the <paramref name="selector" /> invocation result, or an empty sequence if no match is found.</returns>
  1337. /// <exception cref="ArgumentNullException">
  1338. /// <paramref name="selector" /> or <paramref name="sources" /> is null.</exception>
  1339. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources)
  1340. {
  1341. if (provider == null)
  1342. throw new ArgumentNullException(nameof(provider));
  1343. if (selector == null)
  1344. throw new ArgumentNullException(nameof(selector));
  1345. if (sources == null)
  1346. throw new ArgumentNullException(nameof(sources));
  1347. return provider.CreateQuery<TResult>(
  1348. Expression.Call(
  1349. null,
  1350. #if CRIPPLED_REFLECTION
  1351. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>))),
  1352. #else
  1353. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1354. #endif
  1355. Expression.Constant(provider, typeof(IQbservableProvider)),
  1356. selector,
  1357. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>))
  1358. )
  1359. );
  1360. }
  1361. /// <summary>
  1362. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing <paramref name="defaultSource" /> if no match is found.
  1363. /// </summary>
  1364. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1365. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1366. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1367. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1368. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1369. /// <param name="defaultSource">Default source to select in case no matching source in <paramref name="sources" /> is found.</param>
  1370. /// <returns>The observable sequence retrieved from the <paramref name="sources" /> dictionary based on the <paramref name="selector" /> invocation result, or <paramref name="defaultSource" /> if no match is found.</returns>
  1371. /// <exception cref="ArgumentNullException">
  1372. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="defaultSource" /> is null.</exception>
  1373. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IObservable<TResult> defaultSource)
  1374. {
  1375. if (provider == null)
  1376. throw new ArgumentNullException(nameof(provider));
  1377. if (selector == null)
  1378. throw new ArgumentNullException(nameof(selector));
  1379. if (sources == null)
  1380. throw new ArgumentNullException(nameof(sources));
  1381. if (defaultSource == null)
  1382. throw new ArgumentNullException(nameof(defaultSource));
  1383. return provider.CreateQuery<TResult>(
  1384. Expression.Call(
  1385. null,
  1386. #if CRIPPLED_REFLECTION
  1387. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IObservable<TResult>))),
  1388. #else
  1389. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1390. #endif
  1391. Expression.Constant(provider, typeof(IQbservableProvider)),
  1392. selector,
  1393. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1394. GetSourceExpression(defaultSource)
  1395. )
  1396. );
  1397. }
  1398. /// <summary>
  1399. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing an empty sequence on the specified scheduler if no match is found.
  1400. /// </summary>
  1401. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1402. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1403. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1404. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1405. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1406. /// <param name="scheduler">Scheduler to generate an empty sequence on in case no matching source in <paramref name="sources" /> is found.</param>
  1407. /// <returns>The observable sequence retrieved from the <paramref name="sources" /> dictionary based on the <paramref name="selector" /> invocation result, or an empty sequence if no match is found.</returns>
  1408. /// <exception cref="ArgumentNullException">
  1409. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  1410. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IScheduler scheduler)
  1411. {
  1412. if (provider == null)
  1413. throw new ArgumentNullException(nameof(provider));
  1414. if (selector == null)
  1415. throw new ArgumentNullException(nameof(selector));
  1416. if (sources == null)
  1417. throw new ArgumentNullException(nameof(sources));
  1418. if (scheduler == null)
  1419. throw new ArgumentNullException(nameof(scheduler));
  1420. return provider.CreateQuery<TResult>(
  1421. Expression.Call(
  1422. null,
  1423. #if CRIPPLED_REFLECTION
  1424. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IScheduler))),
  1425. #else
  1426. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1427. #endif
  1428. Expression.Constant(provider, typeof(IQbservableProvider)),
  1429. selector,
  1430. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1431. Expression.Constant(scheduler, typeof(IScheduler))
  1432. )
  1433. );
  1434. }
  1435. /// <summary>
  1436. /// Converts the elements of an observable sequence to the specified type.
  1437. /// </summary>
  1438. /// <typeparam name="TResult">The type to convert the elements in the source sequence to.</typeparam>
  1439. /// <param name="source">The observable sequence that contains the elements to be converted.</param>
  1440. /// <returns>An observable sequence that contains each element of the source sequence converted to the specified type.</returns>
  1441. /// <exception cref="ArgumentNullException">
  1442. /// <paramref name="source" /> is null.</exception>
  1443. public static IQbservable<TResult> Cast<TResult>(this IQbservable<object> source)
  1444. {
  1445. if (source == null)
  1446. throw new ArgumentNullException(nameof(source));
  1447. return source.Provider.CreateQuery<TResult>(
  1448. Expression.Call(
  1449. null,
  1450. #if CRIPPLED_REFLECTION
  1451. InfoOf(() => Qbservable.Cast<TResult>(default(IQbservable<object>))),
  1452. #else
  1453. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  1454. #endif
  1455. source.Expression
  1456. )
  1457. );
  1458. }
  1459. /// <summary>
  1460. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1461. /// </summary>
  1462. /// <typeparam name="TSource">The type of the elements in the source sequence and handler sequence.</typeparam>
  1463. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  1464. /// <param name="second">Second observable sequence used to produce results when an error occurred in the first sequence.</param>
  1465. /// <returns>An observable sequence containing the first sequence's elements, followed by the elements of the second sequence in case an exception occurred.</returns>
  1466. /// <exception cref="ArgumentNullException">
  1467. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  1468. public static IQbservable<TSource> Catch<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  1469. {
  1470. if (first == null)
  1471. throw new ArgumentNullException(nameof(first));
  1472. if (second == null)
  1473. throw new ArgumentNullException(nameof(second));
  1474. return first.Provider.CreateQuery<TSource>(
  1475. Expression.Call(
  1476. null,
  1477. #if CRIPPLED_REFLECTION
  1478. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  1479. #else
  1480. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1481. #endif
  1482. first.Expression,
  1483. GetSourceExpression(second)
  1484. )
  1485. );
  1486. }
  1487. /// <summary>
  1488. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1489. /// </summary>
  1490. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1491. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1492. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1493. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1494. /// <exception cref="ArgumentNullException">
  1495. /// <paramref name="sources" /> is null.</exception>
  1496. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1497. {
  1498. if (provider == null)
  1499. throw new ArgumentNullException(nameof(provider));
  1500. if (sources == null)
  1501. throw new ArgumentNullException(nameof(sources));
  1502. return provider.CreateQuery<TSource>(
  1503. Expression.Call(
  1504. null,
  1505. #if CRIPPLED_REFLECTION
  1506. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1507. #else
  1508. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1509. #endif
  1510. Expression.Constant(provider, typeof(IQbservableProvider)),
  1511. GetSourceExpression(sources)
  1512. )
  1513. );
  1514. }
  1515. /// <summary>
  1516. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1517. /// </summary>
  1518. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1519. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1520. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1521. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1522. /// <exception cref="ArgumentNullException">
  1523. /// <paramref name="sources" /> is null.</exception>
  1524. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1525. {
  1526. if (provider == null)
  1527. throw new ArgumentNullException(nameof(provider));
  1528. if (sources == null)
  1529. throw new ArgumentNullException(nameof(sources));
  1530. return provider.CreateQuery<TSource>(
  1531. Expression.Call(
  1532. null,
  1533. #if CRIPPLED_REFLECTION
  1534. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1535. #else
  1536. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1537. #endif
  1538. Expression.Constant(provider, typeof(IQbservableProvider)),
  1539. GetSourceExpression(sources)
  1540. )
  1541. );
  1542. }
  1543. /// <summary>
  1544. /// Continues an observable sequence that is terminated by an exception of the specified type with the observable sequence produced by the handler.
  1545. /// </summary>
  1546. /// <typeparam name="TSource">The type of the elements in the source sequence and sequences returned by the exception handler function.</typeparam>
  1547. /// <typeparam name="TException">The type of the exception to catch and handle. Needs to derive from <see cref="Exception" />.</typeparam>
  1548. /// <param name="source">Source sequence.</param>
  1549. /// <param name="handler">Exception handler function, producing another observable sequence.</param>
  1550. /// <returns>An observable sequence containing the source sequence's elements, followed by the elements produced by the handler's resulting observable sequence in case an exception occurred.</returns>
  1551. /// <exception cref="ArgumentNullException">
  1552. /// <paramref name="source" /> or <paramref name="handler" /> is null.</exception>
  1553. public static IQbservable<TSource> Catch<TSource, TException>(this IQbservable<TSource> source, Expression<Func<TException, IObservable<TSource>>> handler)
  1554. where TException : Exception
  1555. {
  1556. if (source == null)
  1557. throw new ArgumentNullException(nameof(source));
  1558. if (handler == null)
  1559. throw new ArgumentNullException(nameof(handler));
  1560. return source.Provider.CreateQuery<TSource>(
  1561. Expression.Call(
  1562. null,
  1563. #if CRIPPLED_REFLECTION
  1564. InfoOf(() => Qbservable.Catch<TSource, TException>(default(IQbservable<TSource>), default(Expression<Func<TException, IObservable<TSource>>>))),
  1565. #else
  1566. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)),
  1567. #endif
  1568. source.Expression,
  1569. handler
  1570. )
  1571. );
  1572. }
  1573. /// <summary>
  1574. /// Produces an enumerable sequence of consecutive (possibly empty) chunks of the source sequence.
  1575. /// </summary>
  1576. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1577. /// <param name="source">Source observable sequence.</param>
  1578. /// <returns>The enumerable sequence that returns consecutive (possibly empty) chunks upon each iteration.</returns>
  1579. /// <exception cref="ArgumentNullException">
  1580. /// <paramref name="source" /> is null.</exception>
  1581. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1582. public static IQueryable<IList<TSource>> Chunkify<TSource>(this IQbservable<TSource> source)
  1583. {
  1584. if (source == null)
  1585. throw new ArgumentNullException(nameof(source));
  1586. return ((IQueryProvider)source.Provider).CreateQuery<IList<TSource>>(
  1587. Expression.Call(
  1588. null,
  1589. #if CRIPPLED_REFLECTION
  1590. InfoOf(() => Qbservable.Chunkify<TSource>(default(IQbservable<TSource>))),
  1591. #else
  1592. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1593. #endif
  1594. source.Expression
  1595. )
  1596. );
  1597. }
  1598. /// <summary>
  1599. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1600. /// </summary>
  1601. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1602. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1603. /// <param name="source">Source observable sequence.</param>
  1604. /// <param name="getInitialCollector">Factory to create the initial collector object.</param>
  1605. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1606. /// <param name="getNewCollector">Factory to replace the current collector by a new collector.</param>
  1607. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1608. /// <exception cref="ArgumentNullException">
  1609. /// <paramref name="source" /> or <paramref name="getInitialCollector" /> or <paramref name="merge" /> or <paramref name="getNewCollector" /> is null.</exception>
  1610. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1611. public static IQueryable<TResult> Collect<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TResult>> getInitialCollector, Expression<Func<TResult, TSource, TResult>> merge, Expression<Func<TResult, TResult>> getNewCollector)
  1612. {
  1613. if (source == null)
  1614. throw new ArgumentNullException(nameof(source));
  1615. if (getInitialCollector == null)
  1616. throw new ArgumentNullException(nameof(getInitialCollector));
  1617. if (merge == null)
  1618. throw new ArgumentNullException(nameof(merge));
  1619. if (getNewCollector == null)
  1620. throw new ArgumentNullException(nameof(getNewCollector));
  1621. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1622. Expression.Call(
  1623. null,
  1624. #if CRIPPLED_REFLECTION
  1625. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>), default(Expression<Func<TResult, TResult>>))),
  1626. #else
  1627. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1628. #endif
  1629. source.Expression,
  1630. getInitialCollector,
  1631. merge,
  1632. getNewCollector
  1633. )
  1634. );
  1635. }
  1636. /// <summary>
  1637. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1638. /// </summary>
  1639. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1640. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1641. /// <param name="source">Source observable sequence.</param>
  1642. /// <param name="newCollector">Factory to create a new collector object.</param>
  1643. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1644. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1645. /// <exception cref="ArgumentNullException">
  1646. /// <paramref name="source" /> or <paramref name="newCollector" /> or <paramref name="merge" /> is null.</exception>
  1647. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1648. public static IQueryable<TResult> Collect<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TResult>> newCollector, Expression<Func<TResult, TSource, TResult>> merge)
  1649. {
  1650. if (source == null)
  1651. throw new ArgumentNullException(nameof(source));
  1652. if (newCollector == null)
  1653. throw new ArgumentNullException(nameof(newCollector));
  1654. if (merge == null)
  1655. throw new ArgumentNullException(nameof(merge));
  1656. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1657. Expression.Call(
  1658. null,
  1659. #if CRIPPLED_REFLECTION
  1660. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>))),
  1661. #else
  1662. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1663. #endif
  1664. source.Expression,
  1665. newCollector,
  1666. merge
  1667. )
  1668. );
  1669. }
  1670. /// <summary>
  1671. /// Merges the specified observable sequences into one observable sequence by emitting a list with the latest source elements whenever any of the observable sequences produces an element.
  1672. /// </summary>
  1673. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1674. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1675. /// <param name="sources">Observable sources.</param>
  1676. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1677. /// <exception cref="ArgumentNullException">
  1678. /// <paramref name="sources" /> is null.</exception>
  1679. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1680. {
  1681. if (provider == null)
  1682. throw new ArgumentNullException(nameof(provider));
  1683. if (sources == null)
  1684. throw new ArgumentNullException(nameof(sources));
  1685. return provider.CreateQuery<IList<TSource>>(
  1686. Expression.Call(
  1687. null,
  1688. #if CRIPPLED_REFLECTION
  1689. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1690. #else
  1691. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1692. #endif
  1693. Expression.Constant(provider, typeof(IQbservableProvider)),
  1694. GetSourceExpression(sources)
  1695. )
  1696. );
  1697. }
  1698. /// <summary>
  1699. /// Merges the specified observable sequences into one observable sequence by emitting a list with the latest source elements whenever any of the observable sequences produces an element.
  1700. /// </summary>
  1701. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1702. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1703. /// <param name="sources">Observable sources.</param>
  1704. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1705. /// <exception cref="ArgumentNullException">
  1706. /// <paramref name="sources" /> is null.</exception>
  1707. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1708. {
  1709. if (provider == null)
  1710. throw new ArgumentNullException(nameof(provider));
  1711. if (sources == null)
  1712. throw new ArgumentNullException(nameof(sources));
  1713. return provider.CreateQuery<IList<TSource>>(
  1714. Expression.Call(
  1715. null,
  1716. #if CRIPPLED_REFLECTION
  1717. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1718. #else
  1719. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1720. #endif
  1721. Expression.Constant(provider, typeof(IQbservableProvider)),
  1722. GetSourceExpression(sources)
  1723. )
  1724. );
  1725. }
  1726. /// <summary>
  1727. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1728. /// </summary>
  1729. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1730. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  1731. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1732. /// <param name="sources">Observable sources.</param>
  1733. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element. For efficiency, the input list is reused after the selector returns. Either aggregate or copy the values during the function call.</param>
  1734. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1735. /// <exception cref="ArgumentNullException">
  1736. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  1737. public static IQbservable<TResult> CombineLatest<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  1738. {
  1739. if (provider == null)
  1740. throw new ArgumentNullException(nameof(provider));
  1741. if (sources == null)
  1742. throw new ArgumentNullException(nameof(sources));
  1743. if (resultSelector == null)
  1744. throw new ArgumentNullException(nameof(resultSelector));
  1745. return provider.CreateQuery<TResult>(
  1746. Expression.Call(
  1747. null,
  1748. #if CRIPPLED_REFLECTION
  1749. InfoOf(() => Qbservable.CombineLatest<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  1750. #else
  1751. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1752. #endif
  1753. Expression.Constant(provider, typeof(IQbservableProvider)),
  1754. GetSourceExpression(sources),
  1755. resultSelector
  1756. )
  1757. );
  1758. }
  1759. /// <summary>
  1760. /// Merges two observable sequences into one observable sequence by using the selector function whenever one of the observable sequences produces an element.
  1761. /// </summary>
  1762. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1763. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1764. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1765. /// <param name="first">First observable source.</param>
  1766. /// <param name="second">Second observable source.</param>
  1767. /// <param name="resultSelector">Function to invoke whenever either of the sources produces an element.</param>
  1768. /// <returns>An observable sequence containing the result of combining elements of both sources using the specified result selector function.</returns>
  1769. /// <exception cref="ArgumentNullException">
  1770. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  1771. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  1772. {
  1773. if (first == null)
  1774. throw new ArgumentNullException(nameof(first));
  1775. if (second == null)
  1776. throw new ArgumentNullException(nameof(second));
  1777. if (resultSelector == null)
  1778. throw new ArgumentNullException(nameof(resultSelector));
  1779. return first.Provider.CreateQuery<TResult>(
  1780. Expression.Call(
  1781. null,
  1782. #if CRIPPLED_REFLECTION
  1783. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  1784. #else
  1785. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  1786. #endif
  1787. first.Expression,
  1788. GetSourceExpression(second),
  1789. resultSelector
  1790. )
  1791. );
  1792. }
  1793. /// <summary>
  1794. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1795. /// </summary>
  1796. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1797. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1798. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1799. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1800. /// <param name="source1">First observable source.</param>
  1801. /// <param name="source2">Second observable source.</param>
  1802. /// <param name="source3">Third observable source.</param>
  1803. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1804. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1805. /// <exception cref="ArgumentNullException">
  1806. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  1807. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, Expression<Func<TSource1, TSource2, TSource3, TResult>> resultSelector)
  1808. {
  1809. if (source1 == null)
  1810. throw new ArgumentNullException(nameof(source1));
  1811. if (source2 == null)
  1812. throw new ArgumentNullException(nameof(source2));
  1813. if (source3 == null)
  1814. throw new ArgumentNullException(nameof(source3));
  1815. if (resultSelector == null)
  1816. throw new ArgumentNullException(nameof(resultSelector));
  1817. return source1.Provider.CreateQuery<TResult>(
  1818. Expression.Call(
  1819. null,
  1820. #if CRIPPLED_REFLECTION
  1821. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  1822. #else
  1823. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  1824. #endif
  1825. source1.Expression,
  1826. GetSourceExpression(source2),
  1827. GetSourceExpression(source3),
  1828. resultSelector
  1829. )
  1830. );
  1831. }
  1832. /// <summary>
  1833. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1834. /// </summary>
  1835. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1836. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1837. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1838. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1839. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1840. /// <param name="source1">First observable source.</param>
  1841. /// <param name="source2">Second observable source.</param>
  1842. /// <param name="source3">Third observable source.</param>
  1843. /// <param name="source4">Fourth observable source.</param>
  1844. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1845. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1846. /// <exception cref="ArgumentNullException">
  1847. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  1848. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, Expression<Func<TSource1, TSource2, TSource3, TSource4, TResult>> resultSelector)
  1849. {
  1850. if (source1 == null)
  1851. throw new ArgumentNullException(nameof(source1));
  1852. if (source2 == null)
  1853. throw new ArgumentNullException(nameof(source2));
  1854. if (source3 == null)
  1855. throw new ArgumentNullException(nameof(source3));
  1856. if (source4 == null)
  1857. throw new ArgumentNullException(nameof(source4));
  1858. if (resultSelector == null)
  1859. throw new ArgumentNullException(nameof(resultSelector));
  1860. return source1.Provider.CreateQuery<TResult>(
  1861. Expression.Call(
  1862. null,
  1863. #if CRIPPLED_REFLECTION
  1864. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TResult>>))),
  1865. #else
  1866. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  1867. #endif
  1868. source1.Expression,
  1869. GetSourceExpression(source2),
  1870. GetSourceExpression(source3),
  1871. GetSourceExpression(source4),
  1872. resultSelector
  1873. )
  1874. );
  1875. }
  1876. /// <summary>
  1877. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1878. /// </summary>
  1879. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1880. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1881. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1882. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1883. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1884. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1885. /// <param name="source1">First observable source.</param>
  1886. /// <param name="source2">Second observable source.</param>
  1887. /// <param name="source3">Third observable source.</param>
  1888. /// <param name="source4">Fourth observable source.</param>
  1889. /// <param name="source5">Fifth observable source.</param>
  1890. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1891. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1892. /// <exception cref="ArgumentNullException">
  1893. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="resultSelector" /> is null.</exception>
  1894. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>> resultSelector)
  1895. {
  1896. if (source1 == null)
  1897. throw new ArgumentNullException(nameof(source1));
  1898. if (source2 == null)
  1899. throw new ArgumentNullException(nameof(source2));
  1900. if (source3 == null)
  1901. throw new ArgumentNullException(nameof(source3));
  1902. if (source4 == null)
  1903. throw new ArgumentNullException(nameof(source4));
  1904. if (source5 == null)
  1905. throw new ArgumentNullException(nameof(source5));
  1906. if (resultSelector == null)
  1907. throw new ArgumentNullException(nameof(resultSelector));
  1908. return source1.Provider.CreateQuery<TResult>(
  1909. Expression.Call(
  1910. null,
  1911. #if CRIPPLED_REFLECTION
  1912. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>>))),
  1913. #else
  1914. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  1915. #endif
  1916. source1.Expression,
  1917. GetSourceExpression(source2),
  1918. GetSourceExpression(source3),
  1919. GetSourceExpression(source4),
  1920. GetSourceExpression(source5),
  1921. resultSelector
  1922. )
  1923. );
  1924. }
  1925. /// <summary>
  1926. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1927. /// </summary>
  1928. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1929. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1930. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1931. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1932. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1933. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1934. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1935. /// <param name="source1">First observable source.</param>
  1936. /// <param name="source2">Second observable source.</param>
  1937. /// <param name="source3">Third observable source.</param>
  1938. /// <param name="source4">Fourth observable source.</param>
  1939. /// <param name="source5">Fifth observable source.</param>
  1940. /// <param name="source6">Sixth observable source.</param>
  1941. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1942. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1943. /// <exception cref="ArgumentNullException">
  1944. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="resultSelector" /> is null.</exception>
  1945. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>> resultSelector)
  1946. {
  1947. if (source1 == null)
  1948. throw new ArgumentNullException(nameof(source1));
  1949. if (source2 == null)
  1950. throw new ArgumentNullException(nameof(source2));
  1951. if (source3 == null)
  1952. throw new ArgumentNullException(nameof(source3));
  1953. if (source4 == null)
  1954. throw new ArgumentNullException(nameof(source4));
  1955. if (source5 == null)
  1956. throw new ArgumentNullException(nameof(source5));
  1957. if (source6 == null)
  1958. throw new ArgumentNullException(nameof(source6));
  1959. if (resultSelector == null)
  1960. throw new ArgumentNullException(nameof(resultSelector));
  1961. return source1.Provider.CreateQuery<TResult>(
  1962. Expression.Call(
  1963. null,
  1964. #if CRIPPLED_REFLECTION
  1965. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>>))),
  1966. #else
  1967. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  1968. #endif
  1969. source1.Expression,
  1970. GetSourceExpression(source2),
  1971. GetSourceExpression(source3),
  1972. GetSourceExpression(source4),
  1973. GetSourceExpression(source5),
  1974. GetSourceExpression(source6),
  1975. resultSelector
  1976. )
  1977. );
  1978. }
  1979. /// <summary>
  1980. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1981. /// </summary>
  1982. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1983. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1984. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1985. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1986. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1987. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1988. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  1989. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1990. /// <param name="source1">First observable source.</param>
  1991. /// <param name="source2">Second observable source.</param>
  1992. /// <param name="source3">Third observable source.</param>
  1993. /// <param name="source4">Fourth observable source.</param>
  1994. /// <param name="source5">Fifth observable source.</param>
  1995. /// <param name="source6">Sixth observable source.</param>
  1996. /// <param name="source7">Seventh observable source.</param>
  1997. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1998. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1999. /// <exception cref="ArgumentNullException">
  2000. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="resultSelector" /> is null.</exception>
  2001. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>> resultSelector)
  2002. {
  2003. if (source1 == null)
  2004. throw new ArgumentNullException(nameof(source1));
  2005. if (source2 == null)
  2006. throw new ArgumentNullException(nameof(source2));
  2007. if (source3 == null)
  2008. throw new ArgumentNullException(nameof(source3));
  2009. if (source4 == null)
  2010. throw new ArgumentNullException(nameof(source4));
  2011. if (source5 == null)
  2012. throw new ArgumentNullException(nameof(source5));
  2013. if (source6 == null)
  2014. throw new ArgumentNullException(nameof(source6));
  2015. if (source7 == null)
  2016. throw new ArgumentNullException(nameof(source7));
  2017. if (resultSelector == null)
  2018. throw new ArgumentNullException(nameof(resultSelector));
  2019. return source1.Provider.CreateQuery<TResult>(
  2020. Expression.Call(
  2021. null,
  2022. #if CRIPPLED_REFLECTION
  2023. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>>))),
  2024. #else
  2025. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  2026. #endif
  2027. source1.Expression,
  2028. GetSourceExpression(source2),
  2029. GetSourceExpression(source3),
  2030. GetSourceExpression(source4),
  2031. GetSourceExpression(source5),
  2032. GetSourceExpression(source6),
  2033. GetSourceExpression(source7),
  2034. resultSelector
  2035. )
  2036. );
  2037. }
  2038. /// <summary>
  2039. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2040. /// </summary>
  2041. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2042. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2043. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2044. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2045. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2046. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2047. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2048. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2049. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2050. /// <param name="source1">First observable source.</param>
  2051. /// <param name="source2">Second observable source.</param>
  2052. /// <param name="source3">Third observable source.</param>
  2053. /// <param name="source4">Fourth observable source.</param>
  2054. /// <param name="source5">Fifth observable source.</param>
  2055. /// <param name="source6">Sixth observable source.</param>
  2056. /// <param name="source7">Seventh observable source.</param>
  2057. /// <param name="source8">Eighth observable source.</param>
  2058. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2059. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2060. /// <exception cref="ArgumentNullException">
  2061. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="resultSelector" /> is null.</exception>
  2062. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>> resultSelector)
  2063. {
  2064. if (source1 == null)
  2065. throw new ArgumentNullException(nameof(source1));
  2066. if (source2 == null)
  2067. throw new ArgumentNullException(nameof(source2));
  2068. if (source3 == null)
  2069. throw new ArgumentNullException(nameof(source3));
  2070. if (source4 == null)
  2071. throw new ArgumentNullException(nameof(source4));
  2072. if (source5 == null)
  2073. throw new ArgumentNullException(nameof(source5));
  2074. if (source6 == null)
  2075. throw new ArgumentNullException(nameof(source6));
  2076. if (source7 == null)
  2077. throw new ArgumentNullException(nameof(source7));
  2078. if (source8 == null)
  2079. throw new ArgumentNullException(nameof(source8));
  2080. if (resultSelector == null)
  2081. throw new ArgumentNullException(nameof(resultSelector));
  2082. return source1.Provider.CreateQuery<TResult>(
  2083. Expression.Call(
  2084. null,
  2085. #if CRIPPLED_REFLECTION
  2086. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>>))),
  2087. #else
  2088. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  2089. #endif
  2090. source1.Expression,
  2091. GetSourceExpression(source2),
  2092. GetSourceExpression(source3),
  2093. GetSourceExpression(source4),
  2094. GetSourceExpression(source5),
  2095. GetSourceExpression(source6),
  2096. GetSourceExpression(source7),
  2097. GetSourceExpression(source8),
  2098. resultSelector
  2099. )
  2100. );
  2101. }
  2102. /// <summary>
  2103. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2104. /// </summary>
  2105. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2106. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2107. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2108. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2109. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2110. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2111. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2112. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2113. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2114. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2115. /// <param name="source1">First observable source.</param>
  2116. /// <param name="source2">Second observable source.</param>
  2117. /// <param name="source3">Third observable source.</param>
  2118. /// <param name="source4">Fourth observable source.</param>
  2119. /// <param name="source5">Fifth observable source.</param>
  2120. /// <param name="source6">Sixth observable source.</param>
  2121. /// <param name="source7">Seventh observable source.</param>
  2122. /// <param name="source8">Eighth observable source.</param>
  2123. /// <param name="source9">Ninth observable source.</param>
  2124. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2125. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2126. /// <exception cref="ArgumentNullException">
  2127. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="resultSelector" /> is null.</exception>
  2128. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>> resultSelector)
  2129. {
  2130. if (source1 == null)
  2131. throw new ArgumentNullException(nameof(source1));
  2132. if (source2 == null)
  2133. throw new ArgumentNullException(nameof(source2));
  2134. if (source3 == null)
  2135. throw new ArgumentNullException(nameof(source3));
  2136. if (source4 == null)
  2137. throw new ArgumentNullException(nameof(source4));
  2138. if (source5 == null)
  2139. throw new ArgumentNullException(nameof(source5));
  2140. if (source6 == null)
  2141. throw new ArgumentNullException(nameof(source6));
  2142. if (source7 == null)
  2143. throw new ArgumentNullException(nameof(source7));
  2144. if (source8 == null)
  2145. throw new ArgumentNullException(nameof(source8));
  2146. if (source9 == null)
  2147. throw new ArgumentNullException(nameof(source9));
  2148. if (resultSelector == null)
  2149. throw new ArgumentNullException(nameof(resultSelector));
  2150. return source1.Provider.CreateQuery<TResult>(
  2151. Expression.Call(
  2152. null,
  2153. #if CRIPPLED_REFLECTION
  2154. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>>))),
  2155. #else
  2156. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  2157. #endif
  2158. source1.Expression,
  2159. GetSourceExpression(source2),
  2160. GetSourceExpression(source3),
  2161. GetSourceExpression(source4),
  2162. GetSourceExpression(source5),
  2163. GetSourceExpression(source6),
  2164. GetSourceExpression(source7),
  2165. GetSourceExpression(source8),
  2166. GetSourceExpression(source9),
  2167. resultSelector
  2168. )
  2169. );
  2170. }
  2171. /// <summary>
  2172. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2173. /// </summary>
  2174. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2175. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2176. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2177. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2178. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2179. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2180. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2181. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2182. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2183. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2184. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2185. /// <param name="source1">First observable source.</param>
  2186. /// <param name="source2">Second observable source.</param>
  2187. /// <param name="source3">Third observable source.</param>
  2188. /// <param name="source4">Fourth observable source.</param>
  2189. /// <param name="source5">Fifth observable source.</param>
  2190. /// <param name="source6">Sixth observable source.</param>
  2191. /// <param name="source7">Seventh observable source.</param>
  2192. /// <param name="source8">Eighth observable source.</param>
  2193. /// <param name="source9">Ninth observable source.</param>
  2194. /// <param name="source10">Tenth observable source.</param>
  2195. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2196. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2197. /// <exception cref="ArgumentNullException">
  2198. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="resultSelector" /> is null.</exception>
  2199. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>> resultSelector)
  2200. {
  2201. if (source1 == null)
  2202. throw new ArgumentNullException(nameof(source1));
  2203. if (source2 == null)
  2204. throw new ArgumentNullException(nameof(source2));
  2205. if (source3 == null)
  2206. throw new ArgumentNullException(nameof(source3));
  2207. if (source4 == null)
  2208. throw new ArgumentNullException(nameof(source4));
  2209. if (source5 == null)
  2210. throw new ArgumentNullException(nameof(source5));
  2211. if (source6 == null)
  2212. throw new ArgumentNullException(nameof(source6));
  2213. if (source7 == null)
  2214. throw new ArgumentNullException(nameof(source7));
  2215. if (source8 == null)
  2216. throw new ArgumentNullException(nameof(source8));
  2217. if (source9 == null)
  2218. throw new ArgumentNullException(nameof(source9));
  2219. if (source10 == null)
  2220. throw new ArgumentNullException(nameof(source10));
  2221. if (resultSelector == null)
  2222. throw new ArgumentNullException(nameof(resultSelector));
  2223. return source1.Provider.CreateQuery<TResult>(
  2224. Expression.Call(
  2225. null,
  2226. #if CRIPPLED_REFLECTION
  2227. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>>))),
  2228. #else
  2229. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TResult)),
  2230. #endif
  2231. source1.Expression,
  2232. GetSourceExpression(source2),
  2233. GetSourceExpression(source3),
  2234. GetSourceExpression(source4),
  2235. GetSourceExpression(source5),
  2236. GetSourceExpression(source6),
  2237. GetSourceExpression(source7),
  2238. GetSourceExpression(source8),
  2239. GetSourceExpression(source9),
  2240. GetSourceExpression(source10),
  2241. resultSelector
  2242. )
  2243. );
  2244. }
  2245. /// <summary>
  2246. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2247. /// </summary>
  2248. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2249. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2250. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2251. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2252. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2253. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2254. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2255. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2256. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2257. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2258. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2259. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2260. /// <param name="source1">First observable source.</param>
  2261. /// <param name="source2">Second observable source.</param>
  2262. /// <param name="source3">Third observable source.</param>
  2263. /// <param name="source4">Fourth observable source.</param>
  2264. /// <param name="source5">Fifth observable source.</param>
  2265. /// <param name="source6">Sixth observable source.</param>
  2266. /// <param name="source7">Seventh observable source.</param>
  2267. /// <param name="source8">Eighth observable source.</param>
  2268. /// <param name="source9">Ninth observable source.</param>
  2269. /// <param name="source10">Tenth observable source.</param>
  2270. /// <param name="source11">Eleventh observable source.</param>
  2271. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2272. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2273. /// <exception cref="ArgumentNullException">
  2274. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="resultSelector" /> is null.</exception>
  2275. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>> resultSelector)
  2276. {
  2277. if (source1 == null)
  2278. throw new ArgumentNullException(nameof(source1));
  2279. if (source2 == null)
  2280. throw new ArgumentNullException(nameof(source2));
  2281. if (source3 == null)
  2282. throw new ArgumentNullException(nameof(source3));
  2283. if (source4 == null)
  2284. throw new ArgumentNullException(nameof(source4));
  2285. if (source5 == null)
  2286. throw new ArgumentNullException(nameof(source5));
  2287. if (source6 == null)
  2288. throw new ArgumentNullException(nameof(source6));
  2289. if (source7 == null)
  2290. throw new ArgumentNullException(nameof(source7));
  2291. if (source8 == null)
  2292. throw new ArgumentNullException(nameof(source8));
  2293. if (source9 == null)
  2294. throw new ArgumentNullException(nameof(source9));
  2295. if (source10 == null)
  2296. throw new ArgumentNullException(nameof(source10));
  2297. if (source11 == null)
  2298. throw new ArgumentNullException(nameof(source11));
  2299. if (resultSelector == null)
  2300. throw new ArgumentNullException(nameof(resultSelector));
  2301. return source1.Provider.CreateQuery<TResult>(
  2302. Expression.Call(
  2303. null,
  2304. #if CRIPPLED_REFLECTION
  2305. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>>))),
  2306. #else
  2307. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TResult)),
  2308. #endif
  2309. source1.Expression,
  2310. GetSourceExpression(source2),
  2311. GetSourceExpression(source3),
  2312. GetSourceExpression(source4),
  2313. GetSourceExpression(source5),
  2314. GetSourceExpression(source6),
  2315. GetSourceExpression(source7),
  2316. GetSourceExpression(source8),
  2317. GetSourceExpression(source9),
  2318. GetSourceExpression(source10),
  2319. GetSourceExpression(source11),
  2320. resultSelector
  2321. )
  2322. );
  2323. }
  2324. /// <summary>
  2325. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2326. /// </summary>
  2327. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2328. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2329. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2330. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2331. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2332. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2333. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2334. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2335. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2336. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2337. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2338. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2339. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2340. /// <param name="source1">First observable source.</param>
  2341. /// <param name="source2">Second observable source.</param>
  2342. /// <param name="source3">Third observable source.</param>
  2343. /// <param name="source4">Fourth observable source.</param>
  2344. /// <param name="source5">Fifth observable source.</param>
  2345. /// <param name="source6">Sixth observable source.</param>
  2346. /// <param name="source7">Seventh observable source.</param>
  2347. /// <param name="source8">Eighth observable source.</param>
  2348. /// <param name="source9">Ninth observable source.</param>
  2349. /// <param name="source10">Tenth observable source.</param>
  2350. /// <param name="source11">Eleventh observable source.</param>
  2351. /// <param name="source12">Twelfth observable source.</param>
  2352. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2353. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2354. /// <exception cref="ArgumentNullException">
  2355. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="resultSelector" /> is null.</exception>
  2356. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>> resultSelector)
  2357. {
  2358. if (source1 == null)
  2359. throw new ArgumentNullException(nameof(source1));
  2360. if (source2 == null)
  2361. throw new ArgumentNullException(nameof(source2));
  2362. if (source3 == null)
  2363. throw new ArgumentNullException(nameof(source3));
  2364. if (source4 == null)
  2365. throw new ArgumentNullException(nameof(source4));
  2366. if (source5 == null)
  2367. throw new ArgumentNullException(nameof(source5));
  2368. if (source6 == null)
  2369. throw new ArgumentNullException(nameof(source6));
  2370. if (source7 == null)
  2371. throw new ArgumentNullException(nameof(source7));
  2372. if (source8 == null)
  2373. throw new ArgumentNullException(nameof(source8));
  2374. if (source9 == null)
  2375. throw new ArgumentNullException(nameof(source9));
  2376. if (source10 == null)
  2377. throw new ArgumentNullException(nameof(source10));
  2378. if (source11 == null)
  2379. throw new ArgumentNullException(nameof(source11));
  2380. if (source12 == null)
  2381. throw new ArgumentNullException(nameof(source12));
  2382. if (resultSelector == null)
  2383. throw new ArgumentNullException(nameof(resultSelector));
  2384. return source1.Provider.CreateQuery<TResult>(
  2385. Expression.Call(
  2386. null,
  2387. #if CRIPPLED_REFLECTION
  2388. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>>))),
  2389. #else
  2390. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TResult)),
  2391. #endif
  2392. source1.Expression,
  2393. GetSourceExpression(source2),
  2394. GetSourceExpression(source3),
  2395. GetSourceExpression(source4),
  2396. GetSourceExpression(source5),
  2397. GetSourceExpression(source6),
  2398. GetSourceExpression(source7),
  2399. GetSourceExpression(source8),
  2400. GetSourceExpression(source9),
  2401. GetSourceExpression(source10),
  2402. GetSourceExpression(source11),
  2403. GetSourceExpression(source12),
  2404. resultSelector
  2405. )
  2406. );
  2407. }
  2408. /// <summary>
  2409. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2410. /// </summary>
  2411. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2412. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2413. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2414. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2415. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2416. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2417. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2418. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2419. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2420. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2421. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2422. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2423. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2424. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2425. /// <param name="source1">First observable source.</param>
  2426. /// <param name="source2">Second observable source.</param>
  2427. /// <param name="source3">Third observable source.</param>
  2428. /// <param name="source4">Fourth observable source.</param>
  2429. /// <param name="source5">Fifth observable source.</param>
  2430. /// <param name="source6">Sixth observable source.</param>
  2431. /// <param name="source7">Seventh observable source.</param>
  2432. /// <param name="source8">Eighth observable source.</param>
  2433. /// <param name="source9">Ninth observable source.</param>
  2434. /// <param name="source10">Tenth observable source.</param>
  2435. /// <param name="source11">Eleventh observable source.</param>
  2436. /// <param name="source12">Twelfth observable source.</param>
  2437. /// <param name="source13">Thirteenth observable source.</param>
  2438. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2439. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2440. /// <exception cref="ArgumentNullException">
  2441. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="resultSelector" /> is null.</exception>
  2442. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>> resultSelector)
  2443. {
  2444. if (source1 == null)
  2445. throw new ArgumentNullException(nameof(source1));
  2446. if (source2 == null)
  2447. throw new ArgumentNullException(nameof(source2));
  2448. if (source3 == null)
  2449. throw new ArgumentNullException(nameof(source3));
  2450. if (source4 == null)
  2451. throw new ArgumentNullException(nameof(source4));
  2452. if (source5 == null)
  2453. throw new ArgumentNullException(nameof(source5));
  2454. if (source6 == null)
  2455. throw new ArgumentNullException(nameof(source6));
  2456. if (source7 == null)
  2457. throw new ArgumentNullException(nameof(source7));
  2458. if (source8 == null)
  2459. throw new ArgumentNullException(nameof(source8));
  2460. if (source9 == null)
  2461. throw new ArgumentNullException(nameof(source9));
  2462. if (source10 == null)
  2463. throw new ArgumentNullException(nameof(source10));
  2464. if (source11 == null)
  2465. throw new ArgumentNullException(nameof(source11));
  2466. if (source12 == null)
  2467. throw new ArgumentNullException(nameof(source12));
  2468. if (source13 == null)
  2469. throw new ArgumentNullException(nameof(source13));
  2470. if (resultSelector == null)
  2471. throw new ArgumentNullException(nameof(resultSelector));
  2472. return source1.Provider.CreateQuery<TResult>(
  2473. Expression.Call(
  2474. null,
  2475. #if CRIPPLED_REFLECTION
  2476. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>>))),
  2477. #else
  2478. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TResult)),
  2479. #endif
  2480. source1.Expression,
  2481. GetSourceExpression(source2),
  2482. GetSourceExpression(source3),
  2483. GetSourceExpression(source4),
  2484. GetSourceExpression(source5),
  2485. GetSourceExpression(source6),
  2486. GetSourceExpression(source7),
  2487. GetSourceExpression(source8),
  2488. GetSourceExpression(source9),
  2489. GetSourceExpression(source10),
  2490. GetSourceExpression(source11),
  2491. GetSourceExpression(source12),
  2492. GetSourceExpression(source13),
  2493. resultSelector
  2494. )
  2495. );
  2496. }
  2497. /// <summary>
  2498. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2499. /// </summary>
  2500. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2501. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2502. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2503. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2504. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2505. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2506. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2507. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2508. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2509. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2510. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2511. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2512. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2513. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2514. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2515. /// <param name="source1">First observable source.</param>
  2516. /// <param name="source2">Second observable source.</param>
  2517. /// <param name="source3">Third observable source.</param>
  2518. /// <param name="source4">Fourth observable source.</param>
  2519. /// <param name="source5">Fifth observable source.</param>
  2520. /// <param name="source6">Sixth observable source.</param>
  2521. /// <param name="source7">Seventh observable source.</param>
  2522. /// <param name="source8">Eighth observable source.</param>
  2523. /// <param name="source9">Ninth observable source.</param>
  2524. /// <param name="source10">Tenth observable source.</param>
  2525. /// <param name="source11">Eleventh observable source.</param>
  2526. /// <param name="source12">Twelfth observable source.</param>
  2527. /// <param name="source13">Thirteenth observable source.</param>
  2528. /// <param name="source14">Fourteenth observable source.</param>
  2529. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2530. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2531. /// <exception cref="ArgumentNullException">
  2532. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="source14" /> or <paramref name="resultSelector" /> is null.</exception>
  2533. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, IObservable<TSource14> source14, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>> resultSelector)
  2534. {
  2535. if (source1 == null)
  2536. throw new ArgumentNullException(nameof(source1));
  2537. if (source2 == null)
  2538. throw new ArgumentNullException(nameof(source2));
  2539. if (source3 == null)
  2540. throw new ArgumentNullException(nameof(source3));
  2541. if (source4 == null)
  2542. throw new ArgumentNullException(nameof(source4));
  2543. if (source5 == null)
  2544. throw new ArgumentNullException(nameof(source5));
  2545. if (source6 == null)
  2546. throw new ArgumentNullException(nameof(source6));
  2547. if (source7 == null)
  2548. throw new ArgumentNullException(nameof(source7));
  2549. if (source8 == null)
  2550. throw new ArgumentNullException(nameof(source8));
  2551. if (source9 == null)
  2552. throw new ArgumentNullException(nameof(source9));
  2553. if (source10 == null)
  2554. throw new ArgumentNullException(nameof(source10));
  2555. if (source11 == null)
  2556. throw new ArgumentNullException(nameof(source11));
  2557. if (source12 == null)
  2558. throw new ArgumentNullException(nameof(source12));
  2559. if (source13 == null)
  2560. throw new ArgumentNullException(nameof(source13));
  2561. if (source14 == null)
  2562. throw new ArgumentNullException(nameof(source14));
  2563. if (resultSelector == null)
  2564. throw new ArgumentNullException(nameof(resultSelector));
  2565. return source1.Provider.CreateQuery<TResult>(
  2566. Expression.Call(
  2567. null,
  2568. #if CRIPPLED_REFLECTION
  2569. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(IObservable<TSource14>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>>))),
  2570. #else
  2571. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TSource14), typeof(TResult)),
  2572. #endif
  2573. source1.Expression,
  2574. GetSourceExpression(source2),
  2575. GetSourceExpression(source3),
  2576. GetSourceExpression(source4),
  2577. GetSourceExpression(source5),
  2578. GetSourceExpression(source6),
  2579. GetSourceExpression(source7),
  2580. GetSourceExpression(source8),
  2581. GetSourceExpression(source9),
  2582. GetSourceExpression(source10),
  2583. GetSourceExpression(source11),
  2584. GetSourceExpression(source12),
  2585. GetSourceExpression(source13),
  2586. GetSourceExpression(source14),
  2587. resultSelector
  2588. )
  2589. );
  2590. }
  2591. /// <summary>
  2592. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2593. /// </summary>
  2594. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2595. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2596. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2597. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2598. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2599. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2600. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2601. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2602. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2603. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2604. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2605. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2606. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2607. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2608. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2609. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2610. /// <param name="source1">First observable source.</param>
  2611. /// <param name="source2">Second observable source.</param>
  2612. /// <param name="source3">Third observable source.</param>
  2613. /// <param name="source4">Fourth observable source.</param>
  2614. /// <param name="source5">Fifth observable source.</param>
  2615. /// <param name="source6">Sixth observable source.</param>
  2616. /// <param name="source7">Seventh observable source.</param>
  2617. /// <param name="source8">Eighth observable source.</param>
  2618. /// <param name="source9">Ninth observable source.</param>
  2619. /// <param name="source10">Tenth observable source.</param>
  2620. /// <param name="source11">Eleventh observable source.</param>
  2621. /// <param name="source12">Twelfth observable source.</param>
  2622. /// <param name="source13">Thirteenth observable source.</param>
  2623. /// <param name="source14">Fourteenth observable source.</param>
  2624. /// <param name="source15">Fifteenth observable source.</param>
  2625. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2626. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2627. /// <exception cref="ArgumentNullException">
  2628. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="source14" /> or <paramref name="source15" /> or <paramref name="resultSelector" /> is null.</exception>
  2629. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, IObservable<TSource14> source14, IObservable<TSource15> source15, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>> resultSelector)
  2630. {
  2631. if (source1 == null)
  2632. throw new ArgumentNullException(nameof(source1));
  2633. if (source2 == null)
  2634. throw new ArgumentNullException(nameof(source2));
  2635. if (source3 == null)
  2636. throw new ArgumentNullException(nameof(source3));
  2637. if (source4 == null)
  2638. throw new ArgumentNullException(nameof(source4));
  2639. if (source5 == null)
  2640. throw new ArgumentNullException(nameof(source5));
  2641. if (source6 == null)
  2642. throw new ArgumentNullException(nameof(source6));
  2643. if (source7 == null)
  2644. throw new ArgumentNullException(nameof(source7));
  2645. if (source8 == null)
  2646. throw new ArgumentNullException(nameof(source8));
  2647. if (source9 == null)
  2648. throw new ArgumentNullException(nameof(source9));
  2649. if (source10 == null)
  2650. throw new ArgumentNullException(nameof(source10));
  2651. if (source11 == null)
  2652. throw new ArgumentNullException(nameof(source11));
  2653. if (source12 == null)
  2654. throw new ArgumentNullException(nameof(source12));
  2655. if (source13 == null)
  2656. throw new ArgumentNullException(nameof(source13));
  2657. if (source14 == null)
  2658. throw new ArgumentNullException(nameof(source14));
  2659. if (source15 == null)
  2660. throw new ArgumentNullException(nameof(source15));
  2661. if (resultSelector == null)
  2662. throw new ArgumentNullException(nameof(resultSelector));
  2663. return source1.Provider.CreateQuery<TResult>(
  2664. Expression.Call(
  2665. null,
  2666. #if CRIPPLED_REFLECTION
  2667. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(IObservable<TSource14>), default(IObservable<TSource15>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>>))),
  2668. #else
  2669. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TSource14), typeof(TSource15), typeof(TResult)),
  2670. #endif
  2671. source1.Expression,
  2672. GetSourceExpression(source2),
  2673. GetSourceExpression(source3),
  2674. GetSourceExpression(source4),
  2675. GetSourceExpression(source5),
  2676. GetSourceExpression(source6),
  2677. GetSourceExpression(source7),
  2678. GetSourceExpression(source8),
  2679. GetSourceExpression(source9),
  2680. GetSourceExpression(source10),
  2681. GetSourceExpression(source11),
  2682. GetSourceExpression(source12),
  2683. GetSourceExpression(source13),
  2684. GetSourceExpression(source14),
  2685. GetSourceExpression(source15),
  2686. resultSelector
  2687. )
  2688. );
  2689. }
  2690. /// <summary>
  2691. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2692. /// </summary>
  2693. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2694. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2695. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2696. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2697. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2698. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2699. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2700. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2701. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2702. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2703. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2704. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2705. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2706. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2707. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2708. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  2709. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2710. /// <param name="source1">First observable source.</param>
  2711. /// <param name="source2">Second observable source.</param>
  2712. /// <param name="source3">Third observable source.</param>
  2713. /// <param name="source4">Fourth observable source.</param>
  2714. /// <param name="source5">Fifth observable source.</param>
  2715. /// <param name="source6">Sixth observable source.</param>
  2716. /// <param name="source7">Seventh observable source.</param>
  2717. /// <param name="source8">Eighth observable source.</param>
  2718. /// <param name="source9">Ninth observable source.</param>
  2719. /// <param name="source10">Tenth observable source.</param>
  2720. /// <param name="source11">Eleventh observable source.</param>
  2721. /// <param name="source12">Twelfth observable source.</param>
  2722. /// <param name="source13">Thirteenth observable source.</param>
  2723. /// <param name="source14">Fourteenth observable source.</param>
  2724. /// <param name="source15">Fifteenth observable source.</param>
  2725. /// <param name="source16">Sixteenth observable source.</param>
  2726. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2727. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2728. /// <exception cref="ArgumentNullException">
  2729. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="source14" /> or <paramref name="source15" /> or <paramref name="source16" /> or <paramref name="resultSelector" /> is null.</exception>
  2730. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, IObservable<TSource14> source14, IObservable<TSource15> source15, IObservable<TSource16> source16, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>> resultSelector)
  2731. {
  2732. if (source1 == null)
  2733. throw new ArgumentNullException(nameof(source1));
  2734. if (source2 == null)
  2735. throw new ArgumentNullException(nameof(source2));
  2736. if (source3 == null)
  2737. throw new ArgumentNullException(nameof(source3));
  2738. if (source4 == null)
  2739. throw new ArgumentNullException(nameof(source4));
  2740. if (source5 == null)
  2741. throw new ArgumentNullException(nameof(source5));
  2742. if (source6 == null)
  2743. throw new ArgumentNullException(nameof(source6));
  2744. if (source7 == null)
  2745. throw new ArgumentNullException(nameof(source7));
  2746. if (source8 == null)
  2747. throw new ArgumentNullException(nameof(source8));
  2748. if (source9 == null)
  2749. throw new ArgumentNullException(nameof(source9));
  2750. if (source10 == null)
  2751. throw new ArgumentNullException(nameof(source10));
  2752. if (source11 == null)
  2753. throw new ArgumentNullException(nameof(source11));
  2754. if (source12 == null)
  2755. throw new ArgumentNullException(nameof(source12));
  2756. if (source13 == null)
  2757. throw new ArgumentNullException(nameof(source13));
  2758. if (source14 == null)
  2759. throw new ArgumentNullException(nameof(source14));
  2760. if (source15 == null)
  2761. throw new ArgumentNullException(nameof(source15));
  2762. if (source16 == null)
  2763. throw new ArgumentNullException(nameof(source16));
  2764. if (resultSelector == null)
  2765. throw new ArgumentNullException(nameof(resultSelector));
  2766. return source1.Provider.CreateQuery<TResult>(
  2767. Expression.Call(
  2768. null,
  2769. #if CRIPPLED_REFLECTION
  2770. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(IObservable<TSource14>), default(IObservable<TSource15>), default(IObservable<TSource16>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>>))),
  2771. #else
  2772. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TSource14), typeof(TSource15), typeof(TSource16), typeof(TResult)),
  2773. #endif
  2774. source1.Expression,
  2775. GetSourceExpression(source2),
  2776. GetSourceExpression(source3),
  2777. GetSourceExpression(source4),
  2778. GetSourceExpression(source5),
  2779. GetSourceExpression(source6),
  2780. GetSourceExpression(source7),
  2781. GetSourceExpression(source8),
  2782. GetSourceExpression(source9),
  2783. GetSourceExpression(source10),
  2784. GetSourceExpression(source11),
  2785. GetSourceExpression(source12),
  2786. GetSourceExpression(source13),
  2787. GetSourceExpression(source14),
  2788. GetSourceExpression(source15),
  2789. GetSourceExpression(source16),
  2790. resultSelector
  2791. )
  2792. );
  2793. }
  2794. /// <summary>
  2795. /// Concatenates the second observable sequence to the first observable sequence upon successful termination of the first.
  2796. /// </summary>
  2797. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2798. /// <param name="first">First observable sequence.</param>
  2799. /// <param name="second">Second observable sequence.</param>
  2800. /// <returns>An observable sequence that contains the elements of the first sequence, followed by those of the second the sequence.</returns>
  2801. /// <exception cref="ArgumentNullException">
  2802. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  2803. public static IQbservable<TSource> Concat<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  2804. {
  2805. if (first == null)
  2806. throw new ArgumentNullException(nameof(first));
  2807. if (second == null)
  2808. throw new ArgumentNullException(nameof(second));
  2809. return first.Provider.CreateQuery<TSource>(
  2810. Expression.Call(
  2811. null,
  2812. #if CRIPPLED_REFLECTION
  2813. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  2814. #else
  2815. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2816. #endif
  2817. first.Expression,
  2818. GetSourceExpression(second)
  2819. )
  2820. );
  2821. }
  2822. /// <summary>
  2823. /// Concatenates all of the specified observable sequences, as long as the previous observable sequence terminated successfully.
  2824. /// </summary>
  2825. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  2826. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2827. /// <param name="sources">Observable sequences to concatenate.</param>
  2828. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2829. /// <exception cref="ArgumentNullException">
  2830. /// <paramref name="sources" /> is null.</exception>
  2831. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  2832. {
  2833. if (provider == null)
  2834. throw new ArgumentNullException(nameof(provider));
  2835. if (sources == null)
  2836. throw new ArgumentNullException(nameof(sources));
  2837. return provider.CreateQuery<TSource>(
  2838. Expression.Call(
  2839. null,
  2840. #if CRIPPLED_REFLECTION
  2841. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  2842. #else
  2843. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2844. #endif
  2845. Expression.Constant(provider, typeof(IQbservableProvider)),
  2846. GetSourceExpression(sources)
  2847. )
  2848. );
  2849. }
  2850. /// <summary>
  2851. /// Concatenates all observable sequences in the given enumerable sequence, as long as the previous observable sequence terminated successfully.
  2852. /// </summary>
  2853. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  2854. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2855. /// <param name="sources">Observable sequences to concatenate.</param>
  2856. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2857. /// <exception cref="ArgumentNullException">
  2858. /// <paramref name="sources" /> is null.</exception>
  2859. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  2860. {
  2861. if (provider == null)
  2862. throw new ArgumentNullException(nameof(provider));
  2863. if (sources == null)
  2864. throw new ArgumentNullException(nameof(sources));
  2865. return provider.CreateQuery<TSource>(
  2866. Expression.Call(
  2867. null,
  2868. #if CRIPPLED_REFLECTION
  2869. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  2870. #else
  2871. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2872. #endif
  2873. Expression.Constant(provider, typeof(IQbservableProvider)),
  2874. GetSourceExpression(sources)
  2875. )
  2876. );
  2877. }
  2878. /// <summary>
  2879. /// Concatenates all inner observable sequences, as long as the previous observable sequence terminated successfully.
  2880. /// </summary>
  2881. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2882. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  2883. /// <returns>An observable sequence that contains the elements of each observed inner sequence, in sequential order.</returns>
  2884. /// <exception cref="ArgumentNullException">
  2885. /// <paramref name="sources" /> is null.</exception>
  2886. public static IQbservable<TSource> Concat<TSource>(this IQbservable<IObservable<TSource>> sources)
  2887. {
  2888. if (sources == null)
  2889. throw new ArgumentNullException(nameof(sources));
  2890. return sources.Provider.CreateQuery<TSource>(
  2891. Expression.Call(
  2892. null,
  2893. #if CRIPPLED_REFLECTION
  2894. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<IObservable<TSource>>))),
  2895. #else
  2896. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2897. #endif
  2898. sources.Expression
  2899. )
  2900. );
  2901. }
  2902. /// <summary>
  2903. /// Concatenates all task results, as long as the previous task terminated successfully.
  2904. /// </summary>
  2905. /// <typeparam name="TSource">The type of the results produced by the tasks.</typeparam>
  2906. /// <param name="sources">Observable sequence of tasks.</param>
  2907. /// <returns>An observable sequence that contains the results of each task, in sequential order.</returns>
  2908. /// <exception cref="ArgumentNullException">
  2909. /// <paramref name="sources" /> is null.</exception>
  2910. /// <remarks>If the tasks support cancellation, consider manual conversion of the tasks using <see cref="M:System.Reactive.Linq.Observable.FromAsync``1(System.Func{System.Threading.CancellationToken,System.Threading.Tasks.Task{``0}})" />, followed by a concatenation operation using <see cref="M:System.Reactive.Linq.Observable.Concat``1(System.IObservable{System.IObservable{``0}})" />.</remarks>
  2911. public static IQbservable<TSource> Concat<TSource>(this IQbservable<Task<TSource>> sources)
  2912. {
  2913. if (sources == null)
  2914. throw new ArgumentNullException(nameof(sources));
  2915. return sources.Provider.CreateQuery<TSource>(
  2916. Expression.Call(
  2917. null,
  2918. #if CRIPPLED_REFLECTION
  2919. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<Task<TSource>>))),
  2920. #else
  2921. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2922. #endif
  2923. sources.Expression
  2924. )
  2925. );
  2926. }
  2927. /// <summary>
  2928. /// Determines whether an observable sequence contains a specified element by using the default equality comparer.
  2929. /// </summary>
  2930. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2931. /// <param name="source">An observable sequence in which to locate a value.</param>
  2932. /// <param name="value">The value to locate in the source sequence.</param>
  2933. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2934. /// <exception cref="ArgumentNullException">
  2935. /// <paramref name="source" /> is null.</exception>
  2936. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2937. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value)
  2938. {
  2939. if (source == null)
  2940. throw new ArgumentNullException(nameof(source));
  2941. return source.Provider.CreateQuery<bool>(
  2942. Expression.Call(
  2943. null,
  2944. #if CRIPPLED_REFLECTION
  2945. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource))),
  2946. #else
  2947. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2948. #endif
  2949. source.Expression,
  2950. Expression.Constant(value, typeof(TSource))
  2951. )
  2952. );
  2953. }
  2954. /// <summary>
  2955. /// Determines whether an observable sequence contains a specified element by using a specified System.Collections.Generic.IEqualityComparer{T}.
  2956. /// </summary>
  2957. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2958. /// <param name="source">An observable sequence in which to locate a value.</param>
  2959. /// <param name="value">The value to locate in the source sequence.</param>
  2960. /// <param name="comparer">An equality comparer to compare elements.</param>
  2961. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2962. /// <exception cref="ArgumentNullException">
  2963. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  2964. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2965. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
  2966. {
  2967. if (source == null)
  2968. throw new ArgumentNullException(nameof(source));
  2969. if (comparer == null)
  2970. throw new ArgumentNullException(nameof(comparer));
  2971. return source.Provider.CreateQuery<bool>(
  2972. Expression.Call(
  2973. null,
  2974. #if CRIPPLED_REFLECTION
  2975. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource), default(IEqualityComparer<TSource>))),
  2976. #else
  2977. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2978. #endif
  2979. source.Expression,
  2980. Expression.Constant(value, typeof(TSource)),
  2981. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  2982. )
  2983. );
  2984. }
  2985. /// <summary>
  2986. /// Returns an observable sequence containing an <see cref="int" /> that represents the total number of elements in an observable sequence.
  2987. /// </summary>
  2988. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2989. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  2990. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  2991. /// <exception cref="ArgumentNullException">
  2992. /// <paramref name="source" /> is null.</exception>
  2993. /// <exception cref="OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  2994. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2995. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source)
  2996. {
  2997. if (source == null)
  2998. throw new ArgumentNullException(nameof(source));
  2999. return source.Provider.CreateQuery<int>(
  3000. Expression.Call(
  3001. null,
  3002. #if CRIPPLED_REFLECTION
  3003. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>))),
  3004. #else
  3005. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3006. #endif
  3007. source.Expression
  3008. )
  3009. );
  3010. }
  3011. /// <summary>
  3012. /// Returns an observable sequence containing an <see cref="int" /> that represents how many elements in the specified observable sequence satisfy a condition.
  3013. /// </summary>
  3014. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3015. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  3016. /// <param name="predicate">A function to test each element for a condition.</param>
  3017. /// <returns>An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function.</returns>
  3018. /// <exception cref="ArgumentNullException">
  3019. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  3020. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  3021. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  3022. {
  3023. if (source == null)
  3024. throw new ArgumentNullException(nameof(source));
  3025. if (predicate == null)
  3026. throw new ArgumentNullException(nameof(predicate));
  3027. return source.Provider.CreateQuery<int>(
  3028. Expression.Call(
  3029. null,
  3030. #if CRIPPLED_REFLECTION
  3031. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  3032. #else
  3033. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3034. #endif
  3035. source.Expression,
  3036. predicate
  3037. )
  3038. );
  3039. }
  3040. /// <summary>
  3041. /// Creates an observable sequence from a specified Subscribe method implementation.
  3042. /// </summary>
  3043. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3044. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3045. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method.</param>
  3046. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3047. /// <exception cref="ArgumentNullException">
  3048. /// <paramref name="subscribe" /> is null.</exception>
  3049. /// <remarks>
  3050. /// Use of this operator is preferred over manual implementation of the <see cref="IObservable{T}" /> interface. In case
  3051. /// you need a type implementing <see cref="IObservable{T}" /> rather than an anonymous implementation, consider using
  3052. /// the <see cref="T:System.Reactive.ObservableBase`1" /> abstract base class.
  3053. /// </remarks>
  3054. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, IDisposable>> subscribe)
  3055. {
  3056. if (provider == null)
  3057. throw new ArgumentNullException(nameof(provider));
  3058. if (subscribe == null)
  3059. throw new ArgumentNullException(nameof(subscribe));
  3060. return provider.CreateQuery<TResult>(
  3061. Expression.Call(
  3062. null,
  3063. #if CRIPPLED_REFLECTION
  3064. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, IDisposable>>))),
  3065. #else
  3066. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3067. #endif
  3068. Expression.Constant(provider, typeof(IQbservableProvider)),
  3069. subscribe
  3070. )
  3071. );
  3072. }
  3073. /// <summary>
  3074. /// Creates an observable sequence from a specified Subscribe method implementation.
  3075. /// </summary>
  3076. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3077. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3078. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable.</param>
  3079. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3080. /// <exception cref="ArgumentNullException">
  3081. /// <paramref name="subscribe" /> is null.</exception>
  3082. /// <remarks>
  3083. /// Use of this operator is preferred over manual implementation of the <see cref="IObservable{T}" /> interface. In case
  3084. /// you need a type implementing <see cref="IObservable{T}" /> rather than an anonymous implementation, consider using
  3085. /// the <see cref="T:System.Reactive.ObservableBase`1" /> abstract base class.
  3086. /// </remarks>
  3087. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Action>> subscribe)
  3088. {
  3089. if (provider == null)
  3090. throw new ArgumentNullException(nameof(provider));
  3091. if (subscribe == null)
  3092. throw new ArgumentNullException(nameof(subscribe));
  3093. return provider.CreateQuery<TResult>(
  3094. Expression.Call(
  3095. null,
  3096. #if CRIPPLED_REFLECTION
  3097. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Action>>))),
  3098. #else
  3099. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3100. #endif
  3101. Expression.Constant(provider, typeof(IQbservableProvider)),
  3102. subscribe
  3103. )
  3104. );
  3105. }
  3106. /// <summary>
  3107. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3108. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3109. /// </summary>
  3110. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3111. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3112. /// <param name="subscribeAsync">Asynchronous method used to produce elements.</param>
  3113. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3114. /// <exception cref="ArgumentNullException">
  3115. /// <paramref name="subscribeAsync" /> is null.</exception>
  3116. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3117. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3118. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task>> subscribeAsync)
  3119. {
  3120. if (provider == null)
  3121. throw new ArgumentNullException(nameof(provider));
  3122. if (subscribeAsync == null)
  3123. throw new ArgumentNullException(nameof(subscribeAsync));
  3124. return provider.CreateQuery<TResult>(
  3125. Expression.Call(
  3126. null,
  3127. #if CRIPPLED_REFLECTION
  3128. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task>>))),
  3129. #else
  3130. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3131. #endif
  3132. Expression.Constant(provider, typeof(IQbservableProvider)),
  3133. subscribeAsync
  3134. )
  3135. );
  3136. }
  3137. /// <summary>
  3138. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3139. /// </summary>
  3140. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3141. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3142. /// <param name="subscribeAsync">Asynchronous method used to produce elements.</param>
  3143. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3144. /// <exception cref="ArgumentNullException">
  3145. /// <paramref name="subscribeAsync" /> is null.</exception>
  3146. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3147. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task>> subscribeAsync)
  3148. {
  3149. if (provider == null)
  3150. throw new ArgumentNullException(nameof(provider));
  3151. if (subscribeAsync == null)
  3152. throw new ArgumentNullException(nameof(subscribeAsync));
  3153. return provider.CreateQuery<TResult>(
  3154. Expression.Call(
  3155. null,
  3156. #if CRIPPLED_REFLECTION
  3157. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task>>))),
  3158. #else
  3159. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3160. #endif
  3161. Expression.Constant(provider, typeof(IQbservableProvider)),
  3162. subscribeAsync
  3163. )
  3164. );
  3165. }
  3166. /// <summary>
  3167. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3168. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3169. /// </summary>
  3170. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3171. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3172. /// <param name="subscribeAsync">Asynchronous method used to implement the resulting sequence's Subscribe method.</param>
  3173. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3174. /// <exception cref="ArgumentNullException">
  3175. /// <paramref name="subscribeAsync" /> is null.</exception>
  3176. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3177. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3178. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task<IDisposable>>> subscribeAsync)
  3179. {
  3180. if (provider == null)
  3181. throw new ArgumentNullException(nameof(provider));
  3182. if (subscribeAsync == null)
  3183. throw new ArgumentNullException(nameof(subscribeAsync));
  3184. return provider.CreateQuery<TResult>(
  3185. Expression.Call(
  3186. null,
  3187. #if CRIPPLED_REFLECTION
  3188. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task<IDisposable>>>))),
  3189. #else
  3190. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3191. #endif
  3192. Expression.Constant(provider, typeof(IQbservableProvider)),
  3193. subscribeAsync
  3194. )
  3195. );
  3196. }
  3197. /// <summary>
  3198. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3199. /// </summary>
  3200. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3201. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3202. /// <param name="subscribeAsync">Asynchronous method used to implement the resulting sequence's Subscribe method.</param>
  3203. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3204. /// <exception cref="ArgumentNullException">
  3205. /// <paramref name="subscribeAsync" /> is null.</exception>
  3206. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3207. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task<IDisposable>>> subscribeAsync)
  3208. {
  3209. if (provider == null)
  3210. throw new ArgumentNullException(nameof(provider));
  3211. if (subscribeAsync == null)
  3212. throw new ArgumentNullException(nameof(subscribeAsync));
  3213. return provider.CreateQuery<TResult>(
  3214. Expression.Call(
  3215. null,
  3216. #if CRIPPLED_REFLECTION
  3217. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task<IDisposable>>>))),
  3218. #else
  3219. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3220. #endif
  3221. Expression.Constant(provider, typeof(IQbservableProvider)),
  3222. subscribeAsync
  3223. )
  3224. );
  3225. }
  3226. /// <summary>
  3227. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3228. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3229. /// </summary>
  3230. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3231. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3232. /// <param name="subscribeAsync">Asynchronous method used to implement the resulting sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable.</param>
  3233. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3234. /// <exception cref="ArgumentNullException">
  3235. /// <paramref name="subscribeAsync" /> is null.</exception>
  3236. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3237. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3238. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task<Action>>> subscribeAsync)
  3239. {
  3240. if (provider == null)
  3241. throw new ArgumentNullException(nameof(provider));
  3242. if (subscribeAsync == null)
  3243. throw new ArgumentNullException(nameof(subscribeAsync));
  3244. return provider.CreateQuery<TResult>(
  3245. Expression.Call(
  3246. null,
  3247. #if CRIPPLED_REFLECTION
  3248. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task<Action>>>))),
  3249. #else
  3250. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3251. #endif
  3252. Expression.Constant(provider, typeof(IQbservableProvider)),
  3253. subscribeAsync
  3254. )
  3255. );
  3256. }
  3257. /// <summary>
  3258. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3259. /// </summary>
  3260. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3261. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3262. /// <param name="subscribeAsync">Asynchronous method used to implement the resulting sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable.</param>
  3263. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3264. /// <exception cref="ArgumentNullException">
  3265. /// <paramref name="subscribeAsync" /> is null.</exception>
  3266. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3267. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task<Action>>> subscribeAsync)
  3268. {
  3269. if (provider == null)
  3270. throw new ArgumentNullException(nameof(provider));
  3271. if (subscribeAsync == null)
  3272. throw new ArgumentNullException(nameof(subscribeAsync));
  3273. return provider.CreateQuery<TResult>(
  3274. Expression.Call(
  3275. null,
  3276. #if CRIPPLED_REFLECTION
  3277. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task<Action>>>))),
  3278. #else
  3279. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3280. #endif
  3281. Expression.Constant(provider, typeof(IQbservableProvider)),
  3282. subscribeAsync
  3283. )
  3284. );
  3285. }
  3286. /// <summary>
  3287. /// Returns the elements of the specified sequence or the type parameter's default value in a singleton sequence if the sequence is empty.
  3288. /// </summary>
  3289. /// <typeparam name="TSource">The type of the elements in the source sequence (if any), whose default value will be taken if the sequence is empty.</typeparam>
  3290. /// <param name="source">The sequence to return a default value for if it is empty.</param>
  3291. /// <returns>An observable sequence that contains the default value for the TSource type if the source is empty; otherwise, the elements of the source itself.</returns>
  3292. /// <exception cref="ArgumentNullException">
  3293. /// <paramref name="source" /> is null.</exception>
  3294. public static IQbservable<TSource> DefaultIfEmpty<TSource>(this IQbservable<TSource> source)
  3295. {
  3296. if (source == null)
  3297. throw new ArgumentNullException(nameof(source));
  3298. return source.Provider.CreateQuery<TSource>(
  3299. Expression.Call(
  3300. null,
  3301. #if CRIPPLED_REFLECTION
  3302. InfoOf(() => Qbservable.DefaultIfEmpty<TSource>(default(IQbservable<TSource>))),
  3303. #else
  3304. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3305. #endif
  3306. source.Expression
  3307. )
  3308. );
  3309. }
  3310. /// <summary>
  3311. /// Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
  3312. /// </summary>
  3313. /// <typeparam name="TSource">The type of the elements in the source sequence (if any), and the specified default value which will be taken if the sequence is empty.</typeparam>
  3314. /// <param name="source">The sequence to return the specified value for if it is empty.</param>
  3315. /// <param name="defaultValue">The value to return if the sequence is empty.</param>
  3316. /// <returns>An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.</returns>
  3317. /// <exception cref="ArgumentNullException">
  3318. /// <paramref name="source" /> is null.</exception>
  3319. public static IQbservable<TSource> DefaultIfEmpty<TSource>(this IQbservable<TSource> source, TSource defaultValue)
  3320. {
  3321. if (source == null)
  3322. throw new ArgumentNullException(nameof(source));
  3323. return source.Provider.CreateQuery<TSource>(
  3324. Expression.Call(
  3325. null,
  3326. #if CRIPPLED_REFLECTION
  3327. InfoOf(() => Qbservable.DefaultIfEmpty<TSource>(default(IQbservable<TSource>), default(TSource))),
  3328. #else
  3329. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3330. #endif
  3331. source.Expression,
  3332. Expression.Constant(defaultValue, typeof(TSource))
  3333. )
  3334. );
  3335. }
  3336. /// <summary>
  3337. /// Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
  3338. /// </summary>
  3339. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3340. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3341. /// <param name="observableFactory">Observable factory function to invoke for each observer that subscribes to the resulting sequence.</param>
  3342. /// <returns>An observable sequence whose observers trigger an invocation of the given observable factory function.</returns>
  3343. /// <exception cref="ArgumentNullException">
  3344. /// <paramref name="observableFactory" /> is null.</exception>
  3345. public static IQbservable<TResult> Defer<TResult>(this IQbservableProvider provider, Expression<Func<IObservable<TResult>>> observableFactory)
  3346. {
  3347. if (provider == null)
  3348. throw new ArgumentNullException(nameof(provider));
  3349. if (observableFactory == null)
  3350. throw new ArgumentNullException(nameof(observableFactory));
  3351. return provider.CreateQuery<TResult>(
  3352. Expression.Call(
  3353. null,
  3354. #if CRIPPLED_REFLECTION
  3355. InfoOf(() => Qbservable.Defer<TResult>(default(IQbservableProvider), default(Expression<Func<IObservable<TResult>>>))),
  3356. #else
  3357. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3358. #endif
  3359. Expression.Constant(provider, typeof(IQbservableProvider)),
  3360. observableFactory
  3361. )
  3362. );
  3363. }
  3364. /// <summary>
  3365. /// Returns an observable sequence that starts the specified asynchronous factory function whenever a new observer subscribes.
  3366. /// </summary>
  3367. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3368. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3369. /// <param name="observableFactoryAsync">Asynchronous factory function to start for each observer that subscribes to the resulting sequence.</param>
  3370. /// <returns>An observable sequence whose observers trigger the given asynchronous observable factory function to be started.</returns>
  3371. /// <exception cref="ArgumentNullException">
  3372. /// <paramref name="observableFactoryAsync" /> is null.</exception>
  3373. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3374. public static IQbservable<TResult> Defer<TResult>(this IQbservableProvider provider, Expression<Func<Task<IObservable<TResult>>>> observableFactoryAsync)
  3375. {
  3376. if (provider == null)
  3377. throw new ArgumentNullException(nameof(provider));
  3378. if (observableFactoryAsync == null)
  3379. throw new ArgumentNullException(nameof(observableFactoryAsync));
  3380. return provider.CreateQuery<TResult>(
  3381. Expression.Call(
  3382. null,
  3383. #if CRIPPLED_REFLECTION
  3384. InfoOf(() => Qbservable.Defer<TResult>(default(IQbservableProvider), default(Expression<Func<Task<IObservable<TResult>>>>))),
  3385. #else
  3386. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3387. #endif
  3388. Expression.Constant(provider, typeof(IQbservableProvider)),
  3389. observableFactoryAsync
  3390. )
  3391. );
  3392. }
  3393. /// <summary>
  3394. /// Returns an observable sequence that starts the specified cancellable asynchronous factory function whenever a new observer subscribes.
  3395. /// The CancellationToken passed to the asynchronous factory function is tied to the returned disposable subscription, allowing best-effort cancellation.
  3396. /// </summary>
  3397. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3398. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3399. /// <param name="observableFactoryAsync">Asynchronous factory function to start for each observer that subscribes to the resulting sequence.</param>
  3400. /// <returns>An observable sequence whose observers trigger the given asynchronous observable factory function to be started.</returns>
  3401. /// <exception cref="ArgumentNullException">
  3402. /// <paramref name="observableFactoryAsync" /> is null.</exception>
  3403. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3404. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous observable factory function will be signaled.</remarks>
  3405. public static IQbservable<TResult> DeferAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  3406. {
  3407. if (provider == null)
  3408. throw new ArgumentNullException(nameof(provider));
  3409. if (observableFactoryAsync == null)
  3410. throw new ArgumentNullException(nameof(observableFactoryAsync));
  3411. return provider.CreateQuery<TResult>(
  3412. Expression.Call(
  3413. null,
  3414. #if CRIPPLED_REFLECTION
  3415. InfoOf(() => Qbservable.DeferAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<IObservable<TResult>>>>))),
  3416. #else
  3417. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3418. #endif
  3419. Expression.Constant(provider, typeof(IQbservableProvider)),
  3420. observableFactoryAsync
  3421. )
  3422. );
  3423. }
  3424. /// <summary>
  3425. /// Time shifts the observable sequence to start propagating notifications at the specified absolute time.
  3426. /// The relative time intervals between the values are preserved.
  3427. /// </summary>
  3428. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3429. /// <param name="source">Source sequence to delay values for.</param>
  3430. /// <param name="dueTime">Absolute time used to shift the observable sequence; the relative time shift gets computed upon subscription. If this value is less than or equal to DateTimeOffset.UtcNow, the scheduler will dispatch observer callbacks as soon as possible.</param>
  3431. /// <returns>Time-shifted sequence.</returns>
  3432. /// <exception cref="ArgumentNullException">
  3433. /// <paramref name="source" /> is null.</exception>
  3434. /// <remarks>
  3435. /// <para>
  3436. /// This operator is less efficient than <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.DateTimeOffset)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3437. /// </para>
  3438. /// <para>
  3439. /// Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
  3440. /// </para>
  3441. /// <para>
  3442. /// Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped.
  3443. /// In order to delay error propagation, consider using the <see cref="M:System.Reactive.Linq.Observable.Materialize``1(System.IObservable{``0})">Observable.Materialize</see> and <see cref="M:System.Reactive.Linq.Observable.Dematerialize``1(System.IObservable{System.Reactive.Notification{``0}})">Observable.Dematerialize</see> operators, or use <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.DateTimeOffset)">DelaySubscription</see>.
  3444. /// </para>
  3445. /// </remarks>
  3446. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  3447. {
  3448. if (source == null)
  3449. throw new ArgumentNullException(nameof(source));
  3450. return source.Provider.CreateQuery<TSource>(
  3451. Expression.Call(
  3452. null,
  3453. #if CRIPPLED_REFLECTION
  3454. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  3455. #else
  3456. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3457. #endif
  3458. source.Expression,
  3459. Expression.Constant(dueTime, typeof(DateTimeOffset))
  3460. )
  3461. );
  3462. }
  3463. /// <summary>
  3464. /// Time shifts the observable sequence to start propagating notifications at the specified absolute time, using the specified scheduler to run timers.
  3465. /// The relative time intervals between the values are preserved.
  3466. /// </summary>
  3467. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3468. /// <param name="source">Source sequence to delay values for.</param>
  3469. /// <param name="dueTime">Absolute time used to shift the observable sequence; the relative time shift gets computed upon subscription. If this value is less than or equal to DateTimeOffset.UtcNow, the scheduler will dispatch observer callbacks as soon as possible.</param>
  3470. /// <param name="scheduler">Scheduler to run the delay timers on.</param>
  3471. /// <returns>Time-shifted sequence.</returns>
  3472. /// <exception cref="ArgumentNullException">
  3473. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3474. /// <remarks>
  3475. /// <para>
  3476. /// This operator is less efficient than <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.DateTimeOffset,System.Reactive.Concurrency.IScheduler)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3477. /// </para>
  3478. /// <para>
  3479. /// Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
  3480. /// </para>
  3481. /// <para>
  3482. /// Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped.
  3483. /// In order to delay error propagation, consider using the <see cref="M:System.Reactive.Linq.Observable.Materialize``1(System.IObservable{``0})">Observable.Materialize</see> and <see cref="M:System.Reactive.Linq.Observable.Dematerialize``1(System.IObservable{System.Reactive.Notification{``0}})">Observable.Dematerialize</see> operators, or use <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.DateTimeOffset,System.Reactive.Concurrency.IScheduler)">DelaySubscription</see>.
  3484. /// </para>
  3485. /// </remarks>
  3486. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  3487. {
  3488. if (source == null)
  3489. throw new ArgumentNullException(nameof(source));
  3490. if (scheduler == null)
  3491. throw new ArgumentNullException(nameof(scheduler));
  3492. return source.Provider.CreateQuery<TSource>(
  3493. Expression.Call(
  3494. null,
  3495. #if CRIPPLED_REFLECTION
  3496. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  3497. #else
  3498. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3499. #endif
  3500. source.Expression,
  3501. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  3502. Expression.Constant(scheduler, typeof(IScheduler))
  3503. )
  3504. );
  3505. }
  3506. /// <summary>
  3507. /// Time shifts the observable sequence by the specified relative time duration.
  3508. /// The relative time intervals between the values are preserved.
  3509. /// </summary>
  3510. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3511. /// <param name="source">Source sequence to delay values for.</param>
  3512. /// <param name="dueTime">Relative time by which to shift the observable sequence. If this value is equal to TimeSpan.Zero, the scheduler will dispatch observer callbacks as soon as possible.</param>
  3513. /// <returns>Time-shifted sequence.</returns>
  3514. /// <exception cref="ArgumentNullException">
  3515. /// <paramref name="source" /> is null.</exception>
  3516. /// <exception cref="ArgumentOutOfRangeException">
  3517. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3518. /// <remarks>
  3519. /// <para>
  3520. /// This operator is less efficient than <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.TimeSpan)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3521. /// </para>
  3522. /// <para>
  3523. /// Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
  3524. /// </para>
  3525. /// <para>
  3526. /// Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped.
  3527. /// In order to delay error propagation, consider using the <see cref="M:System.Reactive.Linq.Observable.Materialize``1(System.IObservable{``0})">Observable.Materialize</see> and <see cref="M:System.Reactive.Linq.Observable.Dematerialize``1(System.IObservable{System.Reactive.Notification{``0}})">Observable.Dematerialize</see> operators, or use <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.TimeSpan)">DelaySubscription</see>.
  3528. /// </para>
  3529. /// </remarks>
  3530. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  3531. {
  3532. if (source == null)
  3533. throw new ArgumentNullException(nameof(source));
  3534. return source.Provider.CreateQuery<TSource>(
  3535. Expression.Call(
  3536. null,
  3537. #if CRIPPLED_REFLECTION
  3538. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  3539. #else
  3540. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3541. #endif
  3542. source.Expression,
  3543. Expression.Constant(dueTime, typeof(TimeSpan))
  3544. )
  3545. );
  3546. }
  3547. /// <summary>
  3548. /// Time shifts the observable sequence by the specified relative time duration, using the specified scheduler to run timers.
  3549. /// The relative time intervals between the values are preserved.
  3550. /// </summary>
  3551. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3552. /// <param name="source">Source sequence to delay values for.</param>
  3553. /// <param name="dueTime">Relative time by which to shift the observable sequence. If this value is equal to TimeSpan.Zero, the scheduler will dispatch observer callbacks as soon as possible.</param>
  3554. /// <param name="scheduler">Scheduler to run the delay timers on.</param>
  3555. /// <returns>Time-shifted sequence.</returns>
  3556. /// <exception cref="ArgumentNullException">
  3557. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3558. /// <exception cref="ArgumentOutOfRangeException">
  3559. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3560. /// <remarks>
  3561. /// <para>
  3562. /// This operator is less efficient than <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.TimeSpan,System.Reactive.Concurrency.IScheduler)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3563. /// </para>
  3564. /// <para>
  3565. /// Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
  3566. /// </para>
  3567. /// <para>
  3568. /// Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped.
  3569. /// </para>
  3570. /// <para>
  3571. /// Exceptions signaled by the source sequence through an OnError callback are forwarded immediately to the result sequence. Any OnNext notifications that were in the queue at the point of the OnError callback will be dropped.
  3572. /// In order to delay error propagation, consider using the <see cref="M:System.Reactive.Linq.Observable.Materialize``1(System.IObservable{``0})">Observable.Materialize</see> and <see cref="M:System.Reactive.Linq.Observable.Dematerialize``1(System.IObservable{System.Reactive.Notification{``0}})">Observable.Dematerialize</see> operators, or use <see cref="M:System.Reactive.Linq.Observable.DelaySubscription``1(System.IObservable{``0},System.TimeSpan,System.Reactive.Concurrency.IScheduler)">DelaySubscription</see>.
  3573. /// </para>
  3574. /// </remarks>
  3575. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  3576. {
  3577. if (source == null)
  3578. throw new ArgumentNullException(nameof(source));
  3579. if (scheduler == null)
  3580. throw new ArgumentNullException(nameof(scheduler));
  3581. return source.Provider.CreateQuery<TSource>(
  3582. Expression.Call(
  3583. null,
  3584. #if CRIPPLED_REFLECTION
  3585. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  3586. #else
  3587. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3588. #endif
  3589. source.Expression,
  3590. Expression.Constant(dueTime, typeof(TimeSpan)),
  3591. Expression.Constant(scheduler, typeof(IScheduler))
  3592. )
  3593. );
  3594. }
  3595. /// <summary>
  3596. /// Time shifts the observable sequence based on a delay selector function for each element.
  3597. /// </summary>
  3598. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3599. /// <typeparam name="TDelay">The type of the elements in the delay sequences used to denote the delay duration of each element in the source sequence.</typeparam>
  3600. /// <param name="source">Source sequence to delay values for.</param>
  3601. /// <param name="delayDurationSelector">Selector function to retrieve a sequence indicating the delay for each given element.</param>
  3602. /// <returns>Time-shifted sequence.</returns>
  3603. /// <exception cref="ArgumentNullException">
  3604. /// <paramref name="source" /> or <paramref name="delayDurationSelector" /> is null.</exception>
  3605. public static IQbservable<TSource> Delay<TSource, TDelay>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TDelay>>> delayDurationSelector)
  3606. {
  3607. if (source == null)
  3608. throw new ArgumentNullException(nameof(source));
  3609. if (delayDurationSelector == null)
  3610. throw new ArgumentNullException(nameof(delayDurationSelector));
  3611. return source.Provider.CreateQuery<TSource>(
  3612. Expression.Call(
  3613. null,
  3614. #if CRIPPLED_REFLECTION
  3615. InfoOf(() => Qbservable.Delay<TSource, TDelay>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TDelay>>>))),
  3616. #else
  3617. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TDelay)),
  3618. #endif
  3619. source.Expression,
  3620. delayDurationSelector
  3621. )
  3622. );
  3623. }
  3624. /// <summary>
  3625. /// Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
  3626. /// </summary>
  3627. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3628. /// <typeparam name="TDelay">The type of the elements in the delay sequences used to denote the delay duration of each element in the source sequence.</typeparam>
  3629. /// <param name="source">Source sequence to delay values for.</param>
  3630. /// <param name="subscriptionDelay">Sequence indicating the delay for the subscription to the source.</param>
  3631. /// <param name="delayDurationSelector">Selector function to retrieve a sequence indicating the delay for each given element.</param>
  3632. /// <returns>Time-shifted sequence.</returns>
  3633. /// <exception cref="ArgumentNullException">
  3634. /// <paramref name="source" /> or <paramref name="subscriptionDelay" /> or <paramref name="delayDurationSelector" /> is null.</exception>
  3635. public static IQbservable<TSource> Delay<TSource, TDelay>(this IQbservable<TSource> source, IObservable<TDelay> subscriptionDelay, Expression<Func<TSource, IObservable<TDelay>>> delayDurationSelector)
  3636. {
  3637. if (source == null)
  3638. throw new ArgumentNullException(nameof(source));
  3639. if (subscriptionDelay == null)
  3640. throw new ArgumentNullException(nameof(subscriptionDelay));
  3641. if (delayDurationSelector == null)
  3642. throw new ArgumentNullException(nameof(delayDurationSelector));
  3643. return source.Provider.CreateQuery<TSource>(
  3644. Expression.Call(
  3645. null,
  3646. #if CRIPPLED_REFLECTION
  3647. InfoOf(() => Qbservable.Delay<TSource, TDelay>(default(IQbservable<TSource>), default(IObservable<TDelay>), default(Expression<Func<TSource, IObservable<TDelay>>>))),
  3648. #else
  3649. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TDelay)),
  3650. #endif
  3651. source.Expression,
  3652. GetSourceExpression(subscriptionDelay),
  3653. delayDurationSelector
  3654. )
  3655. );
  3656. }
  3657. /// <summary>
  3658. /// Time shifts the observable sequence by delaying the subscription to the specified absolute time.
  3659. /// </summary>
  3660. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3661. /// <param name="source">Source sequence to delay subscription for.</param>
  3662. /// <param name="dueTime">Absolute time to perform the subscription at.</param>
  3663. /// <returns>Time-shifted sequence.</returns>
  3664. /// <exception cref="ArgumentNullException">
  3665. /// <paramref name="source" /> is null.</exception>
  3666. /// <remarks>
  3667. /// <para>
  3668. /// This operator is more efficient than <see cref="M:System.Reactive.Linq.Observable.Delay``1(System.IObservable{``0},System.DateTimeOffset)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3669. /// </para>
  3670. /// <para>
  3671. /// The side-effects of subscribing to the source sequence will be run on the default scheduler. Observer callbacks will not be affected.
  3672. /// </para>
  3673. /// </remarks>
  3674. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  3675. {
  3676. if (source == null)
  3677. throw new ArgumentNullException(nameof(source));
  3678. return source.Provider.CreateQuery<TSource>(
  3679. Expression.Call(
  3680. null,
  3681. #if CRIPPLED_REFLECTION
  3682. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  3683. #else
  3684. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3685. #endif
  3686. source.Expression,
  3687. Expression.Constant(dueTime, typeof(DateTimeOffset))
  3688. )
  3689. );
  3690. }
  3691. /// <summary>
  3692. /// Time shifts the observable sequence by delaying the subscription to the specified absolute time, using the specified scheduler to run timers.
  3693. /// </summary>
  3694. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3695. /// <param name="source">Source sequence to delay subscription for.</param>
  3696. /// <param name="dueTime">Absolute time to perform the subscription at.</param>
  3697. /// <param name="scheduler">Scheduler to run the subscription delay timer on.</param>
  3698. /// <returns>Time-shifted sequence.</returns>
  3699. /// <exception cref="ArgumentNullException">
  3700. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3701. /// <remarks>
  3702. /// <para>
  3703. /// This operator is more efficient than <see cref="M:System.Reactive.Linq.Observable.Delay``1(System.IObservable{``0},System.DateTimeOffset,System.Reactive.Concurrency.IScheduler)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3704. /// </para>
  3705. /// <para>
  3706. /// The side-effects of subscribing to the source sequence will be run on the specified scheduler. Observer callbacks will not be affected.
  3707. /// </para>
  3708. /// </remarks>
  3709. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  3710. {
  3711. if (source == null)
  3712. throw new ArgumentNullException(nameof(source));
  3713. if (scheduler == null)
  3714. throw new ArgumentNullException(nameof(scheduler));
  3715. return source.Provider.CreateQuery<TSource>(
  3716. Expression.Call(
  3717. null,
  3718. #if CRIPPLED_REFLECTION
  3719. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  3720. #else
  3721. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3722. #endif
  3723. source.Expression,
  3724. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  3725. Expression.Constant(scheduler, typeof(IScheduler))
  3726. )
  3727. );
  3728. }
  3729. /// <summary>
  3730. /// Time shifts the observable sequence by delaying the subscription with the specified relative time duration.
  3731. /// </summary>
  3732. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3733. /// <param name="source">Source sequence to delay subscription for.</param>
  3734. /// <param name="dueTime">Relative time shift of the subscription.</param>
  3735. /// <returns>Time-shifted sequence.</returns>
  3736. /// <exception cref="ArgumentNullException">
  3737. /// <paramref name="source" /> is null.</exception>
  3738. /// <exception cref="ArgumentOutOfRangeException">
  3739. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3740. /// <remarks>
  3741. /// <para>
  3742. /// This operator is more efficient than <see cref="M:System.Reactive.Linq.Observable.Delay``1(System.IObservable{``0},System.TimeSpan)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3743. /// </para>
  3744. /// <para>
  3745. /// The side-effects of subscribing to the source sequence will be run on the default scheduler. Observer callbacks will not be affected.
  3746. /// </para>
  3747. /// </remarks>
  3748. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  3749. {
  3750. if (source == null)
  3751. throw new ArgumentNullException(nameof(source));
  3752. return source.Provider.CreateQuery<TSource>(
  3753. Expression.Call(
  3754. null,
  3755. #if CRIPPLED_REFLECTION
  3756. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  3757. #else
  3758. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3759. #endif
  3760. source.Expression,
  3761. Expression.Constant(dueTime, typeof(TimeSpan))
  3762. )
  3763. );
  3764. }
  3765. /// <summary>
  3766. /// Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.
  3767. /// </summary>
  3768. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3769. /// <param name="source">Source sequence to delay subscription for.</param>
  3770. /// <param name="dueTime">Relative time shift of the subscription.</param>
  3771. /// <param name="scheduler">Scheduler to run the subscription delay timer on.</param>
  3772. /// <returns>Time-shifted sequence.</returns>
  3773. /// <exception cref="ArgumentNullException">
  3774. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3775. /// <exception cref="ArgumentOutOfRangeException">
  3776. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3777. /// <remarks>
  3778. /// <para>
  3779. /// This operator is more efficient than <see cref="M:System.Reactive.Linq.Observable.Delay``1(System.IObservable{``0},System.TimeSpan,System.Reactive.Concurrency.IScheduler)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3780. /// </para>
  3781. /// <para>
  3782. /// The side-effects of subscribing to the source sequence will be run on the specified scheduler. Observer callbacks will not be affected.
  3783. /// </para>
  3784. /// </remarks>
  3785. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  3786. {
  3787. if (source == null)
  3788. throw new ArgumentNullException(nameof(source));
  3789. if (scheduler == null)
  3790. throw new ArgumentNullException(nameof(scheduler));
  3791. return source.Provider.CreateQuery<TSource>(
  3792. Expression.Call(
  3793. null,
  3794. #if CRIPPLED_REFLECTION
  3795. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  3796. #else
  3797. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3798. #endif
  3799. source.Expression,
  3800. Expression.Constant(dueTime, typeof(TimeSpan)),
  3801. Expression.Constant(scheduler, typeof(IScheduler))
  3802. )
  3803. );
  3804. }
  3805. /// <summary>
  3806. /// Dematerializes the explicit notification values of an observable sequence as implicit notifications.
  3807. /// </summary>
  3808. /// <typeparam name="TSource">The type of the elements materialized in the source sequence notification objects.</typeparam>
  3809. /// <param name="source">An observable sequence containing explicit notification values which have to be turned into implicit notifications.</param>
  3810. /// <returns>An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.</returns>
  3811. /// <exception cref="ArgumentNullException">
  3812. /// <paramref name="source" /> is null.</exception>
  3813. public static IQbservable<TSource> Dematerialize<TSource>(this IQbservable<Notification<TSource>> source)
  3814. {
  3815. if (source == null)
  3816. throw new ArgumentNullException(nameof(source));
  3817. return source.Provider.CreateQuery<TSource>(
  3818. Expression.Call(
  3819. null,
  3820. #if CRIPPLED_REFLECTION
  3821. InfoOf(() => Qbservable.Dematerialize<TSource>(default(IQbservable<Notification<TSource>>))),
  3822. #else
  3823. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3824. #endif
  3825. source.Expression
  3826. )
  3827. );
  3828. }
  3829. /// <summary>
  3830. /// Returns an observable sequence that contains only distinct elements.
  3831. /// </summary>
  3832. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3833. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3834. /// <returns>An observable sequence only containing the distinct elements from the source sequence.</returns>
  3835. /// <exception cref="ArgumentNullException">
  3836. /// <paramref name="source" /> is null.</exception>
  3837. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3838. public static IQbservable<TSource> Distinct<TSource>(this IQbservable<TSource> source)
  3839. {
  3840. if (source == null)
  3841. throw new ArgumentNullException(nameof(source));
  3842. return source.Provider.CreateQuery<TSource>(
  3843. Expression.Call(
  3844. null,
  3845. #if CRIPPLED_REFLECTION
  3846. InfoOf(() => Qbservable.Distinct<TSource>(default(IQbservable<TSource>))),
  3847. #else
  3848. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3849. #endif
  3850. source.Expression
  3851. )
  3852. );
  3853. }
  3854. /// <summary>
  3855. /// Returns an observable sequence that contains only distinct elements according to the comparer.
  3856. /// </summary>
  3857. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3858. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3859. /// <param name="comparer">Equality comparer for source elements.</param>
  3860. /// <returns>An observable sequence only containing the distinct elements from the source sequence.</returns>
  3861. /// <exception cref="ArgumentNullException">
  3862. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  3863. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3864. public static IQbservable<TSource> Distinct<TSource>(this IQbservable<TSource> source, IEqualityComparer<TSource> comparer)
  3865. {
  3866. if (source == null)
  3867. throw new ArgumentNullException(nameof(source));
  3868. if (comparer == null)
  3869. throw new ArgumentNullException(nameof(comparer));
  3870. return source.Provider.CreateQuery<TSource>(
  3871. Expression.Call(
  3872. null,
  3873. #if CRIPPLED_REFLECTION
  3874. InfoOf(() => Qbservable.Distinct<TSource>(default(IQbservable<TSource>), default(IEqualityComparer<TSource>))),
  3875. #else
  3876. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3877. #endif
  3878. source.Expression,
  3879. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  3880. )
  3881. );
  3882. }
  3883. /// <summary>
  3884. /// Returns an observable sequence that contains only distinct elements according to the keySelector.
  3885. /// </summary>
  3886. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3887. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3888. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3889. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3890. /// <returns>An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.</returns>
  3891. /// <exception cref="ArgumentNullException">
  3892. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  3893. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3894. public static IQbservable<TSource> Distinct<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  3895. {
  3896. if (source == null)
  3897. throw new ArgumentNullException(nameof(source));
  3898. if (keySelector == null)
  3899. throw new ArgumentNullException(nameof(keySelector));
  3900. return source.Provider.CreateQuery<TSource>(
  3901. Expression.Call(
  3902. null,
  3903. #if CRIPPLED_REFLECTION
  3904. InfoOf(() => Qbservable.Distinct<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  3905. #else
  3906. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3907. #endif
  3908. source.Expression,
  3909. keySelector
  3910. )
  3911. );
  3912. }
  3913. /// <summary>
  3914. /// Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.
  3915. /// </summary>
  3916. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3917. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3918. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3919. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3920. /// <param name="comparer">Equality comparer for source elements.</param>
  3921. /// <returns>An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.</returns>
  3922. /// <exception cref="ArgumentNullException">
  3923. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  3924. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3925. public static IQbservable<TSource> Distinct<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  3926. {
  3927. if (source == null)
  3928. throw new ArgumentNullException(nameof(source));
  3929. if (keySelector == null)
  3930. throw new ArgumentNullException(nameof(keySelector));
  3931. if (comparer == null)
  3932. throw new ArgumentNullException(nameof(comparer));
  3933. return source.Provider.CreateQuery<TSource>(
  3934. Expression.Call(
  3935. null,
  3936. #if CRIPPLED_REFLECTION
  3937. InfoOf(() => Qbservable.Distinct<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  3938. #else
  3939. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3940. #endif
  3941. source.Expression,
  3942. keySelector,
  3943. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  3944. )
  3945. );
  3946. }
  3947. /// <summary>
  3948. /// Returns an observable sequence that contains only distinct contiguous elements.
  3949. /// </summary>
  3950. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3951. /// <param name="source">An observable sequence to retain distinct contiguous elements for.</param>
  3952. /// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
  3953. /// <exception cref="ArgumentNullException">
  3954. /// <paramref name="source" /> is null.</exception>
  3955. public static IQbservable<TSource> DistinctUntilChanged<TSource>(this IQbservable<TSource> source)
  3956. {
  3957. if (source == null)
  3958. throw new ArgumentNullException(nameof(source));
  3959. return source.Provider.CreateQuery<TSource>(
  3960. Expression.Call(
  3961. null,
  3962. #if CRIPPLED_REFLECTION
  3963. InfoOf(() => Qbservable.DistinctUntilChanged<TSource>(default(IQbservable<TSource>))),
  3964. #else
  3965. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3966. #endif
  3967. source.Expression
  3968. )
  3969. );
  3970. }
  3971. /// <summary>
  3972. /// Returns an observable sequence that contains only distinct contiguous elements according to the comparer.
  3973. /// </summary>
  3974. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3975. /// <param name="source">An observable sequence to retain distinct contiguous elements for.</param>
  3976. /// <param name="comparer">Equality comparer for source elements.</param>
  3977. /// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
  3978. /// <exception cref="ArgumentNullException">
  3979. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  3980. public static IQbservable<TSource> DistinctUntilChanged<TSource>(this IQbservable<TSource> source, IEqualityComparer<TSource> comparer)
  3981. {
  3982. if (source == null)
  3983. throw new ArgumentNullException(nameof(source));
  3984. if (comparer == null)
  3985. throw new ArgumentNullException(nameof(comparer));
  3986. return source.Provider.CreateQuery<TSource>(
  3987. Expression.Call(
  3988. null,
  3989. #if CRIPPLED_REFLECTION
  3990. InfoOf(() => Qbservable.DistinctUntilChanged<TSource>(default(IQbservable<TSource>), default(IEqualityComparer<TSource>))),
  3991. #else
  3992. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3993. #endif
  3994. source.Expression,
  3995. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  3996. )
  3997. );
  3998. }
  3999. /// <summary>
  4000. /// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector.
  4001. /// </summary>
  4002. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4003. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  4004. /// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
  4005. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  4006. /// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
  4007. /// <exception cref="ArgumentNullException">
  4008. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  4009. public static IQbservable<TSource> DistinctUntilChanged<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  4010. {
  4011. if (source == null)
  4012. throw new ArgumentNullException(nameof(source));
  4013. if (keySelector == null)
  4014. throw new ArgumentNullException(nameof(keySelector));
  4015. return source.Provider.CreateQuery<TSource>(
  4016. Expression.Call(
  4017. null,
  4018. #if CRIPPLED_REFLECTION
  4019. InfoOf(() => Qbservable.DistinctUntilChanged<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  4020. #else
  4021. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  4022. #endif
  4023. source.Expression,
  4024. keySelector
  4025. )
  4026. );
  4027. }
  4028. /// <summary>
  4029. /// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
  4030. /// </summary>
  4031. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4032. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  4033. /// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
  4034. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  4035. /// <param name="comparer">Equality comparer for computed key values.</param>
  4036. /// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
  4037. /// <exception cref="ArgumentNullException">
  4038. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  4039. public static IQbservable<TSource> DistinctUntilChanged<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  4040. {
  4041. if (source == null)
  4042. throw new ArgumentNullException(nameof(source));
  4043. if (keySelector == null)
  4044. throw new ArgumentNullException(nameof(keySelector));
  4045. if (comparer == null)
  4046. throw new ArgumentNullException(nameof(comparer));
  4047. return source.Provider.CreateQuery<TSource>(
  4048. Expression.Call(
  4049. null,
  4050. #if CRIPPLED_REFLECTION
  4051. InfoOf(() => Qbservable.DistinctUntilChanged<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  4052. #else
  4053. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  4054. #endif
  4055. source.Expression,
  4056. keySelector,
  4057. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  4058. )
  4059. );
  4060. }
  4061. /// <summary>
  4062. /// Invokes the observer's methods for each message in the source sequence.
  4063. /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  4064. /// </summary>
  4065. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4066. /// <param name="source">Source sequence.</param>
  4067. /// <param name="observer">Observer whose methods to invoke as part of the source sequence's observation.</param>
  4068. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4069. /// <exception cref="ArgumentNullException">
  4070. /// <paramref name="source" /> or <paramref name="observer" /> is null.</exception>
  4071. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, IObserver<TSource> observer)
  4072. {
  4073. if (source == null)
  4074. throw new ArgumentNullException(nameof(source));
  4075. if (observer == null)
  4076. throw new ArgumentNullException(nameof(observer));
  4077. return source.Provider.CreateQuery<TSource>(
  4078. Expression.Call(
  4079. null,
  4080. #if CRIPPLED_REFLECTION
  4081. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(IObserver<TSource>))),
  4082. #else
  4083. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4084. #endif
  4085. source.Expression,
  4086. Expression.Constant(observer, typeof(IObserver<TSource>))
  4087. )
  4088. );
  4089. }
  4090. /// <summary>
  4091. /// Invokes an action for each element in the observable sequence, and propagates all observer messages through the result sequence.
  4092. /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  4093. /// </summary>
  4094. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4095. /// <param name="source">Source sequence.</param>
  4096. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4097. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4098. /// <exception cref="ArgumentNullException">
  4099. /// <paramref name="source" /> or <paramref name="onNext" /> is null.</exception>
  4100. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext)
  4101. {
  4102. if (source == null)
  4103. throw new ArgumentNullException(nameof(source));
  4104. if (onNext == null)
  4105. throw new ArgumentNullException(nameof(onNext));
  4106. return source.Provider.CreateQuery<TSource>(
  4107. Expression.Call(
  4108. null,
  4109. #if CRIPPLED_REFLECTION
  4110. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>))),
  4111. #else
  4112. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4113. #endif
  4114. source.Expression,
  4115. onNext
  4116. )
  4117. );
  4118. }
  4119. /// <summary>
  4120. /// Invokes an action for each element in the observable sequence and invokes an action upon graceful termination of the observable sequence.
  4121. /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  4122. /// </summary>
  4123. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4124. /// <param name="source">Source sequence.</param>
  4125. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4126. /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
  4127. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4128. /// <exception cref="ArgumentNullException">
  4129. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onCompleted" /> is null.</exception>
  4130. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action> onCompleted)
  4131. {
  4132. if (source == null)
  4133. throw new ArgumentNullException(nameof(source));
  4134. if (onNext == null)
  4135. throw new ArgumentNullException(nameof(onNext));
  4136. if (onCompleted == null)
  4137. throw new ArgumentNullException(nameof(onCompleted));
  4138. return source.Provider.CreateQuery<TSource>(
  4139. Expression.Call(
  4140. null,
  4141. #if CRIPPLED_REFLECTION
  4142. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action>))),
  4143. #else
  4144. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4145. #endif
  4146. source.Expression,
  4147. onNext,
  4148. onCompleted
  4149. )
  4150. );
  4151. }
  4152. /// <summary>
  4153. /// Invokes an action for each element in the observable sequence and invokes an action upon exceptional termination of the observable sequence.
  4154. /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  4155. /// </summary>
  4156. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4157. /// <param name="source">Source sequence.</param>
  4158. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4159. /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
  4160. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4161. /// <exception cref="ArgumentNullException">
  4162. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> is null.</exception>
  4163. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError)
  4164. {
  4165. if (source == null)
  4166. throw new ArgumentNullException(nameof(source));
  4167. if (onNext == null)
  4168. throw new ArgumentNullException(nameof(onNext));
  4169. if (onError == null)
  4170. throw new ArgumentNullException(nameof(onError));
  4171. return source.Provider.CreateQuery<TSource>(
  4172. Expression.Call(
  4173. null,
  4174. #if CRIPPLED_REFLECTION
  4175. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>))),
  4176. #else
  4177. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4178. #endif
  4179. source.Expression,
  4180. onNext,
  4181. onError
  4182. )
  4183. );
  4184. }
  4185. /// <summary>
  4186. /// Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
  4187. /// This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.
  4188. /// </summary>
  4189. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4190. /// <param name="source">Source sequence.</param>
  4191. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4192. /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
  4193. /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
  4194. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4195. /// <exception cref="ArgumentNullException">
  4196. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  4197. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError, Expression<Action> onCompleted)
  4198. {
  4199. if (source == null)
  4200. throw new ArgumentNullException(nameof(source));
  4201. if (onNext == null)
  4202. throw new ArgumentNullException(nameof(onNext));
  4203. if (onError == null)
  4204. throw new ArgumentNullException(nameof(onError));
  4205. if (onCompleted == null)
  4206. throw new ArgumentNullException(nameof(onCompleted));
  4207. return source.Provider.CreateQuery<TSource>(
  4208. Expression.Call(
  4209. null,
  4210. #if CRIPPLED_REFLECTION
  4211. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>), default(Expression<Action>))),
  4212. #else
  4213. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4214. #endif
  4215. source.Expression,
  4216. onNext,
  4217. onError,
  4218. onCompleted
  4219. )
  4220. );
  4221. }
  4222. /// <summary>
  4223. /// Repeats the given <paramref name="source" /> as long as the specified <paramref name="condition" /> holds, where the <paramref name="condition" /> is evaluated after each repeated <paramref name="source" /> completed.
  4224. /// </summary>
  4225. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4226. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  4227. /// <param name="condition">Condition that will be evaluated upon the completion of an iteration through the <paramref name="source" />, to determine whether repetition of the source is required.</param>
  4228. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  4229. /// <exception cref="ArgumentNullException">
  4230. /// <paramref name="source" /> or <paramref name="condition" /> is null.</exception>
  4231. public static IQbservable<TSource> DoWhile<TSource>(this IQbservable<TSource> source, Expression<Func<bool>> condition)
  4232. {
  4233. if (source == null)
  4234. throw new ArgumentNullException(nameof(source));
  4235. if (condition == null)
  4236. throw new ArgumentNullException(nameof(condition));
  4237. return source.Provider.CreateQuery<TSource>(
  4238. Expression.Call(
  4239. null,
  4240. #if CRIPPLED_REFLECTION
  4241. InfoOf(() => Qbservable.DoWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<bool>>))),
  4242. #else
  4243. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4244. #endif
  4245. source.Expression,
  4246. condition
  4247. )
  4248. );
  4249. }
  4250. /// <summary>
  4251. /// Returns the element at a specified index in a sequence.
  4252. /// </summary>
  4253. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4254. /// <param name="source">Observable sequence to return the element from.</param>
  4255. /// <param name="index">The zero-based index of the element to retrieve.</param>
  4256. /// <returns>An observable sequence that produces the element at the specified position in the source sequence.</returns>
  4257. /// <exception cref="ArgumentNullException">
  4258. /// <paramref name="source" /> is null.</exception>
  4259. /// <exception cref="ArgumentOutOfRangeException">
  4260. /// <paramref name="index" /> is less than zero.</exception>
  4261. /// <exception cref="ArgumentOutOfRangeException">(Asynchronous) <paramref name="index" /> is greater than or equal to the number of elements in the source sequence.</exception>
  4262. public static IQbservable<TSource> ElementAt<TSource>(this IQbservable<TSource> source, int index)
  4263. {
  4264. if (source == null)
  4265. throw new ArgumentNullException(nameof(source));
  4266. return source.Provider.CreateQuery<TSource>(
  4267. Expression.Call(
  4268. null,
  4269. #if CRIPPLED_REFLECTION
  4270. InfoOf(() => Qbservable.ElementAt<TSource>(default(IQbservable<TSource>), default(int))),
  4271. #else
  4272. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4273. #endif
  4274. source.Expression,
  4275. Expression.Constant(index, typeof(int))
  4276. )
  4277. );
  4278. }
  4279. /// <summary>
  4280. /// Returns the element at a specified index in a sequence or a default value if the index is out of range.
  4281. /// </summary>
  4282. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4283. /// <param name="source">Observable sequence to return the element from.</param>
  4284. /// <param name="index">The zero-based index of the element to retrieve.</param>
  4285. /// <returns>An observable sequence that produces the element at the specified position in the source sequence, or a default value if the index is outside the bounds of the source sequence.</returns>
  4286. /// <exception cref="ArgumentNullException">
  4287. /// <paramref name="source" /> is null.</exception>
  4288. /// <exception cref="ArgumentOutOfRangeException">
  4289. /// <paramref name="index" /> is less than zero.</exception>
  4290. public static IQbservable<TSource> ElementAtOrDefault<TSource>(this IQbservable<TSource> source, int index)
  4291. {
  4292. if (source == null)
  4293. throw new ArgumentNullException(nameof(source));
  4294. return source.Provider.CreateQuery<TSource>(
  4295. Expression.Call(
  4296. null,
  4297. #if CRIPPLED_REFLECTION
  4298. InfoOf(() => Qbservable.ElementAtOrDefault<TSource>(default(IQbservable<TSource>), default(int))),
  4299. #else
  4300. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4301. #endif
  4302. source.Expression,
  4303. Expression.Constant(index, typeof(int))
  4304. )
  4305. );
  4306. }
  4307. /// <summary>
  4308. /// Returns an empty observable sequence.
  4309. /// </summary>
  4310. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4311. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4312. /// <returns>An observable sequence with no elements.</returns>
  4313. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider)
  4314. {
  4315. if (provider == null)
  4316. throw new ArgumentNullException(nameof(provider));
  4317. return provider.CreateQuery<TResult>(
  4318. Expression.Call(
  4319. null,
  4320. #if CRIPPLED_REFLECTION
  4321. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider))),
  4322. #else
  4323. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4324. #endif
  4325. Expression.Constant(provider, typeof(IQbservableProvider))
  4326. )
  4327. );
  4328. }
  4329. /// <summary>
  4330. /// Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
  4331. /// </summary>
  4332. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4333. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4334. /// <param name="scheduler">Scheduler to send the termination call on.</param>
  4335. /// <returns>An observable sequence with no elements.</returns>
  4336. /// <exception cref="ArgumentNullException">
  4337. /// <paramref name="scheduler" /> is null.</exception>
  4338. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, IScheduler scheduler)
  4339. {
  4340. if (provider == null)
  4341. throw new ArgumentNullException(nameof(provider));
  4342. if (scheduler == null)
  4343. throw new ArgumentNullException(nameof(scheduler));
  4344. return provider.CreateQuery<TResult>(
  4345. Expression.Call(
  4346. null,
  4347. #if CRIPPLED_REFLECTION
  4348. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(IScheduler))),
  4349. #else
  4350. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4351. #endif
  4352. Expression.Constant(provider, typeof(IQbservableProvider)),
  4353. Expression.Constant(scheduler, typeof(IScheduler))
  4354. )
  4355. );
  4356. }
  4357. /// <summary>
  4358. /// Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
  4359. /// </summary>
  4360. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4361. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4362. /// <param name="scheduler">Scheduler to send the termination call on.</param>
  4363. /// <param name="witness">Object solely used to infer the type of the <typeparamref name="TResult" /> type parameter. This parameter is typically used when creating a sequence of anonymously typed elements.</param>
  4364. /// <returns>An observable sequence with no elements.</returns>
  4365. /// <exception cref="ArgumentNullException">
  4366. /// <paramref name="scheduler" /> is null.</exception>
  4367. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, IScheduler scheduler, TResult witness)
  4368. {
  4369. if (provider == null)
  4370. throw new ArgumentNullException(nameof(provider));
  4371. if (scheduler == null)
  4372. throw new ArgumentNullException(nameof(scheduler));
  4373. return provider.CreateQuery<TResult>(
  4374. Expression.Call(
  4375. null,
  4376. #if CRIPPLED_REFLECTION
  4377. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(IScheduler), default(TResult))),
  4378. #else
  4379. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4380. #endif
  4381. Expression.Constant(provider, typeof(IQbservableProvider)),
  4382. Expression.Constant(scheduler, typeof(IScheduler)),
  4383. Expression.Constant(witness, typeof(TResult))
  4384. )
  4385. );
  4386. }
  4387. /// <summary>
  4388. /// Returns an empty observable sequence.
  4389. /// </summary>
  4390. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4391. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4392. /// <param name="witness">Object solely used to infer the type of the <typeparamref name="TResult" /> type parameter. This parameter is typically used when creating a sequence of anonymously typed elements.</param>
  4393. /// <returns>An observable sequence with no elements.</returns>
  4394. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, TResult witness)
  4395. {
  4396. if (provider == null)
  4397. throw new ArgumentNullException(nameof(provider));
  4398. return provider.CreateQuery<TResult>(
  4399. Expression.Call(
  4400. null,
  4401. #if CRIPPLED_REFLECTION
  4402. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(TResult))),
  4403. #else
  4404. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4405. #endif
  4406. Expression.Constant(provider, typeof(IQbservableProvider)),
  4407. Expression.Constant(witness, typeof(TResult))
  4408. )
  4409. );
  4410. }
  4411. /// <summary>
  4412. /// Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
  4413. /// </summary>
  4414. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4415. /// <param name="source">Source sequence.</param>
  4416. /// <param name="finallyAction">Action to invoke after the source observable sequence terminates.</param>
  4417. /// <returns>Source sequence with the action-invoking termination behavior applied.</returns>
  4418. /// <exception cref="ArgumentNullException">
  4419. /// <paramref name="source" /> or <paramref name="finallyAction" /> is null.</exception>
  4420. public static IQbservable<TSource> Finally<TSource>(this IQbservable<TSource> source, Expression<Action> finallyAction)
  4421. {
  4422. if (source == null)
  4423. throw new ArgumentNullException(nameof(source));
  4424. if (finallyAction == null)
  4425. throw new ArgumentNullException(nameof(finallyAction));
  4426. return source.Provider.CreateQuery<TSource>(
  4427. Expression.Call(
  4428. null,
  4429. #if CRIPPLED_REFLECTION
  4430. InfoOf(() => Qbservable.Finally<TSource>(default(IQbservable<TSource>), default(Expression<Action>))),
  4431. #else
  4432. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4433. #endif
  4434. source.Expression,
  4435. finallyAction
  4436. )
  4437. );
  4438. }
  4439. /// <summary>
  4440. /// Returns the first element of an observable sequence.
  4441. /// </summary>
  4442. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4443. /// <param name="source">Source observable sequence.</param>
  4444. /// <returns>Sequence containing the first element in the observable sequence.</returns>
  4445. /// <exception cref="ArgumentNullException">
  4446. /// <paramref name="source" /> is null.</exception>
  4447. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  4448. public static IQbservable<TSource> FirstAsync<TSource>(this IQbservable<TSource> source)
  4449. {
  4450. if (source == null)
  4451. throw new ArgumentNullException(nameof(source));
  4452. return source.Provider.CreateQuery<TSource>(
  4453. Expression.Call(
  4454. null,
  4455. #if CRIPPLED_REFLECTION
  4456. InfoOf(() => Qbservable.FirstAsync<TSource>(default(IQbservable<TSource>))),
  4457. #else
  4458. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4459. #endif
  4460. source.Expression
  4461. )
  4462. );
  4463. }
  4464. /// <summary>
  4465. /// Returns the first element of an observable sequence that satisfies the condition in the predicate.
  4466. /// </summary>
  4467. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4468. /// <param name="source">Source observable sequence.</param>
  4469. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  4470. /// <returns>Sequence containing the first element in the observable sequence that satisfies the condition in the predicate.</returns>
  4471. /// <exception cref="ArgumentNullException">
  4472. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  4473. /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  4474. public static IQbservable<TSource> FirstAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  4475. {
  4476. if (source == null)
  4477. throw new ArgumentNullException(nameof(source));
  4478. if (predicate == null)
  4479. throw new ArgumentNullException(nameof(predicate));
  4480. return source.Provider.CreateQuery<TSource>(
  4481. Expression.Call(
  4482. null,
  4483. #if CRIPPLED_REFLECTION
  4484. InfoOf(() => Qbservable.FirstAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  4485. #else
  4486. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4487. #endif
  4488. source.Expression,
  4489. predicate
  4490. )
  4491. );
  4492. }
  4493. /// <summary>
  4494. /// Returns the first element of an observable sequence, or a default value if no such element exists.
  4495. /// </summary>
  4496. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4497. /// <param name="source">Source observable sequence.</param>
  4498. /// <returns>Sequence containing the first element in the observable sequence, or a default value if no such element exists.</returns>
  4499. /// <exception cref="ArgumentNullException">
  4500. /// <paramref name="source" /> is null.</exception>
  4501. public static IQbservable<TSource> FirstOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  4502. {
  4503. if (source == null)
  4504. throw new ArgumentNullException(nameof(source));
  4505. return source.Provider.CreateQuery<TSource>(
  4506. Expression.Call(
  4507. null,
  4508. #if CRIPPLED_REFLECTION
  4509. InfoOf(() => Qbservable.FirstOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  4510. #else
  4511. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4512. #endif
  4513. source.Expression
  4514. )
  4515. );
  4516. }
  4517. /// <summary>
  4518. /// Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  4519. /// </summary>
  4520. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4521. /// <param name="source">Source observable sequence.</param>
  4522. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  4523. /// <returns>Sequence containing the first element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.</returns>
  4524. /// <exception cref="ArgumentNullException">
  4525. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  4526. public static IQbservable<TSource> FirstOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  4527. {
  4528. if (source == null)
  4529. throw new ArgumentNullException(nameof(source));
  4530. if (predicate == null)
  4531. throw new ArgumentNullException(nameof(predicate));
  4532. return source.Provider.CreateQuery<TSource>(
  4533. Expression.Call(
  4534. null,
  4535. #if CRIPPLED_REFLECTION
  4536. InfoOf(() => Qbservable.FirstOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  4537. #else
  4538. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4539. #endif
  4540. source.Expression,
  4541. predicate
  4542. )
  4543. );
  4544. }
  4545. /// <summary>
  4546. /// Concatenates the observable sequences obtained by running the <paramref name="resultSelector" /> for each element in the given enumerable <paramref name="source" />.
  4547. /// </summary>
  4548. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4549. /// <typeparam name="TSource">The type of the elements in the enumerable source sequence.</typeparam>
  4550. /// <typeparam name="TResult">The type of the elements in the observable result sequence.</typeparam>
  4551. /// <param name="source">Enumerable source for which each element will be mapped onto an observable source that will be concatenated in the result sequence.</param>
  4552. /// <param name="resultSelector">Function to select an observable source for each element in the <paramref name="source" />.</param>
  4553. /// <returns>The observable sequence obtained by concatenating the sources returned by <paramref name="resultSelector" /> for each element in the <paramref name="source" />.</returns>
  4554. /// <exception cref="ArgumentNullException">
  4555. /// <paramref name="source" /> or <paramref name="resultSelector" /> is null.</exception>
  4556. public static IQbservable<TResult> For<TSource, TResult>(this IQbservableProvider provider, IEnumerable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> resultSelector)
  4557. {
  4558. if (provider == null)
  4559. throw new ArgumentNullException(nameof(provider));
  4560. if (source == null)
  4561. throw new ArgumentNullException(nameof(source));
  4562. if (resultSelector == null)
  4563. throw new ArgumentNullException(nameof(resultSelector));
  4564. return provider.CreateQuery<TResult>(
  4565. Expression.Call(
  4566. null,
  4567. #if CRIPPLED_REFLECTION
  4568. InfoOf(() => Qbservable.For<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  4569. #else
  4570. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  4571. #endif
  4572. Expression.Constant(provider, typeof(IQbservableProvider)),
  4573. GetSourceExpression(source),
  4574. resultSelector
  4575. )
  4576. );
  4577. }
  4578. /// <summary>
  4579. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4580. /// </summary>
  4581. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4582. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4583. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4584. /// <exception cref="ArgumentNullException">
  4585. /// <paramref name="actionAsync" /> is null.</exception>
  4586. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  4587. {
  4588. if (provider == null)
  4589. throw new ArgumentNullException(nameof(provider));
  4590. if (actionAsync == null)
  4591. throw new ArgumentNullException(nameof(actionAsync));
  4592. return provider.CreateQuery<Unit>(
  4593. Expression.Call(
  4594. null,
  4595. #if CRIPPLED_REFLECTION
  4596. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  4597. #else
  4598. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4599. #endif
  4600. Expression.Constant(provider, typeof(IQbservableProvider)),
  4601. actionAsync
  4602. )
  4603. );
  4604. }
  4605. /// <summary>
  4606. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4607. /// </summary>
  4608. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4609. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4610. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4611. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4612. /// <exception cref="ArgumentNullException">
  4613. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4614. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync, IScheduler scheduler)
  4615. {
  4616. if (provider == null)
  4617. throw new ArgumentNullException(nameof(provider));
  4618. if (actionAsync == null)
  4619. throw new ArgumentNullException(nameof(actionAsync));
  4620. if (scheduler == null)
  4621. throw new ArgumentNullException(nameof(scheduler));
  4622. return provider.CreateQuery<Unit>(
  4623. Expression.Call(
  4624. null,
  4625. #if CRIPPLED_REFLECTION
  4626. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<Task>>), default(IScheduler))),
  4627. #else
  4628. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4629. #endif
  4630. Expression.Constant(provider, typeof(IQbservableProvider)),
  4631. actionAsync,
  4632. Expression.Constant(scheduler, typeof(IScheduler))
  4633. )
  4634. );
  4635. }
  4636. /// <summary>
  4637. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4638. /// The CancellationToken passed to the asynchronous action is tied to the observable sequence's subscription that triggered the action's invocation and can be used for best-effort cancellation.
  4639. /// </summary>
  4640. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4641. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4642. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4643. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4644. /// <exception cref="ArgumentNullException">
  4645. /// <paramref name="actionAsync" /> is null.</exception>
  4646. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  4647. {
  4648. if (provider == null)
  4649. throw new ArgumentNullException(nameof(provider));
  4650. if (actionAsync == null)
  4651. throw new ArgumentNullException(nameof(actionAsync));
  4652. return provider.CreateQuery<Unit>(
  4653. Expression.Call(
  4654. null,
  4655. #if CRIPPLED_REFLECTION
  4656. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  4657. #else
  4658. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4659. #endif
  4660. Expression.Constant(provider, typeof(IQbservableProvider)),
  4661. actionAsync
  4662. )
  4663. );
  4664. }
  4665. /// <summary>
  4666. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4667. /// The CancellationToken passed to the asynchronous action is tied to the observable sequence's subscription that triggered the action's invocation and can be used for best-effort cancellation.
  4668. /// </summary>
  4669. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4670. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4671. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4672. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4673. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4674. /// <exception cref="ArgumentNullException">
  4675. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4676. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync, IScheduler scheduler)
  4677. {
  4678. if (provider == null)
  4679. throw new ArgumentNullException(nameof(provider));
  4680. if (actionAsync == null)
  4681. throw new ArgumentNullException(nameof(actionAsync));
  4682. if (scheduler == null)
  4683. throw new ArgumentNullException(nameof(scheduler));
  4684. return provider.CreateQuery<Unit>(
  4685. Expression.Call(
  4686. null,
  4687. #if CRIPPLED_REFLECTION
  4688. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>), default(IScheduler))),
  4689. #else
  4690. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4691. #endif
  4692. Expression.Constant(provider, typeof(IQbservableProvider)),
  4693. actionAsync,
  4694. Expression.Constant(scheduler, typeof(IScheduler))
  4695. )
  4696. );
  4697. }
  4698. /// <summary>
  4699. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4700. /// </summary>
  4701. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4702. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4703. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4704. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4705. /// <exception cref="ArgumentNullException">
  4706. /// <paramref name="functionAsync" /> is null.</exception>
  4707. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  4708. {
  4709. if (provider == null)
  4710. throw new ArgumentNullException(nameof(provider));
  4711. if (functionAsync == null)
  4712. throw new ArgumentNullException(nameof(functionAsync));
  4713. return provider.CreateQuery<TResult>(
  4714. Expression.Call(
  4715. null,
  4716. #if CRIPPLED_REFLECTION
  4717. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  4718. #else
  4719. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4720. #endif
  4721. Expression.Constant(provider, typeof(IQbservableProvider)),
  4722. functionAsync
  4723. )
  4724. );
  4725. }
  4726. /// <summary>
  4727. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4728. /// The CancellationToken passed to the asynchronous function is tied to the observable sequence's subscription that triggered the function's invocation and can be used for best-effort cancellation.
  4729. /// </summary>
  4730. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4731. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4732. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4733. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4734. /// <exception cref="ArgumentNullException">
  4735. /// <paramref name="functionAsync" /> is null.</exception>
  4736. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4737. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  4738. {
  4739. if (provider == null)
  4740. throw new ArgumentNullException(nameof(provider));
  4741. if (functionAsync == null)
  4742. throw new ArgumentNullException(nameof(functionAsync));
  4743. return provider.CreateQuery<TResult>(
  4744. Expression.Call(
  4745. null,
  4746. #if CRIPPLED_REFLECTION
  4747. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  4748. #else
  4749. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4750. #endif
  4751. Expression.Constant(provider, typeof(IQbservableProvider)),
  4752. functionAsync
  4753. )
  4754. );
  4755. }
  4756. /// <summary>
  4757. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4758. /// </summary>
  4759. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4760. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4761. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4762. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4763. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4764. /// <exception cref="ArgumentNullException">
  4765. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4766. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync, IScheduler scheduler)
  4767. {
  4768. if (provider == null)
  4769. throw new ArgumentNullException(nameof(provider));
  4770. if (functionAsync == null)
  4771. throw new ArgumentNullException(nameof(functionAsync));
  4772. if (scheduler == null)
  4773. throw new ArgumentNullException(nameof(scheduler));
  4774. return provider.CreateQuery<TResult>(
  4775. Expression.Call(
  4776. null,
  4777. #if CRIPPLED_REFLECTION
  4778. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>), default(IScheduler))),
  4779. #else
  4780. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4781. #endif
  4782. Expression.Constant(provider, typeof(IQbservableProvider)),
  4783. functionAsync,
  4784. Expression.Constant(scheduler, typeof(IScheduler))
  4785. )
  4786. );
  4787. }
  4788. /// <summary>
  4789. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4790. /// The CancellationToken passed to the asynchronous function is tied to the observable sequence's subscription that triggered the function's invocation and can be used for best-effort cancellation.
  4791. /// </summary>
  4792. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4793. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4794. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4795. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4796. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4797. /// <exception cref="ArgumentNullException">
  4798. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4799. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4800. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync, IScheduler scheduler)
  4801. {
  4802. if (provider == null)
  4803. throw new ArgumentNullException(nameof(provider));
  4804. if (functionAsync == null)
  4805. throw new ArgumentNullException(nameof(functionAsync));
  4806. if (scheduler == null)
  4807. throw new ArgumentNullException(nameof(scheduler));
  4808. return provider.CreateQuery<TResult>(
  4809. Expression.Call(
  4810. null,
  4811. #if CRIPPLED_REFLECTION
  4812. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>), default(IScheduler))),
  4813. #else
  4814. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4815. #endif
  4816. Expression.Constant(provider, typeof(IQbservableProvider)),
  4817. functionAsync,
  4818. Expression.Constant(scheduler, typeof(IScheduler))
  4819. )
  4820. );
  4821. }
  4822. /// <summary>
  4823. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4824. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4825. /// </summary>
  4826. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4827. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4828. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4829. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4830. /// <exception cref="ArgumentNullException">
  4831. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4832. /// <remarks>
  4833. /// <para>
  4834. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4835. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4836. /// </para>
  4837. /// <para>
  4838. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  4839. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4840. /// </para>
  4841. /// <para>
  4842. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4843. /// making the Subscribe or Dispose call, respectively.
  4844. /// </para>
  4845. /// <para>
  4846. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4847. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4848. /// more concise and easier to understand.
  4849. /// </para>
  4850. /// </remarks>
  4851. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4852. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler)
  4853. {
  4854. if (provider == null)
  4855. throw new ArgumentNullException(nameof(provider));
  4856. if (addHandler == null)
  4857. throw new ArgumentNullException(nameof(addHandler));
  4858. if (removeHandler == null)
  4859. throw new ArgumentNullException(nameof(removeHandler));
  4860. return provider.CreateQuery<Unit>(
  4861. Expression.Call(
  4862. null,
  4863. #if CRIPPLED_REFLECTION
  4864. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>))),
  4865. #else
  4866. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4867. #endif
  4868. Expression.Constant(provider, typeof(IQbservableProvider)),
  4869. addHandler,
  4870. removeHandler
  4871. )
  4872. );
  4873. }
  4874. /// <summary>
  4875. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4876. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4877. /// </summary>
  4878. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4879. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4880. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4881. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4882. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4883. /// <exception cref="ArgumentNullException">
  4884. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4885. /// <remarks>
  4886. /// <para>
  4887. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4888. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4889. /// </para>
  4890. /// <para>
  4891. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  4892. /// accessed from the same context, as required by some UI frameworks.
  4893. /// </para>
  4894. /// <para>
  4895. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4896. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4897. /// parameter. For more information, see the remarks section on those overloads.
  4898. /// </para>
  4899. /// </remarks>
  4900. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4901. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler, IScheduler scheduler)
  4902. {
  4903. if (provider == null)
  4904. throw new ArgumentNullException(nameof(provider));
  4905. if (addHandler == null)
  4906. throw new ArgumentNullException(nameof(addHandler));
  4907. if (removeHandler == null)
  4908. throw new ArgumentNullException(nameof(removeHandler));
  4909. if (scheduler == null)
  4910. throw new ArgumentNullException(nameof(scheduler));
  4911. return provider.CreateQuery<Unit>(
  4912. Expression.Call(
  4913. null,
  4914. #if CRIPPLED_REFLECTION
  4915. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>), default(IScheduler))),
  4916. #else
  4917. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4918. #endif
  4919. Expression.Constant(provider, typeof(IQbservableProvider)),
  4920. addHandler,
  4921. removeHandler,
  4922. Expression.Constant(scheduler, typeof(IScheduler))
  4923. )
  4924. );
  4925. }
  4926. /// <summary>
  4927. /// Converts a .NET event to an observable sequence, using a supplied event delegate type. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4928. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4929. /// </summary>
  4930. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4931. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4932. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4933. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4934. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4935. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4936. /// <exception cref="ArgumentNullException">
  4937. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4938. /// <remarks>
  4939. /// <para>
  4940. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4941. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4942. /// </para>
  4943. /// <para>
  4944. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  4945. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4946. /// </para>
  4947. /// <para>
  4948. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4949. /// making the Subscribe or Dispose call, respectively.
  4950. /// </para>
  4951. /// <para>
  4952. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4953. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4954. /// more concise and easier to understand.
  4955. /// </para>
  4956. /// </remarks>
  4957. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4958. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  4959. {
  4960. if (provider == null)
  4961. throw new ArgumentNullException(nameof(provider));
  4962. if (addHandler == null)
  4963. throw new ArgumentNullException(nameof(addHandler));
  4964. if (removeHandler == null)
  4965. throw new ArgumentNullException(nameof(removeHandler));
  4966. return provider.CreateQuery<TEventArgs>(
  4967. Expression.Call(
  4968. null,
  4969. #if CRIPPLED_REFLECTION
  4970. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  4971. #else
  4972. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4973. #endif
  4974. Expression.Constant(provider, typeof(IQbservableProvider)),
  4975. addHandler,
  4976. removeHandler
  4977. )
  4978. );
  4979. }
  4980. /// <summary>
  4981. /// Converts a .NET event to an observable sequence, using a supplied event delegate type. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4982. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4983. /// </summary>
  4984. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4985. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4986. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4987. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4988. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4989. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4990. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4991. /// <exception cref="ArgumentNullException">
  4992. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4993. /// <remarks>
  4994. /// <para>
  4995. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4996. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4997. /// </para>
  4998. /// <para>
  4999. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5000. /// accessed from the same context, as required by some UI frameworks.
  5001. /// </para>
  5002. /// <para>
  5003. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5004. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5005. /// parameter. For more information, see the remarks section on those overloads.
  5006. /// </para>
  5007. /// </remarks>
  5008. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5009. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5010. {
  5011. if (provider == null)
  5012. throw new ArgumentNullException(nameof(provider));
  5013. if (addHandler == null)
  5014. throw new ArgumentNullException(nameof(addHandler));
  5015. if (removeHandler == null)
  5016. throw new ArgumentNullException(nameof(removeHandler));
  5017. if (scheduler == null)
  5018. throw new ArgumentNullException(nameof(scheduler));
  5019. return provider.CreateQuery<TEventArgs>(
  5020. Expression.Call(
  5021. null,
  5022. #if CRIPPLED_REFLECTION
  5023. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5024. #else
  5025. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5026. #endif
  5027. Expression.Constant(provider, typeof(IQbservableProvider)),
  5028. addHandler,
  5029. removeHandler,
  5030. Expression.Constant(scheduler, typeof(IScheduler))
  5031. )
  5032. );
  5033. }
  5034. /// <summary>
  5035. /// Converts a .NET event to an observable sequence, using a conversion function to obtain the event delegate. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5036. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5037. /// </summary>
  5038. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5039. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5040. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5041. /// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param>
  5042. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5043. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5044. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5045. /// <exception cref="ArgumentNullException">
  5046. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5047. /// <remarks>
  5048. /// <para>
  5049. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5050. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5051. /// </para>
  5052. /// <para>
  5053. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  5054. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5055. /// </para>
  5056. /// <para>
  5057. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  5058. /// making the Subscribe or Dispose call, respectively.
  5059. /// </para>
  5060. /// <para>
  5061. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5062. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5063. /// more concise and easier to understand.
  5064. /// </para>
  5065. /// </remarks>
  5066. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5067. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5068. {
  5069. if (provider == null)
  5070. throw new ArgumentNullException(nameof(provider));
  5071. if (conversion == null)
  5072. throw new ArgumentNullException(nameof(conversion));
  5073. if (addHandler == null)
  5074. throw new ArgumentNullException(nameof(addHandler));
  5075. if (removeHandler == null)
  5076. throw new ArgumentNullException(nameof(removeHandler));
  5077. return provider.CreateQuery<TEventArgs>(
  5078. Expression.Call(
  5079. null,
  5080. #if CRIPPLED_REFLECTION
  5081. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5082. #else
  5083. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5084. #endif
  5085. Expression.Constant(provider, typeof(IQbservableProvider)),
  5086. conversion,
  5087. addHandler,
  5088. removeHandler
  5089. )
  5090. );
  5091. }
  5092. /// <summary>
  5093. /// Converts a .NET event to an observable sequence, using a conversion function to obtain the event delegate. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5094. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5095. /// </summary>
  5096. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5097. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5098. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5099. /// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param>
  5100. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5101. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5102. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5103. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5104. /// <exception cref="ArgumentNullException">
  5105. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5106. /// <remarks>
  5107. /// <para>
  5108. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5109. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5110. /// </para>
  5111. /// <para>
  5112. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5113. /// accessed from the same context, as required by some UI frameworks.
  5114. /// </para>
  5115. /// <para>
  5116. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5117. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5118. /// parameter. For more information, see the remarks section on those overloads.
  5119. /// </para>
  5120. /// </remarks>
  5121. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5122. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5123. {
  5124. if (provider == null)
  5125. throw new ArgumentNullException(nameof(provider));
  5126. if (conversion == null)
  5127. throw new ArgumentNullException(nameof(conversion));
  5128. if (addHandler == null)
  5129. throw new ArgumentNullException(nameof(addHandler));
  5130. if (removeHandler == null)
  5131. throw new ArgumentNullException(nameof(removeHandler));
  5132. if (scheduler == null)
  5133. throw new ArgumentNullException(nameof(scheduler));
  5134. return provider.CreateQuery<TEventArgs>(
  5135. Expression.Call(
  5136. null,
  5137. #if CRIPPLED_REFLECTION
  5138. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5139. #else
  5140. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5141. #endif
  5142. Expression.Constant(provider, typeof(IQbservableProvider)),
  5143. conversion,
  5144. addHandler,
  5145. removeHandler,
  5146. Expression.Constant(scheduler, typeof(IScheduler))
  5147. )
  5148. );
  5149. }
  5150. /// <summary>
  5151. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5152. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5153. /// </summary>
  5154. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5155. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5156. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5157. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5158. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5159. /// <exception cref="ArgumentNullException">
  5160. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5161. /// <remarks>
  5162. /// <para>
  5163. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5164. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5165. /// </para>
  5166. /// <para>
  5167. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  5168. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5169. /// </para>
  5170. /// <para>
  5171. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  5172. /// making the Subscribe or Dispose call, respectively.
  5173. /// </para>
  5174. /// <para>
  5175. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5176. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5177. /// more concise and easier to understand.
  5178. /// </para>
  5179. /// </remarks>
  5180. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5181. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler)
  5182. {
  5183. if (provider == null)
  5184. throw new ArgumentNullException(nameof(provider));
  5185. if (addHandler == null)
  5186. throw new ArgumentNullException(nameof(addHandler));
  5187. if (removeHandler == null)
  5188. throw new ArgumentNullException(nameof(removeHandler));
  5189. return provider.CreateQuery<TEventArgs>(
  5190. Expression.Call(
  5191. null,
  5192. #if CRIPPLED_REFLECTION
  5193. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>))),
  5194. #else
  5195. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5196. #endif
  5197. Expression.Constant(provider, typeof(IQbservableProvider)),
  5198. addHandler,
  5199. removeHandler
  5200. )
  5201. );
  5202. }
  5203. /// <summary>
  5204. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5205. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5206. /// </summary>
  5207. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5208. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5209. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5210. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5211. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5212. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5213. /// <exception cref="ArgumentNullException">
  5214. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5215. /// <remarks>
  5216. /// <para>
  5217. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5218. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5219. /// </para>
  5220. /// <para>
  5221. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5222. /// accessed from the same context, as required by some UI frameworks.
  5223. /// </para>
  5224. /// <para>
  5225. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5226. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5227. /// parameter. For more information, see the remarks section on those overloads.
  5228. /// </para>
  5229. /// </remarks>
  5230. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5231. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler, IScheduler scheduler)
  5232. {
  5233. if (provider == null)
  5234. throw new ArgumentNullException(nameof(provider));
  5235. if (addHandler == null)
  5236. throw new ArgumentNullException(nameof(addHandler));
  5237. if (removeHandler == null)
  5238. throw new ArgumentNullException(nameof(removeHandler));
  5239. if (scheduler == null)
  5240. throw new ArgumentNullException(nameof(scheduler));
  5241. return provider.CreateQuery<TEventArgs>(
  5242. Expression.Call(
  5243. null,
  5244. #if CRIPPLED_REFLECTION
  5245. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>), default(IScheduler))),
  5246. #else
  5247. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5248. #endif
  5249. Expression.Constant(provider, typeof(IQbservableProvider)),
  5250. addHandler,
  5251. removeHandler,
  5252. Expression.Constant(scheduler, typeof(IScheduler))
  5253. )
  5254. );
  5255. }
  5256. /// <summary>
  5257. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler" />, to an observable sequence.
  5258. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5259. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5260. /// </summary>
  5261. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5262. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5263. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5264. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5265. /// <exception cref="ArgumentNullException">
  5266. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5267. /// <remarks>
  5268. /// <para>
  5269. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5270. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5271. /// </para>
  5272. /// <para>
  5273. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5274. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5275. /// </para>
  5276. /// <para>
  5277. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5278. /// making the Subscribe or Dispose call, respectively.
  5279. /// </para>
  5280. /// <para>
  5281. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5282. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5283. /// more concise and easier to understand.
  5284. /// </para>
  5285. /// </remarks>
  5286. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5287. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)
  5288. {
  5289. if (provider == null)
  5290. throw new ArgumentNullException(nameof(provider));
  5291. if (addHandler == null)
  5292. throw new ArgumentNullException(nameof(addHandler));
  5293. if (removeHandler == null)
  5294. throw new ArgumentNullException(nameof(removeHandler));
  5295. return provider.CreateQuery<EventPattern<object>>(
  5296. Expression.Call(
  5297. null,
  5298. #if CRIPPLED_REFLECTION
  5299. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>))),
  5300. #else
  5301. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5302. #endif
  5303. Expression.Constant(provider, typeof(IQbservableProvider)),
  5304. addHandler,
  5305. removeHandler
  5306. )
  5307. );
  5308. }
  5309. /// <summary>
  5310. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler" />, to an observable sequence.
  5311. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5312. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5313. /// </summary>
  5314. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5315. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5316. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5317. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5318. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5319. /// <exception cref="ArgumentNullException">
  5320. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5321. /// <remarks>
  5322. /// <para>
  5323. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5324. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5325. /// </para>
  5326. /// <para>
  5327. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5328. /// accessed from the same context, as required by some UI frameworks.
  5329. /// </para>
  5330. /// <para>
  5331. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5332. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5333. /// parameter. For more information, see the remarks section on those overloads.
  5334. /// </para>
  5335. /// </remarks>
  5336. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5337. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)
  5338. {
  5339. if (provider == null)
  5340. throw new ArgumentNullException(nameof(provider));
  5341. if (addHandler == null)
  5342. throw new ArgumentNullException(nameof(addHandler));
  5343. if (removeHandler == null)
  5344. throw new ArgumentNullException(nameof(removeHandler));
  5345. if (scheduler == null)
  5346. throw new ArgumentNullException(nameof(scheduler));
  5347. return provider.CreateQuery<EventPattern<object>>(
  5348. Expression.Call(
  5349. null,
  5350. #if CRIPPLED_REFLECTION
  5351. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>), default(IScheduler))),
  5352. #else
  5353. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5354. #endif
  5355. Expression.Constant(provider, typeof(IQbservableProvider)),
  5356. addHandler,
  5357. removeHandler,
  5358. Expression.Constant(scheduler, typeof(IScheduler))
  5359. )
  5360. );
  5361. }
  5362. /// <summary>
  5363. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5364. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5365. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5366. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5367. /// </summary>
  5368. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5369. /// <param name="target">Object instance that exposes the event to convert.</param>
  5370. /// <param name="eventName">Name of the event to convert.</param>
  5371. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5372. /// <exception cref="ArgumentNullException">
  5373. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  5374. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5375. /// <remarks>
  5376. /// <para>
  5377. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5378. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5379. /// </para>
  5380. /// <para>
  5381. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5382. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5383. /// </para>
  5384. /// <para>
  5385. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5386. /// making the Subscribe or Dispose call, respectively.
  5387. /// </para>
  5388. /// <para>
  5389. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5390. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5391. /// more concise and easier to understand.
  5392. /// </para>
  5393. /// </remarks>
  5394. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5395. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)
  5396. {
  5397. if (provider == null)
  5398. throw new ArgumentNullException(nameof(provider));
  5399. if (target == null)
  5400. throw new ArgumentNullException(nameof(target));
  5401. if (eventName == null)
  5402. throw new ArgumentNullException(nameof(eventName));
  5403. return provider.CreateQuery<EventPattern<object>>(
  5404. Expression.Call(
  5405. null,
  5406. #if CRIPPLED_REFLECTION
  5407. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string))),
  5408. #else
  5409. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5410. #endif
  5411. Expression.Constant(provider, typeof(IQbservableProvider)),
  5412. Expression.Constant(target, typeof(object)),
  5413. Expression.Constant(eventName, typeof(string))
  5414. )
  5415. );
  5416. }
  5417. /// <summary>
  5418. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5419. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5420. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5421. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5422. /// </summary>
  5423. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5424. /// <param name="target">Object instance that exposes the event to convert.</param>
  5425. /// <param name="eventName">Name of the event to convert.</param>
  5426. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5427. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5428. /// <exception cref="ArgumentNullException">
  5429. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5430. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5431. /// <remarks>
  5432. /// <para>
  5433. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5434. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5435. /// </para>
  5436. /// <para>
  5437. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5438. /// accessed from the same context, as required by some UI frameworks.
  5439. /// </para>
  5440. /// <para>
  5441. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5442. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5443. /// parameter. For more information, see the remarks section on those overloads.
  5444. /// </para>
  5445. /// </remarks>
  5446. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5447. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  5448. {
  5449. if (provider == null)
  5450. throw new ArgumentNullException(nameof(provider));
  5451. if (target == null)
  5452. throw new ArgumentNullException(nameof(target));
  5453. if (eventName == null)
  5454. throw new ArgumentNullException(nameof(eventName));
  5455. if (scheduler == null)
  5456. throw new ArgumentNullException(nameof(scheduler));
  5457. return provider.CreateQuery<EventPattern<object>>(
  5458. Expression.Call(
  5459. null,
  5460. #if CRIPPLED_REFLECTION
  5461. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  5462. #else
  5463. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5464. #endif
  5465. Expression.Constant(provider, typeof(IQbservableProvider)),
  5466. Expression.Constant(target, typeof(object)),
  5467. Expression.Constant(eventName, typeof(string)),
  5468. Expression.Constant(scheduler, typeof(IScheduler))
  5469. )
  5470. );
  5471. }
  5472. /// <summary>
  5473. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5474. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5475. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5476. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5477. /// </summary>
  5478. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5479. /// <param name="type">Type that exposes the static event to convert.</param>
  5480. /// <param name="eventName">Name of the event to convert.</param>
  5481. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5482. /// <exception cref="ArgumentNullException">
  5483. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  5484. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5485. /// <remarks>
  5486. /// <para>
  5487. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5488. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5489. /// </para>
  5490. /// <para>
  5491. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5492. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5493. /// </para>
  5494. /// <para>
  5495. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5496. /// making the Subscribe or Dispose call, respectively.
  5497. /// </para>
  5498. /// <para>
  5499. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5500. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5501. /// more concise and easier to understand.
  5502. /// </para>
  5503. /// </remarks>
  5504. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5505. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)
  5506. {
  5507. if (provider == null)
  5508. throw new ArgumentNullException(nameof(provider));
  5509. if (type == null)
  5510. throw new ArgumentNullException(nameof(type));
  5511. if (eventName == null)
  5512. throw new ArgumentNullException(nameof(eventName));
  5513. return provider.CreateQuery<EventPattern<object>>(
  5514. Expression.Call(
  5515. null,
  5516. #if CRIPPLED_REFLECTION
  5517. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string))),
  5518. #else
  5519. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5520. #endif
  5521. Expression.Constant(provider, typeof(IQbservableProvider)),
  5522. Expression.Constant(type, typeof(Type)),
  5523. Expression.Constant(eventName, typeof(string))
  5524. )
  5525. );
  5526. }
  5527. /// <summary>
  5528. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5529. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5530. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5531. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5532. /// </summary>
  5533. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5534. /// <param name="type">Type that exposes the static event to convert.</param>
  5535. /// <param name="eventName">Name of the event to convert.</param>
  5536. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5537. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5538. /// <exception cref="ArgumentNullException">
  5539. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5540. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5541. /// <remarks>
  5542. /// <para>
  5543. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5544. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5545. /// </para>
  5546. /// <para>
  5547. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5548. /// accessed from the same context, as required by some UI frameworks.
  5549. /// </para>
  5550. /// <para>
  5551. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5552. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5553. /// parameter. For more information, see the remarks section on those overloads.
  5554. /// </para>
  5555. /// </remarks>
  5556. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5557. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  5558. {
  5559. if (provider == null)
  5560. throw new ArgumentNullException(nameof(provider));
  5561. if (type == null)
  5562. throw new ArgumentNullException(nameof(type));
  5563. if (eventName == null)
  5564. throw new ArgumentNullException(nameof(eventName));
  5565. if (scheduler == null)
  5566. throw new ArgumentNullException(nameof(scheduler));
  5567. return provider.CreateQuery<EventPattern<object>>(
  5568. Expression.Call(
  5569. null,
  5570. #if CRIPPLED_REFLECTION
  5571. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  5572. #else
  5573. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5574. #endif
  5575. Expression.Constant(provider, typeof(IQbservableProvider)),
  5576. Expression.Constant(type, typeof(Type)),
  5577. Expression.Constant(eventName, typeof(string)),
  5578. Expression.Constant(scheduler, typeof(IScheduler))
  5579. )
  5580. );
  5581. }
  5582. /// <summary>
  5583. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5584. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5585. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5586. /// </summary>
  5587. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5588. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5589. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5590. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5591. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5592. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5593. /// <exception cref="ArgumentNullException">
  5594. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5595. /// <remarks>
  5596. /// <para>
  5597. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5598. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5599. /// </para>
  5600. /// <para>
  5601. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5602. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5603. /// </para>
  5604. /// <para>
  5605. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5606. /// making the Subscribe or Dispose call, respectively.
  5607. /// </para>
  5608. /// <para>
  5609. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5610. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5611. /// more concise and easier to understand.
  5612. /// </para>
  5613. /// </remarks>
  5614. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5615. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5616. {
  5617. if (provider == null)
  5618. throw new ArgumentNullException(nameof(provider));
  5619. if (addHandler == null)
  5620. throw new ArgumentNullException(nameof(addHandler));
  5621. if (removeHandler == null)
  5622. throw new ArgumentNullException(nameof(removeHandler));
  5623. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5624. Expression.Call(
  5625. null,
  5626. #if CRIPPLED_REFLECTION
  5627. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5628. #else
  5629. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5630. #endif
  5631. Expression.Constant(provider, typeof(IQbservableProvider)),
  5632. addHandler,
  5633. removeHandler
  5634. )
  5635. );
  5636. }
  5637. /// <summary>
  5638. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5639. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5640. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5641. /// </summary>
  5642. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5643. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5644. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5645. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5646. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5647. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5648. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5649. /// <exception cref="ArgumentNullException">
  5650. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5651. /// <remarks>
  5652. /// <para>
  5653. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5654. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5655. /// </para>
  5656. /// <para>
  5657. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5658. /// accessed from the same context, as required by some UI frameworks.
  5659. /// </para>
  5660. /// <para>
  5661. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5662. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5663. /// parameter. For more information, see the remarks section on those overloads.
  5664. /// </para>
  5665. /// </remarks>
  5666. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5667. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5668. {
  5669. if (provider == null)
  5670. throw new ArgumentNullException(nameof(provider));
  5671. if (addHandler == null)
  5672. throw new ArgumentNullException(nameof(addHandler));
  5673. if (removeHandler == null)
  5674. throw new ArgumentNullException(nameof(removeHandler));
  5675. if (scheduler == null)
  5676. throw new ArgumentNullException(nameof(scheduler));
  5677. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5678. Expression.Call(
  5679. null,
  5680. #if CRIPPLED_REFLECTION
  5681. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5682. #else
  5683. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5684. #endif
  5685. Expression.Constant(provider, typeof(IQbservableProvider)),
  5686. addHandler,
  5687. removeHandler,
  5688. Expression.Constant(scheduler, typeof(IScheduler))
  5689. )
  5690. );
  5691. }
  5692. /// <summary>
  5693. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5694. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5695. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5696. /// </summary>
  5697. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5698. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5699. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5700. /// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param>
  5701. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5702. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5703. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5704. /// <exception cref="ArgumentNullException">
  5705. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5706. /// <remarks>
  5707. /// <para>
  5708. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5709. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5710. /// </para>
  5711. /// <para>
  5712. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5713. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5714. /// </para>
  5715. /// <para>
  5716. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5717. /// making the Subscribe or Dispose call, respectively.
  5718. /// </para>
  5719. /// <para>
  5720. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5721. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5722. /// more concise and easier to understand.
  5723. /// </para>
  5724. /// </remarks>
  5725. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5726. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<EventHandler<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5727. {
  5728. if (provider == null)
  5729. throw new ArgumentNullException(nameof(provider));
  5730. if (conversion == null)
  5731. throw new ArgumentNullException(nameof(conversion));
  5732. if (addHandler == null)
  5733. throw new ArgumentNullException(nameof(addHandler));
  5734. if (removeHandler == null)
  5735. throw new ArgumentNullException(nameof(removeHandler));
  5736. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5737. Expression.Call(
  5738. null,
  5739. #if CRIPPLED_REFLECTION
  5740. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5741. #else
  5742. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5743. #endif
  5744. Expression.Constant(provider, typeof(IQbservableProvider)),
  5745. conversion,
  5746. addHandler,
  5747. removeHandler
  5748. )
  5749. );
  5750. }
  5751. /// <summary>
  5752. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5753. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5754. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5755. /// </summary>
  5756. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5757. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5758. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5759. /// <param name="conversion">A function used to convert the given event handler to a delegate compatible with the underlying .NET event. The resulting delegate is used in calls to the addHandler and removeHandler action parameters.</param>
  5760. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5761. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5762. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5763. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5764. /// <exception cref="ArgumentNullException">
  5765. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5766. /// <remarks>
  5767. /// <para>
  5768. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5769. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5770. /// </para>
  5771. /// <para>
  5772. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5773. /// accessed from the same context, as required by some UI frameworks.
  5774. /// </para>
  5775. /// <para>
  5776. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5777. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5778. /// parameter. For more information, see the remarks section on those overloads.
  5779. /// </para>
  5780. /// </remarks>
  5781. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5782. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<EventHandler<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5783. {
  5784. if (provider == null)
  5785. throw new ArgumentNullException(nameof(provider));
  5786. if (conversion == null)
  5787. throw new ArgumentNullException(nameof(conversion));
  5788. if (addHandler == null)
  5789. throw new ArgumentNullException(nameof(addHandler));
  5790. if (removeHandler == null)
  5791. throw new ArgumentNullException(nameof(removeHandler));
  5792. if (scheduler == null)
  5793. throw new ArgumentNullException(nameof(scheduler));
  5794. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5795. Expression.Call(
  5796. null,
  5797. #if CRIPPLED_REFLECTION
  5798. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5799. #else
  5800. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5801. #endif
  5802. Expression.Constant(provider, typeof(IQbservableProvider)),
  5803. conversion,
  5804. addHandler,
  5805. removeHandler,
  5806. Expression.Constant(scheduler, typeof(IScheduler))
  5807. )
  5808. );
  5809. }
  5810. /// <summary>
  5811. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type with a strongly typed sender parameter, to an observable sequence.
  5812. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5813. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5814. /// </summary>
  5815. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5816. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5817. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  5818. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5819. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5820. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5821. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5822. /// <exception cref="ArgumentNullException">
  5823. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5824. /// <remarks>
  5825. /// <para>
  5826. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5827. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5828. /// </para>
  5829. /// <para>
  5830. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5831. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5832. /// </para>
  5833. /// <para>
  5834. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5835. /// making the Subscribe or Dispose call, respectively.
  5836. /// </para>
  5837. /// <para>
  5838. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5839. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5840. /// more concise and easier to understand.
  5841. /// </para>
  5842. /// </remarks>
  5843. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5844. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5845. {
  5846. if (provider == null)
  5847. throw new ArgumentNullException(nameof(provider));
  5848. if (addHandler == null)
  5849. throw new ArgumentNullException(nameof(addHandler));
  5850. if (removeHandler == null)
  5851. throw new ArgumentNullException(nameof(removeHandler));
  5852. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  5853. Expression.Call(
  5854. null,
  5855. #if CRIPPLED_REFLECTION
  5856. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5857. #else
  5858. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  5859. #endif
  5860. Expression.Constant(provider, typeof(IQbservableProvider)),
  5861. addHandler,
  5862. removeHandler
  5863. )
  5864. );
  5865. }
  5866. /// <summary>
  5867. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type with a strongly typed sender parameter, to an observable sequence.
  5868. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5869. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5870. /// </summary>
  5871. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5872. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5873. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  5874. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5875. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5876. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5877. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5878. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5879. /// <exception cref="ArgumentNullException">
  5880. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5881. /// <remarks>
  5882. /// <para>
  5883. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5884. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5885. /// </para>
  5886. /// <para>
  5887. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5888. /// accessed from the same context, as required by some UI frameworks.
  5889. /// </para>
  5890. /// <para>
  5891. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5892. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5893. /// parameter. For more information, see the remarks section on those overloads.
  5894. /// </para>
  5895. /// </remarks>
  5896. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5897. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5898. {
  5899. if (provider == null)
  5900. throw new ArgumentNullException(nameof(provider));
  5901. if (addHandler == null)
  5902. throw new ArgumentNullException(nameof(addHandler));
  5903. if (removeHandler == null)
  5904. throw new ArgumentNullException(nameof(removeHandler));
  5905. if (scheduler == null)
  5906. throw new ArgumentNullException(nameof(scheduler));
  5907. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  5908. Expression.Call(
  5909. null,
  5910. #if CRIPPLED_REFLECTION
  5911. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5912. #else
  5913. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  5914. #endif
  5915. Expression.Constant(provider, typeof(IQbservableProvider)),
  5916. addHandler,
  5917. removeHandler,
  5918. Expression.Constant(scheduler, typeof(IScheduler))
  5919. )
  5920. );
  5921. }
  5922. /// <summary>
  5923. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5924. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5925. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5926. /// </summary>
  5927. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5928. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5929. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5930. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5931. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5932. /// <remarks>
  5933. /// <para>
  5934. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5935. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5936. /// </para>
  5937. /// <para>
  5938. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5939. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5940. /// </para>
  5941. /// <para>
  5942. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5943. /// making the Subscribe or Dispose call, respectively.
  5944. /// </para>
  5945. /// <para>
  5946. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5947. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5948. /// more concise and easier to understand.
  5949. /// </para>
  5950. /// </remarks>
  5951. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5952. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler)
  5953. {
  5954. if (provider == null)
  5955. throw new ArgumentNullException(nameof(provider));
  5956. if (addHandler == null)
  5957. throw new ArgumentNullException(nameof(addHandler));
  5958. if (removeHandler == null)
  5959. throw new ArgumentNullException(nameof(removeHandler));
  5960. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5961. Expression.Call(
  5962. null,
  5963. #if CRIPPLED_REFLECTION
  5964. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>))),
  5965. #else
  5966. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5967. #endif
  5968. Expression.Constant(provider, typeof(IQbservableProvider)),
  5969. addHandler,
  5970. removeHandler
  5971. )
  5972. );
  5973. }
  5974. /// <summary>
  5975. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5976. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5977. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5978. /// </summary>
  5979. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5980. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5981. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5982. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5983. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5984. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5985. /// <remarks>
  5986. /// <para>
  5987. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5988. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5989. /// </para>
  5990. /// <para>
  5991. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  5992. /// accessed from the same context, as required by some UI frameworks.
  5993. /// </para>
  5994. /// <para>
  5995. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5996. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5997. /// parameter. For more information, see the remarks section on those overloads.
  5998. /// </para>
  5999. /// </remarks>
  6000. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6001. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler, IScheduler scheduler)
  6002. {
  6003. if (provider == null)
  6004. throw new ArgumentNullException(nameof(provider));
  6005. if (addHandler == null)
  6006. throw new ArgumentNullException(nameof(addHandler));
  6007. if (removeHandler == null)
  6008. throw new ArgumentNullException(nameof(removeHandler));
  6009. if (scheduler == null)
  6010. throw new ArgumentNullException(nameof(scheduler));
  6011. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6012. Expression.Call(
  6013. null,
  6014. #if CRIPPLED_REFLECTION
  6015. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>), default(IScheduler))),
  6016. #else
  6017. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6018. #endif
  6019. Expression.Constant(provider, typeof(IQbservableProvider)),
  6020. addHandler,
  6021. removeHandler,
  6022. Expression.Constant(scheduler, typeof(IScheduler))
  6023. )
  6024. );
  6025. }
  6026. /// <summary>
  6027. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6028. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6029. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6030. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6031. /// </summary>
  6032. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6033. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6034. /// <param name="target">Object instance that exposes the event to convert.</param>
  6035. /// <param name="eventName">Name of the event to convert.</param>
  6036. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6037. /// <exception cref="ArgumentNullException">
  6038. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6039. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6040. /// <remarks>
  6041. /// <para>
  6042. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6043. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6044. /// </para>
  6045. /// <para>
  6046. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6047. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6048. /// </para>
  6049. /// <para>
  6050. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6051. /// making the Subscribe or Dispose call, respectively.
  6052. /// </para>
  6053. /// <para>
  6054. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6055. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6056. /// more concise and easier to understand.
  6057. /// </para>
  6058. /// </remarks>
  6059. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6060. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6061. {
  6062. if (provider == null)
  6063. throw new ArgumentNullException(nameof(provider));
  6064. if (target == null)
  6065. throw new ArgumentNullException(nameof(target));
  6066. if (eventName == null)
  6067. throw new ArgumentNullException(nameof(eventName));
  6068. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6069. Expression.Call(
  6070. null,
  6071. #if CRIPPLED_REFLECTION
  6072. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6073. #else
  6074. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6075. #endif
  6076. Expression.Constant(provider, typeof(IQbservableProvider)),
  6077. Expression.Constant(target, typeof(object)),
  6078. Expression.Constant(eventName, typeof(string))
  6079. )
  6080. );
  6081. }
  6082. /// <summary>
  6083. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6084. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6085. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6086. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6087. /// </summary>
  6088. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6089. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6090. /// <param name="target">Object instance that exposes the event to convert.</param>
  6091. /// <param name="eventName">Name of the event to convert.</param>
  6092. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6093. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6094. /// <exception cref="ArgumentNullException">
  6095. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6096. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6097. /// <remarks>
  6098. /// <para>
  6099. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6100. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6101. /// </para>
  6102. /// <para>
  6103. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  6104. /// accessed from the same context, as required by some UI frameworks.
  6105. /// </para>
  6106. /// <para>
  6107. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6108. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6109. /// parameter. For more information, see the remarks section on those overloads.
  6110. /// </para>
  6111. /// </remarks>
  6112. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6113. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6114. {
  6115. if (provider == null)
  6116. throw new ArgumentNullException(nameof(provider));
  6117. if (target == null)
  6118. throw new ArgumentNullException(nameof(target));
  6119. if (eventName == null)
  6120. throw new ArgumentNullException(nameof(eventName));
  6121. if (scheduler == null)
  6122. throw new ArgumentNullException(nameof(scheduler));
  6123. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6124. Expression.Call(
  6125. null,
  6126. #if CRIPPLED_REFLECTION
  6127. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6128. #else
  6129. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6130. #endif
  6131. Expression.Constant(provider, typeof(IQbservableProvider)),
  6132. Expression.Constant(target, typeof(object)),
  6133. Expression.Constant(eventName, typeof(string)),
  6134. Expression.Constant(scheduler, typeof(IScheduler))
  6135. )
  6136. );
  6137. }
  6138. /// <summary>
  6139. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6140. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6141. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6142. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6143. /// </summary>
  6144. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6145. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6146. /// <param name="type">Type that exposes the static event to convert.</param>
  6147. /// <param name="eventName">Name of the event to convert.</param>
  6148. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6149. /// <exception cref="ArgumentNullException">
  6150. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6151. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6152. /// <remarks>
  6153. /// <para>
  6154. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6155. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6156. /// </para>
  6157. /// <para>
  6158. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6159. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6160. /// </para>
  6161. /// <para>
  6162. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6163. /// making the Subscribe or Dispose call, respectively.
  6164. /// </para>
  6165. /// <para>
  6166. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6167. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6168. /// more concise and easier to understand.
  6169. /// </para>
  6170. /// </remarks>
  6171. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6172. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6173. {
  6174. if (provider == null)
  6175. throw new ArgumentNullException(nameof(provider));
  6176. if (type == null)
  6177. throw new ArgumentNullException(nameof(type));
  6178. if (eventName == null)
  6179. throw new ArgumentNullException(nameof(eventName));
  6180. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6181. Expression.Call(
  6182. null,
  6183. #if CRIPPLED_REFLECTION
  6184. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6185. #else
  6186. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6187. #endif
  6188. Expression.Constant(provider, typeof(IQbservableProvider)),
  6189. Expression.Constant(type, typeof(Type)),
  6190. Expression.Constant(eventName, typeof(string))
  6191. )
  6192. );
  6193. }
  6194. /// <summary>
  6195. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6196. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6197. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6198. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6199. /// </summary>
  6200. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6201. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6202. /// <param name="type">Type that exposes the static event to convert.</param>
  6203. /// <param name="eventName">Name of the event to convert.</param>
  6204. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6205. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6206. /// <exception cref="ArgumentNullException">
  6207. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6208. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6209. /// <remarks>
  6210. /// <para>
  6211. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6212. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6213. /// </para>
  6214. /// <para>
  6215. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  6216. /// accessed from the same context, as required by some UI frameworks.
  6217. /// </para>
  6218. /// <para>
  6219. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6220. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6221. /// parameter. For more information, see the remarks section on those overloads.
  6222. /// </para>
  6223. /// </remarks>
  6224. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6225. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6226. {
  6227. if (provider == null)
  6228. throw new ArgumentNullException(nameof(provider));
  6229. if (type == null)
  6230. throw new ArgumentNullException(nameof(type));
  6231. if (eventName == null)
  6232. throw new ArgumentNullException(nameof(eventName));
  6233. if (scheduler == null)
  6234. throw new ArgumentNullException(nameof(scheduler));
  6235. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6236. Expression.Call(
  6237. null,
  6238. #if CRIPPLED_REFLECTION
  6239. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6240. #else
  6241. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6242. #endif
  6243. Expression.Constant(provider, typeof(IQbservableProvider)),
  6244. Expression.Constant(type, typeof(Type)),
  6245. Expression.Constant(eventName, typeof(string)),
  6246. Expression.Constant(scheduler, typeof(IScheduler))
  6247. )
  6248. );
  6249. }
  6250. /// <summary>
  6251. /// Converts an instance .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence.
  6252. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6253. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6254. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6255. /// </summary>
  6256. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6257. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6258. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6259. /// <param name="target">Object instance that exposes the event to convert.</param>
  6260. /// <param name="eventName">Name of the event to convert.</param>
  6261. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6262. /// <exception cref="ArgumentNullException">
  6263. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6264. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6265. /// <remarks>
  6266. /// <para>
  6267. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6268. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6269. /// </para>
  6270. /// <para>
  6271. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6272. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6273. /// </para>
  6274. /// <para>
  6275. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6276. /// making the Subscribe or Dispose call, respectively.
  6277. /// </para>
  6278. /// <para>
  6279. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6280. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6281. /// more concise and easier to understand.
  6282. /// </para>
  6283. /// </remarks>
  6284. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6285. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6286. {
  6287. if (provider == null)
  6288. throw new ArgumentNullException(nameof(provider));
  6289. if (target == null)
  6290. throw new ArgumentNullException(nameof(target));
  6291. if (eventName == null)
  6292. throw new ArgumentNullException(nameof(eventName));
  6293. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6294. Expression.Call(
  6295. null,
  6296. #if CRIPPLED_REFLECTION
  6297. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6298. #else
  6299. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6300. #endif
  6301. Expression.Constant(provider, typeof(IQbservableProvider)),
  6302. Expression.Constant(target, typeof(object)),
  6303. Expression.Constant(eventName, typeof(string))
  6304. )
  6305. );
  6306. }
  6307. /// <summary>
  6308. /// Converts an instance .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence.
  6309. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6310. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6311. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6312. /// </summary>
  6313. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6314. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6315. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6316. /// <param name="target">Object instance that exposes the event to convert.</param>
  6317. /// <param name="eventName">Name of the event to convert.</param>
  6318. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6319. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6320. /// <exception cref="ArgumentNullException">
  6321. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6322. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6323. /// <remarks>
  6324. /// <para>
  6325. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6326. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6327. /// </para>
  6328. /// <para>
  6329. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  6330. /// accessed from the same context, as required by some UI frameworks.
  6331. /// </para>
  6332. /// <para>
  6333. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6334. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6335. /// parameter. For more information, see the remarks section on those overloads.
  6336. /// </para>
  6337. /// </remarks>
  6338. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6339. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6340. {
  6341. if (provider == null)
  6342. throw new ArgumentNullException(nameof(provider));
  6343. if (target == null)
  6344. throw new ArgumentNullException(nameof(target));
  6345. if (eventName == null)
  6346. throw new ArgumentNullException(nameof(eventName));
  6347. if (scheduler == null)
  6348. throw new ArgumentNullException(nameof(scheduler));
  6349. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6350. Expression.Call(
  6351. null,
  6352. #if CRIPPLED_REFLECTION
  6353. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6354. #else
  6355. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6356. #endif
  6357. Expression.Constant(provider, typeof(IQbservableProvider)),
  6358. Expression.Constant(target, typeof(object)),
  6359. Expression.Constant(eventName, typeof(string)),
  6360. Expression.Constant(scheduler, typeof(IScheduler))
  6361. )
  6362. );
  6363. }
  6364. /// <summary>
  6365. /// Converts a static .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence.
  6366. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6367. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6368. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6369. /// </summary>
  6370. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6371. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6372. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6373. /// <param name="type">Type that exposes the static event to convert.</param>
  6374. /// <param name="eventName">Name of the event to convert.</param>
  6375. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6376. /// <exception cref="ArgumentNullException">
  6377. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6378. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6379. /// <remarks>
  6380. /// <para>
  6381. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6382. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6383. /// </para>
  6384. /// <para>
  6385. /// The current <see cref="T:System.Threading.SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6386. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6387. /// </para>
  6388. /// <para>
  6389. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6390. /// making the Subscribe or Dispose call, respectively.
  6391. /// </para>
  6392. /// <para>
  6393. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6394. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6395. /// more concise and easier to understand.
  6396. /// </para>
  6397. /// </remarks>
  6398. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6399. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6400. {
  6401. if (provider == null)
  6402. throw new ArgumentNullException(nameof(provider));
  6403. if (type == null)
  6404. throw new ArgumentNullException(nameof(type));
  6405. if (eventName == null)
  6406. throw new ArgumentNullException(nameof(eventName));
  6407. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6408. Expression.Call(
  6409. null,
  6410. #if CRIPPLED_REFLECTION
  6411. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6412. #else
  6413. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6414. #endif
  6415. Expression.Constant(provider, typeof(IQbservableProvider)),
  6416. Expression.Constant(type, typeof(Type)),
  6417. Expression.Constant(eventName, typeof(string))
  6418. )
  6419. );
  6420. }
  6421. /// <summary>
  6422. /// Converts a static .NET event, conforming to the standard .NET event pattern with a strongly typed sender and strongly typed event arguments, to an observable sequence.
  6423. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6424. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6425. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6426. /// </summary>
  6427. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6428. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6429. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6430. /// <param name="type">Type that exposes the static event to convert.</param>
  6431. /// <param name="eventName">Name of the event to convert.</param>
  6432. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6433. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6434. /// <exception cref="ArgumentNullException">
  6435. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6436. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern. -or- The event's first argument type is not assignable to TSender. -or- The event's second argument type is not assignable to TEventArgs.</exception>
  6437. /// <remarks>
  6438. /// <para>
  6439. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6440. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6441. /// </para>
  6442. /// <para>
  6443. /// Add and remove handler invocations are run on the specified scheduler. This behavior allows add and remove handler operations for thread-affine events to be
  6444. /// accessed from the same context, as required by some UI frameworks.
  6445. /// </para>
  6446. /// <para>
  6447. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6448. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6449. /// parameter. For more information, see the remarks section on those overloads.
  6450. /// </para>
  6451. /// </remarks>
  6452. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6453. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6454. {
  6455. if (provider == null)
  6456. throw new ArgumentNullException(nameof(provider));
  6457. if (type == null)
  6458. throw new ArgumentNullException(nameof(type));
  6459. if (eventName == null)
  6460. throw new ArgumentNullException(nameof(eventName));
  6461. if (scheduler == null)
  6462. throw new ArgumentNullException(nameof(scheduler));
  6463. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6464. Expression.Call(
  6465. null,
  6466. #if CRIPPLED_REFLECTION
  6467. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6468. #else
  6469. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6470. #endif
  6471. Expression.Constant(provider, typeof(IQbservableProvider)),
  6472. Expression.Constant(type, typeof(Type)),
  6473. Expression.Constant(eventName, typeof(string)),
  6474. Expression.Constant(scheduler, typeof(IScheduler))
  6475. )
  6476. );
  6477. }
  6478. /// <summary>
  6479. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements.
  6480. /// </summary>
  6481. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6482. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6483. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6484. /// <param name="initialState">Initial state.</param>
  6485. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6486. /// <param name="iterate">Iteration step function.</param>
  6487. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6488. /// <returns>The generated sequence.</returns>
  6489. /// <exception cref="ArgumentNullException">
  6490. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> is null.</exception>
  6491. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector)
  6492. {
  6493. if (provider == null)
  6494. throw new ArgumentNullException(nameof(provider));
  6495. if (condition == null)
  6496. throw new ArgumentNullException(nameof(condition));
  6497. if (iterate == null)
  6498. throw new ArgumentNullException(nameof(iterate));
  6499. if (resultSelector == null)
  6500. throw new ArgumentNullException(nameof(resultSelector));
  6501. return provider.CreateQuery<TResult>(
  6502. Expression.Call(
  6503. null,
  6504. #if CRIPPLED_REFLECTION
  6505. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>))),
  6506. #else
  6507. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6508. #endif
  6509. Expression.Constant(provider, typeof(IQbservableProvider)),
  6510. Expression.Constant(initialState, typeof(TState)),
  6511. condition,
  6512. iterate,
  6513. resultSelector
  6514. )
  6515. );
  6516. }
  6517. /// <summary>
  6518. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
  6519. /// </summary>
  6520. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6521. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6522. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6523. /// <param name="initialState">Initial state.</param>
  6524. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6525. /// <param name="iterate">Iteration step function.</param>
  6526. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6527. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6528. /// <returns>The generated sequence.</returns>
  6529. /// <exception cref="ArgumentNullException">
  6530. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6531. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector, IScheduler scheduler)
  6532. {
  6533. if (provider == null)
  6534. throw new ArgumentNullException(nameof(provider));
  6535. if (condition == null)
  6536. throw new ArgumentNullException(nameof(condition));
  6537. if (iterate == null)
  6538. throw new ArgumentNullException(nameof(iterate));
  6539. if (resultSelector == null)
  6540. throw new ArgumentNullException(nameof(resultSelector));
  6541. if (scheduler == null)
  6542. throw new ArgumentNullException(nameof(scheduler));
  6543. return provider.CreateQuery<TResult>(
  6544. Expression.Call(
  6545. null,
  6546. #if CRIPPLED_REFLECTION
  6547. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>), default(IScheduler))),
  6548. #else
  6549. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6550. #endif
  6551. Expression.Constant(provider, typeof(IQbservableProvider)),
  6552. Expression.Constant(initialState, typeof(TState)),
  6553. condition,
  6554. iterate,
  6555. resultSelector,
  6556. Expression.Constant(scheduler, typeof(IScheduler))
  6557. )
  6558. );
  6559. }
  6560. /// <summary>
  6561. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6562. /// </summary>
  6563. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6564. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6565. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6566. /// <param name="initialState">Initial state.</param>
  6567. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6568. /// <param name="iterate">Iteration step function.</param>
  6569. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6570. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6571. /// <returns>The generated sequence.</returns>
  6572. /// <exception cref="ArgumentNullException">
  6573. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6574. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector, Expression<Func<TState, TimeSpan>> timeSelector)
  6575. {
  6576. if (provider == null)
  6577. throw new ArgumentNullException(nameof(provider));
  6578. if (condition == null)
  6579. throw new ArgumentNullException(nameof(condition));
  6580. if (iterate == null)
  6581. throw new ArgumentNullException(nameof(iterate));
  6582. if (resultSelector == null)
  6583. throw new ArgumentNullException(nameof(resultSelector));
  6584. if (timeSelector == null)
  6585. throw new ArgumentNullException(nameof(timeSelector));
  6586. return provider.CreateQuery<TResult>(
  6587. Expression.Call(
  6588. null,
  6589. #if CRIPPLED_REFLECTION
  6590. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>), default(Expression<Func<TState, TimeSpan>>))),
  6591. #else
  6592. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6593. #endif
  6594. Expression.Constant(provider, typeof(IQbservableProvider)),
  6595. Expression.Constant(initialState, typeof(TState)),
  6596. condition,
  6597. iterate,
  6598. resultSelector,
  6599. timeSelector
  6600. )
  6601. );
  6602. }
  6603. /// <summary>
  6604. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6605. /// </summary>
  6606. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6607. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6608. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6609. /// <param name="initialState">Initial state.</param>
  6610. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6611. /// <param name="iterate">Iteration step function.</param>
  6612. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6613. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6614. /// <returns>The generated sequence.</returns>
  6615. /// <exception cref="ArgumentNullException">
  6616. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6617. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector, Expression<Func<TState, DateTimeOffset>> timeSelector)
  6618. {
  6619. if (provider == null)
  6620. throw new ArgumentNullException(nameof(provider));
  6621. if (condition == null)
  6622. throw new ArgumentNullException(nameof(condition));
  6623. if (iterate == null)
  6624. throw new ArgumentNullException(nameof(iterate));
  6625. if (resultSelector == null)
  6626. throw new ArgumentNullException(nameof(resultSelector));
  6627. if (timeSelector == null)
  6628. throw new ArgumentNullException(nameof(timeSelector));
  6629. return provider.CreateQuery<TResult>(
  6630. Expression.Call(
  6631. null,
  6632. #if CRIPPLED_REFLECTION
  6633. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>), default(Expression<Func<TState, DateTimeOffset>>))),
  6634. #else
  6635. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6636. #endif
  6637. Expression.Constant(provider, typeof(IQbservableProvider)),
  6638. Expression.Constant(initialState, typeof(TState)),
  6639. condition,
  6640. iterate,
  6641. resultSelector,
  6642. timeSelector
  6643. )
  6644. );
  6645. }
  6646. /// <summary>
  6647. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements, using the specified scheduler to run timers and to send out observer messages.
  6648. /// </summary>
  6649. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6650. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6651. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6652. /// <param name="initialState">Initial state.</param>
  6653. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6654. /// <param name="iterate">Iteration step function.</param>
  6655. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6656. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6657. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6658. /// <returns>The generated sequence.</returns>
  6659. /// <exception cref="ArgumentNullException">
  6660. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6661. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector, Expression<Func<TState, TimeSpan>> timeSelector, IScheduler scheduler)
  6662. {
  6663. if (provider == null)
  6664. throw new ArgumentNullException(nameof(provider));
  6665. if (condition == null)
  6666. throw new ArgumentNullException(nameof(condition));
  6667. if (iterate == null)
  6668. throw new ArgumentNullException(nameof(iterate));
  6669. if (resultSelector == null)
  6670. throw new ArgumentNullException(nameof(resultSelector));
  6671. if (timeSelector == null)
  6672. throw new ArgumentNullException(nameof(timeSelector));
  6673. if (scheduler == null)
  6674. throw new ArgumentNullException(nameof(scheduler));
  6675. return provider.CreateQuery<TResult>(
  6676. Expression.Call(
  6677. null,
  6678. #if CRIPPLED_REFLECTION
  6679. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>), default(Expression<Func<TState, TimeSpan>>), default(IScheduler))),
  6680. #else
  6681. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6682. #endif
  6683. Expression.Constant(provider, typeof(IQbservableProvider)),
  6684. Expression.Constant(initialState, typeof(TState)),
  6685. condition,
  6686. iterate,
  6687. resultSelector,
  6688. timeSelector,
  6689. Expression.Constant(scheduler, typeof(IScheduler))
  6690. )
  6691. );
  6692. }
  6693. /// <summary>
  6694. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements, using the specified scheduler to run timers and to send out observer messages.
  6695. /// </summary>
  6696. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6697. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6698. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6699. /// <param name="initialState">Initial state.</param>
  6700. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6701. /// <param name="iterate">Iteration step function.</param>
  6702. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6703. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6704. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6705. /// <returns>The generated sequence.</returns>
  6706. /// <exception cref="ArgumentNullException">
  6707. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6708. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector, Expression<Func<TState, DateTimeOffset>> timeSelector, IScheduler scheduler)
  6709. {
  6710. if (provider == null)
  6711. throw new ArgumentNullException(nameof(provider));
  6712. if (condition == null)
  6713. throw new ArgumentNullException(nameof(condition));
  6714. if (iterate == null)
  6715. throw new ArgumentNullException(nameof(iterate));
  6716. if (resultSelector == null)
  6717. throw new ArgumentNullException(nameof(resultSelector));
  6718. if (timeSelector == null)
  6719. throw new ArgumentNullException(nameof(timeSelector));
  6720. if (scheduler == null)
  6721. throw new ArgumentNullException(nameof(scheduler));
  6722. return provider.CreateQuery<TResult>(
  6723. Expression.Call(
  6724. null,
  6725. #if CRIPPLED_REFLECTION
  6726. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>), default(Expression<Func<TState, DateTimeOffset>>), default(IScheduler))),
  6727. #else
  6728. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6729. #endif
  6730. Expression.Constant(provider, typeof(IQbservableProvider)),
  6731. Expression.Constant(initialState, typeof(TState)),
  6732. condition,
  6733. iterate,
  6734. resultSelector,
  6735. timeSelector,
  6736. Expression.Constant(scheduler, typeof(IScheduler))
  6737. )
  6738. );
  6739. }
  6740. /// <summary>
  6741. /// Groups the elements of an observable sequence according to a specified key selector function.
  6742. /// </summary>
  6743. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6744. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6745. /// <param name="source">An observable sequence whose elements to group.</param>
  6746. /// <param name="keySelector">A function to extract the key for each element.</param>
  6747. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  6748. /// <exception cref="ArgumentNullException">
  6749. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  6750. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  6751. {
  6752. if (source == null)
  6753. throw new ArgumentNullException(nameof(source));
  6754. if (keySelector == null)
  6755. throw new ArgumentNullException(nameof(keySelector));
  6756. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6757. Expression.Call(
  6758. null,
  6759. #if CRIPPLED_REFLECTION
  6760. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  6761. #else
  6762. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6763. #endif
  6764. source.Expression,
  6765. keySelector
  6766. )
  6767. );
  6768. }
  6769. /// <summary>
  6770. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  6771. /// </summary>
  6772. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6773. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6774. /// <param name="source">An observable sequence whose elements to group.</param>
  6775. /// <param name="keySelector">A function to extract the key for each element.</param>
  6776. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6777. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  6778. /// <exception cref="ArgumentNullException">
  6779. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  6780. /// <exception cref="ArgumentOutOfRangeException">
  6781. /// <paramref name="capacity" /> is less than 0.</exception>
  6782. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity)
  6783. {
  6784. if (source == null)
  6785. throw new ArgumentNullException(nameof(source));
  6786. if (keySelector == null)
  6787. throw new ArgumentNullException(nameof(keySelector));
  6788. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6789. Expression.Call(
  6790. null,
  6791. #if CRIPPLED_REFLECTION
  6792. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int))),
  6793. #else
  6794. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6795. #endif
  6796. source.Expression,
  6797. keySelector,
  6798. Expression.Constant(capacity, typeof(int))
  6799. )
  6800. );
  6801. }
  6802. /// <summary>
  6803. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  6804. /// </summary>
  6805. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6806. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6807. /// <param name="source">An observable sequence whose elements to group.</param>
  6808. /// <param name="keySelector">A function to extract the key for each element.</param>
  6809. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6810. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6811. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  6812. /// <exception cref="ArgumentNullException">
  6813. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  6814. /// <exception cref="ArgumentOutOfRangeException">
  6815. /// <paramref name="capacity" /> is less than 0.</exception>
  6816. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity, IEqualityComparer<TKey> comparer)
  6817. {
  6818. if (source == null)
  6819. throw new ArgumentNullException(nameof(source));
  6820. if (keySelector == null)
  6821. throw new ArgumentNullException(nameof(keySelector));
  6822. if (comparer == null)
  6823. throw new ArgumentNullException(nameof(comparer));
  6824. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6825. Expression.Call(
  6826. null,
  6827. #if CRIPPLED_REFLECTION
  6828. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int), default(IEqualityComparer<TKey>))),
  6829. #else
  6830. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6831. #endif
  6832. source.Expression,
  6833. keySelector,
  6834. Expression.Constant(capacity, typeof(int)),
  6835. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6836. )
  6837. );
  6838. }
  6839. /// <summary>
  6840. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  6841. /// </summary>
  6842. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6843. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6844. /// <param name="source">An observable sequence whose elements to group.</param>
  6845. /// <param name="keySelector">A function to extract the key for each element.</param>
  6846. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6847. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  6848. /// <exception cref="ArgumentNullException">
  6849. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  6850. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  6851. {
  6852. if (source == null)
  6853. throw new ArgumentNullException(nameof(source));
  6854. if (keySelector == null)
  6855. throw new ArgumentNullException(nameof(keySelector));
  6856. if (comparer == null)
  6857. throw new ArgumentNullException(nameof(comparer));
  6858. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6859. Expression.Call(
  6860. null,
  6861. #if CRIPPLED_REFLECTION
  6862. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  6863. #else
  6864. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6865. #endif
  6866. source.Expression,
  6867. keySelector,
  6868. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6869. )
  6870. );
  6871. }
  6872. /// <summary>
  6873. /// Groups the elements of an observable sequence and selects the resulting elements by using a specified function.
  6874. /// </summary>
  6875. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6876. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6877. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6878. /// <param name="source">An observable sequence whose elements to group.</param>
  6879. /// <param name="keySelector">A function to extract the key for each element.</param>
  6880. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6881. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  6882. /// <exception cref="ArgumentNullException">
  6883. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  6884. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  6885. {
  6886. if (source == null)
  6887. throw new ArgumentNullException(nameof(source));
  6888. if (keySelector == null)
  6889. throw new ArgumentNullException(nameof(keySelector));
  6890. if (elementSelector == null)
  6891. throw new ArgumentNullException(nameof(elementSelector));
  6892. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6893. Expression.Call(
  6894. null,
  6895. #if CRIPPLED_REFLECTION
  6896. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  6897. #else
  6898. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6899. #endif
  6900. source.Expression,
  6901. keySelector,
  6902. elementSelector
  6903. )
  6904. );
  6905. }
  6906. /// <summary>
  6907. /// Groups the elements of an observable sequence with the specified initial capacity and selects the resulting elements by using a specified function.
  6908. /// </summary>
  6909. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6910. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6911. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6912. /// <param name="source">An observable sequence whose elements to group.</param>
  6913. /// <param name="keySelector">A function to extract the key for each element.</param>
  6914. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6915. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6916. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  6917. /// <exception cref="ArgumentNullException">
  6918. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  6919. /// <exception cref="ArgumentOutOfRangeException">
  6920. /// <paramref name="capacity" /> is less than 0.</exception>
  6921. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, int capacity)
  6922. {
  6923. if (source == null)
  6924. throw new ArgumentNullException(nameof(source));
  6925. if (keySelector == null)
  6926. throw new ArgumentNullException(nameof(keySelector));
  6927. if (elementSelector == null)
  6928. throw new ArgumentNullException(nameof(elementSelector));
  6929. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6930. Expression.Call(
  6931. null,
  6932. #if CRIPPLED_REFLECTION
  6933. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int))),
  6934. #else
  6935. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6936. #endif
  6937. source.Expression,
  6938. keySelector,
  6939. elementSelector,
  6940. Expression.Constant(capacity, typeof(int))
  6941. )
  6942. );
  6943. }
  6944. /// <summary>
  6945. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  6946. /// </summary>
  6947. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6948. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6949. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6950. /// <param name="source">An observable sequence whose elements to group.</param>
  6951. /// <param name="keySelector">A function to extract the key for each element.</param>
  6952. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6953. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6954. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6955. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  6956. /// <exception cref="ArgumentNullException">
  6957. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  6958. /// <exception cref="ArgumentOutOfRangeException">
  6959. /// <paramref name="capacity" /> is less than 0.</exception>
  6960. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, int capacity, IEqualityComparer<TKey> comparer)
  6961. {
  6962. if (source == null)
  6963. throw new ArgumentNullException(nameof(source));
  6964. if (keySelector == null)
  6965. throw new ArgumentNullException(nameof(keySelector));
  6966. if (elementSelector == null)
  6967. throw new ArgumentNullException(nameof(elementSelector));
  6968. if (comparer == null)
  6969. throw new ArgumentNullException(nameof(comparer));
  6970. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6971. Expression.Call(
  6972. null,
  6973. #if CRIPPLED_REFLECTION
  6974. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int), default(IEqualityComparer<TKey>))),
  6975. #else
  6976. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6977. #endif
  6978. source.Expression,
  6979. keySelector,
  6980. elementSelector,
  6981. Expression.Constant(capacity, typeof(int)),
  6982. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6983. )
  6984. );
  6985. }
  6986. /// <summary>
  6987. /// Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  6988. /// </summary>
  6989. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6990. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6991. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6992. /// <param name="source">An observable sequence whose elements to group.</param>
  6993. /// <param name="keySelector">A function to extract the key for each element.</param>
  6994. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6995. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6996. /// <returns>A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.</returns>
  6997. /// <exception cref="ArgumentNullException">
  6998. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  6999. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer)
  7000. {
  7001. if (source == null)
  7002. throw new ArgumentNullException(nameof(source));
  7003. if (keySelector == null)
  7004. throw new ArgumentNullException(nameof(keySelector));
  7005. if (elementSelector == null)
  7006. throw new ArgumentNullException(nameof(elementSelector));
  7007. if (comparer == null)
  7008. throw new ArgumentNullException(nameof(comparer));
  7009. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7010. Expression.Call(
  7011. null,
  7012. #if CRIPPLED_REFLECTION
  7013. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  7014. #else
  7015. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7016. #endif
  7017. source.Expression,
  7018. keySelector,
  7019. elementSelector,
  7020. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7021. )
  7022. );
  7023. }
  7024. /// <summary>
  7025. /// Groups the elements of an observable sequence according to a specified key selector function.
  7026. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7027. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7028. /// </summary>
  7029. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7030. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7031. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7032. /// <param name="source">An observable sequence whose elements to group.</param>
  7033. /// <param name="keySelector">A function to extract the key for each element.</param>
  7034. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7035. /// <returns>
  7036. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7037. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encountered.
  7038. /// </returns>
  7039. /// <exception cref="ArgumentNullException">
  7040. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7041. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>> durationSelector)
  7042. {
  7043. if (source == null)
  7044. throw new ArgumentNullException(nameof(source));
  7045. if (keySelector == null)
  7046. throw new ArgumentNullException(nameof(keySelector));
  7047. if (durationSelector == null)
  7048. throw new ArgumentNullException(nameof(durationSelector));
  7049. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7050. Expression.Call(
  7051. null,
  7052. #if CRIPPLED_REFLECTION
  7053. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>))),
  7054. #else
  7055. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7056. #endif
  7057. source.Expression,
  7058. keySelector,
  7059. durationSelector
  7060. )
  7061. );
  7062. }
  7063. /// <summary>
  7064. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  7065. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7066. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7067. /// </summary>
  7068. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7069. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7070. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7071. /// <param name="source">An observable sequence whose elements to group.</param>
  7072. /// <param name="keySelector">A function to extract the key for each element.</param>
  7073. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7074. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7075. /// <returns>
  7076. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7077. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encountered.
  7078. /// </returns>
  7079. /// <exception cref="ArgumentNullException">
  7080. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7081. /// <exception cref="ArgumentOutOfRangeException">
  7082. /// <paramref name="capacity" /> is less than 0.</exception>
  7083. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>> durationSelector, int capacity)
  7084. {
  7085. if (source == null)
  7086. throw new ArgumentNullException(nameof(source));
  7087. if (keySelector == null)
  7088. throw new ArgumentNullException(nameof(keySelector));
  7089. if (durationSelector == null)
  7090. throw new ArgumentNullException(nameof(durationSelector));
  7091. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7092. Expression.Call(
  7093. null,
  7094. #if CRIPPLED_REFLECTION
  7095. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(int))),
  7096. #else
  7097. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7098. #endif
  7099. source.Expression,
  7100. keySelector,
  7101. durationSelector,
  7102. Expression.Constant(capacity, typeof(int))
  7103. )
  7104. );
  7105. }
  7106. /// <summary>
  7107. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  7108. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7109. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7110. /// </summary>
  7111. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7112. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7113. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7114. /// <param name="source">An observable sequence whose elements to group.</param>
  7115. /// <param name="keySelector">A function to extract the key for each element.</param>
  7116. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7117. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7118. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7119. /// <returns>
  7120. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7121. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encountered.
  7122. /// </returns>
  7123. /// <exception cref="ArgumentNullException">
  7124. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7125. /// <exception cref="ArgumentOutOfRangeException">
  7126. /// <paramref name="capacity" /> is less than 0.</exception>
  7127. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>> durationSelector, int capacity, IEqualityComparer<TKey> comparer)
  7128. {
  7129. if (source == null)
  7130. throw new ArgumentNullException(nameof(source));
  7131. if (keySelector == null)
  7132. throw new ArgumentNullException(nameof(keySelector));
  7133. if (durationSelector == null)
  7134. throw new ArgumentNullException(nameof(durationSelector));
  7135. if (comparer == null)
  7136. throw new ArgumentNullException(nameof(comparer));
  7137. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7138. Expression.Call(
  7139. null,
  7140. #if CRIPPLED_REFLECTION
  7141. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(int), default(IEqualityComparer<TKey>))),
  7142. #else
  7143. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7144. #endif
  7145. source.Expression,
  7146. keySelector,
  7147. durationSelector,
  7148. Expression.Constant(capacity, typeof(int)),
  7149. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7150. )
  7151. );
  7152. }
  7153. /// <summary>
  7154. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  7155. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7156. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7157. /// </summary>
  7158. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7159. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7160. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7161. /// <param name="source">An observable sequence whose elements to group.</param>
  7162. /// <param name="keySelector">A function to extract the key for each element.</param>
  7163. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7164. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7165. /// <returns>
  7166. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7167. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encountered.
  7168. /// </returns>
  7169. /// <exception cref="ArgumentNullException">
  7170. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7171. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupByUntil<TSource, TKey, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>> durationSelector, IEqualityComparer<TKey> comparer)
  7172. {
  7173. if (source == null)
  7174. throw new ArgumentNullException(nameof(source));
  7175. if (keySelector == null)
  7176. throw new ArgumentNullException(nameof(keySelector));
  7177. if (durationSelector == null)
  7178. throw new ArgumentNullException(nameof(durationSelector));
  7179. if (comparer == null)
  7180. throw new ArgumentNullException(nameof(comparer));
  7181. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7182. Expression.Call(
  7183. null,
  7184. #if CRIPPLED_REFLECTION
  7185. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(IEqualityComparer<TKey>))),
  7186. #else
  7187. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7188. #endif
  7189. source.Expression,
  7190. keySelector,
  7191. durationSelector,
  7192. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7193. )
  7194. );
  7195. }
  7196. /// <summary>
  7197. /// Groups the elements of an observable sequence according to a specified key selector function and selects the resulting elements by using a specified function.
  7198. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7199. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7200. /// </summary>
  7201. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7202. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7203. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7204. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7205. /// <param name="source">An observable sequence whose elements to group.</param>
  7206. /// <param name="keySelector">A function to extract the key for each element.</param>
  7207. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7208. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7209. /// <returns>
  7210. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7211. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encountered.
  7212. /// </returns>
  7213. /// <exception cref="ArgumentNullException">
  7214. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7215. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>> durationSelector)
  7216. {
  7217. if (source == null)
  7218. throw new ArgumentNullException(nameof(source));
  7219. if (keySelector == null)
  7220. throw new ArgumentNullException(nameof(keySelector));
  7221. if (elementSelector == null)
  7222. throw new ArgumentNullException(nameof(elementSelector));
  7223. if (durationSelector == null)
  7224. throw new ArgumentNullException(nameof(durationSelector));
  7225. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7226. Expression.Call(
  7227. null,
  7228. #if CRIPPLED_REFLECTION
  7229. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TElement, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>>))),
  7230. #else
  7231. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7232. #endif
  7233. source.Expression,
  7234. keySelector,
  7235. elementSelector,
  7236. durationSelector
  7237. )
  7238. );
  7239. }
  7240. /// <summary>
  7241. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and selects the resulting elements by using a specified function.
  7242. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7243. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7244. /// </summary>
  7245. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7246. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7247. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7248. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7249. /// <param name="source">An observable sequence whose elements to group.</param>
  7250. /// <param name="keySelector">A function to extract the key for each element.</param>
  7251. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7252. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7253. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7254. /// <returns>
  7255. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7256. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encountered.
  7257. /// </returns>
  7258. /// <exception cref="ArgumentNullException">
  7259. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7260. /// <exception cref="ArgumentOutOfRangeException">
  7261. /// <paramref name="capacity" /> is less than 0.</exception>
  7262. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>> durationSelector, int capacity)
  7263. {
  7264. if (source == null)
  7265. throw new ArgumentNullException(nameof(source));
  7266. if (keySelector == null)
  7267. throw new ArgumentNullException(nameof(keySelector));
  7268. if (elementSelector == null)
  7269. throw new ArgumentNullException(nameof(elementSelector));
  7270. if (durationSelector == null)
  7271. throw new ArgumentNullException(nameof(durationSelector));
  7272. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7273. Expression.Call(
  7274. null,
  7275. #if CRIPPLED_REFLECTION
  7276. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TElement, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>>), default(int))),
  7277. #else
  7278. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7279. #endif
  7280. source.Expression,
  7281. keySelector,
  7282. elementSelector,
  7283. durationSelector,
  7284. Expression.Constant(capacity, typeof(int))
  7285. )
  7286. );
  7287. }
  7288. /// <summary>
  7289. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  7290. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7291. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7292. /// </summary>
  7293. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7294. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7295. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7296. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7297. /// <param name="source">An observable sequence whose elements to group.</param>
  7298. /// <param name="keySelector">A function to extract the key for each element.</param>
  7299. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7300. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7301. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7302. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7303. /// <returns>
  7304. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7305. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encountered.
  7306. /// </returns>
  7307. /// <exception cref="ArgumentNullException">
  7308. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7309. /// <exception cref="ArgumentOutOfRangeException">
  7310. /// <paramref name="capacity" /> is less than 0.</exception>
  7311. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>> durationSelector, int capacity, IEqualityComparer<TKey> comparer)
  7312. {
  7313. if (source == null)
  7314. throw new ArgumentNullException(nameof(source));
  7315. if (keySelector == null)
  7316. throw new ArgumentNullException(nameof(keySelector));
  7317. if (elementSelector == null)
  7318. throw new ArgumentNullException(nameof(elementSelector));
  7319. if (durationSelector == null)
  7320. throw new ArgumentNullException(nameof(durationSelector));
  7321. if (comparer == null)
  7322. throw new ArgumentNullException(nameof(comparer));
  7323. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7324. Expression.Call(
  7325. null,
  7326. #if CRIPPLED_REFLECTION
  7327. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TElement, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>>), default(int), default(IEqualityComparer<TKey>))),
  7328. #else
  7329. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7330. #endif
  7331. source.Expression,
  7332. keySelector,
  7333. elementSelector,
  7334. durationSelector,
  7335. Expression.Constant(capacity, typeof(int)),
  7336. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7337. )
  7338. );
  7339. }
  7340. /// <summary>
  7341. /// Groups the elements of an observable sequence according to a specified key selector function and comparer and selects the resulting elements by using a specified function.
  7342. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7343. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7344. /// </summary>
  7345. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7346. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7347. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7348. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7349. /// <param name="source">An observable sequence whose elements to group.</param>
  7350. /// <param name="keySelector">A function to extract the key for each element.</param>
  7351. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7352. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7353. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7354. /// <returns>
  7355. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7356. /// If a group's lifetime expires, a new group with the same key value can be created once an element with such a key value is encountered.
  7357. /// </returns>
  7358. /// <exception cref="ArgumentNullException">
  7359. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7360. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupByUntil<TSource, TKey, TElement, TDuration>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>> durationSelector, IEqualityComparer<TKey> comparer)
  7361. {
  7362. if (source == null)
  7363. throw new ArgumentNullException(nameof(source));
  7364. if (keySelector == null)
  7365. throw new ArgumentNullException(nameof(keySelector));
  7366. if (elementSelector == null)
  7367. throw new ArgumentNullException(nameof(elementSelector));
  7368. if (durationSelector == null)
  7369. throw new ArgumentNullException(nameof(durationSelector));
  7370. if (comparer == null)
  7371. throw new ArgumentNullException(nameof(comparer));
  7372. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7373. Expression.Call(
  7374. null,
  7375. #if CRIPPLED_REFLECTION
  7376. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TElement, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(Expression<Func<IGroupedObservable<TKey, TElement>, IObservable<TDuration>>>), default(IEqualityComparer<TKey>))),
  7377. #else
  7378. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7379. #endif
  7380. source.Expression,
  7381. keySelector,
  7382. elementSelector,
  7383. durationSelector,
  7384. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7385. )
  7386. );
  7387. }
  7388. /// <summary>
  7389. /// Correlates the elements of two sequences based on overlapping durations, and groups the results.
  7390. /// </summary>
  7391. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7392. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7393. /// <typeparam name="TLeftDuration">The type of the elements in the duration sequence denoting the computed duration of each element in the left source sequence.</typeparam>
  7394. /// <typeparam name="TRightDuration">The type of the elements in the duration sequence denoting the computed duration of each element in the right source sequence.</typeparam>
  7395. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by invoking the result selector function for source elements with overlapping duration.</typeparam>
  7396. /// <param name="left">The left observable sequence to join elements for.</param>
  7397. /// <param name="right">The right observable sequence to join elements for.</param>
  7398. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7399. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7400. /// <param name="resultSelector">A function invoked to compute a result element for any element of the left sequence with overlapping elements from the right observable sequence.</param>
  7401. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7402. /// <exception cref="ArgumentNullException">
  7403. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7404. public static IQbservable<TResult> GroupJoin<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(this IQbservable<TLeft> left, IObservable<TRight> right, Expression<Func<TLeft, IObservable<TLeftDuration>>> leftDurationSelector, Expression<Func<TRight, IObservable<TRightDuration>>> rightDurationSelector, Expression<Func<TLeft, IObservable<TRight>, TResult>> resultSelector)
  7405. {
  7406. if (left == null)
  7407. throw new ArgumentNullException(nameof(left));
  7408. if (right == null)
  7409. throw new ArgumentNullException(nameof(right));
  7410. if (leftDurationSelector == null)
  7411. throw new ArgumentNullException(nameof(leftDurationSelector));
  7412. if (rightDurationSelector == null)
  7413. throw new ArgumentNullException(nameof(rightDurationSelector));
  7414. if (resultSelector == null)
  7415. throw new ArgumentNullException(nameof(resultSelector));
  7416. return left.Provider.CreateQuery<TResult>(
  7417. Expression.Call(
  7418. null,
  7419. #if CRIPPLED_REFLECTION
  7420. InfoOf(() => Qbservable.GroupJoin<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(default(IQbservable<TLeft>), default(IObservable<TRight>), default(Expression<Func<TLeft, IObservable<TLeftDuration>>>), default(Expression<Func<TRight, IObservable<TRightDuration>>>), default(Expression<Func<TLeft, IObservable<TRight>, TResult>>))),
  7421. #else
  7422. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7423. #endif
  7424. left.Expression,
  7425. GetSourceExpression(right),
  7426. leftDurationSelector,
  7427. rightDurationSelector,
  7428. resultSelector
  7429. )
  7430. );
  7431. }
  7432. /// <summary>
  7433. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence.
  7434. /// </summary>
  7435. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7436. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7437. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7438. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7439. /// <returns>
  7440. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7441. /// <exception cref="ArgumentNullException">
  7442. /// <paramref name="condition" /> or <paramref name="thenSource" /> is null.</exception>
  7443. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource)
  7444. {
  7445. if (provider == null)
  7446. throw new ArgumentNullException(nameof(provider));
  7447. if (condition == null)
  7448. throw new ArgumentNullException(nameof(condition));
  7449. if (thenSource == null)
  7450. throw new ArgumentNullException(nameof(thenSource));
  7451. return provider.CreateQuery<TResult>(
  7452. Expression.Call(
  7453. null,
  7454. #if CRIPPLED_REFLECTION
  7455. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>))),
  7456. #else
  7457. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7458. #endif
  7459. Expression.Constant(provider, typeof(IQbservableProvider)),
  7460. condition,
  7461. GetSourceExpression(thenSource)
  7462. )
  7463. );
  7464. }
  7465. /// <summary>
  7466. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, select the <paramref name="elseSource" /> sequence.
  7467. /// </summary>
  7468. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7469. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7470. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7471. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7472. /// <param name="elseSource">Sequence returned in case <paramref name="condition" /> evaluates false.</param>
  7473. /// <returns>
  7474. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; <paramref name="elseSource" /> otherwise.</returns>
  7475. /// <exception cref="ArgumentNullException">
  7476. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="elseSource" /> is null.</exception>
  7477. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IObservable<TResult> elseSource)
  7478. {
  7479. if (provider == null)
  7480. throw new ArgumentNullException(nameof(provider));
  7481. if (condition == null)
  7482. throw new ArgumentNullException(nameof(condition));
  7483. if (thenSource == null)
  7484. throw new ArgumentNullException(nameof(thenSource));
  7485. if (elseSource == null)
  7486. throw new ArgumentNullException(nameof(elseSource));
  7487. return provider.CreateQuery<TResult>(
  7488. Expression.Call(
  7489. null,
  7490. #if CRIPPLED_REFLECTION
  7491. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IObservable<TResult>))),
  7492. #else
  7493. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7494. #endif
  7495. Expression.Constant(provider, typeof(IQbservableProvider)),
  7496. condition,
  7497. GetSourceExpression(thenSource),
  7498. GetSourceExpression(elseSource)
  7499. )
  7500. );
  7501. }
  7502. /// <summary>
  7503. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence generated on the specified scheduler.
  7504. /// </summary>
  7505. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7506. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7507. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7508. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7509. /// <param name="scheduler">Scheduler to generate an empty sequence on in case <paramref name="condition" /> evaluates false.</param>
  7510. /// <returns>
  7511. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7512. /// <exception cref="ArgumentNullException">
  7513. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="scheduler" /> is null.</exception>
  7514. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IScheduler scheduler)
  7515. {
  7516. if (provider == null)
  7517. throw new ArgumentNullException(nameof(provider));
  7518. if (condition == null)
  7519. throw new ArgumentNullException(nameof(condition));
  7520. if (thenSource == null)
  7521. throw new ArgumentNullException(nameof(thenSource));
  7522. if (scheduler == null)
  7523. throw new ArgumentNullException(nameof(scheduler));
  7524. return provider.CreateQuery<TResult>(
  7525. Expression.Call(
  7526. null,
  7527. #if CRIPPLED_REFLECTION
  7528. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IScheduler))),
  7529. #else
  7530. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7531. #endif
  7532. Expression.Constant(provider, typeof(IQbservableProvider)),
  7533. condition,
  7534. GetSourceExpression(thenSource),
  7535. Expression.Constant(scheduler, typeof(IScheduler))
  7536. )
  7537. );
  7538. }
  7539. /// <summary>
  7540. /// Ignores all elements in an observable sequence leaving only the termination messages.
  7541. /// </summary>
  7542. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7543. /// <param name="source">Source sequence.</param>
  7544. /// <returns>An empty observable sequence that signals termination, successful or exceptional, of the source sequence.</returns>
  7545. /// <exception cref="ArgumentNullException">
  7546. /// <paramref name="source" /> is null.</exception>
  7547. public static IQbservable<TSource> IgnoreElements<TSource>(this IQbservable<TSource> source)
  7548. {
  7549. if (source == null)
  7550. throw new ArgumentNullException(nameof(source));
  7551. return source.Provider.CreateQuery<TSource>(
  7552. Expression.Call(
  7553. null,
  7554. #if CRIPPLED_REFLECTION
  7555. InfoOf(() => Qbservable.IgnoreElements<TSource>(default(IQbservable<TSource>))),
  7556. #else
  7557. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7558. #endif
  7559. source.Expression
  7560. )
  7561. );
  7562. }
  7563. /// <summary>
  7564. /// Returns an observable sequence that produces a value after each period.
  7565. /// </summary>
  7566. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7567. /// <param name="period">Period for producing the values in the resulting sequence. If this value is equal to TimeSpan.Zero, the timer will recur as fast as possible.</param>
  7568. /// <returns>An observable sequence that produces a value after each period.</returns>
  7569. /// <exception cref="ArgumentOutOfRangeException">
  7570. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7571. /// <remarks>
  7572. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7573. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7574. /// current one has been handled. In case you need to control the time between the end and the start of consecutive notifications, consider using the
  7575. /// <see cref="M:System.Reactive.Linq.Observable.Generate``2(``0,System.Func{``0,System.Boolean},System.Func{``0,``0},System.Func{``0,``1},System.Func{``0,System.TimeSpan})" />
  7576. /// operator instead.
  7577. /// </remarks>
  7578. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period)
  7579. {
  7580. if (provider == null)
  7581. throw new ArgumentNullException(nameof(provider));
  7582. return provider.CreateQuery<long>(
  7583. Expression.Call(
  7584. null,
  7585. #if CRIPPLED_REFLECTION
  7586. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan))),
  7587. #else
  7588. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7589. #endif
  7590. Expression.Constant(provider, typeof(IQbservableProvider)),
  7591. Expression.Constant(period, typeof(TimeSpan))
  7592. )
  7593. );
  7594. }
  7595. /// <summary>
  7596. /// Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.
  7597. /// </summary>
  7598. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7599. /// <param name="period">Period for producing the values in the resulting sequence. If this value is equal to TimeSpan.Zero, the timer will recur as fast as possible.</param>
  7600. /// <param name="scheduler">Scheduler to run the timer on.</param>
  7601. /// <returns>An observable sequence that produces a value after each period.</returns>
  7602. /// <exception cref="ArgumentOutOfRangeException">
  7603. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7604. /// <exception cref="ArgumentNullException">
  7605. /// <paramref name="scheduler" /> is null.</exception>
  7606. /// <remarks>
  7607. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7608. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7609. /// current one has been handled. In case you need to control the time between the end and the start of consecutive notifications, consider using the
  7610. /// <see cref="M:System.Reactive.Linq.Observable.Generate``2(``0,System.Func{``0,System.Boolean},System.Func{``0,``0},System.Func{``0,``1},System.Func{``0,System.TimeSpan},System.Reactive.Concurrency.IScheduler)" />
  7611. /// operator instead.
  7612. /// </remarks>
  7613. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period, IScheduler scheduler)
  7614. {
  7615. if (provider == null)
  7616. throw new ArgumentNullException(nameof(provider));
  7617. if (scheduler == null)
  7618. throw new ArgumentNullException(nameof(scheduler));
  7619. return provider.CreateQuery<long>(
  7620. Expression.Call(
  7621. null,
  7622. #if CRIPPLED_REFLECTION
  7623. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  7624. #else
  7625. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7626. #endif
  7627. Expression.Constant(provider, typeof(IQbservableProvider)),
  7628. Expression.Constant(period, typeof(TimeSpan)),
  7629. Expression.Constant(scheduler, typeof(IScheduler))
  7630. )
  7631. );
  7632. }
  7633. /// <summary>
  7634. /// Determines whether an observable sequence is empty.
  7635. /// </summary>
  7636. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7637. /// <param name="source">An observable sequence to check for emptiness.</param>
  7638. /// <returns>An observable sequence containing a single element determining whether the source sequence is empty.</returns>
  7639. /// <exception cref="ArgumentNullException">
  7640. /// <paramref name="source" /> is null.</exception>
  7641. public static IQbservable<bool> IsEmpty<TSource>(this IQbservable<TSource> source)
  7642. {
  7643. if (source == null)
  7644. throw new ArgumentNullException(nameof(source));
  7645. return source.Provider.CreateQuery<bool>(
  7646. Expression.Call(
  7647. null,
  7648. #if CRIPPLED_REFLECTION
  7649. InfoOf(() => Qbservable.IsEmpty<TSource>(default(IQbservable<TSource>))),
  7650. #else
  7651. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7652. #endif
  7653. source.Expression
  7654. )
  7655. );
  7656. }
  7657. /// <summary>
  7658. /// Correlates the elements of two sequences based on overlapping durations.
  7659. /// </summary>
  7660. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7661. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7662. /// <typeparam name="TLeftDuration">The type of the elements in the duration sequence denoting the computed duration of each element in the left source sequence.</typeparam>
  7663. /// <typeparam name="TRightDuration">The type of the elements in the duration sequence denoting the computed duration of each element in the right source sequence.</typeparam>
  7664. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by invoking the result selector function for source elements with overlapping duration.</typeparam>
  7665. /// <param name="left">The left observable sequence to join elements for.</param>
  7666. /// <param name="right">The right observable sequence to join elements for.</param>
  7667. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7668. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7669. /// <param name="resultSelector">A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences.</param>
  7670. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7671. /// <exception cref="ArgumentNullException">
  7672. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7673. public static IQbservable<TResult> Join<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(this IQbservable<TLeft> left, IObservable<TRight> right, Expression<Func<TLeft, IObservable<TLeftDuration>>> leftDurationSelector, Expression<Func<TRight, IObservable<TRightDuration>>> rightDurationSelector, Expression<Func<TLeft, TRight, TResult>> resultSelector)
  7674. {
  7675. if (left == null)
  7676. throw new ArgumentNullException(nameof(left));
  7677. if (right == null)
  7678. throw new ArgumentNullException(nameof(right));
  7679. if (leftDurationSelector == null)
  7680. throw new ArgumentNullException(nameof(leftDurationSelector));
  7681. if (rightDurationSelector == null)
  7682. throw new ArgumentNullException(nameof(rightDurationSelector));
  7683. if (resultSelector == null)
  7684. throw new ArgumentNullException(nameof(resultSelector));
  7685. return left.Provider.CreateQuery<TResult>(
  7686. Expression.Call(
  7687. null,
  7688. #if CRIPPLED_REFLECTION
  7689. InfoOf(() => Qbservable.Join<TLeft, TRight, TLeftDuration, TRightDuration, TResult>(default(IQbservable<TLeft>), default(IObservable<TRight>), default(Expression<Func<TLeft, IObservable<TLeftDuration>>>), default(Expression<Func<TRight, IObservable<TRightDuration>>>), default(Expression<Func<TLeft, TRight, TResult>>))),
  7690. #else
  7691. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7692. #endif
  7693. left.Expression,
  7694. GetSourceExpression(right),
  7695. leftDurationSelector,
  7696. rightDurationSelector,
  7697. resultSelector
  7698. )
  7699. );
  7700. }
  7701. /// <summary>
  7702. /// Returns the last element of an observable sequence.
  7703. /// </summary>
  7704. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7705. /// <param name="source">Source observable sequence.</param>
  7706. /// <returns>Sequence containing the last element in the observable sequence.</returns>
  7707. /// <exception cref="ArgumentNullException">
  7708. /// <paramref name="source" /> is null.</exception>
  7709. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  7710. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source)
  7711. {
  7712. if (source == null)
  7713. throw new ArgumentNullException(nameof(source));
  7714. return source.Provider.CreateQuery<TSource>(
  7715. Expression.Call(
  7716. null,
  7717. #if CRIPPLED_REFLECTION
  7718. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>))),
  7719. #else
  7720. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7721. #endif
  7722. source.Expression
  7723. )
  7724. );
  7725. }
  7726. /// <summary>
  7727. /// Returns the last element of an observable sequence that satisfies the condition in the predicate.
  7728. /// </summary>
  7729. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7730. /// <param name="source">Source observable sequence.</param>
  7731. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7732. /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.</returns>
  7733. /// <exception cref="ArgumentNullException">
  7734. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7735. /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  7736. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7737. {
  7738. if (source == null)
  7739. throw new ArgumentNullException(nameof(source));
  7740. if (predicate == null)
  7741. throw new ArgumentNullException(nameof(predicate));
  7742. return source.Provider.CreateQuery<TSource>(
  7743. Expression.Call(
  7744. null,
  7745. #if CRIPPLED_REFLECTION
  7746. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7747. #else
  7748. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7749. #endif
  7750. source.Expression,
  7751. predicate
  7752. )
  7753. );
  7754. }
  7755. /// <summary>
  7756. /// Returns the last element of an observable sequence, or a default value if no such element exists.
  7757. /// </summary>
  7758. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7759. /// <param name="source">Source observable sequence.</param>
  7760. /// <returns>Sequence containing the last element in the observable sequence, or a default value if no such element exists.</returns>
  7761. /// <exception cref="ArgumentNullException">
  7762. /// <paramref name="source" /> is null.</exception>
  7763. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  7764. {
  7765. if (source == null)
  7766. throw new ArgumentNullException(nameof(source));
  7767. return source.Provider.CreateQuery<TSource>(
  7768. Expression.Call(
  7769. null,
  7770. #if CRIPPLED_REFLECTION
  7771. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  7772. #else
  7773. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7774. #endif
  7775. source.Expression
  7776. )
  7777. );
  7778. }
  7779. /// <summary>
  7780. /// Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  7781. /// </summary>
  7782. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7783. /// <param name="source">Source observable sequence.</param>
  7784. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7785. /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.</returns>
  7786. /// <exception cref="ArgumentNullException">
  7787. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7788. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7789. {
  7790. if (source == null)
  7791. throw new ArgumentNullException(nameof(source));
  7792. if (predicate == null)
  7793. throw new ArgumentNullException(nameof(predicate));
  7794. return source.Provider.CreateQuery<TSource>(
  7795. Expression.Call(
  7796. null,
  7797. #if CRIPPLED_REFLECTION
  7798. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7799. #else
  7800. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7801. #endif
  7802. source.Expression,
  7803. predicate
  7804. )
  7805. );
  7806. }
  7807. /// <summary>
  7808. /// Returns an enumerable sequence whose enumeration returns the latest observed element in the source observable sequence.
  7809. /// Enumerators on the resulting sequence will never produce the same element repeatedly, and will block until the next element becomes available.
  7810. /// </summary>
  7811. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7812. /// <param name="source">Source observable sequence.</param>
  7813. /// <returns>The enumerable sequence that returns the last sampled element upon each iteration and subsequently blocks until the next element in the observable source sequence becomes available.</returns>
  7814. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  7815. public static IQueryable<TSource> Latest<TSource>(this IQbservable<TSource> source)
  7816. {
  7817. if (source == null)
  7818. throw new ArgumentNullException(nameof(source));
  7819. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  7820. Expression.Call(
  7821. null,
  7822. #if CRIPPLED_REFLECTION
  7823. InfoOf(() => Qbservable.Latest<TSource>(default(IQbservable<TSource>))),
  7824. #else
  7825. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7826. #endif
  7827. source.Expression
  7828. )
  7829. );
  7830. }
  7831. /// <summary>
  7832. /// Returns an observable sequence containing an <see cref="long" /> that represents the total number of elements in an observable sequence.
  7833. /// </summary>
  7834. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7835. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  7836. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  7837. /// <exception cref="ArgumentNullException">
  7838. /// <paramref name="source" /> is null.</exception>
  7839. /// <exception cref="OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  7840. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7841. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source)
  7842. {
  7843. if (source == null)
  7844. throw new ArgumentNullException(nameof(source));
  7845. return source.Provider.CreateQuery<long>(
  7846. Expression.Call(
  7847. null,
  7848. #if CRIPPLED_REFLECTION
  7849. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>))),
  7850. #else
  7851. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7852. #endif
  7853. source.Expression
  7854. )
  7855. );
  7856. }
  7857. /// <summary>
  7858. /// Returns an observable sequence containing an <see cref="long" /> that represents how many elements in the specified observable sequence satisfy a condition.
  7859. /// </summary>
  7860. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7861. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  7862. /// <param name="predicate">A function to test each element for a condition.</param>
  7863. /// <returns>An observable sequence containing a single element with a number that represents how many elements in the input sequence satisfy the condition in the predicate function.</returns>
  7864. /// <exception cref="ArgumentNullException">
  7865. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7866. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7867. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7868. {
  7869. if (source == null)
  7870. throw new ArgumentNullException(nameof(source));
  7871. if (predicate == null)
  7872. throw new ArgumentNullException(nameof(predicate));
  7873. return source.Provider.CreateQuery<long>(
  7874. Expression.Call(
  7875. null,
  7876. #if CRIPPLED_REFLECTION
  7877. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7878. #else
  7879. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7880. #endif
  7881. source.Expression,
  7882. predicate
  7883. )
  7884. );
  7885. }
  7886. /// <summary>
  7887. /// Materializes the implicit notifications of an observable sequence as explicit notification values.
  7888. /// </summary>
  7889. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7890. /// <param name="source">An observable sequence to get notification values for.</param>
  7891. /// <returns>An observable sequence containing the materialized notification values from the source sequence.</returns>
  7892. /// <exception cref="ArgumentNullException">
  7893. /// <paramref name="source" /> is null.</exception>
  7894. public static IQbservable<Notification<TSource>> Materialize<TSource>(this IQbservable<TSource> source)
  7895. {
  7896. if (source == null)
  7897. throw new ArgumentNullException(nameof(source));
  7898. return source.Provider.CreateQuery<Notification<TSource>>(
  7899. Expression.Call(
  7900. null,
  7901. #if CRIPPLED_REFLECTION
  7902. InfoOf(() => Qbservable.Materialize<TSource>(default(IQbservable<TSource>))),
  7903. #else
  7904. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7905. #endif
  7906. source.Expression
  7907. )
  7908. );
  7909. }
  7910. /// <summary>
  7911. /// Returns the maximum value in an observable sequence of <see cref="Decimal" /> values.
  7912. /// </summary>
  7913. /// <param name="source">A sequence of <see cref="Decimal" /> values to determine the maximum value of.</param>
  7914. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7915. /// <exception cref="ArgumentNullException">
  7916. /// <paramref name="source" /> is null.</exception>
  7917. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7918. public static IQbservable<decimal> Max(this IQbservable<decimal> source)
  7919. {
  7920. if (source == null)
  7921. throw new ArgumentNullException(nameof(source));
  7922. return source.Provider.CreateQuery<decimal>(
  7923. Expression.Call(
  7924. null,
  7925. #if CRIPPLED_REFLECTION
  7926. InfoOf(() => Qbservable.Max(default(IQbservable<decimal>))),
  7927. #else
  7928. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7929. #endif
  7930. source.Expression
  7931. )
  7932. );
  7933. }
  7934. /// <summary>
  7935. /// Returns the maximum value in an observable sequence of <see cref="double" /> values.
  7936. /// </summary>
  7937. /// <param name="source">A sequence of <see cref="double" /> values to determine the maximum value of.</param>
  7938. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7939. /// <exception cref="ArgumentNullException">
  7940. /// <paramref name="source" /> is null.</exception>
  7941. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7942. public static IQbservable<double> Max(this IQbservable<double> source)
  7943. {
  7944. if (source == null)
  7945. throw new ArgumentNullException(nameof(source));
  7946. return source.Provider.CreateQuery<double>(
  7947. Expression.Call(
  7948. null,
  7949. #if CRIPPLED_REFLECTION
  7950. InfoOf(() => Qbservable.Max(default(IQbservable<double>))),
  7951. #else
  7952. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7953. #endif
  7954. source.Expression
  7955. )
  7956. );
  7957. }
  7958. /// <summary>
  7959. /// Returns the maximum value in an observable sequence of <see cref="int" /> values.
  7960. /// </summary>
  7961. /// <param name="source">A sequence of <see cref="int" /> values to determine the maximum value of.</param>
  7962. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7963. /// <exception cref="ArgumentNullException">
  7964. /// <paramref name="source" /> is null.</exception>
  7965. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7966. public static IQbservable<int> Max(this IQbservable<int> source)
  7967. {
  7968. if (source == null)
  7969. throw new ArgumentNullException(nameof(source));
  7970. return source.Provider.CreateQuery<int>(
  7971. Expression.Call(
  7972. null,
  7973. #if CRIPPLED_REFLECTION
  7974. InfoOf(() => Qbservable.Max(default(IQbservable<int>))),
  7975. #else
  7976. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7977. #endif
  7978. source.Expression
  7979. )
  7980. );
  7981. }
  7982. /// <summary>
  7983. /// Returns the maximum value in an observable sequence of <see cref="long" /> values.
  7984. /// </summary>
  7985. /// <param name="source">A sequence of <see cref="long" /> values to determine the maximum value of.</param>
  7986. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7987. /// <exception cref="ArgumentNullException">
  7988. /// <paramref name="source" /> is null.</exception>
  7989. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7990. public static IQbservable<long> Max(this IQbservable<long> source)
  7991. {
  7992. if (source == null)
  7993. throw new ArgumentNullException(nameof(source));
  7994. return source.Provider.CreateQuery<long>(
  7995. Expression.Call(
  7996. null,
  7997. #if CRIPPLED_REFLECTION
  7998. InfoOf(() => Qbservable.Max(default(IQbservable<long>))),
  7999. #else
  8000. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8001. #endif
  8002. source.Expression
  8003. )
  8004. );
  8005. }
  8006. /// <summary>
  8007. /// Returns the maximum value in an observable sequence of nullable <see cref="Decimal" /> values.
  8008. /// </summary>
  8009. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to determine the maximum value of.</param>
  8010. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8011. /// <exception cref="ArgumentNullException">
  8012. /// <paramref name="source" /> is null.</exception>
  8013. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8014. public static IQbservable<decimal?> Max(this IQbservable<decimal?> source)
  8015. {
  8016. if (source == null)
  8017. throw new ArgumentNullException(nameof(source));
  8018. return source.Provider.CreateQuery<decimal?>(
  8019. Expression.Call(
  8020. null,
  8021. #if CRIPPLED_REFLECTION
  8022. InfoOf(() => Qbservable.Max(default(IQbservable<decimal?>))),
  8023. #else
  8024. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8025. #endif
  8026. source.Expression
  8027. )
  8028. );
  8029. }
  8030. /// <summary>
  8031. /// Returns the maximum value in an observable sequence of nullable <see cref="double" /> values.
  8032. /// </summary>
  8033. /// <param name="source">A sequence of nullable <see cref="double" /> values to determine the maximum value of.</param>
  8034. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8035. /// <exception cref="ArgumentNullException">
  8036. /// <paramref name="source" /> is null.</exception>
  8037. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8038. public static IQbservable<double?> Max(this IQbservable<double?> source)
  8039. {
  8040. if (source == null)
  8041. throw new ArgumentNullException(nameof(source));
  8042. return source.Provider.CreateQuery<double?>(
  8043. Expression.Call(
  8044. null,
  8045. #if CRIPPLED_REFLECTION
  8046. InfoOf(() => Qbservable.Max(default(IQbservable<double?>))),
  8047. #else
  8048. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8049. #endif
  8050. source.Expression
  8051. )
  8052. );
  8053. }
  8054. /// <summary>
  8055. /// Returns the maximum value in an observable sequence of nullable <see cref="int" /> values.
  8056. /// </summary>
  8057. /// <param name="source">A sequence of nullable <see cref="int" /> values to determine the maximum value of.</param>
  8058. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8059. /// <exception cref="ArgumentNullException">
  8060. /// <paramref name="source" /> is null.</exception>
  8061. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8062. public static IQbservable<int?> Max(this IQbservable<int?> source)
  8063. {
  8064. if (source == null)
  8065. throw new ArgumentNullException(nameof(source));
  8066. return source.Provider.CreateQuery<int?>(
  8067. Expression.Call(
  8068. null,
  8069. #if CRIPPLED_REFLECTION
  8070. InfoOf(() => Qbservable.Max(default(IQbservable<int?>))),
  8071. #else
  8072. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8073. #endif
  8074. source.Expression
  8075. )
  8076. );
  8077. }
  8078. /// <summary>
  8079. /// Returns the maximum value in an observable sequence of nullable <see cref="long" /> values.
  8080. /// </summary>
  8081. /// <param name="source">A sequence of nullable <see cref="long" /> values to determine the maximum value of.</param>
  8082. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8083. /// <exception cref="ArgumentNullException">
  8084. /// <paramref name="source" /> is null.</exception>
  8085. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8086. public static IQbservable<long?> Max(this IQbservable<long?> source)
  8087. {
  8088. if (source == null)
  8089. throw new ArgumentNullException(nameof(source));
  8090. return source.Provider.CreateQuery<long?>(
  8091. Expression.Call(
  8092. null,
  8093. #if CRIPPLED_REFLECTION
  8094. InfoOf(() => Qbservable.Max(default(IQbservable<long?>))),
  8095. #else
  8096. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8097. #endif
  8098. source.Expression
  8099. )
  8100. );
  8101. }
  8102. /// <summary>
  8103. /// Returns the maximum value in an observable sequence of nullable <see cref="Single" /> values.
  8104. /// </summary>
  8105. /// <param name="source">A sequence of nullable <see cref="Single" /> values to determine the maximum value of.</param>
  8106. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8107. /// <exception cref="ArgumentNullException">
  8108. /// <paramref name="source" /> is null.</exception>
  8109. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8110. public static IQbservable<float?> Max(this IQbservable<float?> source)
  8111. {
  8112. if (source == null)
  8113. throw new ArgumentNullException(nameof(source));
  8114. return source.Provider.CreateQuery<float?>(
  8115. Expression.Call(
  8116. null,
  8117. #if CRIPPLED_REFLECTION
  8118. InfoOf(() => Qbservable.Max(default(IQbservable<float?>))),
  8119. #else
  8120. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8121. #endif
  8122. source.Expression
  8123. )
  8124. );
  8125. }
  8126. /// <summary>
  8127. /// Returns the maximum value in an observable sequence of <see cref="Single" /> values.
  8128. /// </summary>
  8129. /// <param name="source">A sequence of <see cref="Single" /> values to determine the maximum value of.</param>
  8130. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8131. /// <exception cref="ArgumentNullException">
  8132. /// <paramref name="source" /> is null.</exception>
  8133. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8134. public static IQbservable<float> Max(this IQbservable<float> source)
  8135. {
  8136. if (source == null)
  8137. throw new ArgumentNullException(nameof(source));
  8138. return source.Provider.CreateQuery<float>(
  8139. Expression.Call(
  8140. null,
  8141. #if CRIPPLED_REFLECTION
  8142. InfoOf(() => Qbservable.Max(default(IQbservable<float>))),
  8143. #else
  8144. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8145. #endif
  8146. source.Expression
  8147. )
  8148. );
  8149. }
  8150. /// <summary>
  8151. /// Returns the maximum element in an observable sequence.
  8152. /// </summary>
  8153. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8154. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8155. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8156. /// <exception cref="ArgumentNullException">
  8157. /// <paramref name="source" /> is null.</exception>
  8158. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8159. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source)
  8160. {
  8161. if (source == null)
  8162. throw new ArgumentNullException(nameof(source));
  8163. return source.Provider.CreateQuery<TSource>(
  8164. Expression.Call(
  8165. null,
  8166. #if CRIPPLED_REFLECTION
  8167. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>))),
  8168. #else
  8169. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8170. #endif
  8171. source.Expression
  8172. )
  8173. );
  8174. }
  8175. /// <summary>
  8176. /// Returns the maximum value in an observable sequence according to the specified comparer.
  8177. /// </summary>
  8178. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8179. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8180. /// <param name="comparer">Comparer used to compare elements.</param>
  8181. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8182. /// <exception cref="ArgumentNullException">
  8183. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  8184. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8185. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  8186. {
  8187. if (source == null)
  8188. throw new ArgumentNullException(nameof(source));
  8189. if (comparer == null)
  8190. throw new ArgumentNullException(nameof(comparer));
  8191. return source.Provider.CreateQuery<TSource>(
  8192. Expression.Call(
  8193. null,
  8194. #if CRIPPLED_REFLECTION
  8195. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  8196. #else
  8197. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8198. #endif
  8199. source.Expression,
  8200. Expression.Constant(comparer, typeof(IComparer<TSource>))
  8201. )
  8202. );
  8203. }
  8204. /// <summary>
  8205. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="double" /> value.
  8206. /// </summary>
  8207. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8208. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8209. /// <param name="selector">A transform function to apply to each element.</param>
  8210. /// <returns>An observable sequence containing a single element with the value of type <see cref="double" /> that corresponds to the maximum value in the source sequence.</returns>
  8211. /// <exception cref="ArgumentNullException">
  8212. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8213. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8214. public static IQbservable<double> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  8215. {
  8216. if (source == null)
  8217. throw new ArgumentNullException(nameof(source));
  8218. if (selector == null)
  8219. throw new ArgumentNullException(nameof(selector));
  8220. return source.Provider.CreateQuery<double>(
  8221. Expression.Call(
  8222. null,
  8223. #if CRIPPLED_REFLECTION
  8224. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  8225. #else
  8226. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8227. #endif
  8228. source.Expression,
  8229. selector
  8230. )
  8231. );
  8232. }
  8233. /// <summary>
  8234. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="Single" /> value.
  8235. /// </summary>
  8236. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8237. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8238. /// <param name="selector">A transform function to apply to each element.</param>
  8239. /// <returns>An observable sequence containing a single element with the value of type <see cref="Single" /> that corresponds to the maximum value in the source sequence.</returns>
  8240. /// <exception cref="ArgumentNullException">
  8241. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8242. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8243. public static IQbservable<float> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  8244. {
  8245. if (source == null)
  8246. throw new ArgumentNullException(nameof(source));
  8247. if (selector == null)
  8248. throw new ArgumentNullException(nameof(selector));
  8249. return source.Provider.CreateQuery<float>(
  8250. Expression.Call(
  8251. null,
  8252. #if CRIPPLED_REFLECTION
  8253. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  8254. #else
  8255. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8256. #endif
  8257. source.Expression,
  8258. selector
  8259. )
  8260. );
  8261. }
  8262. /// <summary>
  8263. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="Decimal" /> value.
  8264. /// </summary>
  8265. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8266. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8267. /// <param name="selector">A transform function to apply to each element.</param>
  8268. /// <returns>An observable sequence containing a single element with the value of type <see cref="Decimal" /> that corresponds to the maximum value in the source sequence.</returns>
  8269. /// <exception cref="ArgumentNullException">
  8270. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8271. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8272. public static IQbservable<decimal> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  8273. {
  8274. if (source == null)
  8275. throw new ArgumentNullException(nameof(source));
  8276. if (selector == null)
  8277. throw new ArgumentNullException(nameof(selector));
  8278. return source.Provider.CreateQuery<decimal>(
  8279. Expression.Call(
  8280. null,
  8281. #if CRIPPLED_REFLECTION
  8282. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  8283. #else
  8284. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8285. #endif
  8286. source.Expression,
  8287. selector
  8288. )
  8289. );
  8290. }
  8291. /// <summary>
  8292. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="int" /> value.
  8293. /// </summary>
  8294. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8295. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8296. /// <param name="selector">A transform function to apply to each element.</param>
  8297. /// <returns>An observable sequence containing a single element with the value of type <see cref="int" /> that corresponds to the maximum value in the source sequence.</returns>
  8298. /// <exception cref="ArgumentNullException">
  8299. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8300. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8301. public static IQbservable<int> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  8302. {
  8303. if (source == null)
  8304. throw new ArgumentNullException(nameof(source));
  8305. if (selector == null)
  8306. throw new ArgumentNullException(nameof(selector));
  8307. return source.Provider.CreateQuery<int>(
  8308. Expression.Call(
  8309. null,
  8310. #if CRIPPLED_REFLECTION
  8311. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  8312. #else
  8313. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8314. #endif
  8315. source.Expression,
  8316. selector
  8317. )
  8318. );
  8319. }
  8320. /// <summary>
  8321. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="long" /> value.
  8322. /// </summary>
  8323. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8324. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8325. /// <param name="selector">A transform function to apply to each element.</param>
  8326. /// <returns>An observable sequence containing a single element with the value of type <see cref="long" /> that corresponds to the maximum value in the source sequence.</returns>
  8327. /// <exception cref="ArgumentNullException">
  8328. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8329. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8330. public static IQbservable<long> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  8331. {
  8332. if (source == null)
  8333. throw new ArgumentNullException(nameof(source));
  8334. if (selector == null)
  8335. throw new ArgumentNullException(nameof(selector));
  8336. return source.Provider.CreateQuery<long>(
  8337. Expression.Call(
  8338. null,
  8339. #if CRIPPLED_REFLECTION
  8340. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  8341. #else
  8342. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8343. #endif
  8344. source.Expression,
  8345. selector
  8346. )
  8347. );
  8348. }
  8349. /// <summary>
  8350. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="double" /> value.
  8351. /// </summary>
  8352. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8353. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8354. /// <param name="selector">A transform function to apply to each element.</param>
  8355. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable`1" /> that corresponds to the maximum value in the source sequence.</returns>
  8356. /// <exception cref="ArgumentNullException">
  8357. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8358. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8359. public static IQbservable<double?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  8360. {
  8361. if (source == null)
  8362. throw new ArgumentNullException(nameof(source));
  8363. if (selector == null)
  8364. throw new ArgumentNullException(nameof(selector));
  8365. return source.Provider.CreateQuery<double?>(
  8366. Expression.Call(
  8367. null,
  8368. #if CRIPPLED_REFLECTION
  8369. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  8370. #else
  8371. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8372. #endif
  8373. source.Expression,
  8374. selector
  8375. )
  8376. );
  8377. }
  8378. /// <summary>
  8379. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="Single" /> value.
  8380. /// </summary>
  8381. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8382. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8383. /// <param name="selector">A transform function to apply to each element.</param>
  8384. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable`1" /> that corresponds to the maximum value in the source sequence.</returns>
  8385. /// <exception cref="ArgumentNullException">
  8386. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8387. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8388. public static IQbservable<float?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  8389. {
  8390. if (source == null)
  8391. throw new ArgumentNullException(nameof(source));
  8392. if (selector == null)
  8393. throw new ArgumentNullException(nameof(selector));
  8394. return source.Provider.CreateQuery<float?>(
  8395. Expression.Call(
  8396. null,
  8397. #if CRIPPLED_REFLECTION
  8398. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  8399. #else
  8400. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8401. #endif
  8402. source.Expression,
  8403. selector
  8404. )
  8405. );
  8406. }
  8407. /// <summary>
  8408. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="Decimal" /> value.
  8409. /// </summary>
  8410. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8411. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8412. /// <param name="selector">A transform function to apply to each element.</param>
  8413. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable`1" /> that corresponds to the maximum value in the source sequence.</returns>
  8414. /// <exception cref="ArgumentNullException">
  8415. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8416. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8417. public static IQbservable<decimal?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  8418. {
  8419. if (source == null)
  8420. throw new ArgumentNullException(nameof(source));
  8421. if (selector == null)
  8422. throw new ArgumentNullException(nameof(selector));
  8423. return source.Provider.CreateQuery<decimal?>(
  8424. Expression.Call(
  8425. null,
  8426. #if CRIPPLED_REFLECTION
  8427. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  8428. #else
  8429. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8430. #endif
  8431. source.Expression,
  8432. selector
  8433. )
  8434. );
  8435. }
  8436. /// <summary>
  8437. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="int" /> value.
  8438. /// </summary>
  8439. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8440. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8441. /// <param name="selector">A transform function to apply to each element.</param>
  8442. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable`1" /> that corresponds to the maximum value in the source sequence.</returns>
  8443. /// <exception cref="ArgumentNullException">
  8444. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8445. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8446. public static IQbservable<int?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  8447. {
  8448. if (source == null)
  8449. throw new ArgumentNullException(nameof(source));
  8450. if (selector == null)
  8451. throw new ArgumentNullException(nameof(selector));
  8452. return source.Provider.CreateQuery<int?>(
  8453. Expression.Call(
  8454. null,
  8455. #if CRIPPLED_REFLECTION
  8456. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  8457. #else
  8458. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8459. #endif
  8460. source.Expression,
  8461. selector
  8462. )
  8463. );
  8464. }
  8465. /// <summary>
  8466. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="long" /> value.
  8467. /// </summary>
  8468. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8469. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8470. /// <param name="selector">A transform function to apply to each element.</param>
  8471. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable`1" /> that corresponds to the maximum value in the source sequence.</returns>
  8472. /// <exception cref="ArgumentNullException">
  8473. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8474. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8475. public static IQbservable<long?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  8476. {
  8477. if (source == null)
  8478. throw new ArgumentNullException(nameof(source));
  8479. if (selector == null)
  8480. throw new ArgumentNullException(nameof(selector));
  8481. return source.Provider.CreateQuery<long?>(
  8482. Expression.Call(
  8483. null,
  8484. #if CRIPPLED_REFLECTION
  8485. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  8486. #else
  8487. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8488. #endif
  8489. source.Expression,
  8490. selector
  8491. )
  8492. );
  8493. }
  8494. /// <summary>
  8495. /// Invokes a transform function on each element of a sequence and returns the maximum value.
  8496. /// </summary>
  8497. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8498. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8499. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  8500. /// <param name="selector">A transform function to apply to each element.</param>
  8501. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8502. /// <exception cref="ArgumentNullException">
  8503. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8504. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8505. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  8506. {
  8507. if (source == null)
  8508. throw new ArgumentNullException(nameof(source));
  8509. if (selector == null)
  8510. throw new ArgumentNullException(nameof(selector));
  8511. return source.Provider.CreateQuery<TResult>(
  8512. Expression.Call(
  8513. null,
  8514. #if CRIPPLED_REFLECTION
  8515. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  8516. #else
  8517. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8518. #endif
  8519. source.Expression,
  8520. selector
  8521. )
  8522. );
  8523. }
  8524. /// <summary>
  8525. /// Invokes a transform function on each element of a sequence and returns the maximum value according to the specified comparer.
  8526. /// </summary>
  8527. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8528. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8529. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  8530. /// <param name="selector">A transform function to apply to each element.</param>
  8531. /// <param name="comparer">Comparer used to compare elements.</param>
  8532. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8533. /// <exception cref="ArgumentNullException">
  8534. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  8535. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8536. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  8537. {
  8538. if (source == null)
  8539. throw new ArgumentNullException(nameof(source));
  8540. if (selector == null)
  8541. throw new ArgumentNullException(nameof(selector));
  8542. if (comparer == null)
  8543. throw new ArgumentNullException(nameof(comparer));
  8544. return source.Provider.CreateQuery<TResult>(
  8545. Expression.Call(
  8546. null,
  8547. #if CRIPPLED_REFLECTION
  8548. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  8549. #else
  8550. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8551. #endif
  8552. source.Expression,
  8553. selector,
  8554. Expression.Constant(comparer, typeof(IComparer<TResult>))
  8555. )
  8556. );
  8557. }
  8558. /// <summary>
  8559. /// Returns the elements in an observable sequence with the maximum key value.
  8560. /// </summary>
  8561. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8562. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8563. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8564. /// <param name="keySelector">Key selector function.</param>
  8565. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8566. /// <exception cref="ArgumentNullException">
  8567. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  8568. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8569. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  8570. {
  8571. if (source == null)
  8572. throw new ArgumentNullException(nameof(source));
  8573. if (keySelector == null)
  8574. throw new ArgumentNullException(nameof(keySelector));
  8575. return source.Provider.CreateQuery<IList<TSource>>(
  8576. Expression.Call(
  8577. null,
  8578. #if CRIPPLED_REFLECTION
  8579. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  8580. #else
  8581. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8582. #endif
  8583. source.Expression,
  8584. keySelector
  8585. )
  8586. );
  8587. }
  8588. /// <summary>
  8589. /// Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
  8590. /// </summary>
  8591. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8592. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8593. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8594. /// <param name="keySelector">Key selector function.</param>
  8595. /// <param name="comparer">Comparer used to compare key values.</param>
  8596. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8597. /// <exception cref="ArgumentNullException">
  8598. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  8599. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8600. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  8601. {
  8602. if (source == null)
  8603. throw new ArgumentNullException(nameof(source));
  8604. if (keySelector == null)
  8605. throw new ArgumentNullException(nameof(keySelector));
  8606. if (comparer == null)
  8607. throw new ArgumentNullException(nameof(comparer));
  8608. return source.Provider.CreateQuery<IList<TSource>>(
  8609. Expression.Call(
  8610. null,
  8611. #if CRIPPLED_REFLECTION
  8612. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  8613. #else
  8614. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8615. #endif
  8616. source.Expression,
  8617. keySelector,
  8618. Expression.Constant(comparer, typeof(IComparer<TKey>))
  8619. )
  8620. );
  8621. }
  8622. /// <summary>
  8623. /// Merges elements from two observable sequences into a single observable sequence.
  8624. /// </summary>
  8625. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8626. /// <param name="first">First observable sequence.</param>
  8627. /// <param name="second">Second observable sequence.</param>
  8628. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8629. /// <exception cref="ArgumentNullException">
  8630. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  8631. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  8632. {
  8633. if (first == null)
  8634. throw new ArgumentNullException(nameof(first));
  8635. if (second == null)
  8636. throw new ArgumentNullException(nameof(second));
  8637. return first.Provider.CreateQuery<TSource>(
  8638. Expression.Call(
  8639. null,
  8640. #if CRIPPLED_REFLECTION
  8641. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  8642. #else
  8643. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8644. #endif
  8645. first.Expression,
  8646. GetSourceExpression(second)
  8647. )
  8648. );
  8649. }
  8650. /// <summary>
  8651. /// Merges elements from two observable sequences into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  8652. /// </summary>
  8653. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8654. /// <param name="first">First observable sequence.</param>
  8655. /// <param name="second">Second observable sequence.</param>
  8656. /// <param name="scheduler">Scheduler used to introduce concurrency for making subscriptions to the given sequences.</param>
  8657. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8658. /// <exception cref="ArgumentNullException">
  8659. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="scheduler" /> is null.</exception>
  8660. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IScheduler scheduler)
  8661. {
  8662. if (first == null)
  8663. throw new ArgumentNullException(nameof(first));
  8664. if (second == null)
  8665. throw new ArgumentNullException(nameof(second));
  8666. if (scheduler == null)
  8667. throw new ArgumentNullException(nameof(scheduler));
  8668. return first.Provider.CreateQuery<TSource>(
  8669. Expression.Call(
  8670. null,
  8671. #if CRIPPLED_REFLECTION
  8672. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IScheduler))),
  8673. #else
  8674. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8675. #endif
  8676. first.Expression,
  8677. GetSourceExpression(second),
  8678. Expression.Constant(scheduler, typeof(IScheduler))
  8679. )
  8680. );
  8681. }
  8682. /// <summary>
  8683. /// Merges elements from all of the specified observable sequences into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  8684. /// </summary>
  8685. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8686. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8687. /// <param name="sources">Observable sequences.</param>
  8688. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8689. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8690. /// <exception cref="ArgumentNullException">
  8691. /// <paramref name="scheduler" /> or <paramref name="sources" /> is null.</exception>
  8692. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IScheduler scheduler, params IObservable<TSource>[] sources)
  8693. {
  8694. if (provider == null)
  8695. throw new ArgumentNullException(nameof(provider));
  8696. if (scheduler == null)
  8697. throw new ArgumentNullException(nameof(scheduler));
  8698. if (sources == null)
  8699. throw new ArgumentNullException(nameof(sources));
  8700. return provider.CreateQuery<TSource>(
  8701. Expression.Call(
  8702. null,
  8703. #if CRIPPLED_REFLECTION
  8704. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IScheduler), default(IObservable<TSource>[]))),
  8705. #else
  8706. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8707. #endif
  8708. Expression.Constant(provider, typeof(IQbservableProvider)),
  8709. Expression.Constant(scheduler, typeof(IScheduler)),
  8710. GetSourceExpression(sources)
  8711. )
  8712. );
  8713. }
  8714. /// <summary>
  8715. /// Merges elements from all inner observable sequences into a single observable sequence.
  8716. /// </summary>
  8717. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8718. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8719. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8720. /// <exception cref="ArgumentNullException">
  8721. /// <paramref name="sources" /> is null.</exception>
  8722. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources)
  8723. {
  8724. if (sources == null)
  8725. throw new ArgumentNullException(nameof(sources));
  8726. return sources.Provider.CreateQuery<TSource>(
  8727. Expression.Call(
  8728. null,
  8729. #if CRIPPLED_REFLECTION
  8730. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>))),
  8731. #else
  8732. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8733. #endif
  8734. sources.Expression
  8735. )
  8736. );
  8737. }
  8738. /// <summary>
  8739. /// Merges results from all source tasks into a single observable sequence.
  8740. /// </summary>
  8741. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  8742. /// <param name="sources">Observable sequence of tasks.</param>
  8743. /// <returns>The observable sequence that merges the results of the source tasks.</returns>
  8744. /// <exception cref="ArgumentNullException">
  8745. /// <paramref name="sources" /> is null.</exception>
  8746. /// <remarks>If the tasks support cancellation, consider manual conversion of the tasks using <see cref="M:System.Reactive.Linq.Observable.FromAsync``1(System.Func{System.Threading.CancellationToken,System.Threading.Tasks.Task{``0}})" />, followed by a merge operation using <see cref="M:System.Reactive.Linq.Observable.Merge``1(System.IObservable{System.IObservable{``0}})" />.</remarks>
  8747. public static IQbservable<TSource> Merge<TSource>(this IQbservable<Task<TSource>> sources)
  8748. {
  8749. if (sources == null)
  8750. throw new ArgumentNullException(nameof(sources));
  8751. return sources.Provider.CreateQuery<TSource>(
  8752. Expression.Call(
  8753. null,
  8754. #if CRIPPLED_REFLECTION
  8755. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<Task<TSource>>))),
  8756. #else
  8757. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8758. #endif
  8759. sources.Expression
  8760. )
  8761. );
  8762. }
  8763. /// <summary>
  8764. /// Merges elements from all of the specified observable sequences into a single observable sequence.
  8765. /// </summary>
  8766. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8767. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8768. /// <param name="sources">Observable sequences.</param>
  8769. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8770. /// <exception cref="ArgumentNullException">
  8771. /// <paramref name="sources" /> is null.</exception>
  8772. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  8773. {
  8774. if (provider == null)
  8775. throw new ArgumentNullException(nameof(provider));
  8776. if (sources == null)
  8777. throw new ArgumentNullException(nameof(sources));
  8778. return provider.CreateQuery<TSource>(
  8779. Expression.Call(
  8780. null,
  8781. #if CRIPPLED_REFLECTION
  8782. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  8783. #else
  8784. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8785. #endif
  8786. Expression.Constant(provider, typeof(IQbservableProvider)),
  8787. GetSourceExpression(sources)
  8788. )
  8789. );
  8790. }
  8791. /// <summary>
  8792. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence.
  8793. /// </summary>
  8794. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8795. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8796. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8797. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8798. /// <exception cref="ArgumentNullException">
  8799. /// <paramref name="sources" /> is null.</exception>
  8800. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  8801. {
  8802. if (provider == null)
  8803. throw new ArgumentNullException(nameof(provider));
  8804. if (sources == null)
  8805. throw new ArgumentNullException(nameof(sources));
  8806. return provider.CreateQuery<TSource>(
  8807. Expression.Call(
  8808. null,
  8809. #if CRIPPLED_REFLECTION
  8810. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  8811. #else
  8812. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8813. #endif
  8814. Expression.Constant(provider, typeof(IQbservableProvider)),
  8815. GetSourceExpression(sources)
  8816. )
  8817. );
  8818. }
  8819. /// <summary>
  8820. /// Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  8821. /// </summary>
  8822. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8823. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8824. /// <param name="maxConcurrent">Maximum number of inner observable sequences being subscribed to concurrently.</param>
  8825. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8826. /// <exception cref="ArgumentNullException">
  8827. /// <paramref name="sources" /> is null.</exception>
  8828. /// <exception cref="ArgumentOutOfRangeException">
  8829. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8830. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources, int maxConcurrent)
  8831. {
  8832. if (sources == null)
  8833. throw new ArgumentNullException(nameof(sources));
  8834. return sources.Provider.CreateQuery<TSource>(
  8835. Expression.Call(
  8836. null,
  8837. #if CRIPPLED_REFLECTION
  8838. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>), default(int))),
  8839. #else
  8840. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8841. #endif
  8842. sources.Expression,
  8843. Expression.Constant(maxConcurrent, typeof(int))
  8844. )
  8845. );
  8846. }
  8847. /// <summary>
  8848. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  8849. /// </summary>
  8850. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8851. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8852. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8853. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  8854. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8855. /// <exception cref="ArgumentNullException">
  8856. /// <paramref name="sources" /> is null.</exception>
  8857. /// <exception cref="ArgumentOutOfRangeException">
  8858. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8859. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent)
  8860. {
  8861. if (provider == null)
  8862. throw new ArgumentNullException(nameof(provider));
  8863. if (sources == null)
  8864. throw new ArgumentNullException(nameof(sources));
  8865. return provider.CreateQuery<TSource>(
  8866. Expression.Call(
  8867. null,
  8868. #if CRIPPLED_REFLECTION
  8869. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int))),
  8870. #else
  8871. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8872. #endif
  8873. Expression.Constant(provider, typeof(IQbservableProvider)),
  8874. GetSourceExpression(sources),
  8875. Expression.Constant(maxConcurrent, typeof(int))
  8876. )
  8877. );
  8878. }
  8879. /// <summary>
  8880. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences, and using the specified scheduler for enumeration of and subscription to the sources.
  8881. /// </summary>
  8882. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8883. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8884. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8885. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  8886. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8887. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8888. /// <exception cref="ArgumentNullException">
  8889. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  8890. /// <exception cref="ArgumentOutOfRangeException">
  8891. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8892. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent, IScheduler scheduler)
  8893. {
  8894. if (provider == null)
  8895. throw new ArgumentNullException(nameof(provider));
  8896. if (sources == null)
  8897. throw new ArgumentNullException(nameof(sources));
  8898. if (scheduler == null)
  8899. throw new ArgumentNullException(nameof(scheduler));
  8900. return provider.CreateQuery<TSource>(
  8901. Expression.Call(
  8902. null,
  8903. #if CRIPPLED_REFLECTION
  8904. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int), default(IScheduler))),
  8905. #else
  8906. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8907. #endif
  8908. Expression.Constant(provider, typeof(IQbservableProvider)),
  8909. GetSourceExpression(sources),
  8910. Expression.Constant(maxConcurrent, typeof(int)),
  8911. Expression.Constant(scheduler, typeof(IScheduler))
  8912. )
  8913. );
  8914. }
  8915. /// <summary>
  8916. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  8917. /// </summary>
  8918. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8919. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8920. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8921. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8922. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8923. /// <exception cref="ArgumentNullException">
  8924. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  8925. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, IScheduler scheduler)
  8926. {
  8927. if (provider == null)
  8928. throw new ArgumentNullException(nameof(provider));
  8929. if (sources == null)
  8930. throw new ArgumentNullException(nameof(sources));
  8931. if (scheduler == null)
  8932. throw new ArgumentNullException(nameof(scheduler));
  8933. return provider.CreateQuery<TSource>(
  8934. Expression.Call(
  8935. null,
  8936. #if CRIPPLED_REFLECTION
  8937. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(IScheduler))),
  8938. #else
  8939. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8940. #endif
  8941. Expression.Constant(provider, typeof(IQbservableProvider)),
  8942. GetSourceExpression(sources),
  8943. Expression.Constant(scheduler, typeof(IScheduler))
  8944. )
  8945. );
  8946. }
  8947. /// <summary>
  8948. /// Returns the minimum value in an observable sequence of <see cref="Decimal" /> values.
  8949. /// </summary>
  8950. /// <param name="source">A sequence of <see cref="Decimal" /> values to determine the minimum value of.</param>
  8951. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8952. /// <exception cref="ArgumentNullException">
  8953. /// <paramref name="source" /> is null.</exception>
  8954. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8955. public static IQbservable<decimal> Min(this IQbservable<decimal> source)
  8956. {
  8957. if (source == null)
  8958. throw new ArgumentNullException(nameof(source));
  8959. return source.Provider.CreateQuery<decimal>(
  8960. Expression.Call(
  8961. null,
  8962. #if CRIPPLED_REFLECTION
  8963. InfoOf(() => Qbservable.Min(default(IQbservable<decimal>))),
  8964. #else
  8965. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8966. #endif
  8967. source.Expression
  8968. )
  8969. );
  8970. }
  8971. /// <summary>
  8972. /// Returns the minimum value in an observable sequence of <see cref="double" /> values.
  8973. /// </summary>
  8974. /// <param name="source">A sequence of <see cref="double" /> values to determine the minimum value of.</param>
  8975. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8976. /// <exception cref="ArgumentNullException">
  8977. /// <paramref name="source" /> is null.</exception>
  8978. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8979. public static IQbservable<double> Min(this IQbservable<double> source)
  8980. {
  8981. if (source == null)
  8982. throw new ArgumentNullException(nameof(source));
  8983. return source.Provider.CreateQuery<double>(
  8984. Expression.Call(
  8985. null,
  8986. #if CRIPPLED_REFLECTION
  8987. InfoOf(() => Qbservable.Min(default(IQbservable<double>))),
  8988. #else
  8989. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8990. #endif
  8991. source.Expression
  8992. )
  8993. );
  8994. }
  8995. /// <summary>
  8996. /// Returns the minimum value in an observable sequence of <see cref="int" /> values.
  8997. /// </summary>
  8998. /// <param name="source">A sequence of <see cref="int" /> values to determine the minimum value of.</param>
  8999. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9000. /// <exception cref="ArgumentNullException">
  9001. /// <paramref name="source" /> is null.</exception>
  9002. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9003. public static IQbservable<int> Min(this IQbservable<int> source)
  9004. {
  9005. if (source == null)
  9006. throw new ArgumentNullException(nameof(source));
  9007. return source.Provider.CreateQuery<int>(
  9008. Expression.Call(
  9009. null,
  9010. #if CRIPPLED_REFLECTION
  9011. InfoOf(() => Qbservable.Min(default(IQbservable<int>))),
  9012. #else
  9013. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9014. #endif
  9015. source.Expression
  9016. )
  9017. );
  9018. }
  9019. /// <summary>
  9020. /// Returns the minimum value in an observable sequence of <see cref="long" /> values.
  9021. /// </summary>
  9022. /// <param name="source">A sequence of <see cref="long" /> values to determine the minimum value of.</param>
  9023. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9024. /// <exception cref="ArgumentNullException">
  9025. /// <paramref name="source" /> is null.</exception>
  9026. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9027. public static IQbservable<long> Min(this IQbservable<long> source)
  9028. {
  9029. if (source == null)
  9030. throw new ArgumentNullException(nameof(source));
  9031. return source.Provider.CreateQuery<long>(
  9032. Expression.Call(
  9033. null,
  9034. #if CRIPPLED_REFLECTION
  9035. InfoOf(() => Qbservable.Min(default(IQbservable<long>))),
  9036. #else
  9037. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9038. #endif
  9039. source.Expression
  9040. )
  9041. );
  9042. }
  9043. /// <summary>
  9044. /// Returns the minimum value in an observable sequence of nullable <see cref="Decimal" /> values.
  9045. /// </summary>
  9046. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to determine the minimum value of.</param>
  9047. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9048. /// <exception cref="ArgumentNullException">
  9049. /// <paramref name="source" /> is null.</exception>
  9050. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9051. public static IQbservable<decimal?> Min(this IQbservable<decimal?> source)
  9052. {
  9053. if (source == null)
  9054. throw new ArgumentNullException(nameof(source));
  9055. return source.Provider.CreateQuery<decimal?>(
  9056. Expression.Call(
  9057. null,
  9058. #if CRIPPLED_REFLECTION
  9059. InfoOf(() => Qbservable.Min(default(IQbservable<decimal?>))),
  9060. #else
  9061. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9062. #endif
  9063. source.Expression
  9064. )
  9065. );
  9066. }
  9067. /// <summary>
  9068. /// Returns the minimum value in an observable sequence of nullable <see cref="double" /> values.
  9069. /// </summary>
  9070. /// <param name="source">A sequence of nullable <see cref="double" /> values to determine the minimum value of.</param>
  9071. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9072. /// <exception cref="ArgumentNullException">
  9073. /// <paramref name="source" /> is null.</exception>
  9074. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9075. public static IQbservable<double?> Min(this IQbservable<double?> source)
  9076. {
  9077. if (source == null)
  9078. throw new ArgumentNullException(nameof(source));
  9079. return source.Provider.CreateQuery<double?>(
  9080. Expression.Call(
  9081. null,
  9082. #if CRIPPLED_REFLECTION
  9083. InfoOf(() => Qbservable.Min(default(IQbservable<double?>))),
  9084. #else
  9085. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9086. #endif
  9087. source.Expression
  9088. )
  9089. );
  9090. }
  9091. /// <summary>
  9092. /// Returns the minimum value in an observable sequence of nullable <see cref="int" /> values.
  9093. /// </summary>
  9094. /// <param name="source">A sequence of nullable <see cref="int" /> values to determine the minimum value of.</param>
  9095. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9096. /// <exception cref="ArgumentNullException">
  9097. /// <paramref name="source" /> is null.</exception>
  9098. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9099. public static IQbservable<int?> Min(this IQbservable<int?> source)
  9100. {
  9101. if (source == null)
  9102. throw new ArgumentNullException(nameof(source));
  9103. return source.Provider.CreateQuery<int?>(
  9104. Expression.Call(
  9105. null,
  9106. #if CRIPPLED_REFLECTION
  9107. InfoOf(() => Qbservable.Min(default(IQbservable<int?>))),
  9108. #else
  9109. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9110. #endif
  9111. source.Expression
  9112. )
  9113. );
  9114. }
  9115. /// <summary>
  9116. /// Returns the minimum value in an observable sequence of nullable <see cref="long" /> values.
  9117. /// </summary>
  9118. /// <param name="source">A sequence of nullable <see cref="long" /> values to determine the minimum value of.</param>
  9119. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9120. /// <exception cref="ArgumentNullException">
  9121. /// <paramref name="source" /> is null.</exception>
  9122. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9123. public static IQbservable<long?> Min(this IQbservable<long?> source)
  9124. {
  9125. if (source == null)
  9126. throw new ArgumentNullException(nameof(source));
  9127. return source.Provider.CreateQuery<long?>(
  9128. Expression.Call(
  9129. null,
  9130. #if CRIPPLED_REFLECTION
  9131. InfoOf(() => Qbservable.Min(default(IQbservable<long?>))),
  9132. #else
  9133. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9134. #endif
  9135. source.Expression
  9136. )
  9137. );
  9138. }
  9139. /// <summary>
  9140. /// Returns the minimum value in an observable sequence of nullable <see cref="Single" /> values.
  9141. /// </summary>
  9142. /// <param name="source">A sequence of nullable <see cref="Single" /> values to determine the minimum value of.</param>
  9143. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9144. /// <exception cref="ArgumentNullException">
  9145. /// <paramref name="source" /> is null.</exception>
  9146. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9147. public static IQbservable<float?> Min(this IQbservable<float?> source)
  9148. {
  9149. if (source == null)
  9150. throw new ArgumentNullException(nameof(source));
  9151. return source.Provider.CreateQuery<float?>(
  9152. Expression.Call(
  9153. null,
  9154. #if CRIPPLED_REFLECTION
  9155. InfoOf(() => Qbservable.Min(default(IQbservable<float?>))),
  9156. #else
  9157. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9158. #endif
  9159. source.Expression
  9160. )
  9161. );
  9162. }
  9163. /// <summary>
  9164. /// Returns the minimum value in an observable sequence of <see cref="Single" /> values.
  9165. /// </summary>
  9166. /// <param name="source">A sequence of <see cref="Single" /> values to determine the minimum value of.</param>
  9167. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9168. /// <exception cref="ArgumentNullException">
  9169. /// <paramref name="source" /> is null.</exception>
  9170. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9171. public static IQbservable<float> Min(this IQbservable<float> source)
  9172. {
  9173. if (source == null)
  9174. throw new ArgumentNullException(nameof(source));
  9175. return source.Provider.CreateQuery<float>(
  9176. Expression.Call(
  9177. null,
  9178. #if CRIPPLED_REFLECTION
  9179. InfoOf(() => Qbservable.Min(default(IQbservable<float>))),
  9180. #else
  9181. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9182. #endif
  9183. source.Expression
  9184. )
  9185. );
  9186. }
  9187. /// <summary>
  9188. /// Returns the minimum element in an observable sequence.
  9189. /// </summary>
  9190. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9191. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9192. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9193. /// <exception cref="ArgumentNullException">
  9194. /// <paramref name="source" /> is null.</exception>
  9195. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9196. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source)
  9197. {
  9198. if (source == null)
  9199. throw new ArgumentNullException(nameof(source));
  9200. return source.Provider.CreateQuery<TSource>(
  9201. Expression.Call(
  9202. null,
  9203. #if CRIPPLED_REFLECTION
  9204. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>))),
  9205. #else
  9206. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9207. #endif
  9208. source.Expression
  9209. )
  9210. );
  9211. }
  9212. /// <summary>
  9213. /// Returns the minimum element in an observable sequence according to the specified comparer.
  9214. /// </summary>
  9215. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9216. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9217. /// <param name="comparer">Comparer used to compare elements.</param>
  9218. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9219. /// <exception cref="ArgumentNullException">
  9220. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  9221. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9222. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  9223. {
  9224. if (source == null)
  9225. throw new ArgumentNullException(nameof(source));
  9226. if (comparer == null)
  9227. throw new ArgumentNullException(nameof(comparer));
  9228. return source.Provider.CreateQuery<TSource>(
  9229. Expression.Call(
  9230. null,
  9231. #if CRIPPLED_REFLECTION
  9232. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  9233. #else
  9234. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9235. #endif
  9236. source.Expression,
  9237. Expression.Constant(comparer, typeof(IComparer<TSource>))
  9238. )
  9239. );
  9240. }
  9241. /// <summary>
  9242. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="double" /> value.
  9243. /// </summary>
  9244. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9245. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9246. /// <param name="selector">A transform function to apply to each element.</param>
  9247. /// <returns>An observable sequence containing a single element with the value of type <see cref="double" /> that corresponds to the minimum value in the source sequence.</returns>
  9248. /// <exception cref="ArgumentNullException">
  9249. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9250. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9251. public static IQbservable<double> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  9252. {
  9253. if (source == null)
  9254. throw new ArgumentNullException(nameof(source));
  9255. if (selector == null)
  9256. throw new ArgumentNullException(nameof(selector));
  9257. return source.Provider.CreateQuery<double>(
  9258. Expression.Call(
  9259. null,
  9260. #if CRIPPLED_REFLECTION
  9261. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  9262. #else
  9263. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9264. #endif
  9265. source.Expression,
  9266. selector
  9267. )
  9268. );
  9269. }
  9270. /// <summary>
  9271. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="Single" /> value.
  9272. /// </summary>
  9273. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9274. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9275. /// <param name="selector">A transform function to apply to each element.</param>
  9276. /// <returns>An observable sequence containing a single element with the value of type <see cref="Single" /> that corresponds to the minimum value in the source sequence.</returns>
  9277. /// <exception cref="ArgumentNullException">
  9278. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9279. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9280. public static IQbservable<float> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  9281. {
  9282. if (source == null)
  9283. throw new ArgumentNullException(nameof(source));
  9284. if (selector == null)
  9285. throw new ArgumentNullException(nameof(selector));
  9286. return source.Provider.CreateQuery<float>(
  9287. Expression.Call(
  9288. null,
  9289. #if CRIPPLED_REFLECTION
  9290. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  9291. #else
  9292. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9293. #endif
  9294. source.Expression,
  9295. selector
  9296. )
  9297. );
  9298. }
  9299. /// <summary>
  9300. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="Decimal" /> value.
  9301. /// </summary>
  9302. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9303. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9304. /// <param name="selector">A transform function to apply to each element.</param>
  9305. /// <returns>An observable sequence containing a single element with the value of type <see cref="Decimal" /> that corresponds to the minimum value in the source sequence.</returns>
  9306. /// <exception cref="ArgumentNullException">
  9307. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9308. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9309. public static IQbservable<decimal> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  9310. {
  9311. if (source == null)
  9312. throw new ArgumentNullException(nameof(source));
  9313. if (selector == null)
  9314. throw new ArgumentNullException(nameof(selector));
  9315. return source.Provider.CreateQuery<decimal>(
  9316. Expression.Call(
  9317. null,
  9318. #if CRIPPLED_REFLECTION
  9319. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  9320. #else
  9321. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9322. #endif
  9323. source.Expression,
  9324. selector
  9325. )
  9326. );
  9327. }
  9328. /// <summary>
  9329. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="int" /> value.
  9330. /// </summary>
  9331. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9332. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9333. /// <param name="selector">A transform function to apply to each element.</param>
  9334. /// <returns>An observable sequence containing a single element with the value of type <see cref="int" /> that corresponds to the minimum value in the source sequence.</returns>
  9335. /// <exception cref="ArgumentNullException">
  9336. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9337. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9338. public static IQbservable<int> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  9339. {
  9340. if (source == null)
  9341. throw new ArgumentNullException(nameof(source));
  9342. if (selector == null)
  9343. throw new ArgumentNullException(nameof(selector));
  9344. return source.Provider.CreateQuery<int>(
  9345. Expression.Call(
  9346. null,
  9347. #if CRIPPLED_REFLECTION
  9348. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  9349. #else
  9350. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9351. #endif
  9352. source.Expression,
  9353. selector
  9354. )
  9355. );
  9356. }
  9357. /// <summary>
  9358. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="long" /> value.
  9359. /// </summary>
  9360. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9361. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9362. /// <param name="selector">A transform function to apply to each element.</param>
  9363. /// <returns>An observable sequence containing a single element with the value of type <see cref="long" /> that corresponds to the minimum value in the source sequence.</returns>
  9364. /// <exception cref="ArgumentNullException">
  9365. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9366. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9367. public static IQbservable<long> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  9368. {
  9369. if (source == null)
  9370. throw new ArgumentNullException(nameof(source));
  9371. if (selector == null)
  9372. throw new ArgumentNullException(nameof(selector));
  9373. return source.Provider.CreateQuery<long>(
  9374. Expression.Call(
  9375. null,
  9376. #if CRIPPLED_REFLECTION
  9377. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  9378. #else
  9379. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9380. #endif
  9381. source.Expression,
  9382. selector
  9383. )
  9384. );
  9385. }
  9386. /// <summary>
  9387. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="double" /> value.
  9388. /// </summary>
  9389. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9390. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9391. /// <param name="selector">A transform function to apply to each element.</param>
  9392. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable`1" /> that corresponds to the minimum value in the source sequence.</returns>
  9393. /// <exception cref="ArgumentNullException">
  9394. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9395. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9396. public static IQbservable<double?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  9397. {
  9398. if (source == null)
  9399. throw new ArgumentNullException(nameof(source));
  9400. if (selector == null)
  9401. throw new ArgumentNullException(nameof(selector));
  9402. return source.Provider.CreateQuery<double?>(
  9403. Expression.Call(
  9404. null,
  9405. #if CRIPPLED_REFLECTION
  9406. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  9407. #else
  9408. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9409. #endif
  9410. source.Expression,
  9411. selector
  9412. )
  9413. );
  9414. }
  9415. /// <summary>
  9416. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="Single" /> value.
  9417. /// </summary>
  9418. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9419. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9420. /// <param name="selector">A transform function to apply to each element.</param>
  9421. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable`1" /> that corresponds to the minimum value in the source sequence.</returns>
  9422. /// <exception cref="ArgumentNullException">
  9423. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9424. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9425. public static IQbservable<float?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  9426. {
  9427. if (source == null)
  9428. throw new ArgumentNullException(nameof(source));
  9429. if (selector == null)
  9430. throw new ArgumentNullException(nameof(selector));
  9431. return source.Provider.CreateQuery<float?>(
  9432. Expression.Call(
  9433. null,
  9434. #if CRIPPLED_REFLECTION
  9435. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  9436. #else
  9437. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9438. #endif
  9439. source.Expression,
  9440. selector
  9441. )
  9442. );
  9443. }
  9444. /// <summary>
  9445. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="Decimal" /> value.
  9446. /// </summary>
  9447. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9448. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9449. /// <param name="selector">A transform function to apply to each element.</param>
  9450. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable`1" /> that corresponds to the minimum value in the source sequence.</returns>
  9451. /// <exception cref="ArgumentNullException">
  9452. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9453. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9454. public static IQbservable<decimal?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  9455. {
  9456. if (source == null)
  9457. throw new ArgumentNullException(nameof(source));
  9458. if (selector == null)
  9459. throw new ArgumentNullException(nameof(selector));
  9460. return source.Provider.CreateQuery<decimal?>(
  9461. Expression.Call(
  9462. null,
  9463. #if CRIPPLED_REFLECTION
  9464. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  9465. #else
  9466. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9467. #endif
  9468. source.Expression,
  9469. selector
  9470. )
  9471. );
  9472. }
  9473. /// <summary>
  9474. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="int" /> value.
  9475. /// </summary>
  9476. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9477. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9478. /// <param name="selector">A transform function to apply to each element.</param>
  9479. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable`1" /> that corresponds to the minimum value in the source sequence.</returns>
  9480. /// <exception cref="ArgumentNullException">
  9481. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9482. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9483. public static IQbservable<int?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  9484. {
  9485. if (source == null)
  9486. throw new ArgumentNullException(nameof(source));
  9487. if (selector == null)
  9488. throw new ArgumentNullException(nameof(selector));
  9489. return source.Provider.CreateQuery<int?>(
  9490. Expression.Call(
  9491. null,
  9492. #if CRIPPLED_REFLECTION
  9493. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  9494. #else
  9495. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9496. #endif
  9497. source.Expression,
  9498. selector
  9499. )
  9500. );
  9501. }
  9502. /// <summary>
  9503. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="long" /> value.
  9504. /// </summary>
  9505. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9506. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9507. /// <param name="selector">A transform function to apply to each element.</param>
  9508. /// <returns>An observable sequence containing a single element with the value of type <see cref="T:System.Nullable`1" /> that corresponds to the minimum value in the source sequence.</returns>
  9509. /// <exception cref="ArgumentNullException">
  9510. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9511. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9512. public static IQbservable<long?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  9513. {
  9514. if (source == null)
  9515. throw new ArgumentNullException(nameof(source));
  9516. if (selector == null)
  9517. throw new ArgumentNullException(nameof(selector));
  9518. return source.Provider.CreateQuery<long?>(
  9519. Expression.Call(
  9520. null,
  9521. #if CRIPPLED_REFLECTION
  9522. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  9523. #else
  9524. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9525. #endif
  9526. source.Expression,
  9527. selector
  9528. )
  9529. );
  9530. }
  9531. /// <summary>
  9532. /// Invokes a transform function on each element of a sequence and returns the minimum value.
  9533. /// </summary>
  9534. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9535. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9536. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9537. /// <param name="selector">A transform function to apply to each element.</param>
  9538. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9539. /// <exception cref="ArgumentNullException">
  9540. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9541. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9542. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  9543. {
  9544. if (source == null)
  9545. throw new ArgumentNullException(nameof(source));
  9546. if (selector == null)
  9547. throw new ArgumentNullException(nameof(selector));
  9548. return source.Provider.CreateQuery<TResult>(
  9549. Expression.Call(
  9550. null,
  9551. #if CRIPPLED_REFLECTION
  9552. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  9553. #else
  9554. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9555. #endif
  9556. source.Expression,
  9557. selector
  9558. )
  9559. );
  9560. }
  9561. /// <summary>
  9562. /// Invokes a transform function on each element of a sequence and returns the minimum value according to the specified comparer.
  9563. /// </summary>
  9564. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9565. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9566. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9567. /// <param name="selector">A transform function to apply to each element.</param>
  9568. /// <param name="comparer">Comparer used to compare elements.</param>
  9569. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9570. /// <exception cref="ArgumentNullException">
  9571. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  9572. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9573. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  9574. {
  9575. if (source == null)
  9576. throw new ArgumentNullException(nameof(source));
  9577. if (selector == null)
  9578. throw new ArgumentNullException(nameof(selector));
  9579. if (comparer == null)
  9580. throw new ArgumentNullException(nameof(comparer));
  9581. return source.Provider.CreateQuery<TResult>(
  9582. Expression.Call(
  9583. null,
  9584. #if CRIPPLED_REFLECTION
  9585. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  9586. #else
  9587. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9588. #endif
  9589. source.Expression,
  9590. selector,
  9591. Expression.Constant(comparer, typeof(IComparer<TResult>))
  9592. )
  9593. );
  9594. }
  9595. /// <summary>
  9596. /// Returns the elements in an observable sequence with the minimum key value.
  9597. /// </summary>
  9598. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9599. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9600. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9601. /// <param name="keySelector">Key selector function.</param>
  9602. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9603. /// <exception cref="ArgumentNullException">
  9604. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  9605. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9606. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  9607. {
  9608. if (source == null)
  9609. throw new ArgumentNullException(nameof(source));
  9610. if (keySelector == null)
  9611. throw new ArgumentNullException(nameof(keySelector));
  9612. return source.Provider.CreateQuery<IList<TSource>>(
  9613. Expression.Call(
  9614. null,
  9615. #if CRIPPLED_REFLECTION
  9616. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  9617. #else
  9618. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9619. #endif
  9620. source.Expression,
  9621. keySelector
  9622. )
  9623. );
  9624. }
  9625. /// <summary>
  9626. /// Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
  9627. /// </summary>
  9628. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9629. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9630. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9631. /// <param name="keySelector">Key selector function.</param>
  9632. /// <param name="comparer">Comparer used to compare key values.</param>
  9633. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9634. /// <exception cref="ArgumentNullException">
  9635. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  9636. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9637. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  9638. {
  9639. if (source == null)
  9640. throw new ArgumentNullException(nameof(source));
  9641. if (keySelector == null)
  9642. throw new ArgumentNullException(nameof(keySelector));
  9643. if (comparer == null)
  9644. throw new ArgumentNullException(nameof(comparer));
  9645. return source.Provider.CreateQuery<IList<TSource>>(
  9646. Expression.Call(
  9647. null,
  9648. #if CRIPPLED_REFLECTION
  9649. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  9650. #else
  9651. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9652. #endif
  9653. source.Expression,
  9654. keySelector,
  9655. Expression.Constant(comparer, typeof(IComparer<TKey>))
  9656. )
  9657. );
  9658. }
  9659. /// <summary>
  9660. /// Returns an enumerable sequence whose enumeration returns the most recently observed element in the source observable sequence, using the specified initial value in case no element has been sampled yet.
  9661. /// Enumerators on the resulting sequence never block and can produce the same element repeatedly.
  9662. /// </summary>
  9663. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9664. /// <param name="source">Source observable sequence.</param>
  9665. /// <param name="initialValue">Initial value that will be yielded by the enumerable sequence if no element has been sampled yet.</param>
  9666. /// <returns>The enumerable sequence that returns the last sampled element upon each iteration.</returns>
  9667. /// <exception cref="ArgumentNullException">
  9668. /// <paramref name="source" /> is null.</exception>
  9669. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9670. public static IQueryable<TSource> MostRecent<TSource>(this IQbservable<TSource> source, TSource initialValue)
  9671. {
  9672. if (source == null)
  9673. throw new ArgumentNullException(nameof(source));
  9674. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9675. Expression.Call(
  9676. null,
  9677. #if CRIPPLED_REFLECTION
  9678. InfoOf(() => Qbservable.MostRecent<TSource>(default(IQbservable<TSource>), default(TSource))),
  9679. #else
  9680. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9681. #endif
  9682. source.Expression,
  9683. Expression.Constant(initialValue, typeof(TSource))
  9684. )
  9685. );
  9686. }
  9687. /// <summary>
  9688. /// Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
  9689. /// subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
  9690. /// invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
  9691. /// </summary>
  9692. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9693. /// <typeparam name="TIntermediate">The type of the elements produced by the intermediate subject.</typeparam>
  9694. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9695. /// <param name="source">Source sequence which will be multicasted in the specified selector function.</param>
  9696. /// <param name="subjectSelector">Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function.</param>
  9697. /// <param name="selector">Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject.</param>
  9698. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9699. /// <exception cref="ArgumentNullException">
  9700. /// <paramref name="source" /> or <paramref name="subjectSelector" /> or <paramref name="selector" /> is null.</exception>
  9701. public static IQbservable<TResult> Multicast<TSource, TIntermediate, TResult>(this IQbservable<TSource> source, Expression<Func<ISubject<TSource, TIntermediate>>> subjectSelector, Expression<Func<IObservable<TIntermediate>, IObservable<TResult>>> selector)
  9702. {
  9703. if (source == null)
  9704. throw new ArgumentNullException(nameof(source));
  9705. if (subjectSelector == null)
  9706. throw new ArgumentNullException(nameof(subjectSelector));
  9707. if (selector == null)
  9708. throw new ArgumentNullException(nameof(selector));
  9709. return source.Provider.CreateQuery<TResult>(
  9710. Expression.Call(
  9711. null,
  9712. #if CRIPPLED_REFLECTION
  9713. InfoOf(() => Qbservable.Multicast<TSource, TIntermediate, TResult>(default(IQbservable<TSource>), default(Expression<Func<ISubject<TSource, TIntermediate>>>), default(Expression<Func<IObservable<TIntermediate>, IObservable<TResult>>>))),
  9714. #else
  9715. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TIntermediate), typeof(TResult)),
  9716. #endif
  9717. source.Expression,
  9718. subjectSelector,
  9719. selector
  9720. )
  9721. );
  9722. }
  9723. /// <summary>
  9724. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9725. /// </summary>
  9726. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9727. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  9728. /// <returns>An observable sequence whose observers will never get called.</returns>
  9729. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider)
  9730. {
  9731. if (provider == null)
  9732. throw new ArgumentNullException(nameof(provider));
  9733. return provider.CreateQuery<TResult>(
  9734. Expression.Call(
  9735. null,
  9736. #if CRIPPLED_REFLECTION
  9737. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider))),
  9738. #else
  9739. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9740. #endif
  9741. Expression.Constant(provider, typeof(IQbservableProvider))
  9742. )
  9743. );
  9744. }
  9745. /// <summary>
  9746. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9747. /// </summary>
  9748. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9749. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  9750. /// <param name="witness">Object solely used to infer the type of the <typeparamref name="TResult" /> type parameter. This parameter is typically used when creating a sequence of anonymously typed elements.</param>
  9751. /// <returns>An observable sequence whose observers will never get called.</returns>
  9752. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider, TResult witness)
  9753. {
  9754. if (provider == null)
  9755. throw new ArgumentNullException(nameof(provider));
  9756. return provider.CreateQuery<TResult>(
  9757. Expression.Call(
  9758. null,
  9759. #if CRIPPLED_REFLECTION
  9760. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider), default(TResult))),
  9761. #else
  9762. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9763. #endif
  9764. Expression.Constant(provider, typeof(IQbservableProvider)),
  9765. Expression.Constant(witness, typeof(TResult))
  9766. )
  9767. );
  9768. }
  9769. /// <summary>
  9770. /// Returns an enumerable sequence whose enumeration blocks until the next element in the source observable sequence becomes available.
  9771. /// Enumerators on the resulting sequence will block until the next element becomes available.
  9772. /// </summary>
  9773. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9774. /// <param name="source">Source observable sequence.</param>
  9775. /// <returns>The enumerable sequence that blocks upon each iteration until the next element in the observable source sequence becomes available.</returns>
  9776. /// <exception cref="ArgumentNullException">
  9777. /// <paramref name="source" /> is null.</exception>
  9778. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9779. public static IQueryable<TSource> Next<TSource>(this IQbservable<TSource> source)
  9780. {
  9781. if (source == null)
  9782. throw new ArgumentNullException(nameof(source));
  9783. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9784. Expression.Call(
  9785. null,
  9786. #if CRIPPLED_REFLECTION
  9787. InfoOf(() => Qbservable.Next<TSource>(default(IQbservable<TSource>))),
  9788. #else
  9789. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9790. #endif
  9791. source.Expression
  9792. )
  9793. );
  9794. }
  9795. /// <summary>
  9796. /// Wraps the source sequence in order to run its observer callbacks on the specified synchronization context.
  9797. /// </summary>
  9798. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9799. /// <param name="source">Source sequence.</param>
  9800. /// <param name="context">Synchronization context to notify observers on.</param>
  9801. /// <returns>The source sequence whose observations happen on the specified synchronization context.</returns>
  9802. /// <exception cref="ArgumentNullException">
  9803. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  9804. /// <remarks>
  9805. /// This only invokes observer callbacks on a synchronization context. In case the subscription and/or unsubscription actions have side-effects
  9806. /// that require to be run on a synchronization context, use <see cref="M:System.Reactive.Linq.Observable.SubscribeOn``1(System.IObservable{``0},System.Threading.SynchronizationContext)" />.
  9807. /// </remarks>
  9808. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  9809. {
  9810. if (source == null)
  9811. throw new ArgumentNullException(nameof(source));
  9812. if (context == null)
  9813. throw new ArgumentNullException(nameof(context));
  9814. return source.Provider.CreateQuery<TSource>(
  9815. Expression.Call(
  9816. null,
  9817. #if CRIPPLED_REFLECTION
  9818. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  9819. #else
  9820. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9821. #endif
  9822. source.Expression,
  9823. Expression.Constant(context, typeof(SynchronizationContext))
  9824. )
  9825. );
  9826. }
  9827. /// <summary>
  9828. /// Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
  9829. /// </summary>
  9830. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9831. /// <param name="source">Source sequence.</param>
  9832. /// <param name="scheduler">Scheduler to notify observers on.</param>
  9833. /// <returns>The source sequence whose observations happen on the specified scheduler.</returns>
  9834. /// <exception cref="ArgumentNullException">
  9835. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  9836. /// <remarks>
  9837. /// This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
  9838. /// that require to be run on a scheduler, use <see cref="M:System.Reactive.Linq.Observable.SubscribeOn``1(System.IObservable{``0},System.Reactive.Concurrency.IScheduler)" />.
  9839. /// </remarks>
  9840. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  9841. {
  9842. if (source == null)
  9843. throw new ArgumentNullException(nameof(source));
  9844. if (scheduler == null)
  9845. throw new ArgumentNullException(nameof(scheduler));
  9846. return source.Provider.CreateQuery<TSource>(
  9847. Expression.Call(
  9848. null,
  9849. #if CRIPPLED_REFLECTION
  9850. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  9851. #else
  9852. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9853. #endif
  9854. source.Expression,
  9855. Expression.Constant(scheduler, typeof(IScheduler))
  9856. )
  9857. );
  9858. }
  9859. /// <summary>
  9860. /// Filters the elements of an observable sequence based on the specified type.
  9861. /// </summary>
  9862. /// <typeparam name="TResult">The type to filter the elements in the source sequence on.</typeparam>
  9863. /// <param name="source">The observable sequence that contains the elements to be filtered.</param>
  9864. /// <returns>An observable sequence that contains elements from the input sequence of type TResult.</returns>
  9865. /// <exception cref="ArgumentNullException">
  9866. /// <paramref name="source" /> is null.</exception>
  9867. public static IQbservable<TResult> OfType<TResult>(this IQbservable<object> source)
  9868. {
  9869. if (source == null)
  9870. throw new ArgumentNullException(nameof(source));
  9871. return source.Provider.CreateQuery<TResult>(
  9872. Expression.Call(
  9873. null,
  9874. #if CRIPPLED_REFLECTION
  9875. InfoOf(() => Qbservable.OfType<TResult>(default(IQbservable<object>))),
  9876. #else
  9877. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9878. #endif
  9879. source.Expression
  9880. )
  9881. );
  9882. }
  9883. /// <summary>
  9884. /// Concatenates the second observable sequence to the first observable sequence upon successful or exceptional termination of the first.
  9885. /// </summary>
  9886. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9887. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  9888. /// <param name="second">Second observable sequence used to produce results after the first sequence terminates.</param>
  9889. /// <returns>An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.</returns>
  9890. /// <exception cref="ArgumentNullException">
  9891. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  9892. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  9893. {
  9894. if (first == null)
  9895. throw new ArgumentNullException(nameof(first));
  9896. if (second == null)
  9897. throw new ArgumentNullException(nameof(second));
  9898. return first.Provider.CreateQuery<TSource>(
  9899. Expression.Call(
  9900. null,
  9901. #if CRIPPLED_REFLECTION
  9902. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  9903. #else
  9904. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9905. #endif
  9906. first.Expression,
  9907. GetSourceExpression(second)
  9908. )
  9909. );
  9910. }
  9911. /// <summary>
  9912. /// Concatenates all of the specified observable sequences, even if the previous observable sequence terminated exceptionally.
  9913. /// </summary>
  9914. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9915. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9916. /// <param name="sources">Observable sequences to concatenate.</param>
  9917. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  9918. /// <exception cref="ArgumentNullException">
  9919. /// <paramref name="sources" /> is null.</exception>
  9920. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  9921. {
  9922. if (provider == null)
  9923. throw new ArgumentNullException(nameof(provider));
  9924. if (sources == null)
  9925. throw new ArgumentNullException(nameof(sources));
  9926. return provider.CreateQuery<TSource>(
  9927. Expression.Call(
  9928. null,
  9929. #if CRIPPLED_REFLECTION
  9930. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  9931. #else
  9932. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9933. #endif
  9934. Expression.Constant(provider, typeof(IQbservableProvider)),
  9935. GetSourceExpression(sources)
  9936. )
  9937. );
  9938. }
  9939. /// <summary>
  9940. /// Concatenates all observable sequences in the given enumerable sequence, even if the previous observable sequence terminated exceptionally.
  9941. /// </summary>
  9942. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9943. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9944. /// <param name="sources">Observable sequences to concatenate.</param>
  9945. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  9946. /// <exception cref="ArgumentNullException">
  9947. /// <paramref name="sources" /> is null.</exception>
  9948. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  9949. {
  9950. if (provider == null)
  9951. throw new ArgumentNullException(nameof(provider));
  9952. if (sources == null)
  9953. throw new ArgumentNullException(nameof(sources));
  9954. return provider.CreateQuery<TSource>(
  9955. Expression.Call(
  9956. null,
  9957. #if CRIPPLED_REFLECTION
  9958. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  9959. #else
  9960. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9961. #endif
  9962. Expression.Constant(provider, typeof(IQbservableProvider)),
  9963. GetSourceExpression(sources)
  9964. )
  9965. );
  9966. }
  9967. /// <summary>
  9968. /// Prepend a value to an observable sequence.
  9969. /// </summary>
  9970. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9971. /// <param name="source">Source sequence to prepend the value to.</param>
  9972. /// <param name="value">Value to prepend to the specified sequence.</param>
  9973. /// <returns>The source sequence prepended with the specified value.</returns>
  9974. /// <exception cref="ArgumentNullException">
  9975. /// <paramref name="source" /> is null.</exception>
  9976. public static IQbservable<TSource> Prepend<TSource>(this IQbservable<TSource> source, TSource value)
  9977. {
  9978. if (source == null)
  9979. throw new ArgumentNullException(nameof(source));
  9980. return source.Provider.CreateQuery<TSource>(
  9981. Expression.Call(
  9982. null,
  9983. #if CRIPPLED_REFLECTION
  9984. InfoOf(() => Qbservable.Prepend<TSource>(default(IQbservable<TSource>), default(TSource))),
  9985. #else
  9986. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9987. #endif
  9988. source.Expression,
  9989. Expression.Constant(value, typeof(TSource))
  9990. )
  9991. );
  9992. }
  9993. /// <summary>
  9994. /// Prepend a value to an observable sequence.
  9995. /// </summary>
  9996. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9997. /// <param name="source">Source sequence to prepend the value to.</param>
  9998. /// <param name="value">Value to prepend to the specified sequence.</param>
  9999. /// <param name="scheduler">Scheduler to emit the prepend values on.</param>
  10000. /// <returns>The source sequence prepended with the specified value.</returns>
  10001. /// <exception cref="ArgumentNullException">
  10002. /// <paramref name="source" /> is null.</exception>
  10003. public static IQbservable<TSource> Prepend<TSource>(this IQbservable<TSource> source, TSource value, IScheduler scheduler)
  10004. {
  10005. if (source == null)
  10006. throw new ArgumentNullException(nameof(source));
  10007. if (scheduler == null)
  10008. throw new ArgumentNullException(nameof(scheduler));
  10009. return source.Provider.CreateQuery<TSource>(
  10010. Expression.Call(
  10011. null,
  10012. #if CRIPPLED_REFLECTION
  10013. InfoOf(() => Qbservable.Prepend<TSource>(default(IQbservable<TSource>), default(TSource), default(IScheduler))),
  10014. #else
  10015. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10016. #endif
  10017. source.Expression,
  10018. Expression.Constant(value, typeof(TSource)),
  10019. Expression.Constant(scheduler, typeof(IScheduler))
  10020. )
  10021. );
  10022. }
  10023. /// <summary>
  10024. /// Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence.
  10025. /// This operator is a specialization of Multicast using a regular <see cref="T:System.Reactive.Subjects.Subject`1" />.
  10026. /// </summary>
  10027. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10028. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10029. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10030. /// <param name="selector">Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all notifications of the source from the time of the subscription on.</param>
  10031. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10032. /// <exception cref="ArgumentNullException">
  10033. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10034. /// <seealso cref="T:System.Reactive.Subjects.Subject`1" />
  10035. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10036. {
  10037. if (source == null)
  10038. throw new ArgumentNullException(nameof(source));
  10039. if (selector == null)
  10040. throw new ArgumentNullException(nameof(selector));
  10041. return source.Provider.CreateQuery<TResult>(
  10042. Expression.Call(
  10043. null,
  10044. #if CRIPPLED_REFLECTION
  10045. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10046. #else
  10047. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10048. #endif
  10049. source.Expression,
  10050. selector
  10051. )
  10052. );
  10053. }
  10054. /// <summary>
  10055. /// Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence and starts with initialValue.
  10056. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.BehaviorSubject`1" />.
  10057. /// </summary>
  10058. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10059. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10060. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10061. /// <param name="selector">Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive immediately receive the initial value, followed by all notifications of the source from the time of the subscription on.</param>
  10062. /// <param name="initialValue">Initial value received by observers upon subscription.</param>
  10063. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10064. /// <exception cref="ArgumentNullException">
  10065. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10066. /// <seealso cref="T:System.Reactive.Subjects.BehaviorSubject`1" />
  10067. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TSource initialValue)
  10068. {
  10069. if (source == null)
  10070. throw new ArgumentNullException(nameof(source));
  10071. if (selector == null)
  10072. throw new ArgumentNullException(nameof(selector));
  10073. return source.Provider.CreateQuery<TResult>(
  10074. Expression.Call(
  10075. null,
  10076. #if CRIPPLED_REFLECTION
  10077. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TSource))),
  10078. #else
  10079. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10080. #endif
  10081. source.Expression,
  10082. selector,
  10083. Expression.Constant(initialValue, typeof(TSource))
  10084. )
  10085. );
  10086. }
  10087. /// <summary>
  10088. /// Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence containing only the last notification.
  10089. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.AsyncSubject`1" />.
  10090. /// </summary>
  10091. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10092. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10093. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10094. /// <param name="selector">Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will only receive the last notification of the source.</param>
  10095. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10096. /// <exception cref="ArgumentNullException">
  10097. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10098. /// <seealso cref="T:System.Reactive.Subjects.AsyncSubject`1" />
  10099. public static IQbservable<TResult> PublishLast<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10100. {
  10101. if (source == null)
  10102. throw new ArgumentNullException(nameof(source));
  10103. if (selector == null)
  10104. throw new ArgumentNullException(nameof(selector));
  10105. return source.Provider.CreateQuery<TResult>(
  10106. Expression.Call(
  10107. null,
  10108. #if CRIPPLED_REFLECTION
  10109. InfoOf(() => Qbservable.PublishLast<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10110. #else
  10111. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10112. #endif
  10113. source.Expression,
  10114. selector
  10115. )
  10116. );
  10117. }
  10118. /// <summary>
  10119. /// Generates an observable sequence of integral numbers within a specified range.
  10120. /// </summary>
  10121. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10122. /// <param name="start">The value of the first integer in the sequence.</param>
  10123. /// <param name="count">The number of sequential integers to generate.</param>
  10124. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10125. /// <exception cref="ArgumentOutOfRangeException">
  10126. /// <paramref name="count" /> is less than zero. -or- <paramref name="start" /> + <paramref name="count" /> - 1 is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
  10127. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count)
  10128. {
  10129. if (provider == null)
  10130. throw new ArgumentNullException(nameof(provider));
  10131. return provider.CreateQuery<int>(
  10132. Expression.Call(
  10133. null,
  10134. #if CRIPPLED_REFLECTION
  10135. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int))),
  10136. #else
  10137. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10138. #endif
  10139. Expression.Constant(provider, typeof(IQbservableProvider)),
  10140. Expression.Constant(start, typeof(int)),
  10141. Expression.Constant(count, typeof(int))
  10142. )
  10143. );
  10144. }
  10145. /// <summary>
  10146. /// Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
  10147. /// </summary>
  10148. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10149. /// <param name="start">The value of the first integer in the sequence.</param>
  10150. /// <param name="count">The number of sequential integers to generate.</param>
  10151. /// <param name="scheduler">Scheduler to run the generator loop on.</param>
  10152. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10153. /// <exception cref="ArgumentOutOfRangeException">
  10154. /// <paramref name="count" /> is less than zero. -or- <paramref name="start" /> + <paramref name="count" /> - 1 is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
  10155. /// <exception cref="ArgumentNullException">
  10156. /// <paramref name="scheduler" /> is null.</exception>
  10157. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count, IScheduler scheduler)
  10158. {
  10159. if (provider == null)
  10160. throw new ArgumentNullException(nameof(provider));
  10161. if (scheduler == null)
  10162. throw new ArgumentNullException(nameof(scheduler));
  10163. return provider.CreateQuery<int>(
  10164. Expression.Call(
  10165. null,
  10166. #if CRIPPLED_REFLECTION
  10167. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int), default(IScheduler))),
  10168. #else
  10169. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10170. #endif
  10171. Expression.Constant(provider, typeof(IQbservableProvider)),
  10172. Expression.Constant(start, typeof(int)),
  10173. Expression.Constant(count, typeof(int)),
  10174. Expression.Constant(scheduler, typeof(IScheduler))
  10175. )
  10176. );
  10177. }
  10178. /// <summary>
  10179. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10180. /// </summary>
  10181. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10182. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10183. /// <param name="source">Connectable observable sequence.</param>
  10184. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10185. /// <exception cref="ArgumentNullException">
  10186. /// <paramref name="source" /> is null.</exception>
  10187. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source)
  10188. {
  10189. if (provider == null)
  10190. throw new ArgumentNullException(nameof(provider));
  10191. if (source == null)
  10192. throw new ArgumentNullException(nameof(source));
  10193. return provider.CreateQuery<TSource>(
  10194. Expression.Call(
  10195. null,
  10196. #if CRIPPLED_REFLECTION
  10197. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>))),
  10198. #else
  10199. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10200. #endif
  10201. Expression.Constant(provider, typeof(IQbservableProvider)),
  10202. Expression.Constant(source, typeof(IConnectableObservable<TSource>))
  10203. )
  10204. );
  10205. }
  10206. /// <summary>
  10207. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10208. /// </summary>
  10209. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10210. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10211. /// <param name="source">Connectable observable sequence.</param>
  10212. /// <param name="disconnectDelay">The time span that should be waited before possibly unsubscribing from the connectable observable.</param>
  10213. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10214. /// <exception cref="ArgumentNullException">
  10215. /// <paramref name="source" /> is null.</exception>
  10216. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, TimeSpan disconnectDelay)
  10217. {
  10218. if (provider == null)
  10219. throw new ArgumentNullException(nameof(provider));
  10220. if (source == null)
  10221. throw new ArgumentNullException(nameof(source));
  10222. return provider.CreateQuery<TSource>(
  10223. Expression.Call(
  10224. null,
  10225. #if CRIPPLED_REFLECTION
  10226. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(TimeSpan))),
  10227. #else
  10228. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10229. #endif
  10230. Expression.Constant(provider, typeof(IQbservableProvider)),
  10231. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  10232. Expression.Constant(disconnectDelay, typeof(TimeSpan))
  10233. )
  10234. );
  10235. }
  10236. /// <summary>
  10237. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10238. /// </summary>
  10239. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10240. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10241. /// <param name="source">Connectable observable sequence.</param>
  10242. /// <param name="disconnectDelay">The time span that should be waited before possibly unsubscribing from the connectable observable.</param>
  10243. /// <param name="scheduler">The scheduler to use for delayed unsubscription.</param>
  10244. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10245. /// <exception cref="ArgumentNullException">
  10246. /// <paramref name="source" /> is null.</exception>
  10247. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, TimeSpan disconnectDelay, IScheduler scheduler)
  10248. {
  10249. if (provider == null)
  10250. throw new ArgumentNullException(nameof(provider));
  10251. if (source == null)
  10252. throw new ArgumentNullException(nameof(source));
  10253. if (scheduler == null)
  10254. throw new ArgumentNullException(nameof(scheduler));
  10255. return provider.CreateQuery<TSource>(
  10256. Expression.Call(
  10257. null,
  10258. #if CRIPPLED_REFLECTION
  10259. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(TimeSpan), default(IScheduler))),
  10260. #else
  10261. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10262. #endif
  10263. Expression.Constant(provider, typeof(IQbservableProvider)),
  10264. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  10265. Expression.Constant(disconnectDelay, typeof(TimeSpan)),
  10266. Expression.Constant(scheduler, typeof(IScheduler))
  10267. )
  10268. );
  10269. }
  10270. /// <summary>
  10271. /// Generates an observable sequence that repeats the given element infinitely.
  10272. /// </summary>
  10273. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10274. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10275. /// <param name="value">Element to repeat.</param>
  10276. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10277. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value)
  10278. {
  10279. if (provider == null)
  10280. throw new ArgumentNullException(nameof(provider));
  10281. return provider.CreateQuery<TResult>(
  10282. Expression.Call(
  10283. null,
  10284. #if CRIPPLED_REFLECTION
  10285. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult))),
  10286. #else
  10287. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10288. #endif
  10289. Expression.Constant(provider, typeof(IQbservableProvider)),
  10290. Expression.Constant(value, typeof(TResult))
  10291. )
  10292. );
  10293. }
  10294. /// <summary>
  10295. /// Generates an observable sequence that repeats the given element the specified number of times.
  10296. /// </summary>
  10297. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10298. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10299. /// <param name="value">Element to repeat.</param>
  10300. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10301. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10302. /// <exception cref="ArgumentOutOfRangeException">
  10303. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10304. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount)
  10305. {
  10306. if (provider == null)
  10307. throw new ArgumentNullException(nameof(provider));
  10308. return provider.CreateQuery<TResult>(
  10309. Expression.Call(
  10310. null,
  10311. #if CRIPPLED_REFLECTION
  10312. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int))),
  10313. #else
  10314. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10315. #endif
  10316. Expression.Constant(provider, typeof(IQbservableProvider)),
  10317. Expression.Constant(value, typeof(TResult)),
  10318. Expression.Constant(repeatCount, typeof(int))
  10319. )
  10320. );
  10321. }
  10322. /// <summary>
  10323. /// Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
  10324. /// </summary>
  10325. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10326. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10327. /// <param name="value">Element to repeat.</param>
  10328. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10329. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10330. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10331. /// <exception cref="ArgumentOutOfRangeException">
  10332. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10333. /// <exception cref="ArgumentNullException">
  10334. /// <paramref name="scheduler" /> is null.</exception>
  10335. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount, IScheduler scheduler)
  10336. {
  10337. if (provider == null)
  10338. throw new ArgumentNullException(nameof(provider));
  10339. if (scheduler == null)
  10340. throw new ArgumentNullException(nameof(scheduler));
  10341. return provider.CreateQuery<TResult>(
  10342. Expression.Call(
  10343. null,
  10344. #if CRIPPLED_REFLECTION
  10345. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int), default(IScheduler))),
  10346. #else
  10347. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10348. #endif
  10349. Expression.Constant(provider, typeof(IQbservableProvider)),
  10350. Expression.Constant(value, typeof(TResult)),
  10351. Expression.Constant(repeatCount, typeof(int)),
  10352. Expression.Constant(scheduler, typeof(IScheduler))
  10353. )
  10354. );
  10355. }
  10356. /// <summary>
  10357. /// Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.
  10358. /// </summary>
  10359. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10360. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10361. /// <param name="value">Element to repeat.</param>
  10362. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10363. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10364. /// <exception cref="ArgumentNullException">
  10365. /// <paramref name="scheduler" /> is null.</exception>
  10366. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10367. {
  10368. if (provider == null)
  10369. throw new ArgumentNullException(nameof(provider));
  10370. if (scheduler == null)
  10371. throw new ArgumentNullException(nameof(scheduler));
  10372. return provider.CreateQuery<TResult>(
  10373. Expression.Call(
  10374. null,
  10375. #if CRIPPLED_REFLECTION
  10376. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10377. #else
  10378. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10379. #endif
  10380. Expression.Constant(provider, typeof(IQbservableProvider)),
  10381. Expression.Constant(value, typeof(TResult)),
  10382. Expression.Constant(scheduler, typeof(IScheduler))
  10383. )
  10384. );
  10385. }
  10386. /// <summary>
  10387. /// Repeats the observable sequence indefinitely.
  10388. /// </summary>
  10389. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10390. /// <param name="source">Observable sequence to repeat.</param>
  10391. /// <returns>The observable sequence producing the elements of the given sequence repeatedly and sequentially.</returns>
  10392. /// <exception cref="ArgumentNullException">
  10393. /// <paramref name="source" /> is null.</exception>
  10394. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source)
  10395. {
  10396. if (source == null)
  10397. throw new ArgumentNullException(nameof(source));
  10398. return source.Provider.CreateQuery<TSource>(
  10399. Expression.Call(
  10400. null,
  10401. #if CRIPPLED_REFLECTION
  10402. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>))),
  10403. #else
  10404. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10405. #endif
  10406. source.Expression
  10407. )
  10408. );
  10409. }
  10410. /// <summary>
  10411. /// Repeats the observable sequence a specified number of times.
  10412. /// </summary>
  10413. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10414. /// <param name="source">Observable sequence to repeat.</param>
  10415. /// <param name="repeatCount">Number of times to repeat the sequence.</param>
  10416. /// <returns>The observable sequence producing the elements of the given sequence repeatedly.</returns>
  10417. /// <exception cref="ArgumentNullException">
  10418. /// <paramref name="source" /> is null.</exception>
  10419. /// <exception cref="ArgumentOutOfRangeException">
  10420. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10421. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source, int repeatCount)
  10422. {
  10423. if (source == null)
  10424. throw new ArgumentNullException(nameof(source));
  10425. return source.Provider.CreateQuery<TSource>(
  10426. Expression.Call(
  10427. null,
  10428. #if CRIPPLED_REFLECTION
  10429. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>), default(int))),
  10430. #else
  10431. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10432. #endif
  10433. source.Expression,
  10434. Expression.Constant(repeatCount, typeof(int))
  10435. )
  10436. );
  10437. }
  10438. /// <summary>
  10439. /// Repeatedly resubscribes to the source observable after a normal completion and when the observable
  10440. /// returned by a handler produces an arbitrary item.
  10441. /// </summary>
  10442. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10443. /// <typeparam name="TSignal">The arbitrary element type signaled by the handler observable.</typeparam>
  10444. /// <param name="source">Observable sequence to keep repeating when it successfully terminates.</param>
  10445. /// <param name="handler">The function that is called for each observer and takes an observable sequence objects.
  10446. /// It should return an observable of arbitrary items that should signal that arbitrary item in
  10447. /// response to receiving the completion signal from the source observable. If this observable signals
  10448. /// a terminal event, the sequence is terminated with that signal instead.</param>
  10449. /// <returns>An observable sequence producing the elements of the given sequence repeatedly while each repetition terminates successfully.</returns>
  10450. /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
  10451. /// <exception cref="ArgumentNullException"><paramref name="handler"/> is null.</exception>
  10452. public static IQbservable<TSource> RepeatWhen<TSource, TSignal>(this IQbservable<TSource> source, Expression<Func<IObservable<object>, IObservable<TSignal>>> handler)
  10453. {
  10454. if (source == null)
  10455. throw new ArgumentNullException(nameof(source));
  10456. if (handler == null)
  10457. throw new ArgumentNullException(nameof(handler));
  10458. return source.Provider.CreateQuery<TSource>(
  10459. Expression.Call(
  10460. null,
  10461. #if CRIPPLED_REFLECTION
  10462. InfoOf(() => Qbservable.RepeatWhen<TSource, TSignal>(default(IQbservable<TSource>), default(Expression<Func<IObservable<object>, IObservable<TSignal>>>))),
  10463. #else
  10464. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSignal)),
  10465. #endif
  10466. source.Expression,
  10467. handler
  10468. )
  10469. );
  10470. }
  10471. /// <summary>
  10472. /// Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications.
  10473. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10474. /// </summary>
  10475. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10476. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10477. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10478. /// <param name="selector">Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source.</param>
  10479. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10480. /// <exception cref="ArgumentNullException">
  10481. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10482. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10483. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10484. {
  10485. if (source == null)
  10486. throw new ArgumentNullException(nameof(source));
  10487. if (selector == null)
  10488. throw new ArgumentNullException(nameof(selector));
  10489. return source.Provider.CreateQuery<TResult>(
  10490. Expression.Call(
  10491. null,
  10492. #if CRIPPLED_REFLECTION
  10493. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10494. #else
  10495. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10496. #endif
  10497. source.Expression,
  10498. selector
  10499. )
  10500. );
  10501. }
  10502. /// <summary>
  10503. /// Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum element count for the replay buffer.
  10504. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10505. /// </summary>
  10506. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10507. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10508. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10509. /// <param name="selector">Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.</param>
  10510. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10511. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10512. /// <exception cref="ArgumentNullException">
  10513. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10514. /// <exception cref="ArgumentOutOfRangeException">
  10515. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10516. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10517. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize)
  10518. {
  10519. if (source == null)
  10520. throw new ArgumentNullException(nameof(source));
  10521. if (selector == null)
  10522. throw new ArgumentNullException(nameof(selector));
  10523. return source.Provider.CreateQuery<TResult>(
  10524. Expression.Call(
  10525. null,
  10526. #if CRIPPLED_REFLECTION
  10527. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int))),
  10528. #else
  10529. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10530. #endif
  10531. source.Expression,
  10532. selector,
  10533. Expression.Constant(bufferSize, typeof(int))
  10534. )
  10535. );
  10536. }
  10537. /// <summary>
  10538. /// Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum element count for the replay buffer.
  10539. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10540. /// </summary>
  10541. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10542. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10543. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10544. /// <param name="selector">Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.</param>
  10545. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10546. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10547. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10548. /// <exception cref="ArgumentNullException">
  10549. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10550. /// <exception cref="ArgumentOutOfRangeException">
  10551. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10552. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10553. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, IScheduler scheduler)
  10554. {
  10555. if (source == null)
  10556. throw new ArgumentNullException(nameof(source));
  10557. if (selector == null)
  10558. throw new ArgumentNullException(nameof(selector));
  10559. if (scheduler == null)
  10560. throw new ArgumentNullException(nameof(scheduler));
  10561. return source.Provider.CreateQuery<TResult>(
  10562. Expression.Call(
  10563. null,
  10564. #if CRIPPLED_REFLECTION
  10565. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(IScheduler))),
  10566. #else
  10567. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10568. #endif
  10569. source.Expression,
  10570. selector,
  10571. Expression.Constant(bufferSize, typeof(int)),
  10572. Expression.Constant(scheduler, typeof(IScheduler))
  10573. )
  10574. );
  10575. }
  10576. /// <summary>
  10577. /// Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length and element count for the replay buffer.
  10578. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10579. /// </summary>
  10580. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10581. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10582. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10583. /// <param name="selector">Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.</param>
  10584. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10585. /// <param name="window">Maximum time length of the replay buffer.</param>
  10586. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10587. /// <exception cref="ArgumentNullException">
  10588. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10589. /// <exception cref="ArgumentOutOfRangeException">
  10590. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10591. /// <exception cref="ArgumentOutOfRangeException">
  10592. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10593. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10594. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window)
  10595. {
  10596. if (source == null)
  10597. throw new ArgumentNullException(nameof(source));
  10598. if (selector == null)
  10599. throw new ArgumentNullException(nameof(selector));
  10600. return source.Provider.CreateQuery<TResult>(
  10601. Expression.Call(
  10602. null,
  10603. #if CRIPPLED_REFLECTION
  10604. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan))),
  10605. #else
  10606. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10607. #endif
  10608. source.Expression,
  10609. selector,
  10610. Expression.Constant(bufferSize, typeof(int)),
  10611. Expression.Constant(window, typeof(TimeSpan))
  10612. )
  10613. );
  10614. }
  10615. /// <summary>
  10616. /// Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length and element count for the replay buffer.
  10617. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10618. /// </summary>
  10619. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10620. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10621. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10622. /// <param name="selector">Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.</param>
  10623. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10624. /// <param name="window">Maximum time length of the replay buffer.</param>
  10625. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10626. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10627. /// <exception cref="ArgumentNullException">
  10628. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10629. /// <exception cref="ArgumentOutOfRangeException">
  10630. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10631. /// <exception cref="ArgumentOutOfRangeException">
  10632. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10633. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10634. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window, IScheduler scheduler)
  10635. {
  10636. if (source == null)
  10637. throw new ArgumentNullException(nameof(source));
  10638. if (selector == null)
  10639. throw new ArgumentNullException(nameof(selector));
  10640. if (scheduler == null)
  10641. throw new ArgumentNullException(nameof(scheduler));
  10642. return source.Provider.CreateQuery<TResult>(
  10643. Expression.Call(
  10644. null,
  10645. #if CRIPPLED_REFLECTION
  10646. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan), default(IScheduler))),
  10647. #else
  10648. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10649. #endif
  10650. source.Expression,
  10651. selector,
  10652. Expression.Constant(bufferSize, typeof(int)),
  10653. Expression.Constant(window, typeof(TimeSpan)),
  10654. Expression.Constant(scheduler, typeof(IScheduler))
  10655. )
  10656. );
  10657. }
  10658. /// <summary>
  10659. /// Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying all notifications.
  10660. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10661. /// </summary>
  10662. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10663. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10664. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10665. /// <param name="selector">Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source.</param>
  10666. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10667. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10668. /// <exception cref="ArgumentNullException">
  10669. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10670. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10671. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, IScheduler scheduler)
  10672. {
  10673. if (source == null)
  10674. throw new ArgumentNullException(nameof(source));
  10675. if (selector == null)
  10676. throw new ArgumentNullException(nameof(selector));
  10677. if (scheduler == null)
  10678. throw new ArgumentNullException(nameof(scheduler));
  10679. return source.Provider.CreateQuery<TResult>(
  10680. Expression.Call(
  10681. null,
  10682. #if CRIPPLED_REFLECTION
  10683. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(IScheduler))),
  10684. #else
  10685. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10686. #endif
  10687. source.Expression,
  10688. selector,
  10689. Expression.Constant(scheduler, typeof(IScheduler))
  10690. )
  10691. );
  10692. }
  10693. /// <summary>
  10694. /// Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.
  10695. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10696. /// </summary>
  10697. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10698. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10699. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10700. /// <param name="selector">Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.</param>
  10701. /// <param name="window">Maximum time length of the replay buffer.</param>
  10702. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10703. /// <exception cref="ArgumentNullException">
  10704. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10705. /// <exception cref="ArgumentOutOfRangeException">
  10706. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10707. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10708. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window)
  10709. {
  10710. if (source == null)
  10711. throw new ArgumentNullException(nameof(source));
  10712. if (selector == null)
  10713. throw new ArgumentNullException(nameof(selector));
  10714. return source.Provider.CreateQuery<TResult>(
  10715. Expression.Call(
  10716. null,
  10717. #if CRIPPLED_REFLECTION
  10718. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan))),
  10719. #else
  10720. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10721. #endif
  10722. source.Expression,
  10723. selector,
  10724. Expression.Constant(window, typeof(TimeSpan))
  10725. )
  10726. );
  10727. }
  10728. /// <summary>
  10729. /// Returns an observable sequence that is the result of invoking the selector on a connectable observable sequence that shares a single subscription to the underlying sequence replaying notifications subject to a maximum time length for the replay buffer.
  10730. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10731. /// </summary>
  10732. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10733. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10734. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10735. /// <param name="selector">Selector function which can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence. Subscribers to the given source will receive all the notifications of the source subject to the specified replay buffer trimming policy.</param>
  10736. /// <param name="window">Maximum time length of the replay buffer.</param>
  10737. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10738. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10739. /// <exception cref="ArgumentNullException">
  10740. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10741. /// <exception cref="ArgumentOutOfRangeException">
  10742. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10743. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10744. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window, IScheduler scheduler)
  10745. {
  10746. if (source == null)
  10747. throw new ArgumentNullException(nameof(source));
  10748. if (selector == null)
  10749. throw new ArgumentNullException(nameof(selector));
  10750. if (scheduler == null)
  10751. throw new ArgumentNullException(nameof(scheduler));
  10752. return source.Provider.CreateQuery<TResult>(
  10753. Expression.Call(
  10754. null,
  10755. #if CRIPPLED_REFLECTION
  10756. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan), default(IScheduler))),
  10757. #else
  10758. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10759. #endif
  10760. source.Expression,
  10761. selector,
  10762. Expression.Constant(window, typeof(TimeSpan)),
  10763. Expression.Constant(scheduler, typeof(IScheduler))
  10764. )
  10765. );
  10766. }
  10767. /// <summary>
  10768. /// Repeats the source observable sequence until it successfully terminates.
  10769. /// </summary>
  10770. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10771. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10772. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10773. /// <exception cref="ArgumentNullException">
  10774. /// <paramref name="source" /> is null.</exception>
  10775. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source)
  10776. {
  10777. if (source == null)
  10778. throw new ArgumentNullException(nameof(source));
  10779. return source.Provider.CreateQuery<TSource>(
  10780. Expression.Call(
  10781. null,
  10782. #if CRIPPLED_REFLECTION
  10783. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>))),
  10784. #else
  10785. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10786. #endif
  10787. source.Expression
  10788. )
  10789. );
  10790. }
  10791. /// <summary>
  10792. /// Repeats the source observable sequence the specified number of times or until it successfully terminates.
  10793. /// </summary>
  10794. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10795. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10796. /// <param name="retryCount">Number of times to repeat the sequence.</param>
  10797. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10798. /// <exception cref="ArgumentNullException">
  10799. /// <paramref name="source" /> is null.</exception>
  10800. /// <exception cref="ArgumentOutOfRangeException">
  10801. /// <paramref name="retryCount" /> is less than zero.</exception>
  10802. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source, int retryCount)
  10803. {
  10804. if (source == null)
  10805. throw new ArgumentNullException(nameof(source));
  10806. return source.Provider.CreateQuery<TSource>(
  10807. Expression.Call(
  10808. null,
  10809. #if CRIPPLED_REFLECTION
  10810. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>), default(int))),
  10811. #else
  10812. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10813. #endif
  10814. source.Expression,
  10815. Expression.Constant(retryCount, typeof(int))
  10816. )
  10817. );
  10818. }
  10819. /// <summary>
  10820. /// Retries (resubscribes to) the source observable after a failure and when the observable
  10821. /// returned by a handler produces an arbitrary item.
  10822. /// </summary>
  10823. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10824. /// <typeparam name="TSignal">The arbitrary element type signaled by the handler observable.</typeparam>
  10825. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10826. /// <param name="handler">The function that is called for each observer and takes an observable sequence of
  10827. /// errors. It should return an observable of arbitrary items that should signal that arbitrary item in
  10828. /// response to receiving the failure Exception from the source observable. If this observable signals
  10829. /// a terminal event, the sequence is terminated with that signal instead.</param>
  10830. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10831. /// <exception cref="ArgumentNullException">
  10832. /// <paramref name="source" /> is null.</exception>
  10833. /// <exception cref="ArgumentNullException">
  10834. /// <paramref name="handler" /> is null.</exception>
  10835. public static IQbservable<TSource> RetryWhen<TSource, TSignal>(this IQbservable<TSource> source, Expression<Func<IObservable<Exception>, IObservable<TSignal>>> handler)
  10836. {
  10837. if (source == null)
  10838. throw new ArgumentNullException(nameof(source));
  10839. if (handler == null)
  10840. throw new ArgumentNullException(nameof(handler));
  10841. return source.Provider.CreateQuery<TSource>(
  10842. Expression.Call(
  10843. null,
  10844. #if CRIPPLED_REFLECTION
  10845. InfoOf(() => Qbservable.RetryWhen<TSource, TSignal>(default(IQbservable<TSource>), default(Expression<Func<IObservable<Exception>, IObservable<TSignal>>>))),
  10846. #else
  10847. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSignal)),
  10848. #endif
  10849. source.Expression,
  10850. handler
  10851. )
  10852. );
  10853. }
  10854. /// <summary>
  10855. /// Returns an observable sequence that contains a single element.
  10856. /// </summary>
  10857. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10858. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  10859. /// <param name="value">Single element in the resulting observable sequence.</param>
  10860. /// <returns>An observable sequence containing the single specified element.</returns>
  10861. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value)
  10862. {
  10863. if (provider == null)
  10864. throw new ArgumentNullException(nameof(provider));
  10865. return provider.CreateQuery<TResult>(
  10866. Expression.Call(
  10867. null,
  10868. #if CRIPPLED_REFLECTION
  10869. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult))),
  10870. #else
  10871. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10872. #endif
  10873. Expression.Constant(provider, typeof(IQbservableProvider)),
  10874. Expression.Constant(value, typeof(TResult))
  10875. )
  10876. );
  10877. }
  10878. /// <summary>
  10879. /// Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
  10880. /// </summary>
  10881. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10882. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  10883. /// <param name="value">Single element in the resulting observable sequence.</param>
  10884. /// <param name="scheduler">Scheduler to send the single element on.</param>
  10885. /// <returns>An observable sequence containing the single specified element.</returns>
  10886. /// <exception cref="ArgumentNullException">
  10887. /// <paramref name="scheduler" /> is null.</exception>
  10888. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10889. {
  10890. if (provider == null)
  10891. throw new ArgumentNullException(nameof(provider));
  10892. if (scheduler == null)
  10893. throw new ArgumentNullException(nameof(scheduler));
  10894. return provider.CreateQuery<TResult>(
  10895. Expression.Call(
  10896. null,
  10897. #if CRIPPLED_REFLECTION
  10898. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10899. #else
  10900. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10901. #endif
  10902. Expression.Constant(provider, typeof(IQbservableProvider)),
  10903. Expression.Constant(value, typeof(TResult)),
  10904. Expression.Constant(scheduler, typeof(IScheduler))
  10905. )
  10906. );
  10907. }
  10908. /// <summary>
  10909. /// Samples the observable sequence at each interval.
  10910. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10911. /// </summary>
  10912. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10913. /// <param name="source">Source sequence to sample.</param>
  10914. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  10915. /// <returns>Sampled observable sequence.</returns>
  10916. /// <exception cref="ArgumentNullException">
  10917. /// <paramref name="source" /> is null.</exception>
  10918. /// <exception cref="ArgumentOutOfRangeException">
  10919. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  10920. /// <remarks>
  10921. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  10922. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  10923. /// </remarks>
  10924. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval)
  10925. {
  10926. if (source == null)
  10927. throw new ArgumentNullException(nameof(source));
  10928. return source.Provider.CreateQuery<TSource>(
  10929. Expression.Call(
  10930. null,
  10931. #if CRIPPLED_REFLECTION
  10932. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  10933. #else
  10934. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10935. #endif
  10936. source.Expression,
  10937. Expression.Constant(interval, typeof(TimeSpan))
  10938. )
  10939. );
  10940. }
  10941. /// <summary>
  10942. /// Samples the observable sequence at each interval, using the specified scheduler to run sampling timers.
  10943. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10944. /// </summary>
  10945. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10946. /// <param name="source">Source sequence to sample.</param>
  10947. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  10948. /// <param name="scheduler">Scheduler to run the sampling timer on.</param>
  10949. /// <returns>Sampled observable sequence.</returns>
  10950. /// <exception cref="ArgumentNullException">
  10951. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  10952. /// <exception cref="ArgumentOutOfRangeException">
  10953. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  10954. /// <remarks>
  10955. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  10956. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  10957. /// </remarks>
  10958. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval, IScheduler scheduler)
  10959. {
  10960. if (source == null)
  10961. throw new ArgumentNullException(nameof(source));
  10962. if (scheduler == null)
  10963. throw new ArgumentNullException(nameof(scheduler));
  10964. return source.Provider.CreateQuery<TSource>(
  10965. Expression.Call(
  10966. null,
  10967. #if CRIPPLED_REFLECTION
  10968. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  10969. #else
  10970. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10971. #endif
  10972. source.Expression,
  10973. Expression.Constant(interval, typeof(TimeSpan)),
  10974. Expression.Constant(scheduler, typeof(IScheduler))
  10975. )
  10976. );
  10977. }
  10978. /// <summary>
  10979. /// Samples the source observable sequence using a sampler observable sequence producing sampling ticks.
  10980. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10981. /// </summary>
  10982. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10983. /// <typeparam name="TSample">The type of the elements in the sampling sequence.</typeparam>
  10984. /// <param name="source">Source sequence to sample.</param>
  10985. /// <param name="sampler">Sampling tick sequence.</param>
  10986. /// <returns>Sampled observable sequence.</returns>
  10987. /// <exception cref="ArgumentNullException">
  10988. /// <paramref name="source" /> or <paramref name="sampler" /> is null.</exception>
  10989. public static IQbservable<TSource> Sample<TSource, TSample>(this IQbservable<TSource> source, IObservable<TSample> sampler)
  10990. {
  10991. if (source == null)
  10992. throw new ArgumentNullException(nameof(source));
  10993. if (sampler == null)
  10994. throw new ArgumentNullException(nameof(sampler));
  10995. return source.Provider.CreateQuery<TSource>(
  10996. Expression.Call(
  10997. null,
  10998. #if CRIPPLED_REFLECTION
  10999. InfoOf(() => Qbservable.Sample<TSource, TSample>(default(IQbservable<TSource>), default(IObservable<TSample>))),
  11000. #else
  11001. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSample)),
  11002. #endif
  11003. source.Expression,
  11004. GetSourceExpression(sampler)
  11005. )
  11006. );
  11007. }
  11008. /// <summary>
  11009. /// Applies an accumulator function over an observable sequence and returns each intermediate result.
  11010. /// For aggregation behavior with no intermediate results, see <see cref="M:System.Reactive.Linq.Observable.Aggregate``1(System.IObservable{``0},System.Func{``0,``0,``0})" />.
  11011. /// </summary>
  11012. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  11013. /// <param name="source">An observable sequence to accumulate over.</param>
  11014. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11015. /// <returns>An observable sequence containing the accumulated values.</returns>
  11016. /// <exception cref="ArgumentNullException">
  11017. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11018. public static IQbservable<TSource> Scan<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  11019. {
  11020. if (source == null)
  11021. throw new ArgumentNullException(nameof(source));
  11022. if (accumulator == null)
  11023. throw new ArgumentNullException(nameof(accumulator));
  11024. return source.Provider.CreateQuery<TSource>(
  11025. Expression.Call(
  11026. null,
  11027. #if CRIPPLED_REFLECTION
  11028. InfoOf(() => Qbservable.Scan<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  11029. #else
  11030. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11031. #endif
  11032. source.Expression,
  11033. accumulator
  11034. )
  11035. );
  11036. }
  11037. /// <summary>
  11038. /// Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
  11039. /// For aggregation behavior with no intermediate results, see <see cref="M:System.Reactive.Linq.Observable.Aggregate``2(System.IObservable{``0},``1,System.Func{``1,``0,``1})" />.
  11040. /// </summary>
  11041. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11042. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  11043. /// <param name="source">An observable sequence to accumulate over.</param>
  11044. /// <param name="seed">The initial accumulator value.</param>
  11045. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11046. /// <returns>An observable sequence containing the accumulated values.</returns>
  11047. /// <exception cref="ArgumentNullException">
  11048. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11049. public static IQbservable<TAccumulate> Scan<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  11050. {
  11051. if (source == null)
  11052. throw new ArgumentNullException(nameof(source));
  11053. if (accumulator == null)
  11054. throw new ArgumentNullException(nameof(accumulator));
  11055. return source.Provider.CreateQuery<TAccumulate>(
  11056. Expression.Call(
  11057. null,
  11058. #if CRIPPLED_REFLECTION
  11059. InfoOf(() => Qbservable.Scan<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  11060. #else
  11061. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  11062. #endif
  11063. source.Expression,
  11064. Expression.Constant(seed, typeof(TAccumulate)),
  11065. accumulator
  11066. )
  11067. );
  11068. }
  11069. /// <summary>
  11070. /// Projects each element of an observable sequence into a new form.
  11071. /// </summary>
  11072. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11073. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by running the selector function for each element in the source sequence.</typeparam>
  11074. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11075. /// <param name="selector">A transform function to apply to each source element.</param>
  11076. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11077. /// <exception cref="ArgumentNullException">
  11078. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11079. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  11080. {
  11081. if (source == null)
  11082. throw new ArgumentNullException(nameof(source));
  11083. if (selector == null)
  11084. throw new ArgumentNullException(nameof(selector));
  11085. return source.Provider.CreateQuery<TResult>(
  11086. Expression.Call(
  11087. null,
  11088. #if CRIPPLED_REFLECTION
  11089. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  11090. #else
  11091. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11092. #endif
  11093. source.Expression,
  11094. selector
  11095. )
  11096. );
  11097. }
  11098. /// <summary>
  11099. /// Projects each element of an observable sequence into a new form by incorporating the element's index.
  11100. /// </summary>
  11101. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11102. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by running the selector function for each element in the source sequence.</typeparam>
  11103. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11104. /// <param name="selector">A transform function to apply to each source element; the second parameter of the function represents the index of the source element.</param>
  11105. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11106. /// <exception cref="ArgumentNullException">
  11107. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11108. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, TResult>> selector)
  11109. {
  11110. if (source == null)
  11111. throw new ArgumentNullException(nameof(source));
  11112. if (selector == null)
  11113. throw new ArgumentNullException(nameof(selector));
  11114. return source.Provider.CreateQuery<TResult>(
  11115. Expression.Call(
  11116. null,
  11117. #if CRIPPLED_REFLECTION
  11118. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, TResult>>))),
  11119. #else
  11120. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11121. #endif
  11122. source.Expression,
  11123. selector
  11124. )
  11125. );
  11126. }
  11127. /// <summary>
  11128. /// Projects each element of an observable sequence to an observable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  11129. /// </summary>
  11130. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11131. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11132. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate sequence elements.</typeparam>
  11133. /// <param name="source">An observable sequence of elements to project.</param>
  11134. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11135. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11136. /// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.</returns>
  11137. /// <exception cref="ArgumentNullException">
  11138. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11139. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11140. {
  11141. if (source == null)
  11142. throw new ArgumentNullException(nameof(source));
  11143. if (collectionSelector == null)
  11144. throw new ArgumentNullException(nameof(collectionSelector));
  11145. if (resultSelector == null)
  11146. throw new ArgumentNullException(nameof(resultSelector));
  11147. return source.Provider.CreateQuery<TResult>(
  11148. Expression.Call(
  11149. null,
  11150. #if CRIPPLED_REFLECTION
  11151. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11152. #else
  11153. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11154. #endif
  11155. source.Expression,
  11156. collectionSelector,
  11157. resultSelector
  11158. )
  11159. );
  11160. }
  11161. /// <summary>
  11162. /// Projects each element of an observable sequence to an observable sequence by incorporating the element's index, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  11163. /// </summary>
  11164. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11165. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11166. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate sequence elements.</typeparam>
  11167. /// <param name="source">An observable sequence of elements to project.</param>
  11168. /// <param name="collectionSelector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11169. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element and the fourth parameter represents the index of the intermediate element.</param>
  11170. /// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.</returns>
  11171. /// <exception cref="ArgumentNullException">
  11172. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11173. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TCollection>>> collectionSelector, Expression<Func<TSource, int, TCollection, int, TResult>> resultSelector)
  11174. {
  11175. if (source == null)
  11176. throw new ArgumentNullException(nameof(source));
  11177. if (collectionSelector == null)
  11178. throw new ArgumentNullException(nameof(collectionSelector));
  11179. if (resultSelector == null)
  11180. throw new ArgumentNullException(nameof(resultSelector));
  11181. return source.Provider.CreateQuery<TResult>(
  11182. Expression.Call(
  11183. null,
  11184. #if CRIPPLED_REFLECTION
  11185. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11186. #else
  11187. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11188. #endif
  11189. source.Expression,
  11190. collectionSelector,
  11191. resultSelector
  11192. )
  11193. );
  11194. }
  11195. /// <summary>
  11196. /// Projects each element of an observable sequence to an enumerable sequence, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  11197. /// </summary>
  11198. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11199. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11200. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate sequence elements.</typeparam>
  11201. /// <param name="source">An observable sequence of elements to project.</param>
  11202. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11203. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11204. /// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.</returns>
  11205. /// <exception cref="ArgumentNullException">
  11206. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11207. /// <remarks>The projected sequences are enumerated synchronously within the OnNext call of the source sequence. In order to do a concurrent, non-blocking merge, change the selector to return an observable sequence obtained using the <see cref="M:System.Reactive.Linq.Observable.ToObservable``1(System.Collections.Generic.IEnumerable{``0})" /> conversion.</remarks>
  11208. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11209. {
  11210. if (source == null)
  11211. throw new ArgumentNullException(nameof(source));
  11212. if (collectionSelector == null)
  11213. throw new ArgumentNullException(nameof(collectionSelector));
  11214. if (resultSelector == null)
  11215. throw new ArgumentNullException(nameof(resultSelector));
  11216. return source.Provider.CreateQuery<TResult>(
  11217. Expression.Call(
  11218. null,
  11219. #if CRIPPLED_REFLECTION
  11220. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11221. #else
  11222. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11223. #endif
  11224. source.Expression,
  11225. collectionSelector,
  11226. resultSelector
  11227. )
  11228. );
  11229. }
  11230. /// <summary>
  11231. /// Projects each element of an observable sequence to an enumerable sequence by incorporating the element's index, invokes the result selector for the source element and each of the corresponding inner sequence's elements, and merges the results into one observable sequence.
  11232. /// </summary>
  11233. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11234. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11235. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate sequence elements.</typeparam>
  11236. /// <param name="source">An observable sequence of elements to project.</param>
  11237. /// <param name="collectionSelector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11238. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element and the fourth parameter represents the index of the intermediate element.</param>
  11239. /// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function collectionSelector on each element of the input sequence and then mapping each of those sequence elements and their corresponding source element to a result element.</returns>
  11240. /// <exception cref="ArgumentNullException">
  11241. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11242. /// <remarks>The projected sequences are enumerated synchronously within the OnNext call of the source sequence. In order to do a concurrent, non-blocking merge, change the selector to return an observable sequence obtained using the <see cref="M:System.Reactive.Linq.Observable.ToObservable``1(System.Collections.Generic.IEnumerable{``0})" /> conversion.</remarks>
  11243. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, int, TCollection, int, TResult>> resultSelector)
  11244. {
  11245. if (source == null)
  11246. throw new ArgumentNullException(nameof(source));
  11247. if (collectionSelector == null)
  11248. throw new ArgumentNullException(nameof(collectionSelector));
  11249. if (resultSelector == null)
  11250. throw new ArgumentNullException(nameof(resultSelector));
  11251. return source.Provider.CreateQuery<TResult>(
  11252. Expression.Call(
  11253. null,
  11254. #if CRIPPLED_REFLECTION
  11255. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11256. #else
  11257. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11258. #endif
  11259. source.Expression,
  11260. collectionSelector,
  11261. resultSelector
  11262. )
  11263. );
  11264. }
  11265. /// <summary>
  11266. /// Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  11267. /// </summary>
  11268. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11269. /// <typeparam name="TOther">The type of the elements in the other sequence and the elements in the result sequence.</typeparam>
  11270. /// <param name="source">An observable sequence of elements to project.</param>
  11271. /// <param name="other">An observable sequence to project each element from the source sequence onto.</param>
  11272. /// <returns>An observable sequence whose elements are the result of projecting each source element onto the other sequence and merging all the resulting sequences together.</returns>
  11273. /// <exception cref="ArgumentNullException">
  11274. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  11275. public static IQbservable<TOther> SelectMany<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  11276. {
  11277. if (source == null)
  11278. throw new ArgumentNullException(nameof(source));
  11279. if (other == null)
  11280. throw new ArgumentNullException(nameof(other));
  11281. return source.Provider.CreateQuery<TOther>(
  11282. Expression.Call(
  11283. null,
  11284. #if CRIPPLED_REFLECTION
  11285. InfoOf(() => Qbservable.SelectMany<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  11286. #else
  11287. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  11288. #endif
  11289. source.Expression,
  11290. GetSourceExpression(other)
  11291. )
  11292. );
  11293. }
  11294. /// <summary>
  11295. /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11296. /// </summary>
  11297. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11298. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11299. /// <param name="source">An observable sequence of notifications to project.</param>
  11300. /// <param name="onNext">A transform function to apply to each element.</param>
  11301. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11302. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11303. /// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.</returns>
  11304. /// <exception cref="ArgumentNullException">
  11305. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11306. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> onNext, Expression<Func<Exception, IObservable<TResult>>> onError, Expression<Func<IObservable<TResult>>> onCompleted)
  11307. {
  11308. if (source == null)
  11309. throw new ArgumentNullException(nameof(source));
  11310. if (onNext == null)
  11311. throw new ArgumentNullException(nameof(onNext));
  11312. if (onError == null)
  11313. throw new ArgumentNullException(nameof(onError));
  11314. if (onCompleted == null)
  11315. throw new ArgumentNullException(nameof(onCompleted));
  11316. return source.Provider.CreateQuery<TResult>(
  11317. Expression.Call(
  11318. null,
  11319. #if CRIPPLED_REFLECTION
  11320. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>), default(Expression<Func<Exception, IObservable<TResult>>>), default(Expression<Func<IObservable<TResult>>>))),
  11321. #else
  11322. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11323. #endif
  11324. source.Expression,
  11325. onNext,
  11326. onError,
  11327. onCompleted
  11328. )
  11329. );
  11330. }
  11331. /// <summary>
  11332. /// Projects each notification of an observable sequence to an observable sequence by incorporating the element's index and merges the resulting observable sequences into one observable sequence.
  11333. /// </summary>
  11334. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11335. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11336. /// <param name="source">An observable sequence of notifications to project.</param>
  11337. /// <param name="onNext">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11338. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11339. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11340. /// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function corresponding to each notification in the input sequence.</returns>
  11341. /// <exception cref="ArgumentNullException">
  11342. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11343. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TResult>>> onNext, Expression<Func<Exception, IObservable<TResult>>> onError, Expression<Func<IObservable<TResult>>> onCompleted)
  11344. {
  11345. if (source == null)
  11346. throw new ArgumentNullException(nameof(source));
  11347. if (onNext == null)
  11348. throw new ArgumentNullException(nameof(onNext));
  11349. if (onError == null)
  11350. throw new ArgumentNullException(nameof(onError));
  11351. if (onCompleted == null)
  11352. throw new ArgumentNullException(nameof(onCompleted));
  11353. return source.Provider.CreateQuery<TResult>(
  11354. Expression.Call(
  11355. null,
  11356. #if CRIPPLED_REFLECTION
  11357. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>), default(Expression<Func<Exception, IObservable<TResult>>>), default(Expression<Func<IObservable<TResult>>>))),
  11358. #else
  11359. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11360. #endif
  11361. source.Expression,
  11362. onNext,
  11363. onError,
  11364. onCompleted
  11365. )
  11366. );
  11367. }
  11368. /// <summary>
  11369. /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11370. /// </summary>
  11371. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11372. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11373. /// <param name="source">An observable sequence of elements to project.</param>
  11374. /// <param name="selector">A transform function to apply to each element.</param>
  11375. /// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.</returns>
  11376. /// <exception cref="ArgumentNullException">
  11377. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11378. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> selector)
  11379. {
  11380. if (source == null)
  11381. throw new ArgumentNullException(nameof(source));
  11382. if (selector == null)
  11383. throw new ArgumentNullException(nameof(selector));
  11384. return source.Provider.CreateQuery<TResult>(
  11385. Expression.Call(
  11386. null,
  11387. #if CRIPPLED_REFLECTION
  11388. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  11389. #else
  11390. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11391. #endif
  11392. source.Expression,
  11393. selector
  11394. )
  11395. );
  11396. }
  11397. /// <summary>
  11398. /// Projects each element of an observable sequence to an observable sequence by incorporating the element's index and merges the resulting observable sequences into one observable sequence.
  11399. /// </summary>
  11400. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11401. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11402. /// <param name="source">An observable sequence of elements to project.</param>
  11403. /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11404. /// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.</returns>
  11405. /// <exception cref="ArgumentNullException">
  11406. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11407. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TResult>>> selector)
  11408. {
  11409. if (source == null)
  11410. throw new ArgumentNullException(nameof(source));
  11411. if (selector == null)
  11412. throw new ArgumentNullException(nameof(selector));
  11413. return source.Provider.CreateQuery<TResult>(
  11414. Expression.Call(
  11415. null,
  11416. #if CRIPPLED_REFLECTION
  11417. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>))),
  11418. #else
  11419. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11420. #endif
  11421. source.Expression,
  11422. selector
  11423. )
  11424. );
  11425. }
  11426. /// <summary>
  11427. /// Projects each element of an observable sequence to a task and merges all of the task results into one observable sequence.
  11428. /// </summary>
  11429. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11430. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11431. /// <param name="source">An observable sequence of elements to project.</param>
  11432. /// <param name="selector">A transform function to apply to each element.</param>
  11433. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11434. /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11435. /// <exception cref="ArgumentNullException">
  11436. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11437. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TResult>>> selector)
  11438. {
  11439. if (source == null)
  11440. throw new ArgumentNullException(nameof(source));
  11441. if (selector == null)
  11442. throw new ArgumentNullException(nameof(selector));
  11443. return source.Provider.CreateQuery<TResult>(
  11444. Expression.Call(
  11445. null,
  11446. #if CRIPPLED_REFLECTION
  11447. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TResult>>>))),
  11448. #else
  11449. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11450. #endif
  11451. source.Expression,
  11452. selector
  11453. )
  11454. );
  11455. }
  11456. /// <summary>
  11457. /// Projects each element of an observable sequence to a task by incorporating the element's index and merges all of the task results into one observable sequence.
  11458. /// </summary>
  11459. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11460. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11461. /// <param name="source">An observable sequence of elements to project.</param>
  11462. /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11463. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11464. /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11465. /// <exception cref="ArgumentNullException">
  11466. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11467. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, Task<TResult>>> selector)
  11468. {
  11469. if (source == null)
  11470. throw new ArgumentNullException(nameof(source));
  11471. if (selector == null)
  11472. throw new ArgumentNullException(nameof(selector));
  11473. return source.Provider.CreateQuery<TResult>(
  11474. Expression.Call(
  11475. null,
  11476. #if CRIPPLED_REFLECTION
  11477. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TResult>>>))),
  11478. #else
  11479. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11480. #endif
  11481. source.Expression,
  11482. selector
  11483. )
  11484. );
  11485. }
  11486. /// <summary>
  11487. /// Projects each element of an observable sequence to a task with cancellation support and merges all of the task results into one observable sequence.
  11488. /// </summary>
  11489. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11490. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11491. /// <param name="source">An observable sequence of elements to project.</param>
  11492. /// <param name="selector">A transform function to apply to each element.</param>
  11493. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11494. /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11495. /// <exception cref="ArgumentNullException">
  11496. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11497. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, CancellationToken, Task<TResult>>> selector)
  11498. {
  11499. if (source == null)
  11500. throw new ArgumentNullException(nameof(source));
  11501. if (selector == null)
  11502. throw new ArgumentNullException(nameof(selector));
  11503. return source.Provider.CreateQuery<TResult>(
  11504. Expression.Call(
  11505. null,
  11506. #if CRIPPLED_REFLECTION
  11507. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TResult>>>))),
  11508. #else
  11509. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11510. #endif
  11511. source.Expression,
  11512. selector
  11513. )
  11514. );
  11515. }
  11516. /// <summary>
  11517. /// Projects each element of an observable sequence to a task by incorporating the element's index with cancellation support and merges all of the task results into one observable sequence.
  11518. /// </summary>
  11519. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11520. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11521. /// <param name="source">An observable sequence of elements to project.</param>
  11522. /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11523. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11524. /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11525. /// <exception cref="ArgumentNullException">
  11526. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11527. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, CancellationToken, Task<TResult>>> selector)
  11528. {
  11529. if (source == null)
  11530. throw new ArgumentNullException(nameof(source));
  11531. if (selector == null)
  11532. throw new ArgumentNullException(nameof(selector));
  11533. return source.Provider.CreateQuery<TResult>(
  11534. Expression.Call(
  11535. null,
  11536. #if CRIPPLED_REFLECTION
  11537. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TResult>>>))),
  11538. #else
  11539. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11540. #endif
  11541. source.Expression,
  11542. selector
  11543. )
  11544. );
  11545. }
  11546. /// <summary>
  11547. /// Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.
  11548. /// </summary>
  11549. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11550. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11551. /// <param name="source">An observable sequence of elements to project.</param>
  11552. /// <param name="selector">A transform function to apply to each element.</param>
  11553. /// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.</returns>
  11554. /// <exception cref="ArgumentNullException">
  11555. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11556. /// <remarks>The projected sequences are enumerated synchronously within the OnNext call of the source sequence. In order to do a concurrent, non-blocking merge, change the selector to return an observable sequence obtained using the <see cref="M:System.Reactive.Linq.Observable.ToObservable``1(System.Collections.Generic.IEnumerable{``0})" /> conversion.</remarks>
  11557. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector)
  11558. {
  11559. if (source == null)
  11560. throw new ArgumentNullException(nameof(source));
  11561. if (selector == null)
  11562. throw new ArgumentNullException(nameof(selector));
  11563. return source.Provider.CreateQuery<TResult>(
  11564. Expression.Call(
  11565. null,
  11566. #if CRIPPLED_REFLECTION
  11567. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TResult>>>))),
  11568. #else
  11569. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11570. #endif
  11571. source.Expression,
  11572. selector
  11573. )
  11574. );
  11575. }
  11576. /// <summary>
  11577. /// Projects each element of an observable sequence to an enumerable sequence by incorporating the element's index and concatenates the resulting enumerable sequences into one observable sequence.
  11578. /// </summary>
  11579. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11580. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11581. /// <param name="source">An observable sequence of elements to project.</param>
  11582. /// <param name="selector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11583. /// <returns>An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence.</returns>
  11584. /// <exception cref="ArgumentNullException">
  11585. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11586. /// <remarks>The projected sequences are enumerated synchronously within the OnNext call of the source sequence. In order to do a concurrent, non-blocking merge, change the selector to return an observable sequence obtained using the <see cref="M:System.Reactive.Linq.Observable.ToObservable``1(System.Collections.Generic.IEnumerable{``0})" /> conversion.</remarks>
  11587. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IEnumerable<TResult>>> selector)
  11588. {
  11589. if (source == null)
  11590. throw new ArgumentNullException(nameof(source));
  11591. if (selector == null)
  11592. throw new ArgumentNullException(nameof(selector));
  11593. return source.Provider.CreateQuery<TResult>(
  11594. Expression.Call(
  11595. null,
  11596. #if CRIPPLED_REFLECTION
  11597. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TResult>>>))),
  11598. #else
  11599. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11600. #endif
  11601. source.Expression,
  11602. selector
  11603. )
  11604. );
  11605. }
  11606. /// <summary>
  11607. /// Projects each element of an observable sequence to a task, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.
  11608. /// </summary>
  11609. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11610. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11611. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate task results.</typeparam>
  11612. /// <param name="source">An observable sequence of elements to project.</param>
  11613. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11614. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11615. /// <returns>An observable sequence whose elements are the result of obtaining a task for each element of the input sequence and then mapping the task's result and its corresponding source element to a result element.</returns>
  11616. /// <exception cref="ArgumentNullException">
  11617. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11618. /// <remarks>This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11619. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, TTaskResult, TResult>> resultSelector)
  11620. {
  11621. if (source == null)
  11622. throw new ArgumentNullException(nameof(source));
  11623. if (taskSelector == null)
  11624. throw new ArgumentNullException(nameof(taskSelector));
  11625. if (resultSelector == null)
  11626. throw new ArgumentNullException(nameof(resultSelector));
  11627. return source.Provider.CreateQuery<TResult>(
  11628. Expression.Call(
  11629. null,
  11630. #if CRIPPLED_REFLECTION
  11631. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11632. #else
  11633. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11634. #endif
  11635. source.Expression,
  11636. taskSelector,
  11637. resultSelector
  11638. )
  11639. );
  11640. }
  11641. /// <summary>
  11642. /// Projects each element of an observable sequence to a task by incorporating the element's index, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.
  11643. /// </summary>
  11644. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11645. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11646. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate task results.</typeparam>
  11647. /// <param name="source">An observable sequence of elements to project.</param>
  11648. /// <param name="taskSelector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11649. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element.</param>
  11650. /// <returns>An observable sequence whose elements are the result of obtaining a task for each element of the input sequence and then mapping the task's result and its corresponding source element to a result element.</returns>
  11651. /// <exception cref="ArgumentNullException">
  11652. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11653. /// <remarks>This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11654. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, int, TTaskResult, TResult>> resultSelector)
  11655. {
  11656. if (source == null)
  11657. throw new ArgumentNullException(nameof(source));
  11658. if (taskSelector == null)
  11659. throw new ArgumentNullException(nameof(taskSelector));
  11660. if (resultSelector == null)
  11661. throw new ArgumentNullException(nameof(resultSelector));
  11662. return source.Provider.CreateQuery<TResult>(
  11663. Expression.Call(
  11664. null,
  11665. #if CRIPPLED_REFLECTION
  11666. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11667. #else
  11668. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11669. #endif
  11670. source.Expression,
  11671. taskSelector,
  11672. resultSelector
  11673. )
  11674. );
  11675. }
  11676. /// <summary>
  11677. /// Projects each element of an observable sequence to a task with cancellation support, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.
  11678. /// </summary>
  11679. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11680. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11681. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate task results.</typeparam>
  11682. /// <param name="source">An observable sequence of elements to project.</param>
  11683. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11684. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11685. /// <returns>An observable sequence whose elements are the result of obtaining a task for each element of the input sequence and then mapping the task's result and its corresponding source element to a result element.</returns>
  11686. /// <exception cref="ArgumentNullException">
  11687. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11688. /// <remarks>This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11689. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, CancellationToken, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, TTaskResult, TResult>> resultSelector)
  11690. {
  11691. if (source == null)
  11692. throw new ArgumentNullException(nameof(source));
  11693. if (taskSelector == null)
  11694. throw new ArgumentNullException(nameof(taskSelector));
  11695. if (resultSelector == null)
  11696. throw new ArgumentNullException(nameof(resultSelector));
  11697. return source.Provider.CreateQuery<TResult>(
  11698. Expression.Call(
  11699. null,
  11700. #if CRIPPLED_REFLECTION
  11701. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11702. #else
  11703. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11704. #endif
  11705. source.Expression,
  11706. taskSelector,
  11707. resultSelector
  11708. )
  11709. );
  11710. }
  11711. /// <summary>
  11712. /// Projects each element of an observable sequence to a task by incorporating the element's index with cancellation support, invokes the result selector for the source element and the task result, and merges the results into one observable sequence.
  11713. /// </summary>
  11714. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11715. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11716. /// <typeparam name="TResult">The type of the elements in the result sequence, obtained by using the selector to combine source sequence elements with their corresponding intermediate task results.</typeparam>
  11717. /// <param name="source">An observable sequence of elements to project.</param>
  11718. /// <param name="taskSelector">A transform function to apply to each element; the second parameter of the function represents the index of the source element.</param>
  11719. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence; the second parameter of the function represents the index of the source element.</param>
  11720. /// <returns>An observable sequence whose elements are the result of obtaining a task for each element of the input sequence and then mapping the task's result and its corresponding source element to a result element.</returns>
  11721. /// <exception cref="ArgumentNullException">
  11722. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11723. /// <remarks>This overload supports using LINQ query comprehension syntax in C# and Visual Basic to compose observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="M:System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable``1(System.Threading.Tasks.Task{``0})" />.</remarks>
  11724. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, CancellationToken, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, int, TTaskResult, TResult>> resultSelector)
  11725. {
  11726. if (source == null)
  11727. throw new ArgumentNullException(nameof(source));
  11728. if (taskSelector == null)
  11729. throw new ArgumentNullException(nameof(taskSelector));
  11730. if (resultSelector == null)
  11731. throw new ArgumentNullException(nameof(resultSelector));
  11732. return source.Provider.CreateQuery<TResult>(
  11733. Expression.Call(
  11734. null,
  11735. #if CRIPPLED_REFLECTION
  11736. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11737. #else
  11738. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11739. #endif
  11740. source.Expression,
  11741. taskSelector,
  11742. resultSelector
  11743. )
  11744. );
  11745. }
  11746. /// <summary>
  11747. /// Determines whether two sequences are equal by comparing the elements pairwise.
  11748. /// </summary>
  11749. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11750. /// <param name="first">First observable sequence to compare.</param>
  11751. /// <param name="second">Second observable sequence to compare.</param>
  11752. /// <returns>An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type.</returns>
  11753. /// <exception cref="ArgumentNullException">
  11754. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11755. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11756. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  11757. {
  11758. if (first == null)
  11759. throw new ArgumentNullException(nameof(first));
  11760. if (second == null)
  11761. throw new ArgumentNullException(nameof(second));
  11762. return first.Provider.CreateQuery<bool>(
  11763. Expression.Call(
  11764. null,
  11765. #if CRIPPLED_REFLECTION
  11766. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  11767. #else
  11768. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11769. #endif
  11770. first.Expression,
  11771. GetSourceExpression(second)
  11772. )
  11773. );
  11774. }
  11775. /// <summary>
  11776. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise.
  11777. /// </summary>
  11778. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11779. /// <param name="first">First observable sequence to compare.</param>
  11780. /// <param name="second">Second observable sequence to compare.</param>
  11781. /// <returns>An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type.</returns>
  11782. /// <exception cref="ArgumentNullException">
  11783. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11784. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11785. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second)
  11786. {
  11787. if (first == null)
  11788. throw new ArgumentNullException(nameof(first));
  11789. if (second == null)
  11790. throw new ArgumentNullException(nameof(second));
  11791. return first.Provider.CreateQuery<bool>(
  11792. Expression.Call(
  11793. null,
  11794. #if CRIPPLED_REFLECTION
  11795. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  11796. #else
  11797. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11798. #endif
  11799. first.Expression,
  11800. GetSourceExpression(second)
  11801. )
  11802. );
  11803. }
  11804. /// <summary>
  11805. /// Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
  11806. /// </summary>
  11807. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11808. /// <param name="first">First observable sequence to compare.</param>
  11809. /// <param name="second">Second observable sequence to compare.</param>
  11810. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11811. /// <returns>An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.</returns>
  11812. /// <exception cref="ArgumentNullException">
  11813. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11814. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11815. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IEqualityComparer<TSource> comparer)
  11816. {
  11817. if (first == null)
  11818. throw new ArgumentNullException(nameof(first));
  11819. if (second == null)
  11820. throw new ArgumentNullException(nameof(second));
  11821. if (comparer == null)
  11822. throw new ArgumentNullException(nameof(comparer));
  11823. return first.Provider.CreateQuery<bool>(
  11824. Expression.Call(
  11825. null,
  11826. #if CRIPPLED_REFLECTION
  11827. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IEqualityComparer<TSource>))),
  11828. #else
  11829. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11830. #endif
  11831. first.Expression,
  11832. GetSourceExpression(second),
  11833. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11834. )
  11835. );
  11836. }
  11837. /// <summary>
  11838. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise using a specified equality comparer.
  11839. /// </summary>
  11840. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11841. /// <param name="first">First observable sequence to compare.</param>
  11842. /// <param name="second">Second observable sequence to compare.</param>
  11843. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11844. /// <returns>An observable sequence that contains a single element which indicates whether both sequences are of equal length and their corresponding elements are equal according to the specified equality comparer.</returns>
  11845. /// <exception cref="ArgumentNullException">
  11846. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11847. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11848. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  11849. {
  11850. if (first == null)
  11851. throw new ArgumentNullException(nameof(first));
  11852. if (second == null)
  11853. throw new ArgumentNullException(nameof(second));
  11854. if (comparer == null)
  11855. throw new ArgumentNullException(nameof(comparer));
  11856. return first.Provider.CreateQuery<bool>(
  11857. Expression.Call(
  11858. null,
  11859. #if CRIPPLED_REFLECTION
  11860. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>), default(IEqualityComparer<TSource>))),
  11861. #else
  11862. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11863. #endif
  11864. first.Expression,
  11865. GetSourceExpression(second),
  11866. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11867. )
  11868. );
  11869. }
  11870. /// <summary>
  11871. /// Returns the only element of an observable sequence, and reports an exception if there is not exactly one element in the observable sequence.
  11872. /// </summary>
  11873. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11874. /// <param name="source">Source observable sequence.</param>
  11875. /// <returns>Sequence containing the single element in the observable sequence.</returns>
  11876. /// <exception cref="ArgumentNullException">
  11877. /// <paramref name="source" /> is null.</exception>
  11878. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence contains more than one element. -or- The source sequence is empty.</exception>
  11879. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source)
  11880. {
  11881. if (source == null)
  11882. throw new ArgumentNullException(nameof(source));
  11883. return source.Provider.CreateQuery<TSource>(
  11884. Expression.Call(
  11885. null,
  11886. #if CRIPPLED_REFLECTION
  11887. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>))),
  11888. #else
  11889. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11890. #endif
  11891. source.Expression
  11892. )
  11893. );
  11894. }
  11895. /// <summary>
  11896. /// Returns the only element of an observable sequence that satisfies the condition in the predicate, and reports an exception if there is not exactly one element in the observable sequence.
  11897. /// </summary>
  11898. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11899. /// <param name="source">Source observable sequence.</param>
  11900. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  11901. /// <returns>Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.</returns>
  11902. /// <exception cref="ArgumentNullException">
  11903. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  11904. /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- More than one element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  11905. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  11906. {
  11907. if (source == null)
  11908. throw new ArgumentNullException(nameof(source));
  11909. if (predicate == null)
  11910. throw new ArgumentNullException(nameof(predicate));
  11911. return source.Provider.CreateQuery<TSource>(
  11912. Expression.Call(
  11913. null,
  11914. #if CRIPPLED_REFLECTION
  11915. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  11916. #else
  11917. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11918. #endif
  11919. source.Expression,
  11920. predicate
  11921. )
  11922. );
  11923. }
  11924. /// <summary>
  11925. /// Returns the only element of an observable sequence, or a default value if the observable sequence is empty; this method reports an exception if there is more than one element in the observable sequence.
  11926. /// </summary>
  11927. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11928. /// <param name="source">Source observable sequence.</param>
  11929. /// <returns>Sequence containing the single element in the observable sequence, or a default value if no such element exists.</returns>
  11930. /// <exception cref="ArgumentNullException">
  11931. /// <paramref name="source" /> is null.</exception>
  11932. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence contains more than one element.</exception>
  11933. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  11934. {
  11935. if (source == null)
  11936. throw new ArgumentNullException(nameof(source));
  11937. return source.Provider.CreateQuery<TSource>(
  11938. Expression.Call(
  11939. null,
  11940. #if CRIPPLED_REFLECTION
  11941. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  11942. #else
  11943. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11944. #endif
  11945. source.Expression
  11946. )
  11947. );
  11948. }
  11949. /// <summary>
  11950. /// Returns the only element of an observable sequence that matches the predicate, or a default value if no such element exists; this method reports an exception if there is more than one element in the observable sequence.
  11951. /// </summary>
  11952. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11953. /// <param name="source">Source observable sequence.</param>
  11954. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  11955. /// <returns>Sequence containing the single element in the observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.</returns>
  11956. /// <exception cref="ArgumentNullException">
  11957. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  11958. /// <exception cref="InvalidOperationException">(Asynchronous) The sequence contains more than one element that satisfies the condition in the predicate.</exception>
  11959. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  11960. {
  11961. if (source == null)
  11962. throw new ArgumentNullException(nameof(source));
  11963. if (predicate == null)
  11964. throw new ArgumentNullException(nameof(predicate));
  11965. return source.Provider.CreateQuery<TSource>(
  11966. Expression.Call(
  11967. null,
  11968. #if CRIPPLED_REFLECTION
  11969. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  11970. #else
  11971. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11972. #endif
  11973. source.Expression,
  11974. predicate
  11975. )
  11976. );
  11977. }
  11978. /// <summary>
  11979. /// Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
  11980. /// </summary>
  11981. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11982. /// <param name="source">The sequence to take elements from.</param>
  11983. /// <param name="count">The number of elements to skip before returning the remaining elements.</param>
  11984. /// <returns>An observable sequence that contains the elements that occur after the specified index in the input sequence.</returns>
  11985. /// <exception cref="ArgumentNullException">
  11986. /// <paramref name="source" /> is null.</exception>
  11987. /// <exception cref="ArgumentOutOfRangeException">
  11988. /// <paramref name="count" /> is less than zero.</exception>
  11989. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, int count)
  11990. {
  11991. if (source == null)
  11992. throw new ArgumentNullException(nameof(source));
  11993. return source.Provider.CreateQuery<TSource>(
  11994. Expression.Call(
  11995. null,
  11996. #if CRIPPLED_REFLECTION
  11997. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(int))),
  11998. #else
  11999. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12000. #endif
  12001. source.Expression,
  12002. Expression.Constant(count, typeof(int))
  12003. )
  12004. );
  12005. }
  12006. /// <summary>
  12007. /// Skips elements for the specified duration from the start of the observable source sequence.
  12008. /// </summary>
  12009. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12010. /// <param name="source">Source sequence to skip elements for.</param>
  12011. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12012. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12013. /// <exception cref="ArgumentNullException">
  12014. /// <paramref name="source" /> is null.</exception>
  12015. /// <exception cref="ArgumentOutOfRangeException">
  12016. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12017. /// <remarks>
  12018. /// <para>
  12019. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12020. /// This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded
  12021. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12022. /// </para>
  12023. /// <para>
  12024. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12025. /// </para>
  12026. /// </remarks>
  12027. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12028. {
  12029. if (source == null)
  12030. throw new ArgumentNullException(nameof(source));
  12031. return source.Provider.CreateQuery<TSource>(
  12032. Expression.Call(
  12033. null,
  12034. #if CRIPPLED_REFLECTION
  12035. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12036. #else
  12037. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12038. #endif
  12039. source.Expression,
  12040. Expression.Constant(duration, typeof(TimeSpan))
  12041. )
  12042. );
  12043. }
  12044. /// <summary>
  12045. /// Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  12046. /// </summary>
  12047. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12048. /// <param name="source">Source sequence to skip elements for.</param>
  12049. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12050. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12051. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12052. /// <exception cref="ArgumentNullException">
  12053. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12054. /// <exception cref="ArgumentOutOfRangeException">
  12055. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12056. /// <remarks>
  12057. /// <para>
  12058. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12059. /// This is a side-effect of the asynchrony introduced by the scheduler, where the action that causes callbacks from the source sequence to be forwarded
  12060. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12061. /// </para>
  12062. /// <para>
  12063. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12064. /// </para>
  12065. /// </remarks>
  12066. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  12067. {
  12068. if (source == null)
  12069. throw new ArgumentNullException(nameof(source));
  12070. if (scheduler == null)
  12071. throw new ArgumentNullException(nameof(scheduler));
  12072. return source.Provider.CreateQuery<TSource>(
  12073. Expression.Call(
  12074. null,
  12075. #if CRIPPLED_REFLECTION
  12076. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12077. #else
  12078. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12079. #endif
  12080. source.Expression,
  12081. Expression.Constant(duration, typeof(TimeSpan)),
  12082. Expression.Constant(scheduler, typeof(IScheduler))
  12083. )
  12084. );
  12085. }
  12086. /// <summary>
  12087. /// Bypasses a specified number of elements at the end of an observable sequence.
  12088. /// </summary>
  12089. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12090. /// <param name="source">Source sequence.</param>
  12091. /// <param name="count">Number of elements to bypass at the end of the source sequence.</param>
  12092. /// <returns>An observable sequence containing the source sequence elements except for the bypassed ones at the end.</returns>
  12093. /// <exception cref="ArgumentNullException">
  12094. /// <paramref name="source" /> is null.</exception>
  12095. /// <exception cref="ArgumentOutOfRangeException">
  12096. /// <paramref name="count" /> is less than zero.</exception>
  12097. /// <remarks>
  12098. /// This operator accumulates a queue with a length enough to store the first <paramref name="count" /> elements. As more elements are
  12099. /// received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
  12100. /// </remarks>
  12101. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, int count)
  12102. {
  12103. if (source == null)
  12104. throw new ArgumentNullException(nameof(source));
  12105. return source.Provider.CreateQuery<TSource>(
  12106. Expression.Call(
  12107. null,
  12108. #if CRIPPLED_REFLECTION
  12109. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(int))),
  12110. #else
  12111. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12112. #endif
  12113. source.Expression,
  12114. Expression.Constant(count, typeof(int))
  12115. )
  12116. );
  12117. }
  12118. /// <summary>
  12119. /// Skips elements for the specified duration from the end of the observable source sequence.
  12120. /// </summary>
  12121. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12122. /// <param name="source">Source sequence to skip elements for.</param>
  12123. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12124. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12125. /// <exception cref="ArgumentNullException">
  12126. /// <paramref name="source" /> is null.</exception>
  12127. /// <exception cref="ArgumentOutOfRangeException">
  12128. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12129. /// <remarks>
  12130. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12131. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12132. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12133. /// </remarks>
  12134. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12135. {
  12136. if (source == null)
  12137. throw new ArgumentNullException(nameof(source));
  12138. return source.Provider.CreateQuery<TSource>(
  12139. Expression.Call(
  12140. null,
  12141. #if CRIPPLED_REFLECTION
  12142. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12143. #else
  12144. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12145. #endif
  12146. source.Expression,
  12147. Expression.Constant(duration, typeof(TimeSpan))
  12148. )
  12149. );
  12150. }
  12151. /// <summary>
  12152. /// Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  12153. /// </summary>
  12154. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12155. /// <param name="source">Source sequence to skip elements for.</param>
  12156. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12157. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12158. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12159. /// <exception cref="ArgumentNullException">
  12160. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12161. /// <exception cref="ArgumentOutOfRangeException">
  12162. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12163. /// <remarks>
  12164. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12165. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12166. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12167. /// </remarks>
  12168. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  12169. {
  12170. if (source == null)
  12171. throw new ArgumentNullException(nameof(source));
  12172. if (scheduler == null)
  12173. throw new ArgumentNullException(nameof(scheduler));
  12174. return source.Provider.CreateQuery<TSource>(
  12175. Expression.Call(
  12176. null,
  12177. #if CRIPPLED_REFLECTION
  12178. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12179. #else
  12180. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12181. #endif
  12182. source.Expression,
  12183. Expression.Constant(duration, typeof(TimeSpan)),
  12184. Expression.Constant(scheduler, typeof(IScheduler))
  12185. )
  12186. );
  12187. }
  12188. /// <summary>
  12189. /// Skips elements from the observable source sequence until the specified start time.
  12190. /// </summary>
  12191. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12192. /// <param name="source">Source sequence to skip elements for.</param>
  12193. /// <param name="startTime">Time to start taking elements from the source sequence. If this value is less than or equal to DateTimeOffset.UtcNow, no elements will be skipped.</param>
  12194. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12195. /// <exception cref="ArgumentNullException">
  12196. /// <paramref name="source" /> is null.</exception>
  12197. /// <remarks>
  12198. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12199. /// </remarks>
  12200. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime)
  12201. {
  12202. if (source == null)
  12203. throw new ArgumentNullException(nameof(source));
  12204. return source.Provider.CreateQuery<TSource>(
  12205. Expression.Call(
  12206. null,
  12207. #if CRIPPLED_REFLECTION
  12208. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  12209. #else
  12210. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12211. #endif
  12212. source.Expression,
  12213. Expression.Constant(startTime, typeof(DateTimeOffset))
  12214. )
  12215. );
  12216. }
  12217. /// <summary>
  12218. /// Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  12219. /// </summary>
  12220. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12221. /// <param name="source">Source sequence to skip elements for.</param>
  12222. /// <param name="startTime">Time to start taking elements from the source sequence. If this value is less than or equal to DateTimeOffset.UtcNow, no elements will be skipped.</param>
  12223. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12224. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12225. /// <exception cref="ArgumentNullException">
  12226. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12227. /// <remarks>
  12228. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12229. /// </remarks>
  12230. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime, IScheduler scheduler)
  12231. {
  12232. if (source == null)
  12233. throw new ArgumentNullException(nameof(source));
  12234. if (scheduler == null)
  12235. throw new ArgumentNullException(nameof(scheduler));
  12236. return source.Provider.CreateQuery<TSource>(
  12237. Expression.Call(
  12238. null,
  12239. #if CRIPPLED_REFLECTION
  12240. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  12241. #else
  12242. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12243. #endif
  12244. source.Expression,
  12245. Expression.Constant(startTime, typeof(DateTimeOffset)),
  12246. Expression.Constant(scheduler, typeof(IScheduler))
  12247. )
  12248. );
  12249. }
  12250. /// <summary>
  12251. /// Returns the elements from the source observable sequence only after the other observable sequence produces an element.
  12252. /// Starting from Rx.NET 4.0, this will subscribe to <paramref name="other" /> before subscribing to <paramref name="source" />
  12253. /// so in case <paramref name="other" /> emits an element right away, elements from <paramref name="source" /> are not missed.
  12254. /// </summary>
  12255. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12256. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of skip behavior.</typeparam>
  12257. /// <param name="source">Source sequence to propagate elements for.</param>
  12258. /// <param name="other">Observable sequence that triggers propagation of elements of the source sequence.</param>
  12259. /// <returns>An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.</returns>
  12260. /// <exception cref="ArgumentNullException">
  12261. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  12262. public static IQbservable<TSource> SkipUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  12263. {
  12264. if (source == null)
  12265. throw new ArgumentNullException(nameof(source));
  12266. if (other == null)
  12267. throw new ArgumentNullException(nameof(other));
  12268. return source.Provider.CreateQuery<TSource>(
  12269. Expression.Call(
  12270. null,
  12271. #if CRIPPLED_REFLECTION
  12272. InfoOf(() => Qbservable.SkipUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  12273. #else
  12274. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  12275. #endif
  12276. source.Expression,
  12277. GetSourceExpression(other)
  12278. )
  12279. );
  12280. }
  12281. /// <summary>
  12282. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12283. /// </summary>
  12284. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12285. /// <param name="source">An observable sequence to return elements from.</param>
  12286. /// <param name="predicate">A function to test each element for a condition.</param>
  12287. /// <returns>An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.</returns>
  12288. /// <exception cref="ArgumentNullException">
  12289. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12290. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12291. {
  12292. if (source == null)
  12293. throw new ArgumentNullException(nameof(source));
  12294. if (predicate == null)
  12295. throw new ArgumentNullException(nameof(predicate));
  12296. return source.Provider.CreateQuery<TSource>(
  12297. Expression.Call(
  12298. null,
  12299. #if CRIPPLED_REFLECTION
  12300. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12301. #else
  12302. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12303. #endif
  12304. source.Expression,
  12305. predicate
  12306. )
  12307. );
  12308. }
  12309. /// <summary>
  12310. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12311. /// The element's index is used in the logic of the predicate function.
  12312. /// </summary>
  12313. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12314. /// <param name="source">An observable sequence to return elements from.</param>
  12315. /// <param name="predicate">A function to test each element for a condition; the second parameter of the function represents the index of the source element.</param>
  12316. /// <returns>An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate.</returns>
  12317. /// <exception cref="ArgumentNullException">
  12318. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12319. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  12320. {
  12321. if (source == null)
  12322. throw new ArgumentNullException(nameof(source));
  12323. if (predicate == null)
  12324. throw new ArgumentNullException(nameof(predicate));
  12325. return source.Provider.CreateQuery<TSource>(
  12326. Expression.Call(
  12327. null,
  12328. #if CRIPPLED_REFLECTION
  12329. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  12330. #else
  12331. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12332. #endif
  12333. source.Expression,
  12334. predicate
  12335. )
  12336. );
  12337. }
  12338. /// <summary>
  12339. /// Invokes the action asynchronously, surfacing the result through an observable sequence.
  12340. /// </summary>
  12341. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12342. /// <param name="action">Action to run asynchronously.</param>
  12343. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12344. /// <exception cref="ArgumentNullException">
  12345. /// <paramref name="action" /> is null.</exception>
  12346. /// <remarks>
  12347. /// <list type="bullet">
  12348. /// <item>
  12349. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12350. /// </item>
  12351. /// <item>
  12352. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12353. /// </item>
  12354. /// </list>
  12355. /// </remarks>
  12356. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action)
  12357. {
  12358. if (provider == null)
  12359. throw new ArgumentNullException(nameof(provider));
  12360. if (action == null)
  12361. throw new ArgumentNullException(nameof(action));
  12362. return provider.CreateQuery<Unit>(
  12363. Expression.Call(
  12364. null,
  12365. #if CRIPPLED_REFLECTION
  12366. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>))),
  12367. #else
  12368. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12369. #endif
  12370. Expression.Constant(provider, typeof(IQbservableProvider)),
  12371. action
  12372. )
  12373. );
  12374. }
  12375. /// <summary>
  12376. /// Invokes the action asynchronously on the specified scheduler, surfacing the result through an observable sequence.
  12377. /// </summary>
  12378. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12379. /// <param name="action">Action to run asynchronously.</param>
  12380. /// <param name="scheduler">Scheduler to run the action on.</param>
  12381. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12382. /// <exception cref="ArgumentNullException">
  12383. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  12384. /// <remarks>
  12385. /// <list type="bullet">
  12386. /// <item>
  12387. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12388. /// </item>
  12389. /// <item>
  12390. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12391. /// </item>
  12392. /// </list>
  12393. /// </remarks>
  12394. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  12395. {
  12396. if (provider == null)
  12397. throw new ArgumentNullException(nameof(provider));
  12398. if (action == null)
  12399. throw new ArgumentNullException(nameof(action));
  12400. if (scheduler == null)
  12401. throw new ArgumentNullException(nameof(scheduler));
  12402. return provider.CreateQuery<Unit>(
  12403. Expression.Call(
  12404. null,
  12405. #if CRIPPLED_REFLECTION
  12406. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>), default(IScheduler))),
  12407. #else
  12408. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12409. #endif
  12410. Expression.Constant(provider, typeof(IQbservableProvider)),
  12411. action,
  12412. Expression.Constant(scheduler, typeof(IScheduler))
  12413. )
  12414. );
  12415. }
  12416. /// <summary>
  12417. /// Invokes the specified function asynchronously, surfacing the result through an observable sequence.
  12418. /// </summary>
  12419. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12420. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12421. /// <param name="function">Function to run asynchronously.</param>
  12422. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12423. /// <exception cref="ArgumentNullException">
  12424. /// <paramref name="function" /> is null.</exception>
  12425. /// <remarks>
  12426. /// <list type="bullet">
  12427. /// <item>
  12428. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12429. /// </item>
  12430. /// <item>
  12431. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12432. /// </item>
  12433. /// </list>
  12434. /// </remarks>
  12435. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  12436. {
  12437. if (provider == null)
  12438. throw new ArgumentNullException(nameof(provider));
  12439. if (function == null)
  12440. throw new ArgumentNullException(nameof(function));
  12441. return provider.CreateQuery<TResult>(
  12442. Expression.Call(
  12443. null,
  12444. #if CRIPPLED_REFLECTION
  12445. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>))),
  12446. #else
  12447. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12448. #endif
  12449. Expression.Constant(provider, typeof(IQbservableProvider)),
  12450. function
  12451. )
  12452. );
  12453. }
  12454. /// <summary>
  12455. /// Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence
  12456. /// </summary>
  12457. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12458. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12459. /// <param name="function">Function to run asynchronously.</param>
  12460. /// <param name="scheduler">Scheduler to run the function on.</param>
  12461. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12462. /// <exception cref="ArgumentNullException">
  12463. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  12464. /// <remarks>
  12465. /// <list type="bullet">
  12466. /// <item>
  12467. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12468. /// </item>
  12469. /// <item>
  12470. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12471. /// </item>
  12472. /// </list>
  12473. /// </remarks>
  12474. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  12475. {
  12476. if (provider == null)
  12477. throw new ArgumentNullException(nameof(provider));
  12478. if (function == null)
  12479. throw new ArgumentNullException(nameof(function));
  12480. if (scheduler == null)
  12481. throw new ArgumentNullException(nameof(scheduler));
  12482. return provider.CreateQuery<TResult>(
  12483. Expression.Call(
  12484. null,
  12485. #if CRIPPLED_REFLECTION
  12486. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler))),
  12487. #else
  12488. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12489. #endif
  12490. Expression.Constant(provider, typeof(IQbservableProvider)),
  12491. function,
  12492. Expression.Constant(scheduler, typeof(IScheduler))
  12493. )
  12494. );
  12495. }
  12496. /// <summary>
  12497. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12498. /// </summary>
  12499. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12500. /// <param name="actionAsync">Asynchronous action to run.</param>
  12501. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12502. /// <exception cref="ArgumentNullException">
  12503. /// <paramref name="actionAsync" /> is null.</exception>
  12504. /// <remarks>
  12505. /// <list type="bullet">
  12506. /// <item>
  12507. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12508. /// </item>
  12509. /// <item>
  12510. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12511. /// </item>
  12512. /// </list>
  12513. /// </remarks>
  12514. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  12515. {
  12516. if (provider == null)
  12517. throw new ArgumentNullException(nameof(provider));
  12518. if (actionAsync == null)
  12519. throw new ArgumentNullException(nameof(actionAsync));
  12520. return provider.CreateQuery<Unit>(
  12521. Expression.Call(
  12522. null,
  12523. #if CRIPPLED_REFLECTION
  12524. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  12525. #else
  12526. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12527. #endif
  12528. Expression.Constant(provider, typeof(IQbservableProvider)),
  12529. actionAsync
  12530. )
  12531. );
  12532. }
  12533. /// <summary>
  12534. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12535. /// </summary>
  12536. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12537. /// <param name="actionAsync">Asynchronous action to run.</param>
  12538. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12539. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12540. /// <exception cref="ArgumentNullException">
  12541. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12542. /// <remarks>
  12543. /// <list type="bullet">
  12544. /// <item>
  12545. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12546. /// </item>
  12547. /// <item>
  12548. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12549. /// </item>
  12550. /// </list>
  12551. /// </remarks>
  12552. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync, IScheduler scheduler)
  12553. {
  12554. if (provider == null)
  12555. throw new ArgumentNullException(nameof(provider));
  12556. if (actionAsync == null)
  12557. throw new ArgumentNullException(nameof(actionAsync));
  12558. if (scheduler == null)
  12559. throw new ArgumentNullException(nameof(scheduler));
  12560. return provider.CreateQuery<Unit>(
  12561. Expression.Call(
  12562. null,
  12563. #if CRIPPLED_REFLECTION
  12564. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>), default(IScheduler))),
  12565. #else
  12566. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12567. #endif
  12568. Expression.Constant(provider, typeof(IQbservableProvider)),
  12569. actionAsync,
  12570. Expression.Constant(scheduler, typeof(IScheduler))
  12571. )
  12572. );
  12573. }
  12574. /// <summary>
  12575. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12576. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12577. /// </summary>
  12578. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12579. /// <param name="actionAsync">Asynchronous action to run.</param>
  12580. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12581. /// <exception cref="ArgumentNullException">
  12582. /// <paramref name="actionAsync" /> is null.</exception>
  12583. /// <remarks>
  12584. /// <list type="bullet">
  12585. /// <item>
  12586. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12587. /// </item>
  12588. /// <item>
  12589. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12590. /// </item>
  12591. /// <item>
  12592. /// <description>
  12593. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12594. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12595. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12596. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12597. /// multicast operators.
  12598. /// </description>
  12599. /// </item>
  12600. /// </list>
  12601. /// </remarks>
  12602. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  12603. {
  12604. if (provider == null)
  12605. throw new ArgumentNullException(nameof(provider));
  12606. if (actionAsync == null)
  12607. throw new ArgumentNullException(nameof(actionAsync));
  12608. return provider.CreateQuery<Unit>(
  12609. Expression.Call(
  12610. null,
  12611. #if CRIPPLED_REFLECTION
  12612. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  12613. #else
  12614. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12615. #endif
  12616. Expression.Constant(provider, typeof(IQbservableProvider)),
  12617. actionAsync
  12618. )
  12619. );
  12620. }
  12621. /// <summary>
  12622. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12623. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12624. /// </summary>
  12625. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12626. /// <param name="actionAsync">Asynchronous action to run.</param>
  12627. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12628. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12629. /// <exception cref="ArgumentNullException">
  12630. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12631. /// <remarks>
  12632. /// <list type="bullet">
  12633. /// <item>
  12634. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12635. /// </item>
  12636. /// <item>
  12637. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12638. /// </item>
  12639. /// <item>
  12640. /// <description>
  12641. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12642. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12643. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12644. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12645. /// multicast operators.
  12646. /// </description>
  12647. /// </item>
  12648. /// </list>
  12649. /// </remarks>
  12650. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync, IScheduler scheduler)
  12651. {
  12652. if (provider == null)
  12653. throw new ArgumentNullException(nameof(provider));
  12654. if (actionAsync == null)
  12655. throw new ArgumentNullException(nameof(actionAsync));
  12656. if (scheduler == null)
  12657. throw new ArgumentNullException(nameof(scheduler));
  12658. return provider.CreateQuery<Unit>(
  12659. Expression.Call(
  12660. null,
  12661. #if CRIPPLED_REFLECTION
  12662. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>), default(IScheduler))),
  12663. #else
  12664. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12665. #endif
  12666. Expression.Constant(provider, typeof(IQbservableProvider)),
  12667. actionAsync,
  12668. Expression.Constant(scheduler, typeof(IScheduler))
  12669. )
  12670. );
  12671. }
  12672. /// <summary>
  12673. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12674. /// </summary>
  12675. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12676. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12677. /// <param name="functionAsync">Asynchronous function to run.</param>
  12678. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12679. /// <exception cref="ArgumentNullException">
  12680. /// <paramref name="functionAsync" /> is null.</exception>
  12681. /// <remarks>
  12682. /// <list type="bullet">
  12683. /// <item>
  12684. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12685. /// </item>
  12686. /// <item>
  12687. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12688. /// </item>
  12689. /// </list>
  12690. /// </remarks>
  12691. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  12692. {
  12693. if (provider == null)
  12694. throw new ArgumentNullException(nameof(provider));
  12695. if (functionAsync == null)
  12696. throw new ArgumentNullException(nameof(functionAsync));
  12697. return provider.CreateQuery<TResult>(
  12698. Expression.Call(
  12699. null,
  12700. #if CRIPPLED_REFLECTION
  12701. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  12702. #else
  12703. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12704. #endif
  12705. Expression.Constant(provider, typeof(IQbservableProvider)),
  12706. functionAsync
  12707. )
  12708. );
  12709. }
  12710. /// <summary>
  12711. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12712. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12713. /// </summary>
  12714. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12715. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12716. /// <param name="functionAsync">Asynchronous function to run.</param>
  12717. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12718. /// <exception cref="ArgumentNullException">
  12719. /// <paramref name="functionAsync" /> is null.</exception>
  12720. /// <remarks>
  12721. /// <list type="bullet">
  12722. /// <item>
  12723. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12724. /// </item>
  12725. /// <item>
  12726. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12727. /// </item>
  12728. /// <item>
  12729. /// <description>
  12730. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12731. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12732. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12733. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12734. /// multicast operators.
  12735. /// </description>
  12736. /// </item>
  12737. /// </list>
  12738. /// </remarks>
  12739. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  12740. {
  12741. if (provider == null)
  12742. throw new ArgumentNullException(nameof(provider));
  12743. if (functionAsync == null)
  12744. throw new ArgumentNullException(nameof(functionAsync));
  12745. return provider.CreateQuery<TResult>(
  12746. Expression.Call(
  12747. null,
  12748. #if CRIPPLED_REFLECTION
  12749. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  12750. #else
  12751. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12752. #endif
  12753. Expression.Constant(provider, typeof(IQbservableProvider)),
  12754. functionAsync
  12755. )
  12756. );
  12757. }
  12758. /// <summary>
  12759. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12760. /// </summary>
  12761. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12762. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12763. /// <param name="functionAsync">Asynchronous function to run.</param>
  12764. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12765. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12766. /// <exception cref="ArgumentNullException">
  12767. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12768. /// <remarks>
  12769. /// <list type="bullet">
  12770. /// <item>
  12771. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12772. /// </item>
  12773. /// <item>
  12774. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12775. /// </item>
  12776. /// </list>
  12777. /// </remarks>
  12778. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync, IScheduler scheduler)
  12779. {
  12780. if (provider == null)
  12781. throw new ArgumentNullException(nameof(provider));
  12782. if (functionAsync == null)
  12783. throw new ArgumentNullException(nameof(functionAsync));
  12784. if (scheduler == null)
  12785. throw new ArgumentNullException(nameof(scheduler));
  12786. return provider.CreateQuery<TResult>(
  12787. Expression.Call(
  12788. null,
  12789. #if CRIPPLED_REFLECTION
  12790. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>), default(IScheduler))),
  12791. #else
  12792. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12793. #endif
  12794. Expression.Constant(provider, typeof(IQbservableProvider)),
  12795. functionAsync,
  12796. Expression.Constant(scheduler, typeof(IScheduler))
  12797. )
  12798. );
  12799. }
  12800. /// <summary>
  12801. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12802. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12803. /// </summary>
  12804. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12805. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12806. /// <param name="functionAsync">Asynchronous function to run.</param>
  12807. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12808. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12809. /// <exception cref="ArgumentNullException">
  12810. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12811. /// <remarks>
  12812. /// <list type="bullet">
  12813. /// <item>
  12814. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12815. /// </item>
  12816. /// <item>
  12817. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12818. /// </item>
  12819. /// <item>
  12820. /// <description>
  12821. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12822. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12823. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12824. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12825. /// multicast operators.
  12826. /// </description>
  12827. /// </item>
  12828. /// </list>
  12829. /// </remarks>
  12830. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync, IScheduler scheduler)
  12831. {
  12832. if (provider == null)
  12833. throw new ArgumentNullException(nameof(provider));
  12834. if (functionAsync == null)
  12835. throw new ArgumentNullException(nameof(functionAsync));
  12836. if (scheduler == null)
  12837. throw new ArgumentNullException(nameof(scheduler));
  12838. return provider.CreateQuery<TResult>(
  12839. Expression.Call(
  12840. null,
  12841. #if CRIPPLED_REFLECTION
  12842. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>), default(IScheduler))),
  12843. #else
  12844. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12845. #endif
  12846. Expression.Constant(provider, typeof(IQbservableProvider)),
  12847. functionAsync,
  12848. Expression.Constant(scheduler, typeof(IScheduler))
  12849. )
  12850. );
  12851. }
  12852. /// <summary>
  12853. /// Prepends a sequence of values to an observable sequence.
  12854. /// </summary>
  12855. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12856. /// <param name="source">Source sequence to prepend values to.</param>
  12857. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  12858. /// <param name="values">Values to prepend to the specified sequence.</param>
  12859. /// <returns>The source sequence prepended with the specified values.</returns>
  12860. /// <exception cref="ArgumentNullException">
  12861. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  12862. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, params TSource[] values)
  12863. {
  12864. if (source == null)
  12865. throw new ArgumentNullException(nameof(source));
  12866. if (scheduler == null)
  12867. throw new ArgumentNullException(nameof(scheduler));
  12868. if (values == null)
  12869. throw new ArgumentNullException(nameof(values));
  12870. return source.Provider.CreateQuery<TSource>(
  12871. Expression.Call(
  12872. null,
  12873. #if CRIPPLED_REFLECTION
  12874. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(TSource[]))),
  12875. #else
  12876. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12877. #endif
  12878. source.Expression,
  12879. Expression.Constant(scheduler, typeof(IScheduler)),
  12880. Expression.Constant(values, typeof(TSource[]))
  12881. )
  12882. );
  12883. }
  12884. /// <summary>
  12885. /// Prepends a sequence of values to an observable sequence.
  12886. /// </summary>
  12887. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12888. /// <param name="source">Source sequence to prepend values to.</param>
  12889. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  12890. /// <param name="values">Values to prepend to the specified sequence.</param>
  12891. /// <returns>The source sequence prepended with the specified values.</returns>
  12892. /// <exception cref="ArgumentNullException">
  12893. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  12894. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, IEnumerable<TSource> values)
  12895. {
  12896. if (source == null)
  12897. throw new ArgumentNullException(nameof(source));
  12898. if (scheduler == null)
  12899. throw new ArgumentNullException(nameof(scheduler));
  12900. if (values == null)
  12901. throw new ArgumentNullException(nameof(values));
  12902. return source.Provider.CreateQuery<TSource>(
  12903. Expression.Call(
  12904. null,
  12905. #if CRIPPLED_REFLECTION
  12906. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(IEnumerable<TSource>))),
  12907. #else
  12908. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12909. #endif
  12910. source.Expression,
  12911. Expression.Constant(scheduler, typeof(IScheduler)),
  12912. GetSourceExpression(values)
  12913. )
  12914. );
  12915. }
  12916. /// <summary>
  12917. /// Prepends a sequence of values to an observable sequence.
  12918. /// </summary>
  12919. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12920. /// <param name="source">Source sequence to prepend values to.</param>
  12921. /// <param name="values">Values to prepend to the specified sequence.</param>
  12922. /// <returns>The source sequence prepended with the specified values.</returns>
  12923. /// <exception cref="ArgumentNullException">
  12924. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  12925. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, params TSource[] values)
  12926. {
  12927. if (source == null)
  12928. throw new ArgumentNullException(nameof(source));
  12929. if (values == null)
  12930. throw new ArgumentNullException(nameof(values));
  12931. return source.Provider.CreateQuery<TSource>(
  12932. Expression.Call(
  12933. null,
  12934. #if CRIPPLED_REFLECTION
  12935. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(TSource[]))),
  12936. #else
  12937. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12938. #endif
  12939. source.Expression,
  12940. Expression.Constant(values, typeof(TSource[]))
  12941. )
  12942. );
  12943. }
  12944. /// <summary>
  12945. /// Prepends a sequence of values to an observable sequence.
  12946. /// </summary>
  12947. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12948. /// <param name="source">Source sequence to prepend values to.</param>
  12949. /// <param name="values">Values to prepend to the specified sequence.</param>
  12950. /// <returns>The source sequence prepended with the specified values.</returns>
  12951. /// <exception cref="ArgumentNullException">
  12952. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  12953. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IEnumerable<TSource> values)
  12954. {
  12955. if (source == null)
  12956. throw new ArgumentNullException(nameof(source));
  12957. if (values == null)
  12958. throw new ArgumentNullException(nameof(values));
  12959. return source.Provider.CreateQuery<TSource>(
  12960. Expression.Call(
  12961. null,
  12962. #if CRIPPLED_REFLECTION
  12963. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  12964. #else
  12965. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12966. #endif
  12967. source.Expression,
  12968. GetSourceExpression(values)
  12969. )
  12970. );
  12971. }
  12972. /// <summary>
  12973. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context. This operation is not commonly used;
  12974. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  12975. /// </summary>
  12976. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12977. /// <param name="source">Source sequence.</param>
  12978. /// <param name="context">Synchronization context to perform subscription and unsubscription actions on.</param>
  12979. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified synchronization context.</returns>
  12980. /// <exception cref="ArgumentNullException">
  12981. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  12982. /// <remarks>
  12983. /// This only performs the side-effects of subscription and unsubscription on the specified synchronization context. In order to invoke observer
  12984. /// callbacks on a synchronization context, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Threading.SynchronizationContext)" />.
  12985. /// </remarks>
  12986. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  12987. {
  12988. if (source == null)
  12989. throw new ArgumentNullException(nameof(source));
  12990. if (context == null)
  12991. throw new ArgumentNullException(nameof(context));
  12992. return source.Provider.CreateQuery<TSource>(
  12993. Expression.Call(
  12994. null,
  12995. #if CRIPPLED_REFLECTION
  12996. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  12997. #else
  12998. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12999. #endif
  13000. source.Expression,
  13001. Expression.Constant(context, typeof(SynchronizationContext))
  13002. )
  13003. );
  13004. }
  13005. /// <summary>
  13006. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
  13007. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  13008. /// </summary>
  13009. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13010. /// <param name="source">Source sequence.</param>
  13011. /// <param name="scheduler">Scheduler to perform subscription and unsubscription actions on.</param>
  13012. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.</returns>
  13013. /// <exception cref="ArgumentNullException">
  13014. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13015. /// <remarks>
  13016. /// This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
  13017. /// callbacks on a scheduler, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Reactive.Concurrency.IScheduler)" />.
  13018. /// </remarks>
  13019. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  13020. {
  13021. if (source == null)
  13022. throw new ArgumentNullException(nameof(source));
  13023. if (scheduler == null)
  13024. throw new ArgumentNullException(nameof(scheduler));
  13025. return source.Provider.CreateQuery<TSource>(
  13026. Expression.Call(
  13027. null,
  13028. #if CRIPPLED_REFLECTION
  13029. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  13030. #else
  13031. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13032. #endif
  13033. source.Expression,
  13034. Expression.Constant(scheduler, typeof(IScheduler))
  13035. )
  13036. );
  13037. }
  13038. /// <summary>
  13039. /// Computes the sum of a sequence of <see cref="Decimal" /> values.
  13040. /// </summary>
  13041. /// <param name="source">A sequence of <see cref="Decimal" /> values to calculate the sum of.</param>
  13042. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13043. /// <exception cref="ArgumentNullException">
  13044. /// <paramref name="source" /> is null.</exception>
  13045. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  13046. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13047. public static IQbservable<decimal> Sum(this IQbservable<decimal> source)
  13048. {
  13049. if (source == null)
  13050. throw new ArgumentNullException(nameof(source));
  13051. return source.Provider.CreateQuery<decimal>(
  13052. Expression.Call(
  13053. null,
  13054. #if CRIPPLED_REFLECTION
  13055. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal>))),
  13056. #else
  13057. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13058. #endif
  13059. source.Expression
  13060. )
  13061. );
  13062. }
  13063. /// <summary>
  13064. /// Computes the sum of a sequence of <see cref="double" /> values.
  13065. /// </summary>
  13066. /// <param name="source">A sequence of <see cref="double" /> values to calculate the sum of.</param>
  13067. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13068. /// <exception cref="ArgumentNullException">
  13069. /// <paramref name="source" /> is null.</exception>
  13070. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13071. public static IQbservable<double> Sum(this IQbservable<double> source)
  13072. {
  13073. if (source == null)
  13074. throw new ArgumentNullException(nameof(source));
  13075. return source.Provider.CreateQuery<double>(
  13076. Expression.Call(
  13077. null,
  13078. #if CRIPPLED_REFLECTION
  13079. InfoOf(() => Qbservable.Sum(default(IQbservable<double>))),
  13080. #else
  13081. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13082. #endif
  13083. source.Expression
  13084. )
  13085. );
  13086. }
  13087. /// <summary>
  13088. /// Computes the sum of a sequence of <see cref="int" /> values.
  13089. /// </summary>
  13090. /// <param name="source">A sequence of <see cref="int" /> values to calculate the sum of.</param>
  13091. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13092. /// <exception cref="ArgumentNullException">
  13093. /// <paramref name="source" /> is null.</exception>
  13094. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
  13095. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13096. public static IQbservable<int> Sum(this IQbservable<int> source)
  13097. {
  13098. if (source == null)
  13099. throw new ArgumentNullException(nameof(source));
  13100. return source.Provider.CreateQuery<int>(
  13101. Expression.Call(
  13102. null,
  13103. #if CRIPPLED_REFLECTION
  13104. InfoOf(() => Qbservable.Sum(default(IQbservable<int>))),
  13105. #else
  13106. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13107. #endif
  13108. source.Expression
  13109. )
  13110. );
  13111. }
  13112. /// <summary>
  13113. /// Computes the sum of a sequence of <see cref="long" /> values.
  13114. /// </summary>
  13115. /// <param name="source">A sequence of <see cref="long" /> values to calculate the sum of.</param>
  13116. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13117. /// <exception cref="ArgumentNullException">
  13118. /// <paramref name="source" /> is null.</exception>
  13119. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  13120. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13121. public static IQbservable<long> Sum(this IQbservable<long> source)
  13122. {
  13123. if (source == null)
  13124. throw new ArgumentNullException(nameof(source));
  13125. return source.Provider.CreateQuery<long>(
  13126. Expression.Call(
  13127. null,
  13128. #if CRIPPLED_REFLECTION
  13129. InfoOf(() => Qbservable.Sum(default(IQbservable<long>))),
  13130. #else
  13131. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13132. #endif
  13133. source.Expression
  13134. )
  13135. );
  13136. }
  13137. /// <summary>
  13138. /// Computes the sum of a sequence of nullable <see cref="Decimal" /> values.
  13139. /// </summary>
  13140. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to calculate the sum of.</param>
  13141. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13142. /// <exception cref="ArgumentNullException">
  13143. /// <paramref name="source" /> is null.</exception>
  13144. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  13145. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13146. public static IQbservable<decimal?> Sum(this IQbservable<decimal?> source)
  13147. {
  13148. if (source == null)
  13149. throw new ArgumentNullException(nameof(source));
  13150. return source.Provider.CreateQuery<decimal?>(
  13151. Expression.Call(
  13152. null,
  13153. #if CRIPPLED_REFLECTION
  13154. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal?>))),
  13155. #else
  13156. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13157. #endif
  13158. source.Expression
  13159. )
  13160. );
  13161. }
  13162. /// <summary>
  13163. /// Computes the sum of a sequence of nullable <see cref="double" /> values.
  13164. /// </summary>
  13165. /// <param name="source">A sequence of nullable <see cref="double" /> values to calculate the sum of.</param>
  13166. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13167. /// <exception cref="ArgumentNullException">
  13168. /// <paramref name="source" /> is null.</exception>
  13169. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13170. public static IQbservable<double?> Sum(this IQbservable<double?> source)
  13171. {
  13172. if (source == null)
  13173. throw new ArgumentNullException(nameof(source));
  13174. return source.Provider.CreateQuery<double?>(
  13175. Expression.Call(
  13176. null,
  13177. #if CRIPPLED_REFLECTION
  13178. InfoOf(() => Qbservable.Sum(default(IQbservable<double?>))),
  13179. #else
  13180. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13181. #endif
  13182. source.Expression
  13183. )
  13184. );
  13185. }
  13186. /// <summary>
  13187. /// Computes the sum of a sequence of nullable <see cref="int" /> values.
  13188. /// </summary>
  13189. /// <param name="source">A sequence of nullable <see cref="int" /> values to calculate the sum of.</param>
  13190. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13191. /// <exception cref="ArgumentNullException">
  13192. /// <paramref name="source" /> is null.</exception>
  13193. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
  13194. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13195. public static IQbservable<int?> Sum(this IQbservable<int?> source)
  13196. {
  13197. if (source == null)
  13198. throw new ArgumentNullException(nameof(source));
  13199. return source.Provider.CreateQuery<int?>(
  13200. Expression.Call(
  13201. null,
  13202. #if CRIPPLED_REFLECTION
  13203. InfoOf(() => Qbservable.Sum(default(IQbservable<int?>))),
  13204. #else
  13205. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13206. #endif
  13207. source.Expression
  13208. )
  13209. );
  13210. }
  13211. /// <summary>
  13212. /// Computes the sum of a sequence of nullable <see cref="long" /> values.
  13213. /// </summary>
  13214. /// <param name="source">A sequence of nullable <see cref="long" /> values to calculate the sum of.</param>
  13215. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13216. /// <exception cref="ArgumentNullException">
  13217. /// <paramref name="source" /> is null.</exception>
  13218. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  13219. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13220. public static IQbservable<long?> Sum(this IQbservable<long?> source)
  13221. {
  13222. if (source == null)
  13223. throw new ArgumentNullException(nameof(source));
  13224. return source.Provider.CreateQuery<long?>(
  13225. Expression.Call(
  13226. null,
  13227. #if CRIPPLED_REFLECTION
  13228. InfoOf(() => Qbservable.Sum(default(IQbservable<long?>))),
  13229. #else
  13230. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13231. #endif
  13232. source.Expression
  13233. )
  13234. );
  13235. }
  13236. /// <summary>
  13237. /// Computes the sum of a sequence of nullable <see cref="Single" /> values.
  13238. /// </summary>
  13239. /// <param name="source">A sequence of nullable <see cref="Single" /> values to calculate the sum of.</param>
  13240. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13241. /// <exception cref="ArgumentNullException">
  13242. /// <paramref name="source" /> is null.</exception>
  13243. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13244. public static IQbservable<float?> Sum(this IQbservable<float?> source)
  13245. {
  13246. if (source == null)
  13247. throw new ArgumentNullException(nameof(source));
  13248. return source.Provider.CreateQuery<float?>(
  13249. Expression.Call(
  13250. null,
  13251. #if CRIPPLED_REFLECTION
  13252. InfoOf(() => Qbservable.Sum(default(IQbservable<float?>))),
  13253. #else
  13254. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13255. #endif
  13256. source.Expression
  13257. )
  13258. );
  13259. }
  13260. /// <summary>
  13261. /// Computes the sum of a sequence of <see cref="Single" /> values.
  13262. /// </summary>
  13263. /// <param name="source">A sequence of <see cref="Single" /> values to calculate the sum of.</param>
  13264. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13265. /// <exception cref="ArgumentNullException">
  13266. /// <paramref name="source" /> is null.</exception>
  13267. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13268. public static IQbservable<float> Sum(this IQbservable<float> source)
  13269. {
  13270. if (source == null)
  13271. throw new ArgumentNullException(nameof(source));
  13272. return source.Provider.CreateQuery<float>(
  13273. Expression.Call(
  13274. null,
  13275. #if CRIPPLED_REFLECTION
  13276. InfoOf(() => Qbservable.Sum(default(IQbservable<float>))),
  13277. #else
  13278. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13279. #endif
  13280. source.Expression
  13281. )
  13282. );
  13283. }
  13284. /// <summary>
  13285. /// Computes the sum of a sequence of <see cref="double" /> values that are obtained by invoking a transform function on each element of the input sequence.
  13286. /// </summary>
  13287. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13288. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13289. /// <param name="selector">A transform function to apply to each element.</param>
  13290. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13291. /// <exception cref="ArgumentNullException">
  13292. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13293. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13294. public static IQbservable<double> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  13295. {
  13296. if (source == null)
  13297. throw new ArgumentNullException(nameof(source));
  13298. if (selector == null)
  13299. throw new ArgumentNullException(nameof(selector));
  13300. return source.Provider.CreateQuery<double>(
  13301. Expression.Call(
  13302. null,
  13303. #if CRIPPLED_REFLECTION
  13304. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  13305. #else
  13306. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13307. #endif
  13308. source.Expression,
  13309. selector
  13310. )
  13311. );
  13312. }
  13313. /// <summary>
  13314. /// Computes the sum of a sequence of <see cref="Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
  13315. /// </summary>
  13316. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13317. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13318. /// <param name="selector">A transform function to apply to each element.</param>
  13319. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13320. /// <exception cref="ArgumentNullException">
  13321. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13322. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13323. public static IQbservable<float> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  13324. {
  13325. if (source == null)
  13326. throw new ArgumentNullException(nameof(source));
  13327. if (selector == null)
  13328. throw new ArgumentNullException(nameof(selector));
  13329. return source.Provider.CreateQuery<float>(
  13330. Expression.Call(
  13331. null,
  13332. #if CRIPPLED_REFLECTION
  13333. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  13334. #else
  13335. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13336. #endif
  13337. source.Expression,
  13338. selector
  13339. )
  13340. );
  13341. }
  13342. /// <summary>
  13343. /// Computes the sum of a sequence of <see cref="Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
  13344. /// </summary>
  13345. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13346. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13347. /// <param name="selector">A transform function to apply to each element.</param>
  13348. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13349. /// <exception cref="ArgumentNullException">
  13350. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13351. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  13352. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13353. public static IQbservable<decimal> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  13354. {
  13355. if (source == null)
  13356. throw new ArgumentNullException(nameof(source));
  13357. if (selector == null)
  13358. throw new ArgumentNullException(nameof(selector));
  13359. return source.Provider.CreateQuery<decimal>(
  13360. Expression.Call(
  13361. null,
  13362. #if CRIPPLED_REFLECTION
  13363. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  13364. #else
  13365. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13366. #endif
  13367. source.Expression,
  13368. selector
  13369. )
  13370. );
  13371. }
  13372. /// <summary>
  13373. /// Computes the sum of a sequence of <see cref="int" /> values that are obtained by invoking a transform function on each element of the input sequence.
  13374. /// </summary>
  13375. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13376. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13377. /// <param name="selector">A transform function to apply to each element.</param>
  13378. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13379. /// <exception cref="ArgumentNullException">
  13380. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13381. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
  13382. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13383. public static IQbservable<int> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  13384. {
  13385. if (source == null)
  13386. throw new ArgumentNullException(nameof(source));
  13387. if (selector == null)
  13388. throw new ArgumentNullException(nameof(selector));
  13389. return source.Provider.CreateQuery<int>(
  13390. Expression.Call(
  13391. null,
  13392. #if CRIPPLED_REFLECTION
  13393. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  13394. #else
  13395. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13396. #endif
  13397. source.Expression,
  13398. selector
  13399. )
  13400. );
  13401. }
  13402. /// <summary>
  13403. /// Computes the sum of a sequence of <see cref="long" /> values that are obtained by invoking a transform function on each element of the input sequence.
  13404. /// </summary>
  13405. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13406. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13407. /// <param name="selector">A transform function to apply to each element.</param>
  13408. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13409. /// <exception cref="ArgumentNullException">
  13410. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13411. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  13412. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13413. public static IQbservable<long> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  13414. {
  13415. if (source == null)
  13416. throw new ArgumentNullException(nameof(source));
  13417. if (selector == null)
  13418. throw new ArgumentNullException(nameof(selector));
  13419. return source.Provider.CreateQuery<long>(
  13420. Expression.Call(
  13421. null,
  13422. #if CRIPPLED_REFLECTION
  13423. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  13424. #else
  13425. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13426. #endif
  13427. source.Expression,
  13428. selector
  13429. )
  13430. );
  13431. }
  13432. /// <summary>
  13433. /// Computes the sum of a sequence of nullable <see cref="double" /> values that are obtained by invoking a transform function on each element of the input sequence.
  13434. /// </summary>
  13435. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13436. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13437. /// <param name="selector">A transform function to apply to each element.</param>
  13438. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13439. /// <exception cref="ArgumentNullException">
  13440. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13441. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13442. public static IQbservable<double?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  13443. {
  13444. if (source == null)
  13445. throw new ArgumentNullException(nameof(source));
  13446. if (selector == null)
  13447. throw new ArgumentNullException(nameof(selector));
  13448. return source.Provider.CreateQuery<double?>(
  13449. Expression.Call(
  13450. null,
  13451. #if CRIPPLED_REFLECTION
  13452. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  13453. #else
  13454. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13455. #endif
  13456. source.Expression,
  13457. selector
  13458. )
  13459. );
  13460. }
  13461. /// <summary>
  13462. /// Computes the sum of a sequence of nullable <see cref="Single" /> values that are obtained by invoking a transform function on each element of the input sequence.
  13463. /// </summary>
  13464. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13465. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13466. /// <param name="selector">A transform function to apply to each element.</param>
  13467. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13468. /// <exception cref="ArgumentNullException">
  13469. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13470. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13471. public static IQbservable<float?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  13472. {
  13473. if (source == null)
  13474. throw new ArgumentNullException(nameof(source));
  13475. if (selector == null)
  13476. throw new ArgumentNullException(nameof(selector));
  13477. return source.Provider.CreateQuery<float?>(
  13478. Expression.Call(
  13479. null,
  13480. #if CRIPPLED_REFLECTION
  13481. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  13482. #else
  13483. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13484. #endif
  13485. source.Expression,
  13486. selector
  13487. )
  13488. );
  13489. }
  13490. /// <summary>
  13491. /// Computes the sum of a sequence of nullable <see cref="Decimal" /> values that are obtained by invoking a transform function on each element of the input sequence.
  13492. /// </summary>
  13493. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13494. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13495. /// <param name="selector">A transform function to apply to each element.</param>
  13496. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13497. /// <exception cref="ArgumentNullException">
  13498. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13499. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  13500. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13501. public static IQbservable<decimal?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  13502. {
  13503. if (source == null)
  13504. throw new ArgumentNullException(nameof(source));
  13505. if (selector == null)
  13506. throw new ArgumentNullException(nameof(selector));
  13507. return source.Provider.CreateQuery<decimal?>(
  13508. Expression.Call(
  13509. null,
  13510. #if CRIPPLED_REFLECTION
  13511. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  13512. #else
  13513. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13514. #endif
  13515. source.Expression,
  13516. selector
  13517. )
  13518. );
  13519. }
  13520. /// <summary>
  13521. /// Computes the sum of a sequence of nullable <see cref="int" /> values that are obtained by invoking a transform function on each element of the input sequence.
  13522. /// </summary>
  13523. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13524. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13525. /// <param name="selector">A transform function to apply to each element.</param>
  13526. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13527. /// <exception cref="ArgumentNullException">
  13528. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13529. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
  13530. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13531. public static IQbservable<int?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  13532. {
  13533. if (source == null)
  13534. throw new ArgumentNullException(nameof(source));
  13535. if (selector == null)
  13536. throw new ArgumentNullException(nameof(selector));
  13537. return source.Provider.CreateQuery<int?>(
  13538. Expression.Call(
  13539. null,
  13540. #if CRIPPLED_REFLECTION
  13541. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  13542. #else
  13543. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13544. #endif
  13545. source.Expression,
  13546. selector
  13547. )
  13548. );
  13549. }
  13550. /// <summary>
  13551. /// Computes the sum of a sequence of nullable <see cref="long" /> values that are obtained by invoking a transform function on each element of the input sequence.
  13552. /// </summary>
  13553. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13554. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13555. /// <param name="selector">A transform function to apply to each element.</param>
  13556. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13557. /// <exception cref="ArgumentNullException">
  13558. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13559. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  13560. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13561. public static IQbservable<long?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  13562. {
  13563. if (source == null)
  13564. throw new ArgumentNullException(nameof(source));
  13565. if (selector == null)
  13566. throw new ArgumentNullException(nameof(selector));
  13567. return source.Provider.CreateQuery<long?>(
  13568. Expression.Call(
  13569. null,
  13570. #if CRIPPLED_REFLECTION
  13571. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  13572. #else
  13573. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13574. #endif
  13575. source.Expression,
  13576. selector
  13577. )
  13578. );
  13579. }
  13580. /// <summary>
  13581. /// Transforms an observable sequence of observable sequences into an observable sequence
  13582. /// producing values only from the most recent observable sequence.
  13583. /// Each time a new inner observable sequence is received, unsubscribe from the
  13584. /// previous inner observable sequence.
  13585. /// </summary>
  13586. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  13587. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  13588. /// <returns>The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received.</returns>
  13589. /// <exception cref="ArgumentNullException">
  13590. /// <paramref name="sources" /> is null.</exception>
  13591. public static IQbservable<TSource> Switch<TSource>(this IQbservable<IObservable<TSource>> sources)
  13592. {
  13593. if (sources == null)
  13594. throw new ArgumentNullException(nameof(sources));
  13595. return sources.Provider.CreateQuery<TSource>(
  13596. Expression.Call(
  13597. null,
  13598. #if CRIPPLED_REFLECTION
  13599. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<IObservable<TSource>>))),
  13600. #else
  13601. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13602. #endif
  13603. sources.Expression
  13604. )
  13605. );
  13606. }
  13607. /// <summary>
  13608. /// Transforms an observable sequence of tasks into an observable sequence
  13609. /// producing values only from the most recent observable sequence.
  13610. /// Each time a new task is received, the previous task's result is ignored.
  13611. /// </summary>
  13612. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  13613. /// <param name="sources">Observable sequence of tasks.</param>
  13614. /// <returns>The observable sequence that at any point in time produces the result of the most recent task that has been received.</returns>
  13615. /// <exception cref="ArgumentNullException">
  13616. /// <paramref name="sources" /> is null.</exception>
  13617. /// <remarks>If the tasks support cancellation, consider manual conversion of the tasks using <see cref="M:System.Reactive.Linq.Observable.FromAsync``1(System.Func{System.Threading.CancellationToken,System.Threading.Tasks.Task{``0}})" />, followed by a switch operation using <see cref="M:System.Reactive.Linq.Observable.Switch``1(System.IObservable{System.IObservable{``0}})" />.</remarks>
  13618. public static IQbservable<TSource> Switch<TSource>(this IQbservable<Task<TSource>> sources)
  13619. {
  13620. if (sources == null)
  13621. throw new ArgumentNullException(nameof(sources));
  13622. return sources.Provider.CreateQuery<TSource>(
  13623. Expression.Call(
  13624. null,
  13625. #if CRIPPLED_REFLECTION
  13626. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<Task<TSource>>))),
  13627. #else
  13628. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13629. #endif
  13630. sources.Expression
  13631. )
  13632. );
  13633. }
  13634. /// <summary>
  13635. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently.
  13636. /// This overload is useful to "fix" an observable sequence that exhibits concurrent callbacks on individual observers, which is invalid behavior for the query processor.
  13637. /// </summary>
  13638. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13639. /// <param name="source">Source sequence.</param>
  13640. /// <returns>The source sequence whose outgoing calls to observers are synchronized.</returns>
  13641. /// <exception cref="ArgumentNullException">
  13642. /// <paramref name="source" /> is null.</exception>
  13643. /// <remarks>
  13644. /// It's invalid behavior - according to the observer grammar - for a sequence to exhibit concurrent callbacks on a given observer.
  13645. /// This operator can be used to "fix" a source that doesn't conform to this rule.
  13646. /// </remarks>
  13647. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source)
  13648. {
  13649. if (source == null)
  13650. throw new ArgumentNullException(nameof(source));
  13651. return source.Provider.CreateQuery<TSource>(
  13652. Expression.Call(
  13653. null,
  13654. #if CRIPPLED_REFLECTION
  13655. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>))),
  13656. #else
  13657. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13658. #endif
  13659. source.Expression
  13660. )
  13661. );
  13662. }
  13663. /// <summary>
  13664. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently, using the specified gate object.
  13665. /// This overload is useful when writing n-ary query operators, in order to prevent concurrent callbacks from different sources by synchronizing on a common gate object.
  13666. /// </summary>
  13667. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13668. /// <param name="source">Source sequence.</param>
  13669. /// <param name="gate">Gate object to synchronize each observer call on.</param>
  13670. /// <returns>The source sequence whose outgoing calls to observers are synchronized on the given gate object.</returns>
  13671. /// <exception cref="ArgumentNullException">
  13672. /// <paramref name="source" /> or <paramref name="gate" /> is null.</exception>
  13673. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source, object gate)
  13674. {
  13675. if (source == null)
  13676. throw new ArgumentNullException(nameof(source));
  13677. if (gate == null)
  13678. throw new ArgumentNullException(nameof(gate));
  13679. return source.Provider.CreateQuery<TSource>(
  13680. Expression.Call(
  13681. null,
  13682. #if CRIPPLED_REFLECTION
  13683. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>), default(object))),
  13684. #else
  13685. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13686. #endif
  13687. source.Expression,
  13688. Expression.Constant(gate, typeof(object))
  13689. )
  13690. );
  13691. }
  13692. /// <summary>
  13693. /// Returns a specified number of contiguous elements from the start of an observable sequence.
  13694. /// </summary>
  13695. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13696. /// <param name="source">The sequence to take elements from.</param>
  13697. /// <param name="count">The number of elements to return.</param>
  13698. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13699. /// <exception cref="ArgumentNullException">
  13700. /// <paramref name="source" /> is null.</exception>
  13701. /// <exception cref="ArgumentOutOfRangeException">
  13702. /// <paramref name="count" /> is less than zero.</exception>
  13703. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count)
  13704. {
  13705. if (source == null)
  13706. throw new ArgumentNullException(nameof(source));
  13707. return source.Provider.CreateQuery<TSource>(
  13708. Expression.Call(
  13709. null,
  13710. #if CRIPPLED_REFLECTION
  13711. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int))),
  13712. #else
  13713. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13714. #endif
  13715. source.Expression,
  13716. Expression.Constant(count, typeof(int))
  13717. )
  13718. );
  13719. }
  13720. /// <summary>
  13721. /// Returns a specified number of contiguous elements from the start of an observable sequence, using the specified scheduler for the edge case of Take(0).
  13722. /// </summary>
  13723. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13724. /// <param name="source">The sequence to take elements from.</param>
  13725. /// <param name="count">The number of elements to return.</param>
  13726. /// <param name="scheduler">Scheduler used to produce an OnCompleted message in case <paramref name="count">count</paramref> is set to 0.</param>
  13727. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13728. /// <exception cref="ArgumentNullException">
  13729. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13730. /// <exception cref="ArgumentOutOfRangeException">
  13731. /// <paramref name="count" /> is less than zero.</exception>
  13732. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13733. {
  13734. if (source == null)
  13735. throw new ArgumentNullException(nameof(source));
  13736. if (scheduler == null)
  13737. throw new ArgumentNullException(nameof(scheduler));
  13738. return source.Provider.CreateQuery<TSource>(
  13739. Expression.Call(
  13740. null,
  13741. #if CRIPPLED_REFLECTION
  13742. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13743. #else
  13744. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13745. #endif
  13746. source.Expression,
  13747. Expression.Constant(count, typeof(int)),
  13748. Expression.Constant(scheduler, typeof(IScheduler))
  13749. )
  13750. );
  13751. }
  13752. /// <summary>
  13753. /// Takes elements for the specified duration from the start of the observable source sequence.
  13754. /// </summary>
  13755. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13756. /// <param name="source">Source sequence to take elements from.</param>
  13757. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13758. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13759. /// <exception cref="ArgumentNullException">
  13760. /// <paramref name="source" /> is null.</exception>
  13761. /// <exception cref="ArgumentOutOfRangeException">
  13762. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13763. /// <remarks>
  13764. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13765. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13766. /// immediately, despite the TimeSpan.Zero due time.
  13767. /// </remarks>
  13768. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13769. {
  13770. if (source == null)
  13771. throw new ArgumentNullException(nameof(source));
  13772. return source.Provider.CreateQuery<TSource>(
  13773. Expression.Call(
  13774. null,
  13775. #if CRIPPLED_REFLECTION
  13776. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13777. #else
  13778. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13779. #endif
  13780. source.Expression,
  13781. Expression.Constant(duration, typeof(TimeSpan))
  13782. )
  13783. );
  13784. }
  13785. /// <summary>
  13786. /// Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  13787. /// </summary>
  13788. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13789. /// <param name="source">Source sequence to take elements from.</param>
  13790. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13791. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13792. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13793. /// <exception cref="ArgumentNullException">
  13794. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13795. /// <exception cref="ArgumentOutOfRangeException">
  13796. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13797. /// <remarks>
  13798. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13799. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13800. /// immediately, despite the TimeSpan.Zero due time.
  13801. /// </remarks>
  13802. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13803. {
  13804. if (source == null)
  13805. throw new ArgumentNullException(nameof(source));
  13806. if (scheduler == null)
  13807. throw new ArgumentNullException(nameof(scheduler));
  13808. return source.Provider.CreateQuery<TSource>(
  13809. Expression.Call(
  13810. null,
  13811. #if CRIPPLED_REFLECTION
  13812. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13813. #else
  13814. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13815. #endif
  13816. source.Expression,
  13817. Expression.Constant(duration, typeof(TimeSpan)),
  13818. Expression.Constant(scheduler, typeof(IScheduler))
  13819. )
  13820. );
  13821. }
  13822. /// <summary>
  13823. /// Returns a specified number of contiguous elements from the end of an observable sequence.
  13824. /// </summary>
  13825. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13826. /// <param name="source">Source sequence.</param>
  13827. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13828. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13829. /// <exception cref="ArgumentNullException">
  13830. /// <paramref name="source" /> is null.</exception>
  13831. /// <exception cref="ArgumentOutOfRangeException">
  13832. /// <paramref name="count" /> is less than zero.</exception>
  13833. /// <remarks>
  13834. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13835. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13836. /// </remarks>
  13837. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count)
  13838. {
  13839. if (source == null)
  13840. throw new ArgumentNullException(nameof(source));
  13841. return source.Provider.CreateQuery<TSource>(
  13842. Expression.Call(
  13843. null,
  13844. #if CRIPPLED_REFLECTION
  13845. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int))),
  13846. #else
  13847. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13848. #endif
  13849. source.Expression,
  13850. Expression.Constant(count, typeof(int))
  13851. )
  13852. );
  13853. }
  13854. /// <summary>
  13855. /// Returns a specified number of contiguous elements from the end of an observable sequence, using the specified scheduler to drain the queue.
  13856. /// </summary>
  13857. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13858. /// <param name="source">Source sequence.</param>
  13859. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13860. /// <param name="scheduler">Scheduler used to drain the queue upon completion of the source sequence.</param>
  13861. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13862. /// <exception cref="ArgumentNullException">
  13863. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13864. /// <exception cref="ArgumentOutOfRangeException">
  13865. /// <paramref name="count" /> is less than zero.</exception>
  13866. /// <remarks>
  13867. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13868. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13869. /// </remarks>
  13870. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13871. {
  13872. if (source == null)
  13873. throw new ArgumentNullException(nameof(source));
  13874. if (scheduler == null)
  13875. throw new ArgumentNullException(nameof(scheduler));
  13876. return source.Provider.CreateQuery<TSource>(
  13877. Expression.Call(
  13878. null,
  13879. #if CRIPPLED_REFLECTION
  13880. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13881. #else
  13882. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13883. #endif
  13884. source.Expression,
  13885. Expression.Constant(count, typeof(int)),
  13886. Expression.Constant(scheduler, typeof(IScheduler))
  13887. )
  13888. );
  13889. }
  13890. /// <summary>
  13891. /// Returns elements within the specified duration from the end of the observable source sequence.
  13892. /// </summary>
  13893. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13894. /// <param name="source">Source sequence to take elements from.</param>
  13895. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13896. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13897. /// <exception cref="ArgumentNullException">
  13898. /// <paramref name="source" /> is null.</exception>
  13899. /// <exception cref="ArgumentOutOfRangeException">
  13900. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13901. /// <remarks>
  13902. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13903. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13904. /// to be delayed with <paramref name="duration" />.
  13905. /// </remarks>
  13906. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13907. {
  13908. if (source == null)
  13909. throw new ArgumentNullException(nameof(source));
  13910. return source.Provider.CreateQuery<TSource>(
  13911. Expression.Call(
  13912. null,
  13913. #if CRIPPLED_REFLECTION
  13914. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13915. #else
  13916. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13917. #endif
  13918. source.Expression,
  13919. Expression.Constant(duration, typeof(TimeSpan))
  13920. )
  13921. );
  13922. }
  13923. /// <summary>
  13924. /// Returns elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  13925. /// </summary>
  13926. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13927. /// <param name="source">Source sequence to take elements from.</param>
  13928. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13929. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13930. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13931. /// <exception cref="ArgumentNullException">
  13932. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13933. /// <exception cref="ArgumentOutOfRangeException">
  13934. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13935. /// <remarks>
  13936. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13937. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13938. /// to be delayed with <paramref name="duration" />.
  13939. /// </remarks>
  13940. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13941. {
  13942. if (source == null)
  13943. throw new ArgumentNullException(nameof(source));
  13944. if (scheduler == null)
  13945. throw new ArgumentNullException(nameof(scheduler));
  13946. return source.Provider.CreateQuery<TSource>(
  13947. Expression.Call(
  13948. null,
  13949. #if CRIPPLED_REFLECTION
  13950. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13951. #else
  13952. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13953. #endif
  13954. source.Expression,
  13955. Expression.Constant(duration, typeof(TimeSpan)),
  13956. Expression.Constant(scheduler, typeof(IScheduler))
  13957. )
  13958. );
  13959. }
  13960. /// <summary>
  13961. /// Returns elements within the specified duration from the end of the observable source sequence, using the specified schedulers to run timers and to drain the collected elements.
  13962. /// </summary>
  13963. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13964. /// <param name="source">Source sequence to take elements from.</param>
  13965. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13966. /// <param name="timerScheduler">Scheduler to run the timer on.</param>
  13967. /// <param name="loopScheduler">Scheduler to drain the collected elements.</param>
  13968. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13969. /// <exception cref="ArgumentNullException">
  13970. /// <paramref name="source" /> or <paramref name="timerScheduler" /> or <paramref name="loopScheduler" /> is null.</exception>
  13971. /// <exception cref="ArgumentOutOfRangeException">
  13972. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13973. /// <remarks>
  13974. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13975. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13976. /// to be delayed with <paramref name="duration" />.
  13977. /// </remarks>
  13978. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler timerScheduler, IScheduler loopScheduler)
  13979. {
  13980. if (source == null)
  13981. throw new ArgumentNullException(nameof(source));
  13982. if (timerScheduler == null)
  13983. throw new ArgumentNullException(nameof(timerScheduler));
  13984. if (loopScheduler == null)
  13985. throw new ArgumentNullException(nameof(loopScheduler));
  13986. return source.Provider.CreateQuery<TSource>(
  13987. Expression.Call(
  13988. null,
  13989. #if CRIPPLED_REFLECTION
  13990. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler), default(IScheduler))),
  13991. #else
  13992. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13993. #endif
  13994. source.Expression,
  13995. Expression.Constant(duration, typeof(TimeSpan)),
  13996. Expression.Constant(timerScheduler, typeof(IScheduler)),
  13997. Expression.Constant(loopScheduler, typeof(IScheduler))
  13998. )
  13999. );
  14000. }
  14001. /// <summary>
  14002. /// Returns a list with the specified number of contiguous elements from the end of an observable sequence.
  14003. /// </summary>
  14004. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14005. /// <param name="source">Source sequence.</param>
  14006. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  14007. /// <returns>An observable sequence containing a single list with the specified number of elements from the end of the source sequence.</returns>
  14008. /// <exception cref="ArgumentNullException">
  14009. /// <paramref name="source" /> is null.</exception>
  14010. /// <exception cref="ArgumentOutOfRangeException">
  14011. /// <paramref name="count" /> is less than zero.</exception>
  14012. /// <remarks>
  14013. /// This operator accumulates a buffer with a length enough to store <paramref name="count" /> elements. Upon completion of the
  14014. /// source sequence, this buffer is produced on the result sequence.
  14015. /// </remarks>
  14016. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, int count)
  14017. {
  14018. if (source == null)
  14019. throw new ArgumentNullException(nameof(source));
  14020. return source.Provider.CreateQuery<IList<TSource>>(
  14021. Expression.Call(
  14022. null,
  14023. #if CRIPPLED_REFLECTION
  14024. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(int))),
  14025. #else
  14026. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14027. #endif
  14028. source.Expression,
  14029. Expression.Constant(count, typeof(int))
  14030. )
  14031. );
  14032. }
  14033. /// <summary>
  14034. /// Returns a list with the elements within the specified duration from the end of the observable source sequence.
  14035. /// </summary>
  14036. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14037. /// <param name="source">Source sequence to take elements from.</param>
  14038. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14039. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  14040. /// <exception cref="ArgumentNullException">
  14041. /// <paramref name="source" /> is null.</exception>
  14042. /// <exception cref="ArgumentOutOfRangeException">
  14043. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14044. /// <remarks>
  14045. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14046. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  14047. /// </remarks>
  14048. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  14049. {
  14050. if (source == null)
  14051. throw new ArgumentNullException(nameof(source));
  14052. return source.Provider.CreateQuery<IList<TSource>>(
  14053. Expression.Call(
  14054. null,
  14055. #if CRIPPLED_REFLECTION
  14056. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14057. #else
  14058. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14059. #endif
  14060. source.Expression,
  14061. Expression.Constant(duration, typeof(TimeSpan))
  14062. )
  14063. );
  14064. }
  14065. /// <summary>
  14066. /// Returns a list with the elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  14067. /// </summary>
  14068. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14069. /// <param name="source">Source sequence to take elements from.</param>
  14070. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14071. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14072. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  14073. /// <exception cref="ArgumentNullException">
  14074. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14075. /// <exception cref="ArgumentOutOfRangeException">
  14076. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14077. /// <remarks>
  14078. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14079. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  14080. /// </remarks>
  14081. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  14082. {
  14083. if (source == null)
  14084. throw new ArgumentNullException(nameof(source));
  14085. if (scheduler == null)
  14086. throw new ArgumentNullException(nameof(scheduler));
  14087. return source.Provider.CreateQuery<IList<TSource>>(
  14088. Expression.Call(
  14089. null,
  14090. #if CRIPPLED_REFLECTION
  14091. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14092. #else
  14093. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14094. #endif
  14095. source.Expression,
  14096. Expression.Constant(duration, typeof(TimeSpan)),
  14097. Expression.Constant(scheduler, typeof(IScheduler))
  14098. )
  14099. );
  14100. }
  14101. /// <summary>
  14102. /// Takes elements for the specified duration until the specified end time.
  14103. /// </summary>
  14104. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14105. /// <param name="source">Source sequence to take elements from.</param>
  14106. /// <param name="endTime">Time to stop taking elements from the source sequence. If this value is less than or equal to DateTimeOffset.UtcNow, the result stream will complete immediately.</param>
  14107. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  14108. /// <exception cref="ArgumentNullException">
  14109. /// <paramref name="source" /> is null.</exception>
  14110. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime)
  14111. {
  14112. if (source == null)
  14113. throw new ArgumentNullException(nameof(source));
  14114. return source.Provider.CreateQuery<TSource>(
  14115. Expression.Call(
  14116. null,
  14117. #if CRIPPLED_REFLECTION
  14118. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14119. #else
  14120. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14121. #endif
  14122. source.Expression,
  14123. Expression.Constant(endTime, typeof(DateTimeOffset))
  14124. )
  14125. );
  14126. }
  14127. /// <summary>
  14128. /// Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  14129. /// </summary>
  14130. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14131. /// <param name="source">Source sequence to take elements from.</param>
  14132. /// <param name="endTime">Time to stop taking elements from the source sequence. If this value is less than or equal to DateTimeOffset.UtcNow, the result stream will complete immediately.</param>
  14133. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14134. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  14135. /// <exception cref="ArgumentNullException">
  14136. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14137. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime, IScheduler scheduler)
  14138. {
  14139. if (source == null)
  14140. throw new ArgumentNullException(nameof(source));
  14141. if (scheduler == null)
  14142. throw new ArgumentNullException(nameof(scheduler));
  14143. return source.Provider.CreateQuery<TSource>(
  14144. Expression.Call(
  14145. null,
  14146. #if CRIPPLED_REFLECTION
  14147. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14148. #else
  14149. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14150. #endif
  14151. source.Expression,
  14152. Expression.Constant(endTime, typeof(DateTimeOffset)),
  14153. Expression.Constant(scheduler, typeof(IScheduler))
  14154. )
  14155. );
  14156. }
  14157. /// <summary>
  14158. /// Returns the elements from the source observable sequence until the other observable sequence produces an element.
  14159. /// </summary>
  14160. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14161. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of take behavior.</typeparam>
  14162. /// <param name="source">Source sequence to propagate elements for.</param>
  14163. /// <param name="other">Observable sequence that terminates propagation of elements of the source sequence.</param>
  14164. /// <returns>An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.</returns>
  14165. /// <exception cref="ArgumentNullException">
  14166. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14167. public static IQbservable<TSource> TakeUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  14168. {
  14169. if (source == null)
  14170. throw new ArgumentNullException(nameof(source));
  14171. if (other == null)
  14172. throw new ArgumentNullException(nameof(other));
  14173. return source.Provider.CreateQuery<TSource>(
  14174. Expression.Call(
  14175. null,
  14176. #if CRIPPLED_REFLECTION
  14177. InfoOf(() => Qbservable.TakeUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  14178. #else
  14179. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  14180. #endif
  14181. source.Expression,
  14182. GetSourceExpression(other)
  14183. )
  14184. );
  14185. }
  14186. /// <summary>
  14187. /// Relays elements from the source observable sequence and calls the predicate after an
  14188. /// emission to check if the sequence should stop after that specific item.
  14189. /// </summary>
  14190. /// <typeparam name="TSource">The type of the elements in the source and result sequences.</typeparam>
  14191. /// <param name="source">The source sequence to relay elements of.</param>
  14192. /// <param name="stopPredicate">Called after each upstream item has been emitted with
  14193. /// that upstream item and should return <code>true</code> to indicate the sequence should
  14194. /// complete.</param>
  14195. /// <returns>The observable sequence with the source elements until the stop predicate returns true.</returns>
  14196. /// <example>
  14197. /// The following sequence will stop after the value 5 has been encountered:
  14198. /// <code>
  14199. /// Observable.Range(1, 10)
  14200. /// .TakeUntil(item =&gt; item == 5)
  14201. /// .Subscribe(Console.WriteLine);
  14202. /// </code>
  14203. /// </example>
  14204. /// <exception cref="ArgumentException">If <typeparamref name="TSource"/> or <paramref name="stopPredicate"/> is <code>null</code>.</exception>
  14205. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> stopPredicate)
  14206. {
  14207. if (source == null)
  14208. throw new ArgumentNullException(nameof(source));
  14209. if (stopPredicate == null)
  14210. throw new ArgumentNullException(nameof(stopPredicate));
  14211. return source.Provider.CreateQuery<TSource>(
  14212. Expression.Call(
  14213. null,
  14214. #if CRIPPLED_REFLECTION
  14215. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  14216. #else
  14217. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14218. #endif
  14219. source.Expression,
  14220. stopPredicate
  14221. )
  14222. );
  14223. }
  14224. /// <summary>
  14225. /// Returns elements from an observable sequence as long as a specified condition is true.
  14226. /// </summary>
  14227. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14228. /// <param name="source">A sequence to return elements from.</param>
  14229. /// <param name="predicate">A function to test each element for a condition.</param>
  14230. /// <returns>An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.</returns>
  14231. /// <exception cref="ArgumentNullException">
  14232. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14233. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  14234. {
  14235. if (source == null)
  14236. throw new ArgumentNullException(nameof(source));
  14237. if (predicate == null)
  14238. throw new ArgumentNullException(nameof(predicate));
  14239. return source.Provider.CreateQuery<TSource>(
  14240. Expression.Call(
  14241. null,
  14242. #if CRIPPLED_REFLECTION
  14243. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  14244. #else
  14245. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14246. #endif
  14247. source.Expression,
  14248. predicate
  14249. )
  14250. );
  14251. }
  14252. /// <summary>
  14253. /// Returns elements from an observable sequence as long as a specified condition is true.
  14254. /// The element's index is used in the logic of the predicate function.
  14255. /// </summary>
  14256. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14257. /// <param name="source">A sequence to return elements from.</param>
  14258. /// <param name="predicate">A function to test each element for a condition; the second parameter of the function represents the index of the source element.</param>
  14259. /// <returns>An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes.</returns>
  14260. /// <exception cref="ArgumentNullException">
  14261. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14262. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  14263. {
  14264. if (source == null)
  14265. throw new ArgumentNullException(nameof(source));
  14266. if (predicate == null)
  14267. throw new ArgumentNullException(nameof(predicate));
  14268. return source.Provider.CreateQuery<TSource>(
  14269. Expression.Call(
  14270. null,
  14271. #if CRIPPLED_REFLECTION
  14272. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  14273. #else
  14274. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14275. #endif
  14276. source.Expression,
  14277. predicate
  14278. )
  14279. );
  14280. }
  14281. /// <summary>
  14282. /// Ignores elements from an observable sequence which are followed by another element within a specified relative time duration.
  14283. /// </summary>
  14284. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14285. /// <param name="source">Source sequence to throttle.</param>
  14286. /// <param name="dueTime">Throttling duration for each element.</param>
  14287. /// <returns>The throttled sequence.</returns>
  14288. /// <exception cref="ArgumentNullException">
  14289. /// <paramref name="source" /> is null.</exception>
  14290. /// <exception cref="ArgumentOutOfRangeException">
  14291. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14292. /// <remarks>
  14293. /// <para>
  14294. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14295. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14296. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14297. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14298. /// Observable.Sample set of operators.
  14299. /// </para>
  14300. /// <para>
  14301. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14302. /// that are due immediately. However, this doesn't guarantee all elements will be retained in the result sequence. This is a side-effect of the
  14303. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14304. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14305. /// </para>
  14306. /// </remarks>
  14307. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14308. {
  14309. if (source == null)
  14310. throw new ArgumentNullException(nameof(source));
  14311. return source.Provider.CreateQuery<TSource>(
  14312. Expression.Call(
  14313. null,
  14314. #if CRIPPLED_REFLECTION
  14315. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14316. #else
  14317. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14318. #endif
  14319. source.Expression,
  14320. Expression.Constant(dueTime, typeof(TimeSpan))
  14321. )
  14322. );
  14323. }
  14324. /// <summary>
  14325. /// Ignores elements from an observable sequence which are followed by another element within a specified relative time duration, using the specified scheduler to run throttling timers.
  14326. /// </summary>
  14327. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14328. /// <param name="source">Source sequence to throttle.</param>
  14329. /// <param name="dueTime">Throttling duration for each element.</param>
  14330. /// <param name="scheduler">Scheduler to run the throttle timers on.</param>
  14331. /// <returns>The throttled sequence.</returns>
  14332. /// <exception cref="ArgumentNullException">
  14333. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14334. /// <exception cref="ArgumentOutOfRangeException">
  14335. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14336. /// <remarks>
  14337. /// <para>
  14338. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14339. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14340. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14341. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14342. /// Observable.Sample set of operators.
  14343. /// </para>
  14344. /// <para>
  14345. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14346. /// that are due immediately. However, this doesn't guarantee all elements will be retained in the result sequence. This is a side-effect of the
  14347. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14348. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14349. /// </para>
  14350. /// </remarks>
  14351. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14352. {
  14353. if (source == null)
  14354. throw new ArgumentNullException(nameof(source));
  14355. if (scheduler == null)
  14356. throw new ArgumentNullException(nameof(scheduler));
  14357. return source.Provider.CreateQuery<TSource>(
  14358. Expression.Call(
  14359. null,
  14360. #if CRIPPLED_REFLECTION
  14361. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14362. #else
  14363. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14364. #endif
  14365. source.Expression,
  14366. Expression.Constant(dueTime, typeof(TimeSpan)),
  14367. Expression.Constant(scheduler, typeof(IScheduler))
  14368. )
  14369. );
  14370. }
  14371. /// <summary>
  14372. /// Ignores elements from an observable sequence which are followed by another value within a computed throttle duration.
  14373. /// </summary>
  14374. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14375. /// <typeparam name="TThrottle">The type of the elements in the throttle sequences selected for each element in the source sequence.</typeparam>
  14376. /// <param name="source">Source sequence to throttle.</param>
  14377. /// <param name="throttleDurationSelector">Selector function to retrieve a sequence indicating the throttle duration for each given element.</param>
  14378. /// <returns>The throttled sequence.</returns>
  14379. /// <exception cref="ArgumentNullException">
  14380. /// <paramref name="source" /> or <paramref name="throttleDurationSelector" /> is null.</exception>
  14381. /// <remarks>
  14382. /// This operator throttles the source sequence by holding on to each element for the duration denoted by <paramref name="throttleDurationSelector" />.
  14383. /// If another element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this
  14384. /// whole process. For streams where the duration computed by applying the <paramref name="throttleDurationSelector" /> to each element overlaps with
  14385. /// the occurrence of the successor element, the resulting stream won't produce any elements. In order to reduce the volume of a stream whilst
  14386. /// guaranteeing the periodic production of elements, consider using the Observable.Sample set of operators.
  14387. /// </remarks>
  14388. public static IQbservable<TSource> Throttle<TSource, TThrottle>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TThrottle>>> throttleDurationSelector)
  14389. {
  14390. if (source == null)
  14391. throw new ArgumentNullException(nameof(source));
  14392. if (throttleDurationSelector == null)
  14393. throw new ArgumentNullException(nameof(throttleDurationSelector));
  14394. return source.Provider.CreateQuery<TSource>(
  14395. Expression.Call(
  14396. null,
  14397. #if CRIPPLED_REFLECTION
  14398. InfoOf(() => Qbservable.Throttle<TSource, TThrottle>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TThrottle>>>))),
  14399. #else
  14400. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TThrottle)),
  14401. #endif
  14402. source.Expression,
  14403. throttleDurationSelector
  14404. )
  14405. );
  14406. }
  14407. /// <summary>
  14408. /// Returns an observable sequence that terminates with an exception.
  14409. /// </summary>
  14410. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14411. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14412. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14413. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14414. /// <exception cref="ArgumentNullException">
  14415. /// <paramref name="exception" /> is null.</exception>
  14416. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception)
  14417. {
  14418. if (provider == null)
  14419. throw new ArgumentNullException(nameof(provider));
  14420. if (exception == null)
  14421. throw new ArgumentNullException(nameof(exception));
  14422. return provider.CreateQuery<TResult>(
  14423. Expression.Call(
  14424. null,
  14425. #if CRIPPLED_REFLECTION
  14426. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception))),
  14427. #else
  14428. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14429. #endif
  14430. Expression.Constant(provider, typeof(IQbservableProvider)),
  14431. Expression.Constant(exception, typeof(Exception))
  14432. )
  14433. );
  14434. }
  14435. /// <summary>
  14436. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14437. /// </summary>
  14438. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14439. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14440. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14441. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14442. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14443. /// <exception cref="ArgumentNullException">
  14444. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14445. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler)
  14446. {
  14447. if (provider == null)
  14448. throw new ArgumentNullException(nameof(provider));
  14449. if (exception == null)
  14450. throw new ArgumentNullException(nameof(exception));
  14451. if (scheduler == null)
  14452. throw new ArgumentNullException(nameof(scheduler));
  14453. return provider.CreateQuery<TResult>(
  14454. Expression.Call(
  14455. null,
  14456. #if CRIPPLED_REFLECTION
  14457. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler))),
  14458. #else
  14459. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14460. #endif
  14461. Expression.Constant(provider, typeof(IQbservableProvider)),
  14462. Expression.Constant(exception, typeof(Exception)),
  14463. Expression.Constant(scheduler, typeof(IScheduler))
  14464. )
  14465. );
  14466. }
  14467. /// <summary>
  14468. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14469. /// </summary>
  14470. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14471. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14472. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14473. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14474. /// <param name="witness">Object solely used to infer the type of the <typeparamref name="TResult" /> type parameter. This parameter is typically used when creating a sequence of anonymously typed elements.</param>
  14475. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14476. /// <exception cref="ArgumentNullException">
  14477. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14478. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler, TResult witness)
  14479. {
  14480. if (provider == null)
  14481. throw new ArgumentNullException(nameof(provider));
  14482. if (exception == null)
  14483. throw new ArgumentNullException(nameof(exception));
  14484. if (scheduler == null)
  14485. throw new ArgumentNullException(nameof(scheduler));
  14486. return provider.CreateQuery<TResult>(
  14487. Expression.Call(
  14488. null,
  14489. #if CRIPPLED_REFLECTION
  14490. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler), default(TResult))),
  14491. #else
  14492. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14493. #endif
  14494. Expression.Constant(provider, typeof(IQbservableProvider)),
  14495. Expression.Constant(exception, typeof(Exception)),
  14496. Expression.Constant(scheduler, typeof(IScheduler)),
  14497. Expression.Constant(witness, typeof(TResult))
  14498. )
  14499. );
  14500. }
  14501. /// <summary>
  14502. /// Returns an observable sequence that terminates with an exception.
  14503. /// </summary>
  14504. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14505. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14506. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14507. /// <param name="witness">Object solely used to infer the type of the <typeparamref name="TResult" /> type parameter. This parameter is typically used when creating a sequence of anonymously typed elements.</param>
  14508. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14509. /// <exception cref="ArgumentNullException">
  14510. /// <paramref name="exception" /> is null.</exception>
  14511. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, TResult witness)
  14512. {
  14513. if (provider == null)
  14514. throw new ArgumentNullException(nameof(provider));
  14515. if (exception == null)
  14516. throw new ArgumentNullException(nameof(exception));
  14517. return provider.CreateQuery<TResult>(
  14518. Expression.Call(
  14519. null,
  14520. #if CRIPPLED_REFLECTION
  14521. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(TResult))),
  14522. #else
  14523. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14524. #endif
  14525. Expression.Constant(provider, typeof(IQbservableProvider)),
  14526. Expression.Constant(exception, typeof(Exception)),
  14527. Expression.Constant(witness, typeof(TResult))
  14528. )
  14529. );
  14530. }
  14531. /// <summary>
  14532. /// Records the time interval between consecutive elements in an observable sequence.
  14533. /// </summary>
  14534. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14535. /// <param name="source">Source sequence to record time intervals for.</param>
  14536. /// <returns>An observable sequence with time interval information on elements.</returns>
  14537. /// <exception cref="ArgumentNullException">
  14538. /// <paramref name="source" /> is null.</exception>
  14539. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source)
  14540. {
  14541. if (source == null)
  14542. throw new ArgumentNullException(nameof(source));
  14543. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14544. Expression.Call(
  14545. null,
  14546. #if CRIPPLED_REFLECTION
  14547. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>))),
  14548. #else
  14549. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14550. #endif
  14551. source.Expression
  14552. )
  14553. );
  14554. }
  14555. /// <summary>
  14556. /// Records the time interval between consecutive elements in an observable sequence, using the specified scheduler to compute time intervals.
  14557. /// </summary>
  14558. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14559. /// <param name="source">Source sequence to record time intervals for.</param>
  14560. /// <param name="scheduler">Scheduler used to compute time intervals.</param>
  14561. /// <returns>An observable sequence with time interval information on elements.</returns>
  14562. /// <exception cref="ArgumentNullException">
  14563. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14564. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  14565. {
  14566. if (source == null)
  14567. throw new ArgumentNullException(nameof(source));
  14568. if (scheduler == null)
  14569. throw new ArgumentNullException(nameof(scheduler));
  14570. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14571. Expression.Call(
  14572. null,
  14573. #if CRIPPLED_REFLECTION
  14574. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  14575. #else
  14576. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14577. #endif
  14578. source.Expression,
  14579. Expression.Constant(scheduler, typeof(IScheduler))
  14580. )
  14581. );
  14582. }
  14583. /// <summary>
  14584. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14585. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14586. /// </summary>
  14587. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14588. /// <param name="source">Source sequence to perform a timeout for.</param>
  14589. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14590. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14591. /// <exception cref="ArgumentNullException">
  14592. /// <paramref name="source" /> is null.</exception>
  14593. /// <exception cref="TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14594. /// <remarks>
  14595. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14596. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14597. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14598. /// </remarks>
  14599. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  14600. {
  14601. if (source == null)
  14602. throw new ArgumentNullException(nameof(source));
  14603. return source.Provider.CreateQuery<TSource>(
  14604. Expression.Call(
  14605. null,
  14606. #if CRIPPLED_REFLECTION
  14607. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14608. #else
  14609. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14610. #endif
  14611. source.Expression,
  14612. Expression.Constant(dueTime, typeof(DateTimeOffset))
  14613. )
  14614. );
  14615. }
  14616. /// <summary>
  14617. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14618. /// If the sequence doesn't terminate before the specified absolute due time, the other observable sequence is used to produce future messages from that point on.
  14619. /// </summary>
  14620. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14621. /// <param name="source">Source sequence to perform a timeout for.</param>
  14622. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14623. /// <param name="other">Sequence to return in case of a timeout.</param>
  14624. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14625. /// <exception cref="ArgumentNullException">
  14626. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14627. /// <remarks>
  14628. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14629. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14630. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14631. /// </remarks>
  14632. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other)
  14633. {
  14634. if (source == null)
  14635. throw new ArgumentNullException(nameof(source));
  14636. if (other == null)
  14637. throw new ArgumentNullException(nameof(other));
  14638. return source.Provider.CreateQuery<TSource>(
  14639. Expression.Call(
  14640. null,
  14641. #if CRIPPLED_REFLECTION
  14642. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>))),
  14643. #else
  14644. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14645. #endif
  14646. source.Expression,
  14647. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14648. GetSourceExpression(other)
  14649. )
  14650. );
  14651. }
  14652. /// <summary>
  14653. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14654. /// If the sequence doesn't terminate before the specified absolute due time, the other observable sequence is used to produce future messages from that point on.
  14655. /// </summary>
  14656. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14657. /// <param name="source">Source sequence to perform a timeout for.</param>
  14658. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14659. /// <param name="other">Sequence to return in case of a timeout.</param>
  14660. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14661. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14662. /// <exception cref="ArgumentNullException">
  14663. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14664. /// <remarks>
  14665. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14666. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14667. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14668. /// </remarks>
  14669. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other, IScheduler scheduler)
  14670. {
  14671. if (source == null)
  14672. throw new ArgumentNullException(nameof(source));
  14673. if (other == null)
  14674. throw new ArgumentNullException(nameof(other));
  14675. if (scheduler == null)
  14676. throw new ArgumentNullException(nameof(scheduler));
  14677. return source.Provider.CreateQuery<TSource>(
  14678. Expression.Call(
  14679. null,
  14680. #if CRIPPLED_REFLECTION
  14681. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>), default(IScheduler))),
  14682. #else
  14683. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14684. #endif
  14685. source.Expression,
  14686. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14687. GetSourceExpression(other),
  14688. Expression.Constant(scheduler, typeof(IScheduler))
  14689. )
  14690. );
  14691. }
  14692. /// <summary>
  14693. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14694. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14695. /// </summary>
  14696. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14697. /// <param name="source">Source sequence to perform a timeout for.</param>
  14698. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14699. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14700. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14701. /// <exception cref="ArgumentNullException">
  14702. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14703. /// <exception cref="TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14704. /// <remarks>
  14705. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14706. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14707. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14708. /// </remarks>
  14709. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  14710. {
  14711. if (source == null)
  14712. throw new ArgumentNullException(nameof(source));
  14713. if (scheduler == null)
  14714. throw new ArgumentNullException(nameof(scheduler));
  14715. return source.Provider.CreateQuery<TSource>(
  14716. Expression.Call(
  14717. null,
  14718. #if CRIPPLED_REFLECTION
  14719. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14720. #else
  14721. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14722. #endif
  14723. source.Expression,
  14724. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14725. Expression.Constant(scheduler, typeof(IScheduler))
  14726. )
  14727. );
  14728. }
  14729. /// <summary>
  14730. /// Applies a timeout policy for each element in the observable sequence.
  14731. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14732. /// </summary>
  14733. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14734. /// <param name="source">Source sequence to perform a timeout for.</param>
  14735. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14736. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14737. /// <exception cref="ArgumentNullException">
  14738. /// <paramref name="source" /> is null.</exception>
  14739. /// <exception cref="ArgumentOutOfRangeException">
  14740. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14741. /// <exception cref="TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14742. /// <remarks>
  14743. /// <para>
  14744. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14745. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14746. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14747. /// </para>
  14748. /// <para>
  14749. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14750. /// immediately. However, this doesn't guarantee a timeout will occur, even for the first element. This is a side-effect of the asynchrony introduced by the
  14751. /// scheduler, where the action to propagate a timeout may not execute immediately, despite the TimeSpan.Zero due time. In such cases, the next element may
  14752. /// arrive before the scheduler gets a chance to run the timeout action.
  14753. /// </para>
  14754. /// </remarks>
  14755. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14756. {
  14757. if (source == null)
  14758. throw new ArgumentNullException(nameof(source));
  14759. return source.Provider.CreateQuery<TSource>(
  14760. Expression.Call(
  14761. null,
  14762. #if CRIPPLED_REFLECTION
  14763. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14764. #else
  14765. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14766. #endif
  14767. source.Expression,
  14768. Expression.Constant(dueTime, typeof(TimeSpan))
  14769. )
  14770. );
  14771. }
  14772. /// <summary>
  14773. /// Applies a timeout policy for each element in the observable sequence.
  14774. /// If the next element isn't received within the specified timeout duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on.
  14775. /// </summary>
  14776. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14777. /// <param name="source">Source sequence to perform a timeout for.</param>
  14778. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14779. /// <param name="other">Sequence to return in case of a timeout.</param>
  14780. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14781. /// <exception cref="ArgumentNullException">
  14782. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14783. /// <exception cref="ArgumentOutOfRangeException">
  14784. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14785. /// <remarks>
  14786. /// <para>
  14787. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14788. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14789. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14790. /// </para>
  14791. /// <para>
  14792. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14793. /// immediately. However, this doesn't guarantee a timeout will occur, even for the first element. This is a side-effect of the asynchrony introduced by the
  14794. /// scheduler, where the action to propagate a timeout may not execute immediately, despite the TimeSpan.Zero due time. In such cases, the next element may
  14795. /// arrive before the scheduler gets a chance to run the timeout action.
  14796. /// </para>
  14797. /// </remarks>
  14798. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other)
  14799. {
  14800. if (source == null)
  14801. throw new ArgumentNullException(nameof(source));
  14802. if (other == null)
  14803. throw new ArgumentNullException(nameof(other));
  14804. return source.Provider.CreateQuery<TSource>(
  14805. Expression.Call(
  14806. null,
  14807. #if CRIPPLED_REFLECTION
  14808. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>))),
  14809. #else
  14810. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14811. #endif
  14812. source.Expression,
  14813. Expression.Constant(dueTime, typeof(TimeSpan)),
  14814. GetSourceExpression(other)
  14815. )
  14816. );
  14817. }
  14818. /// <summary>
  14819. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14820. /// If the next element isn't received within the specified timeout duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on.
  14821. /// </summary>
  14822. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14823. /// <param name="source">Source sequence to perform a timeout for.</param>
  14824. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14825. /// <param name="other">Sequence to return in case of a timeout.</param>
  14826. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14827. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14828. /// <exception cref="ArgumentNullException">
  14829. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14830. /// <exception cref="ArgumentOutOfRangeException">
  14831. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14832. /// <remarks>
  14833. /// <para>
  14834. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14835. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14836. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14837. /// </para>
  14838. /// <para>
  14839. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14840. /// immediately. However, this doesn't guarantee a timeout will occur, even for the first element. This is a side-effect of the asynchrony introduced by the
  14841. /// scheduler, where the action to propagate a timeout may not execute immediately, despite the TimeSpan.Zero due time. In such cases, the next element may
  14842. /// arrive before the scheduler gets a chance to run the timeout action.
  14843. /// </para>
  14844. /// </remarks>
  14845. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other, IScheduler scheduler)
  14846. {
  14847. if (source == null)
  14848. throw new ArgumentNullException(nameof(source));
  14849. if (other == null)
  14850. throw new ArgumentNullException(nameof(other));
  14851. if (scheduler == null)
  14852. throw new ArgumentNullException(nameof(scheduler));
  14853. return source.Provider.CreateQuery<TSource>(
  14854. Expression.Call(
  14855. null,
  14856. #if CRIPPLED_REFLECTION
  14857. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>), default(IScheduler))),
  14858. #else
  14859. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14860. #endif
  14861. source.Expression,
  14862. Expression.Constant(dueTime, typeof(TimeSpan)),
  14863. GetSourceExpression(other),
  14864. Expression.Constant(scheduler, typeof(IScheduler))
  14865. )
  14866. );
  14867. }
  14868. /// <summary>
  14869. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14870. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14871. /// </summary>
  14872. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14873. /// <param name="source">Source sequence to perform a timeout for.</param>
  14874. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14875. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14876. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14877. /// <exception cref="ArgumentNullException">
  14878. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14879. /// <exception cref="ArgumentOutOfRangeException">
  14880. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14881. /// <exception cref="TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14882. /// <remarks>
  14883. /// <para>
  14884. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14885. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14886. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14887. /// </para>
  14888. /// <para>
  14889. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14890. /// immediately. However, this doesn't guarantee a timeout will occur, even for the first element. This is a side-effect of the asynchrony introduced by the
  14891. /// scheduler, where the action to propagate a timeout may not execute immediately, despite the TimeSpan.Zero due time. In such cases, the next element may
  14892. /// arrive before the scheduler gets a chance to run the timeout action.
  14893. /// </para>
  14894. /// </remarks>
  14895. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14896. {
  14897. if (source == null)
  14898. throw new ArgumentNullException(nameof(source));
  14899. if (scheduler == null)
  14900. throw new ArgumentNullException(nameof(scheduler));
  14901. return source.Provider.CreateQuery<TSource>(
  14902. Expression.Call(
  14903. null,
  14904. #if CRIPPLED_REFLECTION
  14905. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14906. #else
  14907. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14908. #endif
  14909. source.Expression,
  14910. Expression.Constant(dueTime, typeof(TimeSpan)),
  14911. Expression.Constant(scheduler, typeof(IScheduler))
  14912. )
  14913. );
  14914. }
  14915. /// <summary>
  14916. /// Applies a timeout policy to the observable sequence based on an initial timeout duration for the first element, and a timeout duration computed for each subsequent element.
  14917. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14918. /// </summary>
  14919. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14920. /// <typeparam name="TTimeout">The type of the elements in the timeout sequences used to indicate the timeout duration for each element in the source sequence.</typeparam>
  14921. /// <param name="source">Source sequence to perform a timeout for.</param>
  14922. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  14923. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14924. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14925. /// <exception cref="ArgumentNullException">
  14926. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  14927. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  14928. {
  14929. if (source == null)
  14930. throw new ArgumentNullException(nameof(source));
  14931. if (firstTimeout == null)
  14932. throw new ArgumentNullException(nameof(firstTimeout));
  14933. if (timeoutDurationSelector == null)
  14934. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  14935. return source.Provider.CreateQuery<TSource>(
  14936. Expression.Call(
  14937. null,
  14938. #if CRIPPLED_REFLECTION
  14939. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  14940. #else
  14941. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14942. #endif
  14943. source.Expression,
  14944. GetSourceExpression(firstTimeout),
  14945. timeoutDurationSelector
  14946. )
  14947. );
  14948. }
  14949. /// <summary>
  14950. /// Applies a timeout policy to the observable sequence based on an initial timeout duration for the first element, and a timeout duration computed for each subsequent element.
  14951. /// If the next element isn't received within the computed duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on.
  14952. /// </summary>
  14953. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14954. /// <typeparam name="TTimeout">The type of the elements in the timeout sequences used to indicate the timeout duration for each element in the source sequence.</typeparam>
  14955. /// <param name="source">Source sequence to perform a timeout for.</param>
  14956. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  14957. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14958. /// <param name="other">Sequence to return in case of a timeout.</param>
  14959. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14960. /// <exception cref="ArgumentNullException">
  14961. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  14962. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  14963. {
  14964. if (source == null)
  14965. throw new ArgumentNullException(nameof(source));
  14966. if (firstTimeout == null)
  14967. throw new ArgumentNullException(nameof(firstTimeout));
  14968. if (timeoutDurationSelector == null)
  14969. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  14970. if (other == null)
  14971. throw new ArgumentNullException(nameof(other));
  14972. return source.Provider.CreateQuery<TSource>(
  14973. Expression.Call(
  14974. null,
  14975. #if CRIPPLED_REFLECTION
  14976. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  14977. #else
  14978. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14979. #endif
  14980. source.Expression,
  14981. GetSourceExpression(firstTimeout),
  14982. timeoutDurationSelector,
  14983. GetSourceExpression(other)
  14984. )
  14985. );
  14986. }
  14987. /// <summary>
  14988. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  14989. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14990. /// </summary>
  14991. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14992. /// <typeparam name="TTimeout">The type of the elements in the timeout sequences used to indicate the timeout duration for each element in the source sequence.</typeparam>
  14993. /// <param name="source">Source sequence to perform a timeout for.</param>
  14994. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14995. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14996. /// <exception cref="ArgumentNullException">
  14997. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  14998. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  14999. {
  15000. if (source == null)
  15001. throw new ArgumentNullException(nameof(source));
  15002. if (timeoutDurationSelector == null)
  15003. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  15004. return source.Provider.CreateQuery<TSource>(
  15005. Expression.Call(
  15006. null,
  15007. #if CRIPPLED_REFLECTION
  15008. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  15009. #else
  15010. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15011. #endif
  15012. source.Expression,
  15013. timeoutDurationSelector
  15014. )
  15015. );
  15016. }
  15017. /// <summary>
  15018. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  15019. /// If the next element isn't received within the computed duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on.
  15020. /// </summary>
  15021. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  15022. /// <typeparam name="TTimeout">The type of the elements in the timeout sequences used to indicate the timeout duration for each element in the source sequence.</typeparam>
  15023. /// <param name="source">Source sequence to perform a timeout for.</param>
  15024. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15025. /// <param name="other">Sequence to return in case of a timeout.</param>
  15026. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15027. /// <exception cref="ArgumentNullException">
  15028. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  15029. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  15030. {
  15031. if (source == null)
  15032. throw new ArgumentNullException(nameof(source));
  15033. if (timeoutDurationSelector == null)
  15034. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  15035. if (other == null)
  15036. throw new ArgumentNullException(nameof(other));
  15037. return source.Provider.CreateQuery<TSource>(
  15038. Expression.Call(
  15039. null,
  15040. #if CRIPPLED_REFLECTION
  15041. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  15042. #else
  15043. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15044. #endif
  15045. source.Expression,
  15046. timeoutDurationSelector,
  15047. GetSourceExpression(other)
  15048. )
  15049. );
  15050. }
  15051. /// <summary>
  15052. /// Returns an observable sequence that produces a single value at the specified absolute due time.
  15053. /// </summary>
  15054. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15055. /// <param name="dueTime">Absolute time at which to produce the value. If this value is less than or equal to DateTimeOffset.UtcNow, the timer will fire as soon as possible.</param>
  15056. /// <returns>An observable sequence that produces a value at due time.</returns>
  15057. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime)
  15058. {
  15059. if (provider == null)
  15060. throw new ArgumentNullException(nameof(provider));
  15061. return provider.CreateQuery<long>(
  15062. Expression.Call(
  15063. null,
  15064. #if CRIPPLED_REFLECTION
  15065. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset))),
  15066. #else
  15067. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15068. #endif
  15069. Expression.Constant(provider, typeof(IQbservableProvider)),
  15070. Expression.Constant(dueTime, typeof(DateTimeOffset))
  15071. )
  15072. );
  15073. }
  15074. /// <summary>
  15075. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time.
  15076. /// </summary>
  15077. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15078. /// <param name="dueTime">Absolute time at which to produce the first value. If this value is less than or equal to DateTimeOffset.UtcNow, the timer will fire as soon as possible.</param>
  15079. /// <param name="period">Period to produce subsequent values. If this value is equal to TimeSpan.Zero, the timer will recur as fast as possible.</param>
  15080. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  15081. /// <exception cref="ArgumentOutOfRangeException">
  15082. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15083. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period)
  15084. {
  15085. if (provider == null)
  15086. throw new ArgumentNullException(nameof(provider));
  15087. return provider.CreateQuery<long>(
  15088. Expression.Call(
  15089. null,
  15090. #if CRIPPLED_REFLECTION
  15091. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan))),
  15092. #else
  15093. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15094. #endif
  15095. Expression.Constant(provider, typeof(IQbservableProvider)),
  15096. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15097. Expression.Constant(period, typeof(TimeSpan))
  15098. )
  15099. );
  15100. }
  15101. /// <summary>
  15102. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time, using the specified scheduler to run timers.
  15103. /// </summary>
  15104. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15105. /// <param name="dueTime">Absolute time at which to produce the first value. If this value is less than or equal to DateTimeOffset.UtcNow, the timer will fire as soon as possible.</param>
  15106. /// <param name="period">Period to produce subsequent values. If this value is equal to TimeSpan.Zero, the timer will recur as fast as possible.</param>
  15107. /// <param name="scheduler">Scheduler to run timers on.</param>
  15108. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  15109. /// <exception cref="ArgumentOutOfRangeException">
  15110. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15111. /// <exception cref="ArgumentNullException">
  15112. /// <paramref name="scheduler" /> is null.</exception>
  15113. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period, IScheduler scheduler)
  15114. {
  15115. if (provider == null)
  15116. throw new ArgumentNullException(nameof(provider));
  15117. if (scheduler == null)
  15118. throw new ArgumentNullException(nameof(scheduler));
  15119. return provider.CreateQuery<long>(
  15120. Expression.Call(
  15121. null,
  15122. #if CRIPPLED_REFLECTION
  15123. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan), default(IScheduler))),
  15124. #else
  15125. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15126. #endif
  15127. Expression.Constant(provider, typeof(IQbservableProvider)),
  15128. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15129. Expression.Constant(period, typeof(TimeSpan)),
  15130. Expression.Constant(scheduler, typeof(IScheduler))
  15131. )
  15132. );
  15133. }
  15134. /// <summary>
  15135. /// Returns an observable sequence that produces a single value at the specified absolute due time, using the specified scheduler to run the timer.
  15136. /// </summary>
  15137. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15138. /// <param name="dueTime">Absolute time at which to produce the value. If this value is less than or equal to DateTimeOffset.UtcNow, the timer will fire as soon as possible.</param>
  15139. /// <param name="scheduler">Scheduler to run the timer on.</param>
  15140. /// <returns>An observable sequence that produces a value at due time.</returns>
  15141. /// <exception cref="ArgumentNullException">
  15142. /// <paramref name="scheduler" /> is null.</exception>
  15143. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, IScheduler scheduler)
  15144. {
  15145. if (provider == null)
  15146. throw new ArgumentNullException(nameof(provider));
  15147. if (scheduler == null)
  15148. throw new ArgumentNullException(nameof(scheduler));
  15149. return provider.CreateQuery<long>(
  15150. Expression.Call(
  15151. null,
  15152. #if CRIPPLED_REFLECTION
  15153. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(IScheduler))),
  15154. #else
  15155. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15156. #endif
  15157. Expression.Constant(provider, typeof(IQbservableProvider)),
  15158. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15159. Expression.Constant(scheduler, typeof(IScheduler))
  15160. )
  15161. );
  15162. }
  15163. /// <summary>
  15164. /// Returns an observable sequence that produces a single value after the specified relative due time has elapsed.
  15165. /// </summary>
  15166. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15167. /// <param name="dueTime">Relative time at which to produce the value. If this value is less than or equal to TimeSpan.Zero, the timer will fire as soon as possible.</param>
  15168. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15169. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime)
  15170. {
  15171. if (provider == null)
  15172. throw new ArgumentNullException(nameof(provider));
  15173. return provider.CreateQuery<long>(
  15174. Expression.Call(
  15175. null,
  15176. #if CRIPPLED_REFLECTION
  15177. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan))),
  15178. #else
  15179. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15180. #endif
  15181. Expression.Constant(provider, typeof(IQbservableProvider)),
  15182. Expression.Constant(dueTime, typeof(TimeSpan))
  15183. )
  15184. );
  15185. }
  15186. /// <summary>
  15187. /// Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed.
  15188. /// </summary>
  15189. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15190. /// <param name="dueTime">Relative time at which to produce the first value. If this value is less than or equal to TimeSpan.Zero, the timer will fire as soon as possible.</param>
  15191. /// <param name="period">Period to produce subsequent values. If this value is equal to TimeSpan.Zero, the timer will recur as fast as possible.</param>
  15192. /// <returns>An observable sequence that produces a value after due time has elapsed and then after each period.</returns>
  15193. /// <exception cref="ArgumentOutOfRangeException">
  15194. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15195. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period)
  15196. {
  15197. if (provider == null)
  15198. throw new ArgumentNullException(nameof(provider));
  15199. return provider.CreateQuery<long>(
  15200. Expression.Call(
  15201. null,
  15202. #if CRIPPLED_REFLECTION
  15203. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan))),
  15204. #else
  15205. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15206. #endif
  15207. Expression.Constant(provider, typeof(IQbservableProvider)),
  15208. Expression.Constant(dueTime, typeof(TimeSpan)),
  15209. Expression.Constant(period, typeof(TimeSpan))
  15210. )
  15211. );
  15212. }
  15213. /// <summary>
  15214. /// Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed, using the specified scheduler to run timers.
  15215. /// </summary>
  15216. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15217. /// <param name="dueTime">Relative time at which to produce the first value. If this value is less than or equal to TimeSpan.Zero, the timer will fire as soon as possible.</param>
  15218. /// <param name="period">Period to produce subsequent values. If this value is equal to TimeSpan.Zero, the timer will recur as fast as possible.</param>
  15219. /// <param name="scheduler">Scheduler to run timers on.</param>
  15220. /// <returns>An observable sequence that produces a value after due time has elapsed and then each period.</returns>
  15221. /// <exception cref="ArgumentOutOfRangeException">
  15222. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15223. /// <exception cref="ArgumentNullException">
  15224. /// <paramref name="scheduler" /> is null.</exception>
  15225. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period, IScheduler scheduler)
  15226. {
  15227. if (provider == null)
  15228. throw new ArgumentNullException(nameof(provider));
  15229. if (scheduler == null)
  15230. throw new ArgumentNullException(nameof(scheduler));
  15231. return provider.CreateQuery<long>(
  15232. Expression.Call(
  15233. null,
  15234. #if CRIPPLED_REFLECTION
  15235. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  15236. #else
  15237. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15238. #endif
  15239. Expression.Constant(provider, typeof(IQbservableProvider)),
  15240. Expression.Constant(dueTime, typeof(TimeSpan)),
  15241. Expression.Constant(period, typeof(TimeSpan)),
  15242. Expression.Constant(scheduler, typeof(IScheduler))
  15243. )
  15244. );
  15245. }
  15246. /// <summary>
  15247. /// Returns an observable sequence that produces a single value after the specified relative due time has elapsed, using the specified scheduler to run the timer.
  15248. /// </summary>
  15249. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15250. /// <param name="dueTime">Relative time at which to produce the value. If this value is less than or equal to TimeSpan.Zero, the timer will fire as soon as possible.</param>
  15251. /// <param name="scheduler">Scheduler to run the timer on.</param>
  15252. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15253. /// <exception cref="ArgumentNullException">
  15254. /// <paramref name="scheduler" /> is null.</exception>
  15255. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, IScheduler scheduler)
  15256. {
  15257. if (provider == null)
  15258. throw new ArgumentNullException(nameof(provider));
  15259. if (scheduler == null)
  15260. throw new ArgumentNullException(nameof(scheduler));
  15261. return provider.CreateQuery<long>(
  15262. Expression.Call(
  15263. null,
  15264. #if CRIPPLED_REFLECTION
  15265. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  15266. #else
  15267. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15268. #endif
  15269. Expression.Constant(provider, typeof(IQbservableProvider)),
  15270. Expression.Constant(dueTime, typeof(TimeSpan)),
  15271. Expression.Constant(scheduler, typeof(IScheduler))
  15272. )
  15273. );
  15274. }
  15275. /// <summary>
  15276. /// Timestamps each element in an observable sequence using the local system clock.
  15277. /// </summary>
  15278. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15279. /// <param name="source">Source sequence to timestamp elements for.</param>
  15280. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15281. /// <exception cref="ArgumentNullException">
  15282. /// <paramref name="source" /> is null.</exception>
  15283. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source)
  15284. {
  15285. if (source == null)
  15286. throw new ArgumentNullException(nameof(source));
  15287. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15288. Expression.Call(
  15289. null,
  15290. #if CRIPPLED_REFLECTION
  15291. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>))),
  15292. #else
  15293. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15294. #endif
  15295. source.Expression
  15296. )
  15297. );
  15298. }
  15299. /// <summary>
  15300. /// Timestamp each element in an observable sequence using the clock of the specified scheduler.
  15301. /// </summary>
  15302. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15303. /// <param name="source">Source sequence to timestamp elements for.</param>
  15304. /// <param name="scheduler">Scheduler used to compute timestamps.</param>
  15305. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15306. /// <exception cref="ArgumentNullException">
  15307. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15308. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  15309. {
  15310. if (source == null)
  15311. throw new ArgumentNullException(nameof(source));
  15312. if (scheduler == null)
  15313. throw new ArgumentNullException(nameof(scheduler));
  15314. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15315. Expression.Call(
  15316. null,
  15317. #if CRIPPLED_REFLECTION
  15318. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  15319. #else
  15320. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15321. #endif
  15322. source.Expression,
  15323. Expression.Constant(scheduler, typeof(IScheduler))
  15324. )
  15325. );
  15326. }
  15327. /// <summary>
  15328. /// Creates an array from an observable sequence.
  15329. /// </summary>
  15330. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15331. /// <param name="source">The source observable sequence to get an array of elements for.</param>
  15332. /// <returns>An observable sequence containing a single element with an array containing all the elements of the source sequence.</returns>
  15333. /// <exception cref="ArgumentNullException">
  15334. /// <paramref name="source" /> is null.</exception>
  15335. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15336. public static IQbservable<TSource[]> ToArray<TSource>(this IQbservable<TSource> source)
  15337. {
  15338. if (source == null)
  15339. throw new ArgumentNullException(nameof(source));
  15340. return source.Provider.CreateQuery<TSource[]>(
  15341. Expression.Call(
  15342. null,
  15343. #if CRIPPLED_REFLECTION
  15344. InfoOf(() => Qbservable.ToArray<TSource>(default(IQbservable<TSource>))),
  15345. #else
  15346. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15347. #endif
  15348. source.Expression
  15349. )
  15350. );
  15351. }
  15352. /// <summary>
  15353. /// Creates a dictionary from an observable sequence according to a specified key selector function.
  15354. /// </summary>
  15355. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15356. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15357. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15358. /// <param name="keySelector">A function to extract a key from each element.</param>
  15359. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15360. /// <exception cref="ArgumentNullException">
  15361. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15362. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15363. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15364. {
  15365. if (source == null)
  15366. throw new ArgumentNullException(nameof(source));
  15367. if (keySelector == null)
  15368. throw new ArgumentNullException(nameof(keySelector));
  15369. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15370. Expression.Call(
  15371. null,
  15372. #if CRIPPLED_REFLECTION
  15373. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15374. #else
  15375. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15376. #endif
  15377. source.Expression,
  15378. keySelector
  15379. )
  15380. );
  15381. }
  15382. /// <summary>
  15383. /// Creates a dictionary from an observable sequence according to a specified key selector function, and a comparer.
  15384. /// </summary>
  15385. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15386. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15387. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15388. /// <param name="keySelector">A function to extract a key from each element.</param>
  15389. /// <param name="comparer">An equality comparer to compare keys.</param>
  15390. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15391. /// <exception cref="ArgumentNullException">
  15392. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15393. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15394. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15395. {
  15396. if (source == null)
  15397. throw new ArgumentNullException(nameof(source));
  15398. if (keySelector == null)
  15399. throw new ArgumentNullException(nameof(keySelector));
  15400. if (comparer == null)
  15401. throw new ArgumentNullException(nameof(comparer));
  15402. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15403. Expression.Call(
  15404. null,
  15405. #if CRIPPLED_REFLECTION
  15406. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15407. #else
  15408. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15409. #endif
  15410. source.Expression,
  15411. keySelector,
  15412. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15413. )
  15414. );
  15415. }
  15416. /// <summary>
  15417. /// Creates a dictionary from an observable sequence according to a specified key selector function, and an element selector function.
  15418. /// </summary>
  15419. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15420. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15421. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15422. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15423. /// <param name="keySelector">A function to extract a key from each element.</param>
  15424. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15425. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15426. /// <exception cref="ArgumentNullException">
  15427. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15428. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15429. public static IQbservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15430. {
  15431. if (source == null)
  15432. throw new ArgumentNullException(nameof(source));
  15433. if (keySelector == null)
  15434. throw new ArgumentNullException(nameof(keySelector));
  15435. if (elementSelector == null)
  15436. throw new ArgumentNullException(nameof(elementSelector));
  15437. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15438. Expression.Call(
  15439. null,
  15440. #if CRIPPLED_REFLECTION
  15441. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15442. #else
  15443. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15444. #endif
  15445. source.Expression,
  15446. keySelector,
  15447. elementSelector
  15448. )
  15449. );
  15450. }
  15451. /// <summary>
  15452. /// Creates a dictionary from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15453. /// </summary>
  15454. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15455. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15456. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15457. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15458. /// <param name="keySelector">A function to extract a key from each element.</param>
  15459. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15460. /// <param name="comparer">An equality comparer to compare keys.</param>
  15461. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15462. /// <exception cref="ArgumentNullException">
  15463. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15464. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15465. public static IQbservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer)
  15466. {
  15467. if (source == null)
  15468. throw new ArgumentNullException(nameof(source));
  15469. if (keySelector == null)
  15470. throw new ArgumentNullException(nameof(keySelector));
  15471. if (elementSelector == null)
  15472. throw new ArgumentNullException(nameof(elementSelector));
  15473. if (comparer == null)
  15474. throw new ArgumentNullException(nameof(comparer));
  15475. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15476. Expression.Call(
  15477. null,
  15478. #if CRIPPLED_REFLECTION
  15479. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15480. #else
  15481. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15482. #endif
  15483. source.Expression,
  15484. keySelector,
  15485. elementSelector,
  15486. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15487. )
  15488. );
  15489. }
  15490. /// <summary>
  15491. /// Converts an observable sequence to an enumerable sequence.
  15492. /// </summary>
  15493. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15494. /// <param name="source">An observable sequence to convert to an enumerable sequence.</param>
  15495. /// <returns>The enumerable sequence containing the elements in the observable sequence.</returns>
  15496. /// <exception cref="ArgumentNullException">
  15497. /// <paramref name="source" /> is null.</exception>
  15498. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  15499. public static IQueryable<TSource> ToQueryable<TSource>(this IQbservable<TSource> source)
  15500. {
  15501. if (source == null)
  15502. throw new ArgumentNullException(nameof(source));
  15503. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  15504. Expression.Call(
  15505. null,
  15506. #if CRIPPLED_REFLECTION
  15507. InfoOf(() => Qbservable.ToQueryable<TSource>(default(IQbservable<TSource>))),
  15508. #else
  15509. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15510. #endif
  15511. source.Expression
  15512. )
  15513. );
  15514. }
  15515. /// <summary>
  15516. /// Creates a list from an observable sequence.
  15517. /// </summary>
  15518. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15519. /// <param name="source">The source observable sequence to get a list of elements for.</param>
  15520. /// <returns>An observable sequence containing a single element with a list containing all the elements of the source sequence.</returns>
  15521. /// <exception cref="ArgumentNullException">
  15522. /// <paramref name="source" /> is null.</exception>
  15523. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15524. public static IQbservable<IList<TSource>> ToList<TSource>(this IQbservable<TSource> source)
  15525. {
  15526. if (source == null)
  15527. throw new ArgumentNullException(nameof(source));
  15528. return source.Provider.CreateQuery<IList<TSource>>(
  15529. Expression.Call(
  15530. null,
  15531. #if CRIPPLED_REFLECTION
  15532. InfoOf(() => Qbservable.ToList<TSource>(default(IQbservable<TSource>))),
  15533. #else
  15534. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15535. #endif
  15536. source.Expression
  15537. )
  15538. );
  15539. }
  15540. /// <summary>
  15541. /// Creates a lookup from an observable sequence according to a specified key selector function.
  15542. /// </summary>
  15543. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15544. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15545. /// <param name="source">An observable sequence to create a lookup for.</param>
  15546. /// <param name="keySelector">A function to extract a key from each element.</param>
  15547. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15548. /// <exception cref="ArgumentNullException">
  15549. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15550. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15551. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15552. {
  15553. if (source == null)
  15554. throw new ArgumentNullException(nameof(source));
  15555. if (keySelector == null)
  15556. throw new ArgumentNullException(nameof(keySelector));
  15557. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15558. Expression.Call(
  15559. null,
  15560. #if CRIPPLED_REFLECTION
  15561. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15562. #else
  15563. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15564. #endif
  15565. source.Expression,
  15566. keySelector
  15567. )
  15568. );
  15569. }
  15570. /// <summary>
  15571. /// Creates a lookup from an observable sequence according to a specified key selector function, and a comparer.
  15572. /// </summary>
  15573. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15574. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15575. /// <param name="source">An observable sequence to create a lookup for.</param>
  15576. /// <param name="keySelector">A function to extract a key from each element.</param>
  15577. /// <param name="comparer">An equality comparer to compare keys.</param>
  15578. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15579. /// <exception cref="ArgumentNullException">
  15580. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15581. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15582. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15583. {
  15584. if (source == null)
  15585. throw new ArgumentNullException(nameof(source));
  15586. if (keySelector == null)
  15587. throw new ArgumentNullException(nameof(keySelector));
  15588. if (comparer == null)
  15589. throw new ArgumentNullException(nameof(comparer));
  15590. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15591. Expression.Call(
  15592. null,
  15593. #if CRIPPLED_REFLECTION
  15594. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15595. #else
  15596. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15597. #endif
  15598. source.Expression,
  15599. keySelector,
  15600. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15601. )
  15602. );
  15603. }
  15604. /// <summary>
  15605. /// Creates a lookup from an observable sequence according to a specified key selector function, and an element selector function.
  15606. /// </summary>
  15607. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15608. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15609. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15610. /// <param name="source">An observable sequence to create a lookup for.</param>
  15611. /// <param name="keySelector">A function to extract a key from each element.</param>
  15612. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15613. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15614. /// <exception cref="ArgumentNullException">
  15615. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15616. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15617. public static IQbservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15618. {
  15619. if (source == null)
  15620. throw new ArgumentNullException(nameof(source));
  15621. if (keySelector == null)
  15622. throw new ArgumentNullException(nameof(keySelector));
  15623. if (elementSelector == null)
  15624. throw new ArgumentNullException(nameof(elementSelector));
  15625. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15626. Expression.Call(
  15627. null,
  15628. #if CRIPPLED_REFLECTION
  15629. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15630. #else
  15631. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15632. #endif
  15633. source.Expression,
  15634. keySelector,
  15635. elementSelector
  15636. )
  15637. );
  15638. }
  15639. /// <summary>
  15640. /// Creates a lookup from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15641. /// </summary>
  15642. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15643. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15644. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15645. /// <param name="source">An observable sequence to create a lookup for.</param>
  15646. /// <param name="keySelector">A function to extract a key from each element.</param>
  15647. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15648. /// <param name="comparer">An equality comparer to compare keys.</param>
  15649. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15650. /// <exception cref="ArgumentNullException">
  15651. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15652. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15653. public static IQbservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer)
  15654. {
  15655. if (source == null)
  15656. throw new ArgumentNullException(nameof(source));
  15657. if (keySelector == null)
  15658. throw new ArgumentNullException(nameof(keySelector));
  15659. if (elementSelector == null)
  15660. throw new ArgumentNullException(nameof(elementSelector));
  15661. if (comparer == null)
  15662. throw new ArgumentNullException(nameof(comparer));
  15663. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15664. Expression.Call(
  15665. null,
  15666. #if CRIPPLED_REFLECTION
  15667. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15668. #else
  15669. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15670. #endif
  15671. source.Expression,
  15672. keySelector,
  15673. elementSelector,
  15674. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15675. )
  15676. );
  15677. }
  15678. /// <summary>
  15679. /// Converts an enumerable sequence to an observable sequence.
  15680. /// </summary>
  15681. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15682. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15683. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15684. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15685. /// <exception cref="ArgumentNullException">
  15686. /// <paramref name="source" /> is null.</exception>
  15687. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source)
  15688. {
  15689. if (provider == null)
  15690. throw new ArgumentNullException(nameof(provider));
  15691. if (source == null)
  15692. throw new ArgumentNullException(nameof(source));
  15693. return provider.CreateQuery<TSource>(
  15694. Expression.Call(
  15695. null,
  15696. #if CRIPPLED_REFLECTION
  15697. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>))),
  15698. #else
  15699. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15700. #endif
  15701. Expression.Constant(provider, typeof(IQbservableProvider)),
  15702. GetSourceExpression(source)
  15703. )
  15704. );
  15705. }
  15706. /// <summary>
  15707. /// Converts an enumerable sequence to an observable sequence, using the specified scheduler to run the enumeration loop.
  15708. /// </summary>
  15709. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15710. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15711. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15712. /// <param name="scheduler">Scheduler to run the enumeration of the input sequence on.</param>
  15713. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15714. /// <exception cref="ArgumentNullException">
  15715. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15716. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source, IScheduler scheduler)
  15717. {
  15718. if (provider == null)
  15719. throw new ArgumentNullException(nameof(provider));
  15720. if (source == null)
  15721. throw new ArgumentNullException(nameof(source));
  15722. if (scheduler == null)
  15723. throw new ArgumentNullException(nameof(scheduler));
  15724. return provider.CreateQuery<TSource>(
  15725. Expression.Call(
  15726. null,
  15727. #if CRIPPLED_REFLECTION
  15728. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>), default(IScheduler))),
  15729. #else
  15730. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15731. #endif
  15732. Expression.Constant(provider, typeof(IQbservableProvider)),
  15733. GetSourceExpression(source),
  15734. Expression.Constant(scheduler, typeof(IScheduler))
  15735. )
  15736. );
  15737. }
  15738. /// <summary>
  15739. /// Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
  15740. /// </summary>
  15741. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15742. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15743. /// <typeparam name="TResource">The type of the resource used during the generation of the resulting sequence. Needs to implement <see cref="IDisposable" />.</typeparam>
  15744. /// <param name="resourceFactory">Factory function to obtain a resource object.</param>
  15745. /// <param name="observableFactory">Factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15746. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15747. /// <exception cref="ArgumentNullException">
  15748. /// <paramref name="resourceFactory" /> or <paramref name="observableFactory" /> is null.</exception>
  15749. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<TResource>> resourceFactory, Expression<Func<TResource, IObservable<TResult>>> observableFactory)
  15750. where TResource : IDisposable
  15751. {
  15752. if (provider == null)
  15753. throw new ArgumentNullException(nameof(provider));
  15754. if (resourceFactory == null)
  15755. throw new ArgumentNullException(nameof(resourceFactory));
  15756. if (observableFactory == null)
  15757. throw new ArgumentNullException(nameof(observableFactory));
  15758. return provider.CreateQuery<TResult>(
  15759. Expression.Call(
  15760. null,
  15761. #if CRIPPLED_REFLECTION
  15762. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<TResource>>), default(Expression<Func<TResource, IObservable<TResult>>>))),
  15763. #else
  15764. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15765. #endif
  15766. Expression.Constant(provider, typeof(IQbservableProvider)),
  15767. resourceFactory,
  15768. observableFactory
  15769. )
  15770. );
  15771. }
  15772. /// <summary>
  15773. /// Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime. The resource is obtained and used through asynchronous methods.
  15774. /// The CancellationToken passed to the asynchronous methods is tied to the returned disposable subscription, allowing best-effort cancellation at any stage of the resource acquisition or usage.
  15775. /// </summary>
  15776. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15777. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15778. /// <typeparam name="TResource">The type of the resource used during the generation of the resulting sequence. Needs to implement <see cref="IDisposable" />.</typeparam>
  15779. /// <param name="resourceFactoryAsync">Asynchronous factory function to obtain a resource object.</param>
  15780. /// <param name="observableFactoryAsync">Asynchronous factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15781. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15782. /// <exception cref="ArgumentNullException">
  15783. /// <paramref name="resourceFactoryAsync" /> or <paramref name="observableFactoryAsync" /> is null.</exception>
  15784. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  15785. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous resource factory and observable factory functions will be signaled.</remarks>
  15786. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResource>>> resourceFactoryAsync, Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  15787. where TResource : IDisposable
  15788. {
  15789. if (provider == null)
  15790. throw new ArgumentNullException(nameof(provider));
  15791. if (resourceFactoryAsync == null)
  15792. throw new ArgumentNullException(nameof(resourceFactoryAsync));
  15793. if (observableFactoryAsync == null)
  15794. throw new ArgumentNullException(nameof(observableFactoryAsync));
  15795. return provider.CreateQuery<TResult>(
  15796. Expression.Call(
  15797. null,
  15798. #if CRIPPLED_REFLECTION
  15799. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResource>>>), default(Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>>))),
  15800. #else
  15801. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15802. #endif
  15803. Expression.Constant(provider, typeof(IQbservableProvider)),
  15804. resourceFactoryAsync,
  15805. observableFactoryAsync
  15806. )
  15807. );
  15808. }
  15809. /// <summary>
  15810. /// Filters the elements of an observable sequence based on a predicate.
  15811. /// </summary>
  15812. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15813. /// <param name="source">An observable sequence whose elements to filter.</param>
  15814. /// <param name="predicate">A function to test each source element for a condition.</param>
  15815. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15816. /// <exception cref="ArgumentNullException">
  15817. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15818. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  15819. {
  15820. if (source == null)
  15821. throw new ArgumentNullException(nameof(source));
  15822. if (predicate == null)
  15823. throw new ArgumentNullException(nameof(predicate));
  15824. return source.Provider.CreateQuery<TSource>(
  15825. Expression.Call(
  15826. null,
  15827. #if CRIPPLED_REFLECTION
  15828. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  15829. #else
  15830. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15831. #endif
  15832. source.Expression,
  15833. predicate
  15834. )
  15835. );
  15836. }
  15837. /// <summary>
  15838. /// Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
  15839. /// </summary>
  15840. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15841. /// <param name="source">An observable sequence whose elements to filter.</param>
  15842. /// <param name="predicate">A function to test each source element for a condition; the second parameter of the function represents the index of the source element.</param>
  15843. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15844. /// <exception cref="ArgumentNullException">
  15845. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15846. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  15847. {
  15848. if (source == null)
  15849. throw new ArgumentNullException(nameof(source));
  15850. if (predicate == null)
  15851. throw new ArgumentNullException(nameof(predicate));
  15852. return source.Provider.CreateQuery<TSource>(
  15853. Expression.Call(
  15854. null,
  15855. #if CRIPPLED_REFLECTION
  15856. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  15857. #else
  15858. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15859. #endif
  15860. source.Expression,
  15861. predicate
  15862. )
  15863. );
  15864. }
  15865. /// <summary>
  15866. /// Repeats the given <paramref name="source" /> as long as the specified <paramref name="condition" /> holds, where the <paramref name="condition" /> is evaluated before each repeated <paramref name="source" /> is subscribed to.
  15867. /// </summary>
  15868. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15869. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15870. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  15871. /// <param name="condition">Condition that will be evaluated before subscription to the <paramref name="source" />, to determine whether repetition of the source is required.</param>
  15872. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  15873. /// <exception cref="ArgumentNullException">
  15874. /// <paramref name="condition" /> or <paramref name="source" /> is null.</exception>
  15875. public static IQbservable<TSource> While<TSource>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TSource> source)
  15876. {
  15877. if (provider == null)
  15878. throw new ArgumentNullException(nameof(provider));
  15879. if (condition == null)
  15880. throw new ArgumentNullException(nameof(condition));
  15881. if (source == null)
  15882. throw new ArgumentNullException(nameof(source));
  15883. return provider.CreateQuery<TSource>(
  15884. Expression.Call(
  15885. null,
  15886. #if CRIPPLED_REFLECTION
  15887. InfoOf(() => Qbservable.While<TSource>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TSource>))),
  15888. #else
  15889. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15890. #endif
  15891. Expression.Constant(provider, typeof(IQbservableProvider)),
  15892. condition,
  15893. GetSourceExpression(source)
  15894. )
  15895. );
  15896. }
  15897. /// <summary>
  15898. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on element count information.
  15899. /// </summary>
  15900. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15901. /// <param name="source">Source sequence to produce windows over.</param>
  15902. /// <param name="count">Length of each window.</param>
  15903. /// <returns>An observable sequence of windows.</returns>
  15904. /// <exception cref="ArgumentNullException">
  15905. /// <paramref name="source" /> is null.</exception>
  15906. /// <exception cref="ArgumentOutOfRangeException">
  15907. /// <paramref name="count" /> is less than or equal to zero.</exception>
  15908. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count)
  15909. {
  15910. if (source == null)
  15911. throw new ArgumentNullException(nameof(source));
  15912. return source.Provider.CreateQuery<IObservable<TSource>>(
  15913. Expression.Call(
  15914. null,
  15915. #if CRIPPLED_REFLECTION
  15916. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int))),
  15917. #else
  15918. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15919. #endif
  15920. source.Expression,
  15921. Expression.Constant(count, typeof(int))
  15922. )
  15923. );
  15924. }
  15925. /// <summary>
  15926. /// Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
  15927. /// </summary>
  15928. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15929. /// <param name="source">Source sequence to produce windows over.</param>
  15930. /// <param name="count">Length of each window.</param>
  15931. /// <param name="skip">Number of elements to skip between creation of consecutive windows.</param>
  15932. /// <returns>An observable sequence of windows.</returns>
  15933. /// <exception cref="ArgumentNullException">
  15934. /// <paramref name="source" /> is null.</exception>
  15935. /// <exception cref="ArgumentOutOfRangeException">
  15936. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  15937. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count, int skip)
  15938. {
  15939. if (source == null)
  15940. throw new ArgumentNullException(nameof(source));
  15941. return source.Provider.CreateQuery<IObservable<TSource>>(
  15942. Expression.Call(
  15943. null,
  15944. #if CRIPPLED_REFLECTION
  15945. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  15946. #else
  15947. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15948. #endif
  15949. source.Expression,
  15950. Expression.Constant(count, typeof(int)),
  15951. Expression.Constant(skip, typeof(int))
  15952. )
  15953. );
  15954. }
  15955. /// <summary>
  15956. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information.
  15957. /// </summary>
  15958. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15959. /// <param name="source">Source sequence to produce windows over.</param>
  15960. /// <param name="timeSpan">Length of each window.</param>
  15961. /// <returns>The sequence of windows.</returns>
  15962. /// <exception cref="ArgumentNullException">
  15963. /// <paramref name="source" /> is null.</exception>
  15964. /// <exception cref="ArgumentOutOfRangeException">
  15965. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15966. /// <remarks>
  15967. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows as fast as it can.
  15968. /// Because all source sequence elements end up in one of the windows, some windows won't have a zero time span. This is a side-effect of the asynchrony introduced
  15969. /// by the scheduler, where the action to close the current window and to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  15970. /// </remarks>
  15971. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  15972. {
  15973. if (source == null)
  15974. throw new ArgumentNullException(nameof(source));
  15975. return source.Provider.CreateQuery<IObservable<TSource>>(
  15976. Expression.Call(
  15977. null,
  15978. #if CRIPPLED_REFLECTION
  15979. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  15980. #else
  15981. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15982. #endif
  15983. source.Expression,
  15984. Expression.Constant(timeSpan, typeof(TimeSpan))
  15985. )
  15986. );
  15987. }
  15988. /// <summary>
  15989. /// Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed.
  15990. /// A useful real-world analogy of this overload is the behavior of a ferry leaving the dock when all seats are taken, or at the scheduled time of departure, whichever event occurs first.
  15991. /// </summary>
  15992. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15993. /// <param name="source">Source sequence to produce windows over.</param>
  15994. /// <param name="timeSpan">Maximum time length of a window.</param>
  15995. /// <param name="count">Maximum element count of a window.</param>
  15996. /// <returns>An observable sequence of windows.</returns>
  15997. /// <exception cref="ArgumentNullException">
  15998. /// <paramref name="source" /> is null.</exception>
  15999. /// <exception cref="ArgumentOutOfRangeException">
  16000. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  16001. /// <remarks>
  16002. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows as fast as it can.
  16003. /// Because all source sequence elements end up in one of the windows, some windows won't have a zero time span. This is a side-effect of the asynchrony introduced
  16004. /// by the scheduler, where the action to close the current window and to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16005. /// </remarks>
  16006. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  16007. {
  16008. if (source == null)
  16009. throw new ArgumentNullException(nameof(source));
  16010. return source.Provider.CreateQuery<IObservable<TSource>>(
  16011. Expression.Call(
  16012. null,
  16013. #if CRIPPLED_REFLECTION
  16014. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  16015. #else
  16016. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16017. #endif
  16018. source.Expression,
  16019. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16020. Expression.Constant(count, typeof(int))
  16021. )
  16022. );
  16023. }
  16024. /// <summary>
  16025. /// Projects each element of an observable sequence into a window that is completed when either it's full or a given amount of time has elapsed, using the specified scheduler to run timers.
  16026. /// A useful real-world analogy of this overload is the behavior of a ferry leaving the dock when all seats are taken, or at the scheduled time of departure, whichever event occurs first.
  16027. /// </summary>
  16028. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16029. /// <param name="source">Source sequence to produce windows over.</param>
  16030. /// <param name="timeSpan">Maximum time length of a window.</param>
  16031. /// <param name="count">Maximum element count of a window.</param>
  16032. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16033. /// <returns>An observable sequence of windows.</returns>
  16034. /// <exception cref="ArgumentNullException">
  16035. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16036. /// <exception cref="ArgumentOutOfRangeException">
  16037. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  16038. /// <remarks>
  16039. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows as fast as it can.
  16040. /// Because all source sequence elements end up in one of the windows, some windows won't have a zero time span. This is a side-effect of the asynchrony introduced
  16041. /// by the scheduler, where the action to close the current window and to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16042. /// </remarks>
  16043. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  16044. {
  16045. if (source == null)
  16046. throw new ArgumentNullException(nameof(source));
  16047. if (scheduler == null)
  16048. throw new ArgumentNullException(nameof(scheduler));
  16049. return source.Provider.CreateQuery<IObservable<TSource>>(
  16050. Expression.Call(
  16051. null,
  16052. #if CRIPPLED_REFLECTION
  16053. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  16054. #else
  16055. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16056. #endif
  16057. source.Expression,
  16058. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16059. Expression.Constant(count, typeof(int)),
  16060. Expression.Constant(scheduler, typeof(IScheduler))
  16061. )
  16062. );
  16063. }
  16064. /// <summary>
  16065. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information, using the specified scheduler to run timers.
  16066. /// </summary>
  16067. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16068. /// <param name="source">Source sequence to produce windows over.</param>
  16069. /// <param name="timeSpan">Length of each window.</param>
  16070. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16071. /// <returns>An observable sequence of windows.</returns>
  16072. /// <exception cref="ArgumentNullException">
  16073. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16074. /// <exception cref="ArgumentOutOfRangeException">
  16075. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16076. /// <remarks>
  16077. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows as fast as it can.
  16078. /// Because all source sequence elements end up in one of the windows, some windows won't have a zero time span. This is a side-effect of the asynchrony introduced
  16079. /// by the scheduler, where the action to close the current window and to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16080. /// </remarks>
  16081. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  16082. {
  16083. if (source == null)
  16084. throw new ArgumentNullException(nameof(source));
  16085. if (scheduler == null)
  16086. throw new ArgumentNullException(nameof(scheduler));
  16087. return source.Provider.CreateQuery<IObservable<TSource>>(
  16088. Expression.Call(
  16089. null,
  16090. #if CRIPPLED_REFLECTION
  16091. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  16092. #else
  16093. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16094. #endif
  16095. source.Expression,
  16096. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16097. Expression.Constant(scheduler, typeof(IScheduler))
  16098. )
  16099. );
  16100. }
  16101. /// <summary>
  16102. /// Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  16103. /// </summary>
  16104. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16105. /// <param name="source">Source sequence to produce windows over.</param>
  16106. /// <param name="timeSpan">Length of each window.</param>
  16107. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  16108. /// <returns>An observable sequence of windows.</returns>
  16109. /// <exception cref="ArgumentNullException">
  16110. /// <paramref name="source" /> is null.</exception>
  16111. /// <exception cref="ArgumentOutOfRangeException">
  16112. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16113. /// <remarks>
  16114. /// <para>
  16115. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  16116. /// length. However, some windows won't have a zero time span. This is a side-effect of the asynchrony introduced by the scheduler, where the action to close the
  16117. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  16118. /// </para>
  16119. /// <para>
  16120. /// Specifying a TimeSpan.Zero value for <paramref name="timeShift" /> is not recommended but supported, causing the scheduler to create windows as fast as it can.
  16121. /// However, this doesn't mean all windows will start at the beginning of the source sequence. This is a side-effect of the asynchrony introduced by the scheduler,
  16122. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16123. /// </para>
  16124. /// </remarks>
  16125. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  16126. {
  16127. if (source == null)
  16128. throw new ArgumentNullException(nameof(source));
  16129. return source.Provider.CreateQuery<IObservable<TSource>>(
  16130. Expression.Call(
  16131. null,
  16132. #if CRIPPLED_REFLECTION
  16133. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  16134. #else
  16135. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16136. #endif
  16137. source.Expression,
  16138. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16139. Expression.Constant(timeShift, typeof(TimeSpan))
  16140. )
  16141. );
  16142. }
  16143. /// <summary>
  16144. /// Projects each element of an observable sequence into zero or more windows which are produced based on timing information, using the specified scheduler to run timers.
  16145. /// </summary>
  16146. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16147. /// <param name="source">Source sequence to produce windows over.</param>
  16148. /// <param name="timeSpan">Length of each window.</param>
  16149. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  16150. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16151. /// <returns>An observable sequence of windows.</returns>
  16152. /// <exception cref="ArgumentNullException">
  16153. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16154. /// <exception cref="ArgumentOutOfRangeException">
  16155. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16156. /// <remarks>
  16157. /// <para>
  16158. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  16159. /// length. However, some windows won't have a zero time span. This is a side-effect of the asynchrony introduced by the scheduler, where the action to close the
  16160. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  16161. /// </para>
  16162. /// <para>
  16163. /// Specifying a TimeSpan.Zero value for <paramref name="timeShift" /> is not recommended but supported, causing the scheduler to create windows as fast as it can.
  16164. /// However, this doesn't mean all windows will start at the beginning of the source sequence. This is a side-effect of the asynchrony introduced by the scheduler,
  16165. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16166. /// </para>
  16167. /// </remarks>
  16168. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  16169. {
  16170. if (source == null)
  16171. throw new ArgumentNullException(nameof(source));
  16172. if (scheduler == null)
  16173. throw new ArgumentNullException(nameof(scheduler));
  16174. return source.Provider.CreateQuery<IObservable<TSource>>(
  16175. Expression.Call(
  16176. null,
  16177. #if CRIPPLED_REFLECTION
  16178. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  16179. #else
  16180. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16181. #endif
  16182. source.Expression,
  16183. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16184. Expression.Constant(timeShift, typeof(TimeSpan)),
  16185. Expression.Constant(scheduler, typeof(IScheduler))
  16186. )
  16187. );
  16188. }
  16189. /// <summary>
  16190. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16191. /// </summary>
  16192. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16193. /// <typeparam name="TWindowBoundary">The type of the elements in the sequences indicating window boundary events.</typeparam>
  16194. /// <param name="source">Source sequence to produce windows over.</param>
  16195. /// <param name="windowBoundaries">Sequence of window boundary markers. The current window is closed and a new window is opened upon receiving a boundary marker.</param>
  16196. /// <returns>An observable sequence of windows.</returns>
  16197. /// <exception cref="ArgumentNullException">
  16198. /// <paramref name="source" /> or <paramref name="windowBoundaries" /> is null.</exception>
  16199. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowBoundary>(this IQbservable<TSource> source, IObservable<TWindowBoundary> windowBoundaries)
  16200. {
  16201. if (source == null)
  16202. throw new ArgumentNullException(nameof(source));
  16203. if (windowBoundaries == null)
  16204. throw new ArgumentNullException(nameof(windowBoundaries));
  16205. return source.Provider.CreateQuery<IObservable<TSource>>(
  16206. Expression.Call(
  16207. null,
  16208. #if CRIPPLED_REFLECTION
  16209. InfoOf(() => Qbservable.Window<TSource, TWindowBoundary>(default(IQbservable<TSource>), default(IObservable<TWindowBoundary>))),
  16210. #else
  16211. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowBoundary)),
  16212. #endif
  16213. source.Expression,
  16214. GetSourceExpression(windowBoundaries)
  16215. )
  16216. );
  16217. }
  16218. /// <summary>
  16219. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16220. /// </summary>
  16221. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16222. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16223. /// <param name="source">Source sequence to produce windows over.</param>
  16224. /// <param name="windowClosingSelector">A function invoked to define the boundaries of the produced windows. A new window is started when the previous one is closed.</param>
  16225. /// <returns>An observable sequence of windows.</returns>
  16226. /// <exception cref="ArgumentNullException">
  16227. /// <paramref name="source" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16228. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TWindowClosing>>> windowClosingSelector)
  16229. {
  16230. if (source == null)
  16231. throw new ArgumentNullException(nameof(source));
  16232. if (windowClosingSelector == null)
  16233. throw new ArgumentNullException(nameof(windowClosingSelector));
  16234. return source.Provider.CreateQuery<IObservable<TSource>>(
  16235. Expression.Call(
  16236. null,
  16237. #if CRIPPLED_REFLECTION
  16238. InfoOf(() => Qbservable.Window<TSource, TWindowClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TWindowClosing>>>))),
  16239. #else
  16240. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowClosing)),
  16241. #endif
  16242. source.Expression,
  16243. windowClosingSelector
  16244. )
  16245. );
  16246. }
  16247. /// <summary>
  16248. /// Projects each element of an observable sequence into zero or more windows.
  16249. /// </summary>
  16250. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16251. /// <typeparam name="TWindowOpening">The type of the elements in the sequence indicating window opening events, also passed to the closing selector to obtain a sequence of window closing events.</typeparam>
  16252. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16253. /// <param name="source">Source sequence to produce windows over.</param>
  16254. /// <param name="windowOpenings">Observable sequence whose elements denote the creation of new windows.</param>
  16255. /// <param name="windowClosingSelector">A function invoked to define the closing of each produced window.</param>
  16256. /// <returns>An observable sequence of windows.</returns>
  16257. /// <exception cref="ArgumentNullException">
  16258. /// <paramref name="source" /> or <paramref name="windowOpenings" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16259. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowOpening, TWindowClosing>(this IQbservable<TSource> source, IObservable<TWindowOpening> windowOpenings, Expression<Func<TWindowOpening, IObservable<TWindowClosing>>> windowClosingSelector)
  16260. {
  16261. if (source == null)
  16262. throw new ArgumentNullException(nameof(source));
  16263. if (windowOpenings == null)
  16264. throw new ArgumentNullException(nameof(windowOpenings));
  16265. if (windowClosingSelector == null)
  16266. throw new ArgumentNullException(nameof(windowClosingSelector));
  16267. return source.Provider.CreateQuery<IObservable<TSource>>(
  16268. Expression.Call(
  16269. null,
  16270. #if CRIPPLED_REFLECTION
  16271. InfoOf(() => Qbservable.Window<TSource, TWindowOpening, TWindowClosing>(default(IQbservable<TSource>), default(IObservable<TWindowOpening>), default(Expression<Func<TWindowOpening, IObservable<TWindowClosing>>>))),
  16272. #else
  16273. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowOpening), typeof(TWindowClosing)),
  16274. #endif
  16275. source.Expression,
  16276. GetSourceExpression(windowOpenings),
  16277. windowClosingSelector
  16278. )
  16279. );
  16280. }
  16281. /// <summary>
  16282. /// Merges two observable sequences into one observable sequence by combining each element from the first source with the latest element from the second source, if any.
  16283. /// Starting from Rx.NET 4.0, this will subscribe to <paramref name="second" /> before subscribing to <paramref name="first" /> to have a latest element readily available
  16284. /// in case <paramref name="first" /> emits an element right away.
  16285. /// </summary>
  16286. /// <typeparam name="TFirst">The type of the elements in the first source sequence.</typeparam>
  16287. /// <typeparam name="TSecond">The type of the elements in the second source sequence.</typeparam>
  16288. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16289. /// <param name="first">First observable source.</param>
  16290. /// <param name="second">Second observable source.</param>
  16291. /// <param name="resultSelector">Function to invoke for each element from the first source combined with the latest element from the second source, if any.</param>
  16292. /// <returns>An observable sequence containing the result of combining each element of the first source with the latest element from the second source, if any, using the specified result selector function.</returns>
  16293. /// <exception cref="ArgumentNullException">
  16294. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16295. public static IQbservable<TResult> WithLatestFrom<TFirst, TSecond, TResult>(this IQbservable<TFirst> first, IObservable<TSecond> second, Expression<Func<TFirst, TSecond, TResult>> resultSelector)
  16296. {
  16297. if (first == null)
  16298. throw new ArgumentNullException(nameof(first));
  16299. if (second == null)
  16300. throw new ArgumentNullException(nameof(second));
  16301. if (resultSelector == null)
  16302. throw new ArgumentNullException(nameof(resultSelector));
  16303. return first.Provider.CreateQuery<TResult>(
  16304. Expression.Call(
  16305. null,
  16306. #if CRIPPLED_REFLECTION
  16307. InfoOf(() => Qbservable.WithLatestFrom<TFirst, TSecond, TResult>(default(IQbservable<TFirst>), default(IObservable<TSecond>), default(Expression<Func<TFirst, TSecond, TResult>>))),
  16308. #else
  16309. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)),
  16310. #endif
  16311. first.Expression,
  16312. GetSourceExpression(second),
  16313. resultSelector
  16314. )
  16315. );
  16316. }
  16317. /// <summary>
  16318. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16319. /// </summary>
  16320. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16321. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16322. /// <param name="sources">Observable sources.</param>
  16323. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16324. /// <exception cref="ArgumentNullException">
  16325. /// <paramref name="sources" /> is null.</exception>
  16326. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  16327. {
  16328. if (provider == null)
  16329. throw new ArgumentNullException(nameof(provider));
  16330. if (sources == null)
  16331. throw new ArgumentNullException(nameof(sources));
  16332. return provider.CreateQuery<IList<TSource>>(
  16333. Expression.Call(
  16334. null,
  16335. #if CRIPPLED_REFLECTION
  16336. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  16337. #else
  16338. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16339. #endif
  16340. Expression.Constant(provider, typeof(IQbservableProvider)),
  16341. GetSourceExpression(sources)
  16342. )
  16343. );
  16344. }
  16345. /// <summary>
  16346. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16347. /// </summary>
  16348. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16349. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16350. /// <param name="sources">Observable sources.</param>
  16351. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16352. /// <exception cref="ArgumentNullException">
  16353. /// <paramref name="sources" /> is null.</exception>
  16354. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  16355. {
  16356. if (provider == null)
  16357. throw new ArgumentNullException(nameof(provider));
  16358. if (sources == null)
  16359. throw new ArgumentNullException(nameof(sources));
  16360. return provider.CreateQuery<IList<TSource>>(
  16361. Expression.Call(
  16362. null,
  16363. #if CRIPPLED_REFLECTION
  16364. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  16365. #else
  16366. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16367. #endif
  16368. Expression.Constant(provider, typeof(IQbservableProvider)),
  16369. GetSourceExpression(sources)
  16370. )
  16371. );
  16372. }
  16373. /// <summary>
  16374. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16375. /// </summary>
  16376. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16377. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  16378. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16379. /// <param name="sources">Observable sources.</param>
  16380. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16381. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16382. /// <exception cref="ArgumentNullException">
  16383. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  16384. public static IQbservable<TResult> Zip<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  16385. {
  16386. if (provider == null)
  16387. throw new ArgumentNullException(nameof(provider));
  16388. if (sources == null)
  16389. throw new ArgumentNullException(nameof(sources));
  16390. if (resultSelector == null)
  16391. throw new ArgumentNullException(nameof(resultSelector));
  16392. return provider.CreateQuery<TResult>(
  16393. Expression.Call(
  16394. null,
  16395. #if CRIPPLED_REFLECTION
  16396. InfoOf(() => Qbservable.Zip<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  16397. #else
  16398. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  16399. #endif
  16400. Expression.Constant(provider, typeof(IQbservableProvider)),
  16401. GetSourceExpression(sources),
  16402. resultSelector
  16403. )
  16404. );
  16405. }
  16406. /// <summary>
  16407. /// Merges two observable sequences into one observable sequence by combining their elements in a pairwise fashion.
  16408. /// </summary>
  16409. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16410. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16411. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16412. /// <param name="first">First observable source.</param>
  16413. /// <param name="second">Second observable source.</param>
  16414. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16415. /// <returns>An observable sequence containing the result of pairwise combining the elements of the first and second source using the specified result selector function.</returns>
  16416. /// <exception cref="ArgumentNullException">
  16417. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16418. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16419. {
  16420. if (first == null)
  16421. throw new ArgumentNullException(nameof(first));
  16422. if (second == null)
  16423. throw new ArgumentNullException(nameof(second));
  16424. if (resultSelector == null)
  16425. throw new ArgumentNullException(nameof(resultSelector));
  16426. return first.Provider.CreateQuery<TResult>(
  16427. Expression.Call(
  16428. null,
  16429. #if CRIPPLED_REFLECTION
  16430. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16431. #else
  16432. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16433. #endif
  16434. first.Expression,
  16435. GetSourceExpression(second),
  16436. resultSelector
  16437. )
  16438. );
  16439. }
  16440. /// <summary>
  16441. /// Merges an observable sequence and an enumerable sequence into one observable sequence by using the selector function.
  16442. /// </summary>
  16443. /// <typeparam name="TSource1">The type of the elements in the first observable source sequence.</typeparam>
  16444. /// <typeparam name="TSource2">The type of the elements in the second enumerable source sequence.</typeparam>
  16445. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16446. /// <param name="first">First observable source.</param>
  16447. /// <param name="second">Second enumerable source.</param>
  16448. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16449. /// <returns>An observable sequence containing the result of pairwise combining the elements of the first and second source using the specified result selector function.</returns>
  16450. /// <exception cref="ArgumentNullException">
  16451. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16452. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IEnumerable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16453. {
  16454. if (first == null)
  16455. throw new ArgumentNullException(nameof(first));
  16456. if (second == null)
  16457. throw new ArgumentNullException(nameof(second));
  16458. if (resultSelector == null)
  16459. throw new ArgumentNullException(nameof(resultSelector));
  16460. return first.Provider.CreateQuery<TResult>(
  16461. Expression.Call(
  16462. null,
  16463. #if CRIPPLED_REFLECTION
  16464. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IEnumerable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16465. #else
  16466. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16467. #endif
  16468. first.Expression,
  16469. GetSourceExpression(second),
  16470. resultSelector
  16471. )
  16472. );
  16473. }
  16474. /// <summary>
  16475. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16476. /// </summary>
  16477. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16478. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16479. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16480. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16481. /// <param name="source1">First observable source.</param>
  16482. /// <param name="source2">Second observable source.</param>
  16483. /// <param name="source3">Third observable source.</param>
  16484. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16485. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16486. /// <exception cref="ArgumentNullException">
  16487. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  16488. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, Expression<Func<TSource1, TSource2, TSource3, TResult>> resultSelector)
  16489. {
  16490. if (source1 == null)
  16491. throw new ArgumentNullException(nameof(source1));
  16492. if (source2 == null)
  16493. throw new ArgumentNullException(nameof(source2));
  16494. if (source3 == null)
  16495. throw new ArgumentNullException(nameof(source3));
  16496. if (resultSelector == null)
  16497. throw new ArgumentNullException(nameof(resultSelector));
  16498. return source1.Provider.CreateQuery<TResult>(
  16499. Expression.Call(
  16500. null,
  16501. #if CRIPPLED_REFLECTION
  16502. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  16503. #else
  16504. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  16505. #endif
  16506. source1.Expression,
  16507. GetSourceExpression(source2),
  16508. GetSourceExpression(source3),
  16509. resultSelector
  16510. )
  16511. );
  16512. }
  16513. /// <summary>
  16514. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16515. /// </summary>
  16516. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16517. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16518. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16519. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16520. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16521. /// <param name="source1">First observable source.</param>
  16522. /// <param name="source2">Second observable source.</param>
  16523. /// <param name="source3">Third observable source.</param>
  16524. /// <param name="source4">Fourth observable source.</param>
  16525. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16526. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16527. /// <exception cref="ArgumentNullException">
  16528. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  16529. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, Expression<Func<TSource1, TSource2, TSource3, TSource4, TResult>> resultSelector)
  16530. {
  16531. if (source1 == null)
  16532. throw new ArgumentNullException(nameof(source1));
  16533. if (source2 == null)
  16534. throw new ArgumentNullException(nameof(source2));
  16535. if (source3 == null)
  16536. throw new ArgumentNullException(nameof(source3));
  16537. if (source4 == null)
  16538. throw new ArgumentNullException(nameof(source4));
  16539. if (resultSelector == null)
  16540. throw new ArgumentNullException(nameof(resultSelector));
  16541. return source1.Provider.CreateQuery<TResult>(
  16542. Expression.Call(
  16543. null,
  16544. #if CRIPPLED_REFLECTION
  16545. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TResult>>))),
  16546. #else
  16547. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  16548. #endif
  16549. source1.Expression,
  16550. GetSourceExpression(source2),
  16551. GetSourceExpression(source3),
  16552. GetSourceExpression(source4),
  16553. resultSelector
  16554. )
  16555. );
  16556. }
  16557. /// <summary>
  16558. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16559. /// </summary>
  16560. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16561. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16562. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16563. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16564. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16565. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16566. /// <param name="source1">First observable source.</param>
  16567. /// <param name="source2">Second observable source.</param>
  16568. /// <param name="source3">Third observable source.</param>
  16569. /// <param name="source4">Fourth observable source.</param>
  16570. /// <param name="source5">Fifth observable source.</param>
  16571. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16572. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16573. /// <exception cref="ArgumentNullException">
  16574. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="resultSelector" /> is null.</exception>
  16575. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>> resultSelector)
  16576. {
  16577. if (source1 == null)
  16578. throw new ArgumentNullException(nameof(source1));
  16579. if (source2 == null)
  16580. throw new ArgumentNullException(nameof(source2));
  16581. if (source3 == null)
  16582. throw new ArgumentNullException(nameof(source3));
  16583. if (source4 == null)
  16584. throw new ArgumentNullException(nameof(source4));
  16585. if (source5 == null)
  16586. throw new ArgumentNullException(nameof(source5));
  16587. if (resultSelector == null)
  16588. throw new ArgumentNullException(nameof(resultSelector));
  16589. return source1.Provider.CreateQuery<TResult>(
  16590. Expression.Call(
  16591. null,
  16592. #if CRIPPLED_REFLECTION
  16593. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TResult>>))),
  16594. #else
  16595. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  16596. #endif
  16597. source1.Expression,
  16598. GetSourceExpression(source2),
  16599. GetSourceExpression(source3),
  16600. GetSourceExpression(source4),
  16601. GetSourceExpression(source5),
  16602. resultSelector
  16603. )
  16604. );
  16605. }
  16606. /// <summary>
  16607. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16608. /// </summary>
  16609. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16610. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16611. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16612. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16613. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16614. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16615. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16616. /// <param name="source1">First observable source.</param>
  16617. /// <param name="source2">Second observable source.</param>
  16618. /// <param name="source3">Third observable source.</param>
  16619. /// <param name="source4">Fourth observable source.</param>
  16620. /// <param name="source5">Fifth observable source.</param>
  16621. /// <param name="source6">Sixth observable source.</param>
  16622. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16623. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16624. /// <exception cref="ArgumentNullException">
  16625. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="resultSelector" /> is null.</exception>
  16626. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>> resultSelector)
  16627. {
  16628. if (source1 == null)
  16629. throw new ArgumentNullException(nameof(source1));
  16630. if (source2 == null)
  16631. throw new ArgumentNullException(nameof(source2));
  16632. if (source3 == null)
  16633. throw new ArgumentNullException(nameof(source3));
  16634. if (source4 == null)
  16635. throw new ArgumentNullException(nameof(source4));
  16636. if (source5 == null)
  16637. throw new ArgumentNullException(nameof(source5));
  16638. if (source6 == null)
  16639. throw new ArgumentNullException(nameof(source6));
  16640. if (resultSelector == null)
  16641. throw new ArgumentNullException(nameof(resultSelector));
  16642. return source1.Provider.CreateQuery<TResult>(
  16643. Expression.Call(
  16644. null,
  16645. #if CRIPPLED_REFLECTION
  16646. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TResult>>))),
  16647. #else
  16648. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  16649. #endif
  16650. source1.Expression,
  16651. GetSourceExpression(source2),
  16652. GetSourceExpression(source3),
  16653. GetSourceExpression(source4),
  16654. GetSourceExpression(source5),
  16655. GetSourceExpression(source6),
  16656. resultSelector
  16657. )
  16658. );
  16659. }
  16660. /// <summary>
  16661. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16662. /// </summary>
  16663. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16664. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16665. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16666. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16667. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16668. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16669. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16670. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16671. /// <param name="source1">First observable source.</param>
  16672. /// <param name="source2">Second observable source.</param>
  16673. /// <param name="source3">Third observable source.</param>
  16674. /// <param name="source4">Fourth observable source.</param>
  16675. /// <param name="source5">Fifth observable source.</param>
  16676. /// <param name="source6">Sixth observable source.</param>
  16677. /// <param name="source7">Seventh observable source.</param>
  16678. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16679. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16680. /// <exception cref="ArgumentNullException">
  16681. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="resultSelector" /> is null.</exception>
  16682. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>> resultSelector)
  16683. {
  16684. if (source1 == null)
  16685. throw new ArgumentNullException(nameof(source1));
  16686. if (source2 == null)
  16687. throw new ArgumentNullException(nameof(source2));
  16688. if (source3 == null)
  16689. throw new ArgumentNullException(nameof(source3));
  16690. if (source4 == null)
  16691. throw new ArgumentNullException(nameof(source4));
  16692. if (source5 == null)
  16693. throw new ArgumentNullException(nameof(source5));
  16694. if (source6 == null)
  16695. throw new ArgumentNullException(nameof(source6));
  16696. if (source7 == null)
  16697. throw new ArgumentNullException(nameof(source7));
  16698. if (resultSelector == null)
  16699. throw new ArgumentNullException(nameof(resultSelector));
  16700. return source1.Provider.CreateQuery<TResult>(
  16701. Expression.Call(
  16702. null,
  16703. #if CRIPPLED_REFLECTION
  16704. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TResult>>))),
  16705. #else
  16706. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  16707. #endif
  16708. source1.Expression,
  16709. GetSourceExpression(source2),
  16710. GetSourceExpression(source3),
  16711. GetSourceExpression(source4),
  16712. GetSourceExpression(source5),
  16713. GetSourceExpression(source6),
  16714. GetSourceExpression(source7),
  16715. resultSelector
  16716. )
  16717. );
  16718. }
  16719. /// <summary>
  16720. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16721. /// </summary>
  16722. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16723. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16724. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16725. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16726. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16727. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16728. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16729. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16730. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16731. /// <param name="source1">First observable source.</param>
  16732. /// <param name="source2">Second observable source.</param>
  16733. /// <param name="source3">Third observable source.</param>
  16734. /// <param name="source4">Fourth observable source.</param>
  16735. /// <param name="source5">Fifth observable source.</param>
  16736. /// <param name="source6">Sixth observable source.</param>
  16737. /// <param name="source7">Seventh observable source.</param>
  16738. /// <param name="source8">Eighth observable source.</param>
  16739. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16740. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16741. /// <exception cref="ArgumentNullException">
  16742. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="resultSelector" /> is null.</exception>
  16743. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>> resultSelector)
  16744. {
  16745. if (source1 == null)
  16746. throw new ArgumentNullException(nameof(source1));
  16747. if (source2 == null)
  16748. throw new ArgumentNullException(nameof(source2));
  16749. if (source3 == null)
  16750. throw new ArgumentNullException(nameof(source3));
  16751. if (source4 == null)
  16752. throw new ArgumentNullException(nameof(source4));
  16753. if (source5 == null)
  16754. throw new ArgumentNullException(nameof(source5));
  16755. if (source6 == null)
  16756. throw new ArgumentNullException(nameof(source6));
  16757. if (source7 == null)
  16758. throw new ArgumentNullException(nameof(source7));
  16759. if (source8 == null)
  16760. throw new ArgumentNullException(nameof(source8));
  16761. if (resultSelector == null)
  16762. throw new ArgumentNullException(nameof(resultSelector));
  16763. return source1.Provider.CreateQuery<TResult>(
  16764. Expression.Call(
  16765. null,
  16766. #if CRIPPLED_REFLECTION
  16767. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TResult>>))),
  16768. #else
  16769. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  16770. #endif
  16771. source1.Expression,
  16772. GetSourceExpression(source2),
  16773. GetSourceExpression(source3),
  16774. GetSourceExpression(source4),
  16775. GetSourceExpression(source5),
  16776. GetSourceExpression(source6),
  16777. GetSourceExpression(source7),
  16778. GetSourceExpression(source8),
  16779. resultSelector
  16780. )
  16781. );
  16782. }
  16783. /// <summary>
  16784. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16785. /// </summary>
  16786. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16787. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16788. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16789. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16790. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16791. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16792. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16793. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16794. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16795. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16796. /// <param name="source1">First observable source.</param>
  16797. /// <param name="source2">Second observable source.</param>
  16798. /// <param name="source3">Third observable source.</param>
  16799. /// <param name="source4">Fourth observable source.</param>
  16800. /// <param name="source5">Fifth observable source.</param>
  16801. /// <param name="source6">Sixth observable source.</param>
  16802. /// <param name="source7">Seventh observable source.</param>
  16803. /// <param name="source8">Eighth observable source.</param>
  16804. /// <param name="source9">Ninth observable source.</param>
  16805. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16806. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16807. /// <exception cref="ArgumentNullException">
  16808. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="resultSelector" /> is null.</exception>
  16809. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>> resultSelector)
  16810. {
  16811. if (source1 == null)
  16812. throw new ArgumentNullException(nameof(source1));
  16813. if (source2 == null)
  16814. throw new ArgumentNullException(nameof(source2));
  16815. if (source3 == null)
  16816. throw new ArgumentNullException(nameof(source3));
  16817. if (source4 == null)
  16818. throw new ArgumentNullException(nameof(source4));
  16819. if (source5 == null)
  16820. throw new ArgumentNullException(nameof(source5));
  16821. if (source6 == null)
  16822. throw new ArgumentNullException(nameof(source6));
  16823. if (source7 == null)
  16824. throw new ArgumentNullException(nameof(source7));
  16825. if (source8 == null)
  16826. throw new ArgumentNullException(nameof(source8));
  16827. if (source9 == null)
  16828. throw new ArgumentNullException(nameof(source9));
  16829. if (resultSelector == null)
  16830. throw new ArgumentNullException(nameof(resultSelector));
  16831. return source1.Provider.CreateQuery<TResult>(
  16832. Expression.Call(
  16833. null,
  16834. #if CRIPPLED_REFLECTION
  16835. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TResult>>))),
  16836. #else
  16837. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  16838. #endif
  16839. source1.Expression,
  16840. GetSourceExpression(source2),
  16841. GetSourceExpression(source3),
  16842. GetSourceExpression(source4),
  16843. GetSourceExpression(source5),
  16844. GetSourceExpression(source6),
  16845. GetSourceExpression(source7),
  16846. GetSourceExpression(source8),
  16847. GetSourceExpression(source9),
  16848. resultSelector
  16849. )
  16850. );
  16851. }
  16852. /// <summary>
  16853. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16854. /// </summary>
  16855. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16856. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16857. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16858. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16859. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16860. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16861. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16862. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16863. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16864. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16865. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16866. /// <param name="source1">First observable source.</param>
  16867. /// <param name="source2">Second observable source.</param>
  16868. /// <param name="source3">Third observable source.</param>
  16869. /// <param name="source4">Fourth observable source.</param>
  16870. /// <param name="source5">Fifth observable source.</param>
  16871. /// <param name="source6">Sixth observable source.</param>
  16872. /// <param name="source7">Seventh observable source.</param>
  16873. /// <param name="source8">Eighth observable source.</param>
  16874. /// <param name="source9">Ninth observable source.</param>
  16875. /// <param name="source10">Tenth observable source.</param>
  16876. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16877. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16878. /// <exception cref="ArgumentNullException">
  16879. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="resultSelector" /> is null.</exception>
  16880. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>> resultSelector)
  16881. {
  16882. if (source1 == null)
  16883. throw new ArgumentNullException(nameof(source1));
  16884. if (source2 == null)
  16885. throw new ArgumentNullException(nameof(source2));
  16886. if (source3 == null)
  16887. throw new ArgumentNullException(nameof(source3));
  16888. if (source4 == null)
  16889. throw new ArgumentNullException(nameof(source4));
  16890. if (source5 == null)
  16891. throw new ArgumentNullException(nameof(source5));
  16892. if (source6 == null)
  16893. throw new ArgumentNullException(nameof(source6));
  16894. if (source7 == null)
  16895. throw new ArgumentNullException(nameof(source7));
  16896. if (source8 == null)
  16897. throw new ArgumentNullException(nameof(source8));
  16898. if (source9 == null)
  16899. throw new ArgumentNullException(nameof(source9));
  16900. if (source10 == null)
  16901. throw new ArgumentNullException(nameof(source10));
  16902. if (resultSelector == null)
  16903. throw new ArgumentNullException(nameof(resultSelector));
  16904. return source1.Provider.CreateQuery<TResult>(
  16905. Expression.Call(
  16906. null,
  16907. #if CRIPPLED_REFLECTION
  16908. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TResult>>))),
  16909. #else
  16910. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TResult)),
  16911. #endif
  16912. source1.Expression,
  16913. GetSourceExpression(source2),
  16914. GetSourceExpression(source3),
  16915. GetSourceExpression(source4),
  16916. GetSourceExpression(source5),
  16917. GetSourceExpression(source6),
  16918. GetSourceExpression(source7),
  16919. GetSourceExpression(source8),
  16920. GetSourceExpression(source9),
  16921. GetSourceExpression(source10),
  16922. resultSelector
  16923. )
  16924. );
  16925. }
  16926. /// <summary>
  16927. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16928. /// </summary>
  16929. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16930. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16931. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16932. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16933. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16934. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16935. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16936. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16937. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16938. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16939. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16940. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16941. /// <param name="source1">First observable source.</param>
  16942. /// <param name="source2">Second observable source.</param>
  16943. /// <param name="source3">Third observable source.</param>
  16944. /// <param name="source4">Fourth observable source.</param>
  16945. /// <param name="source5">Fifth observable source.</param>
  16946. /// <param name="source6">Sixth observable source.</param>
  16947. /// <param name="source7">Seventh observable source.</param>
  16948. /// <param name="source8">Eighth observable source.</param>
  16949. /// <param name="source9">Ninth observable source.</param>
  16950. /// <param name="source10">Tenth observable source.</param>
  16951. /// <param name="source11">Eleventh observable source.</param>
  16952. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16953. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16954. /// <exception cref="ArgumentNullException">
  16955. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="resultSelector" /> is null.</exception>
  16956. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>> resultSelector)
  16957. {
  16958. if (source1 == null)
  16959. throw new ArgumentNullException(nameof(source1));
  16960. if (source2 == null)
  16961. throw new ArgumentNullException(nameof(source2));
  16962. if (source3 == null)
  16963. throw new ArgumentNullException(nameof(source3));
  16964. if (source4 == null)
  16965. throw new ArgumentNullException(nameof(source4));
  16966. if (source5 == null)
  16967. throw new ArgumentNullException(nameof(source5));
  16968. if (source6 == null)
  16969. throw new ArgumentNullException(nameof(source6));
  16970. if (source7 == null)
  16971. throw new ArgumentNullException(nameof(source7));
  16972. if (source8 == null)
  16973. throw new ArgumentNullException(nameof(source8));
  16974. if (source9 == null)
  16975. throw new ArgumentNullException(nameof(source9));
  16976. if (source10 == null)
  16977. throw new ArgumentNullException(nameof(source10));
  16978. if (source11 == null)
  16979. throw new ArgumentNullException(nameof(source11));
  16980. if (resultSelector == null)
  16981. throw new ArgumentNullException(nameof(resultSelector));
  16982. return source1.Provider.CreateQuery<TResult>(
  16983. Expression.Call(
  16984. null,
  16985. #if CRIPPLED_REFLECTION
  16986. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TResult>>))),
  16987. #else
  16988. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TResult)),
  16989. #endif
  16990. source1.Expression,
  16991. GetSourceExpression(source2),
  16992. GetSourceExpression(source3),
  16993. GetSourceExpression(source4),
  16994. GetSourceExpression(source5),
  16995. GetSourceExpression(source6),
  16996. GetSourceExpression(source7),
  16997. GetSourceExpression(source8),
  16998. GetSourceExpression(source9),
  16999. GetSourceExpression(source10),
  17000. GetSourceExpression(source11),
  17001. resultSelector
  17002. )
  17003. );
  17004. }
  17005. /// <summary>
  17006. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  17007. /// </summary>
  17008. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17009. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17010. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17011. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17012. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17013. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17014. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17015. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17016. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17017. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17018. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17019. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17020. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17021. /// <param name="source1">First observable source.</param>
  17022. /// <param name="source2">Second observable source.</param>
  17023. /// <param name="source3">Third observable source.</param>
  17024. /// <param name="source4">Fourth observable source.</param>
  17025. /// <param name="source5">Fifth observable source.</param>
  17026. /// <param name="source6">Sixth observable source.</param>
  17027. /// <param name="source7">Seventh observable source.</param>
  17028. /// <param name="source8">Eighth observable source.</param>
  17029. /// <param name="source9">Ninth observable source.</param>
  17030. /// <param name="source10">Tenth observable source.</param>
  17031. /// <param name="source11">Eleventh observable source.</param>
  17032. /// <param name="source12">Twelfth observable source.</param>
  17033. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17034. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17035. /// <exception cref="ArgumentNullException">
  17036. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="resultSelector" /> is null.</exception>
  17037. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>> resultSelector)
  17038. {
  17039. if (source1 == null)
  17040. throw new ArgumentNullException(nameof(source1));
  17041. if (source2 == null)
  17042. throw new ArgumentNullException(nameof(source2));
  17043. if (source3 == null)
  17044. throw new ArgumentNullException(nameof(source3));
  17045. if (source4 == null)
  17046. throw new ArgumentNullException(nameof(source4));
  17047. if (source5 == null)
  17048. throw new ArgumentNullException(nameof(source5));
  17049. if (source6 == null)
  17050. throw new ArgumentNullException(nameof(source6));
  17051. if (source7 == null)
  17052. throw new ArgumentNullException(nameof(source7));
  17053. if (source8 == null)
  17054. throw new ArgumentNullException(nameof(source8));
  17055. if (source9 == null)
  17056. throw new ArgumentNullException(nameof(source9));
  17057. if (source10 == null)
  17058. throw new ArgumentNullException(nameof(source10));
  17059. if (source11 == null)
  17060. throw new ArgumentNullException(nameof(source11));
  17061. if (source12 == null)
  17062. throw new ArgumentNullException(nameof(source12));
  17063. if (resultSelector == null)
  17064. throw new ArgumentNullException(nameof(resultSelector));
  17065. return source1.Provider.CreateQuery<TResult>(
  17066. Expression.Call(
  17067. null,
  17068. #if CRIPPLED_REFLECTION
  17069. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TResult>>))),
  17070. #else
  17071. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TResult)),
  17072. #endif
  17073. source1.Expression,
  17074. GetSourceExpression(source2),
  17075. GetSourceExpression(source3),
  17076. GetSourceExpression(source4),
  17077. GetSourceExpression(source5),
  17078. GetSourceExpression(source6),
  17079. GetSourceExpression(source7),
  17080. GetSourceExpression(source8),
  17081. GetSourceExpression(source9),
  17082. GetSourceExpression(source10),
  17083. GetSourceExpression(source11),
  17084. GetSourceExpression(source12),
  17085. resultSelector
  17086. )
  17087. );
  17088. }
  17089. /// <summary>
  17090. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  17091. /// </summary>
  17092. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17093. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17094. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17095. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17096. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17097. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17098. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17099. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17100. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17101. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17102. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17103. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17104. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17105. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17106. /// <param name="source1">First observable source.</param>
  17107. /// <param name="source2">Second observable source.</param>
  17108. /// <param name="source3">Third observable source.</param>
  17109. /// <param name="source4">Fourth observable source.</param>
  17110. /// <param name="source5">Fifth observable source.</param>
  17111. /// <param name="source6">Sixth observable source.</param>
  17112. /// <param name="source7">Seventh observable source.</param>
  17113. /// <param name="source8">Eighth observable source.</param>
  17114. /// <param name="source9">Ninth observable source.</param>
  17115. /// <param name="source10">Tenth observable source.</param>
  17116. /// <param name="source11">Eleventh observable source.</param>
  17117. /// <param name="source12">Twelfth observable source.</param>
  17118. /// <param name="source13">Thirteenth observable source.</param>
  17119. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17120. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17121. /// <exception cref="ArgumentNullException">
  17122. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="resultSelector" /> is null.</exception>
  17123. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>> resultSelector)
  17124. {
  17125. if (source1 == null)
  17126. throw new ArgumentNullException(nameof(source1));
  17127. if (source2 == null)
  17128. throw new ArgumentNullException(nameof(source2));
  17129. if (source3 == null)
  17130. throw new ArgumentNullException(nameof(source3));
  17131. if (source4 == null)
  17132. throw new ArgumentNullException(nameof(source4));
  17133. if (source5 == null)
  17134. throw new ArgumentNullException(nameof(source5));
  17135. if (source6 == null)
  17136. throw new ArgumentNullException(nameof(source6));
  17137. if (source7 == null)
  17138. throw new ArgumentNullException(nameof(source7));
  17139. if (source8 == null)
  17140. throw new ArgumentNullException(nameof(source8));
  17141. if (source9 == null)
  17142. throw new ArgumentNullException(nameof(source9));
  17143. if (source10 == null)
  17144. throw new ArgumentNullException(nameof(source10));
  17145. if (source11 == null)
  17146. throw new ArgumentNullException(nameof(source11));
  17147. if (source12 == null)
  17148. throw new ArgumentNullException(nameof(source12));
  17149. if (source13 == null)
  17150. throw new ArgumentNullException(nameof(source13));
  17151. if (resultSelector == null)
  17152. throw new ArgumentNullException(nameof(resultSelector));
  17153. return source1.Provider.CreateQuery<TResult>(
  17154. Expression.Call(
  17155. null,
  17156. #if CRIPPLED_REFLECTION
  17157. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TResult>>))),
  17158. #else
  17159. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TResult)),
  17160. #endif
  17161. source1.Expression,
  17162. GetSourceExpression(source2),
  17163. GetSourceExpression(source3),
  17164. GetSourceExpression(source4),
  17165. GetSourceExpression(source5),
  17166. GetSourceExpression(source6),
  17167. GetSourceExpression(source7),
  17168. GetSourceExpression(source8),
  17169. GetSourceExpression(source9),
  17170. GetSourceExpression(source10),
  17171. GetSourceExpression(source11),
  17172. GetSourceExpression(source12),
  17173. GetSourceExpression(source13),
  17174. resultSelector
  17175. )
  17176. );
  17177. }
  17178. /// <summary>
  17179. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  17180. /// </summary>
  17181. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17182. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17183. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17184. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17185. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17186. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17187. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17188. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17189. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17190. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17191. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17192. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17193. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17194. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17195. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17196. /// <param name="source1">First observable source.</param>
  17197. /// <param name="source2">Second observable source.</param>
  17198. /// <param name="source3">Third observable source.</param>
  17199. /// <param name="source4">Fourth observable source.</param>
  17200. /// <param name="source5">Fifth observable source.</param>
  17201. /// <param name="source6">Sixth observable source.</param>
  17202. /// <param name="source7">Seventh observable source.</param>
  17203. /// <param name="source8">Eighth observable source.</param>
  17204. /// <param name="source9">Ninth observable source.</param>
  17205. /// <param name="source10">Tenth observable source.</param>
  17206. /// <param name="source11">Eleventh observable source.</param>
  17207. /// <param name="source12">Twelfth observable source.</param>
  17208. /// <param name="source13">Thirteenth observable source.</param>
  17209. /// <param name="source14">Fourteenth observable source.</param>
  17210. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17211. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17212. /// <exception cref="ArgumentNullException">
  17213. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="source14" /> or <paramref name="resultSelector" /> is null.</exception>
  17214. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, IObservable<TSource14> source14, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>> resultSelector)
  17215. {
  17216. if (source1 == null)
  17217. throw new ArgumentNullException(nameof(source1));
  17218. if (source2 == null)
  17219. throw new ArgumentNullException(nameof(source2));
  17220. if (source3 == null)
  17221. throw new ArgumentNullException(nameof(source3));
  17222. if (source4 == null)
  17223. throw new ArgumentNullException(nameof(source4));
  17224. if (source5 == null)
  17225. throw new ArgumentNullException(nameof(source5));
  17226. if (source6 == null)
  17227. throw new ArgumentNullException(nameof(source6));
  17228. if (source7 == null)
  17229. throw new ArgumentNullException(nameof(source7));
  17230. if (source8 == null)
  17231. throw new ArgumentNullException(nameof(source8));
  17232. if (source9 == null)
  17233. throw new ArgumentNullException(nameof(source9));
  17234. if (source10 == null)
  17235. throw new ArgumentNullException(nameof(source10));
  17236. if (source11 == null)
  17237. throw new ArgumentNullException(nameof(source11));
  17238. if (source12 == null)
  17239. throw new ArgumentNullException(nameof(source12));
  17240. if (source13 == null)
  17241. throw new ArgumentNullException(nameof(source13));
  17242. if (source14 == null)
  17243. throw new ArgumentNullException(nameof(source14));
  17244. if (resultSelector == null)
  17245. throw new ArgumentNullException(nameof(resultSelector));
  17246. return source1.Provider.CreateQuery<TResult>(
  17247. Expression.Call(
  17248. null,
  17249. #if CRIPPLED_REFLECTION
  17250. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(IObservable<TSource14>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TResult>>))),
  17251. #else
  17252. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TSource14), typeof(TResult)),
  17253. #endif
  17254. source1.Expression,
  17255. GetSourceExpression(source2),
  17256. GetSourceExpression(source3),
  17257. GetSourceExpression(source4),
  17258. GetSourceExpression(source5),
  17259. GetSourceExpression(source6),
  17260. GetSourceExpression(source7),
  17261. GetSourceExpression(source8),
  17262. GetSourceExpression(source9),
  17263. GetSourceExpression(source10),
  17264. GetSourceExpression(source11),
  17265. GetSourceExpression(source12),
  17266. GetSourceExpression(source13),
  17267. GetSourceExpression(source14),
  17268. resultSelector
  17269. )
  17270. );
  17271. }
  17272. /// <summary>
  17273. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  17274. /// </summary>
  17275. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17276. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17277. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17278. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17279. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17280. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17281. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17282. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17283. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17284. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17285. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17286. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17287. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17288. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17289. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17290. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17291. /// <param name="source1">First observable source.</param>
  17292. /// <param name="source2">Second observable source.</param>
  17293. /// <param name="source3">Third observable source.</param>
  17294. /// <param name="source4">Fourth observable source.</param>
  17295. /// <param name="source5">Fifth observable source.</param>
  17296. /// <param name="source6">Sixth observable source.</param>
  17297. /// <param name="source7">Seventh observable source.</param>
  17298. /// <param name="source8">Eighth observable source.</param>
  17299. /// <param name="source9">Ninth observable source.</param>
  17300. /// <param name="source10">Tenth observable source.</param>
  17301. /// <param name="source11">Eleventh observable source.</param>
  17302. /// <param name="source12">Twelfth observable source.</param>
  17303. /// <param name="source13">Thirteenth observable source.</param>
  17304. /// <param name="source14">Fourteenth observable source.</param>
  17305. /// <param name="source15">Fifteenth observable source.</param>
  17306. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17307. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17308. /// <exception cref="ArgumentNullException">
  17309. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="source14" /> or <paramref name="source15" /> or <paramref name="resultSelector" /> is null.</exception>
  17310. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, IObservable<TSource14> source14, IObservable<TSource15> source15, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>> resultSelector)
  17311. {
  17312. if (source1 == null)
  17313. throw new ArgumentNullException(nameof(source1));
  17314. if (source2 == null)
  17315. throw new ArgumentNullException(nameof(source2));
  17316. if (source3 == null)
  17317. throw new ArgumentNullException(nameof(source3));
  17318. if (source4 == null)
  17319. throw new ArgumentNullException(nameof(source4));
  17320. if (source5 == null)
  17321. throw new ArgumentNullException(nameof(source5));
  17322. if (source6 == null)
  17323. throw new ArgumentNullException(nameof(source6));
  17324. if (source7 == null)
  17325. throw new ArgumentNullException(nameof(source7));
  17326. if (source8 == null)
  17327. throw new ArgumentNullException(nameof(source8));
  17328. if (source9 == null)
  17329. throw new ArgumentNullException(nameof(source9));
  17330. if (source10 == null)
  17331. throw new ArgumentNullException(nameof(source10));
  17332. if (source11 == null)
  17333. throw new ArgumentNullException(nameof(source11));
  17334. if (source12 == null)
  17335. throw new ArgumentNullException(nameof(source12));
  17336. if (source13 == null)
  17337. throw new ArgumentNullException(nameof(source13));
  17338. if (source14 == null)
  17339. throw new ArgumentNullException(nameof(source14));
  17340. if (source15 == null)
  17341. throw new ArgumentNullException(nameof(source15));
  17342. if (resultSelector == null)
  17343. throw new ArgumentNullException(nameof(resultSelector));
  17344. return source1.Provider.CreateQuery<TResult>(
  17345. Expression.Call(
  17346. null,
  17347. #if CRIPPLED_REFLECTION
  17348. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(IObservable<TSource14>), default(IObservable<TSource15>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TResult>>))),
  17349. #else
  17350. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TSource14), typeof(TSource15), typeof(TResult)),
  17351. #endif
  17352. source1.Expression,
  17353. GetSourceExpression(source2),
  17354. GetSourceExpression(source3),
  17355. GetSourceExpression(source4),
  17356. GetSourceExpression(source5),
  17357. GetSourceExpression(source6),
  17358. GetSourceExpression(source7),
  17359. GetSourceExpression(source8),
  17360. GetSourceExpression(source9),
  17361. GetSourceExpression(source10),
  17362. GetSourceExpression(source11),
  17363. GetSourceExpression(source12),
  17364. GetSourceExpression(source13),
  17365. GetSourceExpression(source14),
  17366. GetSourceExpression(source15),
  17367. resultSelector
  17368. )
  17369. );
  17370. }
  17371. /// <summary>
  17372. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  17373. /// </summary>
  17374. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17375. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17376. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17377. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17378. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17379. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17380. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17381. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17382. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17383. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17384. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17385. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17386. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17387. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17388. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17389. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  17390. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17391. /// <param name="source1">First observable source.</param>
  17392. /// <param name="source2">Second observable source.</param>
  17393. /// <param name="source3">Third observable source.</param>
  17394. /// <param name="source4">Fourth observable source.</param>
  17395. /// <param name="source5">Fifth observable source.</param>
  17396. /// <param name="source6">Sixth observable source.</param>
  17397. /// <param name="source7">Seventh observable source.</param>
  17398. /// <param name="source8">Eighth observable source.</param>
  17399. /// <param name="source9">Ninth observable source.</param>
  17400. /// <param name="source10">Tenth observable source.</param>
  17401. /// <param name="source11">Eleventh observable source.</param>
  17402. /// <param name="source12">Twelfth observable source.</param>
  17403. /// <param name="source13">Thirteenth observable source.</param>
  17404. /// <param name="source14">Fourteenth observable source.</param>
  17405. /// <param name="source15">Fifteenth observable source.</param>
  17406. /// <param name="source16">Sixteenth observable source.</param>
  17407. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17408. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17409. /// <exception cref="ArgumentNullException">
  17410. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="source6" /> or <paramref name="source7" /> or <paramref name="source8" /> or <paramref name="source9" /> or <paramref name="source10" /> or <paramref name="source11" /> or <paramref name="source12" /> or <paramref name="source13" /> or <paramref name="source14" /> or <paramref name="source15" /> or <paramref name="source16" /> or <paramref name="resultSelector" /> is null.</exception>
  17411. public static IQbservable<TResult> Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>(this IQbservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7, IObservable<TSource8> source8, IObservable<TSource9> source9, IObservable<TSource10> source10, IObservable<TSource11> source11, IObservable<TSource12> source12, IObservable<TSource13> source13, IObservable<TSource14> source14, IObservable<TSource15> source15, IObservable<TSource16> source16, Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>> resultSelector)
  17412. {
  17413. if (source1 == null)
  17414. throw new ArgumentNullException(nameof(source1));
  17415. if (source2 == null)
  17416. throw new ArgumentNullException(nameof(source2));
  17417. if (source3 == null)
  17418. throw new ArgumentNullException(nameof(source3));
  17419. if (source4 == null)
  17420. throw new ArgumentNullException(nameof(source4));
  17421. if (source5 == null)
  17422. throw new ArgumentNullException(nameof(source5));
  17423. if (source6 == null)
  17424. throw new ArgumentNullException(nameof(source6));
  17425. if (source7 == null)
  17426. throw new ArgumentNullException(nameof(source7));
  17427. if (source8 == null)
  17428. throw new ArgumentNullException(nameof(source8));
  17429. if (source9 == null)
  17430. throw new ArgumentNullException(nameof(source9));
  17431. if (source10 == null)
  17432. throw new ArgumentNullException(nameof(source10));
  17433. if (source11 == null)
  17434. throw new ArgumentNullException(nameof(source11));
  17435. if (source12 == null)
  17436. throw new ArgumentNullException(nameof(source12));
  17437. if (source13 == null)
  17438. throw new ArgumentNullException(nameof(source13));
  17439. if (source14 == null)
  17440. throw new ArgumentNullException(nameof(source14));
  17441. if (source15 == null)
  17442. throw new ArgumentNullException(nameof(source15));
  17443. if (source16 == null)
  17444. throw new ArgumentNullException(nameof(source16));
  17445. if (resultSelector == null)
  17446. throw new ArgumentNullException(nameof(resultSelector));
  17447. return source1.Provider.CreateQuery<TResult>(
  17448. Expression.Call(
  17449. null,
  17450. #if CRIPPLED_REFLECTION
  17451. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(IObservable<TSource4>), default(IObservable<TSource5>), default(IObservable<TSource6>), default(IObservable<TSource7>), default(IObservable<TSource8>), default(IObservable<TSource9>), default(IObservable<TSource10>), default(IObservable<TSource11>), default(IObservable<TSource12>), default(IObservable<TSource13>), default(IObservable<TSource14>), default(IObservable<TSource15>), default(IObservable<TSource16>), default(Expression<Func<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7, TSource8, TSource9, TSource10, TSource11, TSource12, TSource13, TSource14, TSource15, TSource16, TResult>>))),
  17452. #else
  17453. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TSource10), typeof(TSource11), typeof(TSource12), typeof(TSource13), typeof(TSource14), typeof(TSource15), typeof(TSource16), typeof(TResult)),
  17454. #endif
  17455. source1.Expression,
  17456. GetSourceExpression(source2),
  17457. GetSourceExpression(source3),
  17458. GetSourceExpression(source4),
  17459. GetSourceExpression(source5),
  17460. GetSourceExpression(source6),
  17461. GetSourceExpression(source7),
  17462. GetSourceExpression(source8),
  17463. GetSourceExpression(source9),
  17464. GetSourceExpression(source10),
  17465. GetSourceExpression(source11),
  17466. GetSourceExpression(source12),
  17467. GetSourceExpression(source13),
  17468. GetSourceExpression(source14),
  17469. GetSourceExpression(source15),
  17470. GetSourceExpression(source16),
  17471. resultSelector
  17472. )
  17473. );
  17474. }
  17475. /// <summary>
  17476. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  17477. /// </summary>
  17478. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17479. /// <param name="action">Action to convert to an asynchronous action.</param>
  17480. /// <returns>Asynchronous action.</returns>
  17481. /// <exception cref="ArgumentNullException">
  17482. /// <paramref name="action" /> is null.</exception>
  17483. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action)
  17484. {
  17485. if (provider == null)
  17486. throw new ArgumentNullException(nameof(provider));
  17487. if (action == null)
  17488. throw new ArgumentNullException(nameof(action));
  17489. #if CRIPPLED_REFLECTION
  17490. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>)));
  17491. #else
  17492. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17493. #endif
  17494. return () => provider.CreateQuery<Unit>(
  17495. Expression.Invoke(
  17496. Expression.Call(
  17497. null,
  17498. m,
  17499. Expression.Constant(provider, typeof(IQbservableProvider)),
  17500. action
  17501. )
  17502. )
  17503. );
  17504. }
  17505. /// <summary>
  17506. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  17507. /// </summary>
  17508. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17509. /// <param name="action">Action to convert to an asynchronous action.</param>
  17510. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17511. /// <returns>Asynchronous action.</returns>
  17512. /// <exception cref="ArgumentNullException">
  17513. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17514. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  17515. {
  17516. if (provider == null)
  17517. throw new ArgumentNullException(nameof(provider));
  17518. if (action == null)
  17519. throw new ArgumentNullException(nameof(action));
  17520. if (scheduler == null)
  17521. throw new ArgumentNullException(nameof(scheduler));
  17522. #if CRIPPLED_REFLECTION
  17523. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>), default(IScheduler)));
  17524. #else
  17525. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17526. #endif
  17527. return () => provider.CreateQuery<Unit>(
  17528. Expression.Invoke(
  17529. Expression.Call(
  17530. null,
  17531. m,
  17532. Expression.Constant(provider, typeof(IQbservableProvider)),
  17533. action,
  17534. Expression.Constant(scheduler, typeof(IScheduler))
  17535. )
  17536. )
  17537. );
  17538. }
  17539. /// <summary>
  17540. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  17541. /// </summary>
  17542. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17543. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17544. /// <param name="action">Action to convert to an asynchronous action.</param>
  17545. /// <returns>Asynchronous action.</returns>
  17546. /// <exception cref="ArgumentNullException">
  17547. /// <paramref name="action" /> is null.</exception>
  17548. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action)
  17549. {
  17550. if (provider == null)
  17551. throw new ArgumentNullException(nameof(provider));
  17552. if (action == null)
  17553. throw new ArgumentNullException(nameof(action));
  17554. #if CRIPPLED_REFLECTION
  17555. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>)));
  17556. #else
  17557. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17558. #endif
  17559. return (t1) => provider.CreateQuery<Unit>(
  17560. Expression.Invoke(
  17561. Expression.Call(
  17562. null,
  17563. m,
  17564. Expression.Constant(provider, typeof(IQbservableProvider)),
  17565. action
  17566. ),
  17567. Expression.Constant(t1, typeof(TArg1))
  17568. )
  17569. );
  17570. }
  17571. /// <summary>
  17572. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  17573. /// </summary>
  17574. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17575. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17576. /// <param name="action">Action to convert to an asynchronous action.</param>
  17577. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17578. /// <returns>Asynchronous action.</returns>
  17579. /// <exception cref="ArgumentNullException">
  17580. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17581. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action, IScheduler scheduler)
  17582. {
  17583. if (provider == null)
  17584. throw new ArgumentNullException(nameof(provider));
  17585. if (action == null)
  17586. throw new ArgumentNullException(nameof(action));
  17587. if (scheduler == null)
  17588. throw new ArgumentNullException(nameof(scheduler));
  17589. #if CRIPPLED_REFLECTION
  17590. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>), default(IScheduler)));
  17591. #else
  17592. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17593. #endif
  17594. return (t1) => provider.CreateQuery<Unit>(
  17595. Expression.Invoke(
  17596. Expression.Call(
  17597. null,
  17598. m,
  17599. Expression.Constant(provider, typeof(IQbservableProvider)),
  17600. action,
  17601. Expression.Constant(scheduler, typeof(IScheduler))
  17602. ),
  17603. Expression.Constant(t1, typeof(TArg1))
  17604. )
  17605. );
  17606. }
  17607. /// <summary>
  17608. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  17609. /// </summary>
  17610. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17611. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17612. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17613. /// <param name="action">Action to convert to an asynchronous action.</param>
  17614. /// <returns>Asynchronous action.</returns>
  17615. /// <exception cref="ArgumentNullException">
  17616. /// <paramref name="action" /> is null.</exception>
  17617. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action)
  17618. {
  17619. if (provider == null)
  17620. throw new ArgumentNullException(nameof(provider));
  17621. if (action == null)
  17622. throw new ArgumentNullException(nameof(action));
  17623. #if CRIPPLED_REFLECTION
  17624. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>)));
  17625. #else
  17626. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17627. #endif
  17628. return (t1, t2) => provider.CreateQuery<Unit>(
  17629. Expression.Invoke(
  17630. Expression.Call(
  17631. null,
  17632. m,
  17633. Expression.Constant(provider, typeof(IQbservableProvider)),
  17634. action
  17635. ),
  17636. Expression.Constant(t1, typeof(TArg1)),
  17637. Expression.Constant(t2, typeof(TArg2))
  17638. )
  17639. );
  17640. }
  17641. /// <summary>
  17642. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  17643. /// </summary>
  17644. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17645. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17646. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17647. /// <param name="action">Action to convert to an asynchronous action.</param>
  17648. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17649. /// <returns>Asynchronous action.</returns>
  17650. /// <exception cref="ArgumentNullException">
  17651. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17652. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action, IScheduler scheduler)
  17653. {
  17654. if (provider == null)
  17655. throw new ArgumentNullException(nameof(provider));
  17656. if (action == null)
  17657. throw new ArgumentNullException(nameof(action));
  17658. if (scheduler == null)
  17659. throw new ArgumentNullException(nameof(scheduler));
  17660. #if CRIPPLED_REFLECTION
  17661. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>), default(IScheduler)));
  17662. #else
  17663. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17664. #endif
  17665. return (t1, t2) => provider.CreateQuery<Unit>(
  17666. Expression.Invoke(
  17667. Expression.Call(
  17668. null,
  17669. m,
  17670. Expression.Constant(provider, typeof(IQbservableProvider)),
  17671. action,
  17672. Expression.Constant(scheduler, typeof(IScheduler))
  17673. ),
  17674. Expression.Constant(t1, typeof(TArg1)),
  17675. Expression.Constant(t2, typeof(TArg2))
  17676. )
  17677. );
  17678. }
  17679. /// <summary>
  17680. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  17681. /// </summary>
  17682. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17683. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17684. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17685. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17686. /// <param name="action">Action to convert to an asynchronous action.</param>
  17687. /// <returns>Asynchronous action.</returns>
  17688. /// <exception cref="ArgumentNullException">
  17689. /// <paramref name="action" /> is null.</exception>
  17690. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action)
  17691. {
  17692. if (provider == null)
  17693. throw new ArgumentNullException(nameof(provider));
  17694. if (action == null)
  17695. throw new ArgumentNullException(nameof(action));
  17696. #if CRIPPLED_REFLECTION
  17697. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>)));
  17698. #else
  17699. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17700. #endif
  17701. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17702. Expression.Invoke(
  17703. Expression.Call(
  17704. null,
  17705. m,
  17706. Expression.Constant(provider, typeof(IQbservableProvider)),
  17707. action
  17708. ),
  17709. Expression.Constant(t1, typeof(TArg1)),
  17710. Expression.Constant(t2, typeof(TArg2)),
  17711. Expression.Constant(t3, typeof(TArg3))
  17712. )
  17713. );
  17714. }
  17715. /// <summary>
  17716. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  17717. /// </summary>
  17718. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17719. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17720. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17721. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17722. /// <param name="action">Action to convert to an asynchronous action.</param>
  17723. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17724. /// <returns>Asynchronous action.</returns>
  17725. /// <exception cref="ArgumentNullException">
  17726. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17727. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action, IScheduler scheduler)
  17728. {
  17729. if (provider == null)
  17730. throw new ArgumentNullException(nameof(provider));
  17731. if (action == null)
  17732. throw new ArgumentNullException(nameof(action));
  17733. if (scheduler == null)
  17734. throw new ArgumentNullException(nameof(scheduler));
  17735. #if CRIPPLED_REFLECTION
  17736. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>), default(IScheduler)));
  17737. #else
  17738. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17739. #endif
  17740. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17741. Expression.Invoke(
  17742. Expression.Call(
  17743. null,
  17744. m,
  17745. Expression.Constant(provider, typeof(IQbservableProvider)),
  17746. action,
  17747. Expression.Constant(scheduler, typeof(IScheduler))
  17748. ),
  17749. Expression.Constant(t1, typeof(TArg1)),
  17750. Expression.Constant(t2, typeof(TArg2)),
  17751. Expression.Constant(t3, typeof(TArg3))
  17752. )
  17753. );
  17754. }
  17755. /// <summary>
  17756. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  17757. /// </summary>
  17758. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17759. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17760. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17761. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17762. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17763. /// <param name="action">Action to convert to an asynchronous action.</param>
  17764. /// <returns>Asynchronous action.</returns>
  17765. /// <exception cref="ArgumentNullException">
  17766. /// <paramref name="action" /> is null.</exception>
  17767. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4>> action)
  17768. {
  17769. if (provider == null)
  17770. throw new ArgumentNullException(nameof(provider));
  17771. if (action == null)
  17772. throw new ArgumentNullException(nameof(action));
  17773. #if CRIPPLED_REFLECTION
  17774. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>)));
  17775. #else
  17776. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17777. #endif
  17778. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17779. Expression.Invoke(
  17780. Expression.Call(
  17781. null,
  17782. m,
  17783. Expression.Constant(provider, typeof(IQbservableProvider)),
  17784. action
  17785. ),
  17786. Expression.Constant(t1, typeof(TArg1)),
  17787. Expression.Constant(t2, typeof(TArg2)),
  17788. Expression.Constant(t3, typeof(TArg3)),
  17789. Expression.Constant(t4, typeof(TArg4))
  17790. )
  17791. );
  17792. }
  17793. /// <summary>
  17794. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  17795. /// </summary>
  17796. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17797. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17798. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17799. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17800. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17801. /// <param name="action">Action to convert to an asynchronous action.</param>
  17802. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17803. /// <returns>Asynchronous action.</returns>
  17804. /// <exception cref="ArgumentNullException">
  17805. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17806. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4>> action, IScheduler scheduler)
  17807. {
  17808. if (provider == null)
  17809. throw new ArgumentNullException(nameof(provider));
  17810. if (action == null)
  17811. throw new ArgumentNullException(nameof(action));
  17812. if (scheduler == null)
  17813. throw new ArgumentNullException(nameof(scheduler));
  17814. #if CRIPPLED_REFLECTION
  17815. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>), default(IScheduler)));
  17816. #else
  17817. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17818. #endif
  17819. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17820. Expression.Invoke(
  17821. Expression.Call(
  17822. null,
  17823. m,
  17824. Expression.Constant(provider, typeof(IQbservableProvider)),
  17825. action,
  17826. Expression.Constant(scheduler, typeof(IScheduler))
  17827. ),
  17828. Expression.Constant(t1, typeof(TArg1)),
  17829. Expression.Constant(t2, typeof(TArg2)),
  17830. Expression.Constant(t3, typeof(TArg3)),
  17831. Expression.Constant(t4, typeof(TArg4))
  17832. )
  17833. );
  17834. }
  17835. /// <summary>
  17836. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  17837. /// </summary>
  17838. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17839. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17840. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17841. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17842. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17843. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17844. /// <param name="action">Action to convert to an asynchronous action.</param>
  17845. /// <returns>Asynchronous action.</returns>
  17846. /// <exception cref="ArgumentNullException">
  17847. /// <paramref name="action" /> is null.</exception>
  17848. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>> action)
  17849. {
  17850. if (provider == null)
  17851. throw new ArgumentNullException(nameof(provider));
  17852. if (action == null)
  17853. throw new ArgumentNullException(nameof(action));
  17854. #if CRIPPLED_REFLECTION
  17855. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>)));
  17856. #else
  17857. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  17858. #endif
  17859. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  17860. Expression.Invoke(
  17861. Expression.Call(
  17862. null,
  17863. m,
  17864. Expression.Constant(provider, typeof(IQbservableProvider)),
  17865. action
  17866. ),
  17867. Expression.Constant(t1, typeof(TArg1)),
  17868. Expression.Constant(t2, typeof(TArg2)),
  17869. Expression.Constant(t3, typeof(TArg3)),
  17870. Expression.Constant(t4, typeof(TArg4)),
  17871. Expression.Constant(t5, typeof(TArg5))
  17872. )
  17873. );
  17874. }
  17875. /// <summary>
  17876. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  17877. /// </summary>
  17878. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17879. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17880. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17881. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17882. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17883. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17884. /// <param name="action">Action to convert to an asynchronous action.</param>
  17885. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17886. /// <returns>Asynchronous action.</returns>
  17887. /// <exception cref="ArgumentNullException">
  17888. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17889. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>> action, IScheduler scheduler)
  17890. {
  17891. if (provider == null)
  17892. throw new ArgumentNullException(nameof(provider));
  17893. if (action == null)
  17894. throw new ArgumentNullException(nameof(action));
  17895. if (scheduler == null)
  17896. throw new ArgumentNullException(nameof(scheduler));
  17897. #if CRIPPLED_REFLECTION
  17898. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>), default(IScheduler)));
  17899. #else
  17900. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  17901. #endif
  17902. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  17903. Expression.Invoke(
  17904. Expression.Call(
  17905. null,
  17906. m,
  17907. Expression.Constant(provider, typeof(IQbservableProvider)),
  17908. action,
  17909. Expression.Constant(scheduler, typeof(IScheduler))
  17910. ),
  17911. Expression.Constant(t1, typeof(TArg1)),
  17912. Expression.Constant(t2, typeof(TArg2)),
  17913. Expression.Constant(t3, typeof(TArg3)),
  17914. Expression.Constant(t4, typeof(TArg4)),
  17915. Expression.Constant(t5, typeof(TArg5))
  17916. )
  17917. );
  17918. }
  17919. /// <summary>
  17920. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  17921. /// </summary>
  17922. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17923. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17924. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17925. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17926. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17927. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17928. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17929. /// <param name="action">Action to convert to an asynchronous action.</param>
  17930. /// <returns>Asynchronous action.</returns>
  17931. /// <exception cref="ArgumentNullException">
  17932. /// <paramref name="action" /> is null.</exception>
  17933. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>> action)
  17934. {
  17935. if (provider == null)
  17936. throw new ArgumentNullException(nameof(provider));
  17937. if (action == null)
  17938. throw new ArgumentNullException(nameof(action));
  17939. #if CRIPPLED_REFLECTION
  17940. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>)));
  17941. #else
  17942. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  17943. #endif
  17944. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  17945. Expression.Invoke(
  17946. Expression.Call(
  17947. null,
  17948. m,
  17949. Expression.Constant(provider, typeof(IQbservableProvider)),
  17950. action
  17951. ),
  17952. Expression.Constant(t1, typeof(TArg1)),
  17953. Expression.Constant(t2, typeof(TArg2)),
  17954. Expression.Constant(t3, typeof(TArg3)),
  17955. Expression.Constant(t4, typeof(TArg4)),
  17956. Expression.Constant(t5, typeof(TArg5)),
  17957. Expression.Constant(t6, typeof(TArg6))
  17958. )
  17959. );
  17960. }
  17961. /// <summary>
  17962. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  17963. /// </summary>
  17964. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17965. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17966. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17967. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17968. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17969. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17970. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17971. /// <param name="action">Action to convert to an asynchronous action.</param>
  17972. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17973. /// <returns>Asynchronous action.</returns>
  17974. /// <exception cref="ArgumentNullException">
  17975. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17976. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>> action, IScheduler scheduler)
  17977. {
  17978. if (provider == null)
  17979. throw new ArgumentNullException(nameof(provider));
  17980. if (action == null)
  17981. throw new ArgumentNullException(nameof(action));
  17982. if (scheduler == null)
  17983. throw new ArgumentNullException(nameof(scheduler));
  17984. #if CRIPPLED_REFLECTION
  17985. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>), default(IScheduler)));
  17986. #else
  17987. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  17988. #endif
  17989. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  17990. Expression.Invoke(
  17991. Expression.Call(
  17992. null,
  17993. m,
  17994. Expression.Constant(provider, typeof(IQbservableProvider)),
  17995. action,
  17996. Expression.Constant(scheduler, typeof(IScheduler))
  17997. ),
  17998. Expression.Constant(t1, typeof(TArg1)),
  17999. Expression.Constant(t2, typeof(TArg2)),
  18000. Expression.Constant(t3, typeof(TArg3)),
  18001. Expression.Constant(t4, typeof(TArg4)),
  18002. Expression.Constant(t5, typeof(TArg5)),
  18003. Expression.Constant(t6, typeof(TArg6))
  18004. )
  18005. );
  18006. }
  18007. /// <summary>
  18008. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18009. /// </summary>
  18010. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18011. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18012. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18013. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18014. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18015. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18016. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18017. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18018. /// <param name="action">Action to convert to an asynchronous action.</param>
  18019. /// <returns>Asynchronous action.</returns>
  18020. /// <exception cref="ArgumentNullException">
  18021. /// <paramref name="action" /> is null.</exception>
  18022. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>> action)
  18023. {
  18024. if (provider == null)
  18025. throw new ArgumentNullException(nameof(provider));
  18026. if (action == null)
  18027. throw new ArgumentNullException(nameof(action));
  18028. #if CRIPPLED_REFLECTION
  18029. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>>)));
  18030. #else
  18031. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  18032. #endif
  18033. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  18034. Expression.Invoke(
  18035. Expression.Call(
  18036. null,
  18037. m,
  18038. Expression.Constant(provider, typeof(IQbservableProvider)),
  18039. action
  18040. ),
  18041. Expression.Constant(t1, typeof(TArg1)),
  18042. Expression.Constant(t2, typeof(TArg2)),
  18043. Expression.Constant(t3, typeof(TArg3)),
  18044. Expression.Constant(t4, typeof(TArg4)),
  18045. Expression.Constant(t5, typeof(TArg5)),
  18046. Expression.Constant(t6, typeof(TArg6)),
  18047. Expression.Constant(t7, typeof(TArg7))
  18048. )
  18049. );
  18050. }
  18051. /// <summary>
  18052. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  18053. /// </summary>
  18054. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18055. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18056. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18057. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18058. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18059. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18060. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18061. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18062. /// <param name="action">Action to convert to an asynchronous action.</param>
  18063. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18064. /// <returns>Asynchronous action.</returns>
  18065. /// <exception cref="ArgumentNullException">
  18066. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18067. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>> action, IScheduler scheduler)
  18068. {
  18069. if (provider == null)
  18070. throw new ArgumentNullException(nameof(provider));
  18071. if (action == null)
  18072. throw new ArgumentNullException(nameof(action));
  18073. if (scheduler == null)
  18074. throw new ArgumentNullException(nameof(scheduler));
  18075. #if CRIPPLED_REFLECTION
  18076. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>>), default(IScheduler)));
  18077. #else
  18078. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  18079. #endif
  18080. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  18081. Expression.Invoke(
  18082. Expression.Call(
  18083. null,
  18084. m,
  18085. Expression.Constant(provider, typeof(IQbservableProvider)),
  18086. action,
  18087. Expression.Constant(scheduler, typeof(IScheduler))
  18088. ),
  18089. Expression.Constant(t1, typeof(TArg1)),
  18090. Expression.Constant(t2, typeof(TArg2)),
  18091. Expression.Constant(t3, typeof(TArg3)),
  18092. Expression.Constant(t4, typeof(TArg4)),
  18093. Expression.Constant(t5, typeof(TArg5)),
  18094. Expression.Constant(t6, typeof(TArg6)),
  18095. Expression.Constant(t7, typeof(TArg7))
  18096. )
  18097. );
  18098. }
  18099. /// <summary>
  18100. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18101. /// </summary>
  18102. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18103. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18104. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18105. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18106. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18107. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18108. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18109. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18110. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18111. /// <param name="action">Action to convert to an asynchronous action.</param>
  18112. /// <returns>Asynchronous action.</returns>
  18113. /// <exception cref="ArgumentNullException">
  18114. /// <paramref name="action" /> is null.</exception>
  18115. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>> action)
  18116. {
  18117. if (provider == null)
  18118. throw new ArgumentNullException(nameof(provider));
  18119. if (action == null)
  18120. throw new ArgumentNullException(nameof(action));
  18121. #if CRIPPLED_REFLECTION
  18122. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>>)));
  18123. #else
  18124. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  18125. #endif
  18126. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  18127. Expression.Invoke(
  18128. Expression.Call(
  18129. null,
  18130. m,
  18131. Expression.Constant(provider, typeof(IQbservableProvider)),
  18132. action
  18133. ),
  18134. Expression.Constant(t1, typeof(TArg1)),
  18135. Expression.Constant(t2, typeof(TArg2)),
  18136. Expression.Constant(t3, typeof(TArg3)),
  18137. Expression.Constant(t4, typeof(TArg4)),
  18138. Expression.Constant(t5, typeof(TArg5)),
  18139. Expression.Constant(t6, typeof(TArg6)),
  18140. Expression.Constant(t7, typeof(TArg7)),
  18141. Expression.Constant(t8, typeof(TArg8))
  18142. )
  18143. );
  18144. }
  18145. /// <summary>
  18146. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  18147. /// </summary>
  18148. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18149. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18150. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18151. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18152. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18153. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18154. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18155. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18156. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18157. /// <param name="action">Action to convert to an asynchronous action.</param>
  18158. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18159. /// <returns>Asynchronous action.</returns>
  18160. /// <exception cref="ArgumentNullException">
  18161. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18162. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>> action, IScheduler scheduler)
  18163. {
  18164. if (provider == null)
  18165. throw new ArgumentNullException(nameof(provider));
  18166. if (action == null)
  18167. throw new ArgumentNullException(nameof(action));
  18168. if (scheduler == null)
  18169. throw new ArgumentNullException(nameof(scheduler));
  18170. #if CRIPPLED_REFLECTION
  18171. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>>), default(IScheduler)));
  18172. #else
  18173. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  18174. #endif
  18175. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  18176. Expression.Invoke(
  18177. Expression.Call(
  18178. null,
  18179. m,
  18180. Expression.Constant(provider, typeof(IQbservableProvider)),
  18181. action,
  18182. Expression.Constant(scheduler, typeof(IScheduler))
  18183. ),
  18184. Expression.Constant(t1, typeof(TArg1)),
  18185. Expression.Constant(t2, typeof(TArg2)),
  18186. Expression.Constant(t3, typeof(TArg3)),
  18187. Expression.Constant(t4, typeof(TArg4)),
  18188. Expression.Constant(t5, typeof(TArg5)),
  18189. Expression.Constant(t6, typeof(TArg6)),
  18190. Expression.Constant(t7, typeof(TArg7)),
  18191. Expression.Constant(t8, typeof(TArg8))
  18192. )
  18193. );
  18194. }
  18195. /// <summary>
  18196. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18197. /// </summary>
  18198. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18199. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18200. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18201. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18202. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18203. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18204. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18205. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18206. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18207. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18208. /// <param name="action">Action to convert to an asynchronous action.</param>
  18209. /// <returns>Asynchronous action.</returns>
  18210. /// <exception cref="ArgumentNullException">
  18211. /// <paramref name="action" /> is null.</exception>
  18212. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>> action)
  18213. {
  18214. if (provider == null)
  18215. throw new ArgumentNullException(nameof(provider));
  18216. if (action == null)
  18217. throw new ArgumentNullException(nameof(action));
  18218. #if CRIPPLED_REFLECTION
  18219. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>>)));
  18220. #else
  18221. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18222. #endif
  18223. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18224. Expression.Invoke(
  18225. Expression.Call(
  18226. null,
  18227. m,
  18228. Expression.Constant(provider, typeof(IQbservableProvider)),
  18229. action
  18230. ),
  18231. Expression.Constant(t1, typeof(TArg1)),
  18232. Expression.Constant(t2, typeof(TArg2)),
  18233. Expression.Constant(t3, typeof(TArg3)),
  18234. Expression.Constant(t4, typeof(TArg4)),
  18235. Expression.Constant(t5, typeof(TArg5)),
  18236. Expression.Constant(t6, typeof(TArg6)),
  18237. Expression.Constant(t7, typeof(TArg7)),
  18238. Expression.Constant(t8, typeof(TArg8)),
  18239. Expression.Constant(t9, typeof(TArg9))
  18240. )
  18241. );
  18242. }
  18243. /// <summary>
  18244. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  18245. /// </summary>
  18246. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18247. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18248. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18249. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18250. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18251. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18252. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18253. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18254. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18255. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18256. /// <param name="action">Action to convert to an asynchronous action.</param>
  18257. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18258. /// <returns>Asynchronous action.</returns>
  18259. /// <exception cref="ArgumentNullException">
  18260. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18261. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>> action, IScheduler scheduler)
  18262. {
  18263. if (provider == null)
  18264. throw new ArgumentNullException(nameof(provider));
  18265. if (action == null)
  18266. throw new ArgumentNullException(nameof(action));
  18267. if (scheduler == null)
  18268. throw new ArgumentNullException(nameof(scheduler));
  18269. #if CRIPPLED_REFLECTION
  18270. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>>), default(IScheduler)));
  18271. #else
  18272. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18273. #endif
  18274. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18275. Expression.Invoke(
  18276. Expression.Call(
  18277. null,
  18278. m,
  18279. Expression.Constant(provider, typeof(IQbservableProvider)),
  18280. action,
  18281. Expression.Constant(scheduler, typeof(IScheduler))
  18282. ),
  18283. Expression.Constant(t1, typeof(TArg1)),
  18284. Expression.Constant(t2, typeof(TArg2)),
  18285. Expression.Constant(t3, typeof(TArg3)),
  18286. Expression.Constant(t4, typeof(TArg4)),
  18287. Expression.Constant(t5, typeof(TArg5)),
  18288. Expression.Constant(t6, typeof(TArg6)),
  18289. Expression.Constant(t7, typeof(TArg7)),
  18290. Expression.Constant(t8, typeof(TArg8)),
  18291. Expression.Constant(t9, typeof(TArg9))
  18292. )
  18293. );
  18294. }
  18295. /// <summary>
  18296. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18297. /// </summary>
  18298. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18299. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18300. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18301. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18302. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18303. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18304. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18305. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18306. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18307. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18308. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18309. /// <param name="action">Action to convert to an asynchronous action.</param>
  18310. /// <returns>Asynchronous action.</returns>
  18311. /// <exception cref="ArgumentNullException">
  18312. /// <paramref name="action" /> is null.</exception>
  18313. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>> action)
  18314. {
  18315. if (provider == null)
  18316. throw new ArgumentNullException(nameof(provider));
  18317. if (action == null)
  18318. throw new ArgumentNullException(nameof(action));
  18319. #if CRIPPLED_REFLECTION
  18320. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>>)));
  18321. #else
  18322. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10));
  18323. #endif
  18324. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18325. Expression.Invoke(
  18326. Expression.Call(
  18327. null,
  18328. m,
  18329. Expression.Constant(provider, typeof(IQbservableProvider)),
  18330. action
  18331. ),
  18332. Expression.Constant(t1, typeof(TArg1)),
  18333. Expression.Constant(t2, typeof(TArg2)),
  18334. Expression.Constant(t3, typeof(TArg3)),
  18335. Expression.Constant(t4, typeof(TArg4)),
  18336. Expression.Constant(t5, typeof(TArg5)),
  18337. Expression.Constant(t6, typeof(TArg6)),
  18338. Expression.Constant(t7, typeof(TArg7)),
  18339. Expression.Constant(t8, typeof(TArg8)),
  18340. Expression.Constant(t9, typeof(TArg9)),
  18341. Expression.Constant(t10, typeof(TArg10))
  18342. )
  18343. );
  18344. }
  18345. /// <summary>
  18346. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  18347. /// </summary>
  18348. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18349. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18350. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18351. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18352. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18353. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18354. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18355. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18356. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18357. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18358. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18359. /// <param name="action">Action to convert to an asynchronous action.</param>
  18360. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18361. /// <returns>Asynchronous action.</returns>
  18362. /// <exception cref="ArgumentNullException">
  18363. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18364. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>> action, IScheduler scheduler)
  18365. {
  18366. if (provider == null)
  18367. throw new ArgumentNullException(nameof(provider));
  18368. if (action == null)
  18369. throw new ArgumentNullException(nameof(action));
  18370. if (scheduler == null)
  18371. throw new ArgumentNullException(nameof(scheduler));
  18372. #if CRIPPLED_REFLECTION
  18373. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>>), default(IScheduler)));
  18374. #else
  18375. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10));
  18376. #endif
  18377. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18378. Expression.Invoke(
  18379. Expression.Call(
  18380. null,
  18381. m,
  18382. Expression.Constant(provider, typeof(IQbservableProvider)),
  18383. action,
  18384. Expression.Constant(scheduler, typeof(IScheduler))
  18385. ),
  18386. Expression.Constant(t1, typeof(TArg1)),
  18387. Expression.Constant(t2, typeof(TArg2)),
  18388. Expression.Constant(t3, typeof(TArg3)),
  18389. Expression.Constant(t4, typeof(TArg4)),
  18390. Expression.Constant(t5, typeof(TArg5)),
  18391. Expression.Constant(t6, typeof(TArg6)),
  18392. Expression.Constant(t7, typeof(TArg7)),
  18393. Expression.Constant(t8, typeof(TArg8)),
  18394. Expression.Constant(t9, typeof(TArg9)),
  18395. Expression.Constant(t10, typeof(TArg10))
  18396. )
  18397. );
  18398. }
  18399. /// <summary>
  18400. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18401. /// </summary>
  18402. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18403. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18404. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18405. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18406. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18407. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18408. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18409. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18410. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18411. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18412. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18413. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18414. /// <param name="action">Action to convert to an asynchronous action.</param>
  18415. /// <returns>Asynchronous action.</returns>
  18416. /// <exception cref="ArgumentNullException">
  18417. /// <paramref name="action" /> is null.</exception>
  18418. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>> action)
  18419. {
  18420. if (provider == null)
  18421. throw new ArgumentNullException(nameof(provider));
  18422. if (action == null)
  18423. throw new ArgumentNullException(nameof(action));
  18424. #if CRIPPLED_REFLECTION
  18425. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>>)));
  18426. #else
  18427. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11));
  18428. #endif
  18429. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18430. Expression.Invoke(
  18431. Expression.Call(
  18432. null,
  18433. m,
  18434. Expression.Constant(provider, typeof(IQbservableProvider)),
  18435. action
  18436. ),
  18437. Expression.Constant(t1, typeof(TArg1)),
  18438. Expression.Constant(t2, typeof(TArg2)),
  18439. Expression.Constant(t3, typeof(TArg3)),
  18440. Expression.Constant(t4, typeof(TArg4)),
  18441. Expression.Constant(t5, typeof(TArg5)),
  18442. Expression.Constant(t6, typeof(TArg6)),
  18443. Expression.Constant(t7, typeof(TArg7)),
  18444. Expression.Constant(t8, typeof(TArg8)),
  18445. Expression.Constant(t9, typeof(TArg9)),
  18446. Expression.Constant(t10, typeof(TArg10)),
  18447. Expression.Constant(t11, typeof(TArg11))
  18448. )
  18449. );
  18450. }
  18451. /// <summary>
  18452. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  18453. /// </summary>
  18454. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18455. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18456. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18457. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18458. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18459. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18460. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18461. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18462. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18463. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18464. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18465. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18466. /// <param name="action">Action to convert to an asynchronous action.</param>
  18467. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18468. /// <returns>Asynchronous action.</returns>
  18469. /// <exception cref="ArgumentNullException">
  18470. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18471. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>> action, IScheduler scheduler)
  18472. {
  18473. if (provider == null)
  18474. throw new ArgumentNullException(nameof(provider));
  18475. if (action == null)
  18476. throw new ArgumentNullException(nameof(action));
  18477. if (scheduler == null)
  18478. throw new ArgumentNullException(nameof(scheduler));
  18479. #if CRIPPLED_REFLECTION
  18480. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>>), default(IScheduler)));
  18481. #else
  18482. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11));
  18483. #endif
  18484. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18485. Expression.Invoke(
  18486. Expression.Call(
  18487. null,
  18488. m,
  18489. Expression.Constant(provider, typeof(IQbservableProvider)),
  18490. action,
  18491. Expression.Constant(scheduler, typeof(IScheduler))
  18492. ),
  18493. Expression.Constant(t1, typeof(TArg1)),
  18494. Expression.Constant(t2, typeof(TArg2)),
  18495. Expression.Constant(t3, typeof(TArg3)),
  18496. Expression.Constant(t4, typeof(TArg4)),
  18497. Expression.Constant(t5, typeof(TArg5)),
  18498. Expression.Constant(t6, typeof(TArg6)),
  18499. Expression.Constant(t7, typeof(TArg7)),
  18500. Expression.Constant(t8, typeof(TArg8)),
  18501. Expression.Constant(t9, typeof(TArg9)),
  18502. Expression.Constant(t10, typeof(TArg10)),
  18503. Expression.Constant(t11, typeof(TArg11))
  18504. )
  18505. );
  18506. }
  18507. /// <summary>
  18508. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18509. /// </summary>
  18510. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18511. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18512. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18513. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18514. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18515. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18516. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18517. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18518. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18519. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18520. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18521. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18522. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18523. /// <param name="action">Action to convert to an asynchronous action.</param>
  18524. /// <returns>Asynchronous action.</returns>
  18525. /// <exception cref="ArgumentNullException">
  18526. /// <paramref name="action" /> is null.</exception>
  18527. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>> action)
  18528. {
  18529. if (provider == null)
  18530. throw new ArgumentNullException(nameof(provider));
  18531. if (action == null)
  18532. throw new ArgumentNullException(nameof(action));
  18533. #if CRIPPLED_REFLECTION
  18534. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>>)));
  18535. #else
  18536. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12));
  18537. #endif
  18538. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18539. Expression.Invoke(
  18540. Expression.Call(
  18541. null,
  18542. m,
  18543. Expression.Constant(provider, typeof(IQbservableProvider)),
  18544. action
  18545. ),
  18546. Expression.Constant(t1, typeof(TArg1)),
  18547. Expression.Constant(t2, typeof(TArg2)),
  18548. Expression.Constant(t3, typeof(TArg3)),
  18549. Expression.Constant(t4, typeof(TArg4)),
  18550. Expression.Constant(t5, typeof(TArg5)),
  18551. Expression.Constant(t6, typeof(TArg6)),
  18552. Expression.Constant(t7, typeof(TArg7)),
  18553. Expression.Constant(t8, typeof(TArg8)),
  18554. Expression.Constant(t9, typeof(TArg9)),
  18555. Expression.Constant(t10, typeof(TArg10)),
  18556. Expression.Constant(t11, typeof(TArg11)),
  18557. Expression.Constant(t12, typeof(TArg12))
  18558. )
  18559. );
  18560. }
  18561. /// <summary>
  18562. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  18563. /// </summary>
  18564. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18565. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18566. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18567. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18568. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18569. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18570. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18571. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18572. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18573. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18574. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18575. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18576. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18577. /// <param name="action">Action to convert to an asynchronous action.</param>
  18578. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18579. /// <returns>Asynchronous action.</returns>
  18580. /// <exception cref="ArgumentNullException">
  18581. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18582. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>> action, IScheduler scheduler)
  18583. {
  18584. if (provider == null)
  18585. throw new ArgumentNullException(nameof(provider));
  18586. if (action == null)
  18587. throw new ArgumentNullException(nameof(action));
  18588. if (scheduler == null)
  18589. throw new ArgumentNullException(nameof(scheduler));
  18590. #if CRIPPLED_REFLECTION
  18591. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>>), default(IScheduler)));
  18592. #else
  18593. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12));
  18594. #endif
  18595. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18596. Expression.Invoke(
  18597. Expression.Call(
  18598. null,
  18599. m,
  18600. Expression.Constant(provider, typeof(IQbservableProvider)),
  18601. action,
  18602. Expression.Constant(scheduler, typeof(IScheduler))
  18603. ),
  18604. Expression.Constant(t1, typeof(TArg1)),
  18605. Expression.Constant(t2, typeof(TArg2)),
  18606. Expression.Constant(t3, typeof(TArg3)),
  18607. Expression.Constant(t4, typeof(TArg4)),
  18608. Expression.Constant(t5, typeof(TArg5)),
  18609. Expression.Constant(t6, typeof(TArg6)),
  18610. Expression.Constant(t7, typeof(TArg7)),
  18611. Expression.Constant(t8, typeof(TArg8)),
  18612. Expression.Constant(t9, typeof(TArg9)),
  18613. Expression.Constant(t10, typeof(TArg10)),
  18614. Expression.Constant(t11, typeof(TArg11)),
  18615. Expression.Constant(t12, typeof(TArg12))
  18616. )
  18617. );
  18618. }
  18619. /// <summary>
  18620. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18621. /// </summary>
  18622. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18623. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18624. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18625. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18626. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18627. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18628. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18629. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18630. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18631. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18632. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18633. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18634. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18635. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18636. /// <param name="action">Action to convert to an asynchronous action.</param>
  18637. /// <returns>Asynchronous action.</returns>
  18638. /// <exception cref="ArgumentNullException">
  18639. /// <paramref name="action" /> is null.</exception>
  18640. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>> action)
  18641. {
  18642. if (provider == null)
  18643. throw new ArgumentNullException(nameof(provider));
  18644. if (action == null)
  18645. throw new ArgumentNullException(nameof(action));
  18646. #if CRIPPLED_REFLECTION
  18647. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>>)));
  18648. #else
  18649. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13));
  18650. #endif
  18651. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18652. Expression.Invoke(
  18653. Expression.Call(
  18654. null,
  18655. m,
  18656. Expression.Constant(provider, typeof(IQbservableProvider)),
  18657. action
  18658. ),
  18659. Expression.Constant(t1, typeof(TArg1)),
  18660. Expression.Constant(t2, typeof(TArg2)),
  18661. Expression.Constant(t3, typeof(TArg3)),
  18662. Expression.Constant(t4, typeof(TArg4)),
  18663. Expression.Constant(t5, typeof(TArg5)),
  18664. Expression.Constant(t6, typeof(TArg6)),
  18665. Expression.Constant(t7, typeof(TArg7)),
  18666. Expression.Constant(t8, typeof(TArg8)),
  18667. Expression.Constant(t9, typeof(TArg9)),
  18668. Expression.Constant(t10, typeof(TArg10)),
  18669. Expression.Constant(t11, typeof(TArg11)),
  18670. Expression.Constant(t12, typeof(TArg12)),
  18671. Expression.Constant(t13, typeof(TArg13))
  18672. )
  18673. );
  18674. }
  18675. /// <summary>
  18676. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  18677. /// </summary>
  18678. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18679. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18680. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18681. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18682. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18683. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18684. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18685. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18686. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18687. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18688. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18689. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18690. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18691. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18692. /// <param name="action">Action to convert to an asynchronous action.</param>
  18693. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18694. /// <returns>Asynchronous action.</returns>
  18695. /// <exception cref="ArgumentNullException">
  18696. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18697. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>> action, IScheduler scheduler)
  18698. {
  18699. if (provider == null)
  18700. throw new ArgumentNullException(nameof(provider));
  18701. if (action == null)
  18702. throw new ArgumentNullException(nameof(action));
  18703. if (scheduler == null)
  18704. throw new ArgumentNullException(nameof(scheduler));
  18705. #if CRIPPLED_REFLECTION
  18706. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>>), default(IScheduler)));
  18707. #else
  18708. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13));
  18709. #endif
  18710. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18711. Expression.Invoke(
  18712. Expression.Call(
  18713. null,
  18714. m,
  18715. Expression.Constant(provider, typeof(IQbservableProvider)),
  18716. action,
  18717. Expression.Constant(scheduler, typeof(IScheduler))
  18718. ),
  18719. Expression.Constant(t1, typeof(TArg1)),
  18720. Expression.Constant(t2, typeof(TArg2)),
  18721. Expression.Constant(t3, typeof(TArg3)),
  18722. Expression.Constant(t4, typeof(TArg4)),
  18723. Expression.Constant(t5, typeof(TArg5)),
  18724. Expression.Constant(t6, typeof(TArg6)),
  18725. Expression.Constant(t7, typeof(TArg7)),
  18726. Expression.Constant(t8, typeof(TArg8)),
  18727. Expression.Constant(t9, typeof(TArg9)),
  18728. Expression.Constant(t10, typeof(TArg10)),
  18729. Expression.Constant(t11, typeof(TArg11)),
  18730. Expression.Constant(t12, typeof(TArg12)),
  18731. Expression.Constant(t13, typeof(TArg13))
  18732. )
  18733. );
  18734. }
  18735. /// <summary>
  18736. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18737. /// </summary>
  18738. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18739. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18740. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18741. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18742. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18743. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18744. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18745. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18746. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18747. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18748. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18749. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18750. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18751. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18752. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18753. /// <param name="action">Action to convert to an asynchronous action.</param>
  18754. /// <returns>Asynchronous action.</returns>
  18755. /// <exception cref="ArgumentNullException">
  18756. /// <paramref name="action" /> is null.</exception>
  18757. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>> action)
  18758. {
  18759. if (provider == null)
  18760. throw new ArgumentNullException(nameof(provider));
  18761. if (action == null)
  18762. throw new ArgumentNullException(nameof(action));
  18763. #if CRIPPLED_REFLECTION
  18764. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>>)));
  18765. #else
  18766. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14));
  18767. #endif
  18768. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18769. Expression.Invoke(
  18770. Expression.Call(
  18771. null,
  18772. m,
  18773. Expression.Constant(provider, typeof(IQbservableProvider)),
  18774. action
  18775. ),
  18776. Expression.Constant(t1, typeof(TArg1)),
  18777. Expression.Constant(t2, typeof(TArg2)),
  18778. Expression.Constant(t3, typeof(TArg3)),
  18779. Expression.Constant(t4, typeof(TArg4)),
  18780. Expression.Constant(t5, typeof(TArg5)),
  18781. Expression.Constant(t6, typeof(TArg6)),
  18782. Expression.Constant(t7, typeof(TArg7)),
  18783. Expression.Constant(t8, typeof(TArg8)),
  18784. Expression.Constant(t9, typeof(TArg9)),
  18785. Expression.Constant(t10, typeof(TArg10)),
  18786. Expression.Constant(t11, typeof(TArg11)),
  18787. Expression.Constant(t12, typeof(TArg12)),
  18788. Expression.Constant(t13, typeof(TArg13)),
  18789. Expression.Constant(t14, typeof(TArg14))
  18790. )
  18791. );
  18792. }
  18793. /// <summary>
  18794. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  18795. /// </summary>
  18796. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18797. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18798. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18799. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18800. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18801. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18802. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18803. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18804. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18805. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18806. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18807. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18808. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18809. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18810. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18811. /// <param name="action">Action to convert to an asynchronous action.</param>
  18812. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18813. /// <returns>Asynchronous action.</returns>
  18814. /// <exception cref="ArgumentNullException">
  18815. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18816. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>> action, IScheduler scheduler)
  18817. {
  18818. if (provider == null)
  18819. throw new ArgumentNullException(nameof(provider));
  18820. if (action == null)
  18821. throw new ArgumentNullException(nameof(action));
  18822. if (scheduler == null)
  18823. throw new ArgumentNullException(nameof(scheduler));
  18824. #if CRIPPLED_REFLECTION
  18825. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>>), default(IScheduler)));
  18826. #else
  18827. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14));
  18828. #endif
  18829. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18830. Expression.Invoke(
  18831. Expression.Call(
  18832. null,
  18833. m,
  18834. Expression.Constant(provider, typeof(IQbservableProvider)),
  18835. action,
  18836. Expression.Constant(scheduler, typeof(IScheduler))
  18837. ),
  18838. Expression.Constant(t1, typeof(TArg1)),
  18839. Expression.Constant(t2, typeof(TArg2)),
  18840. Expression.Constant(t3, typeof(TArg3)),
  18841. Expression.Constant(t4, typeof(TArg4)),
  18842. Expression.Constant(t5, typeof(TArg5)),
  18843. Expression.Constant(t6, typeof(TArg6)),
  18844. Expression.Constant(t7, typeof(TArg7)),
  18845. Expression.Constant(t8, typeof(TArg8)),
  18846. Expression.Constant(t9, typeof(TArg9)),
  18847. Expression.Constant(t10, typeof(TArg10)),
  18848. Expression.Constant(t11, typeof(TArg11)),
  18849. Expression.Constant(t12, typeof(TArg12)),
  18850. Expression.Constant(t13, typeof(TArg13)),
  18851. Expression.Constant(t14, typeof(TArg14))
  18852. )
  18853. );
  18854. }
  18855. /// <summary>
  18856. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18857. /// </summary>
  18858. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18859. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18860. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18861. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18862. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18863. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18864. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18865. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18866. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18867. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18868. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18869. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18870. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18871. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18872. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18873. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18874. /// <param name="action">Action to convert to an asynchronous action.</param>
  18875. /// <returns>Asynchronous action.</returns>
  18876. /// <exception cref="ArgumentNullException">
  18877. /// <paramref name="action" /> is null.</exception>
  18878. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>> action)
  18879. {
  18880. if (provider == null)
  18881. throw new ArgumentNullException(nameof(provider));
  18882. if (action == null)
  18883. throw new ArgumentNullException(nameof(action));
  18884. #if CRIPPLED_REFLECTION
  18885. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>>)));
  18886. #else
  18887. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TArg15));
  18888. #endif
  18889. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  18890. Expression.Invoke(
  18891. Expression.Call(
  18892. null,
  18893. m,
  18894. Expression.Constant(provider, typeof(IQbservableProvider)),
  18895. action
  18896. ),
  18897. Expression.Constant(t1, typeof(TArg1)),
  18898. Expression.Constant(t2, typeof(TArg2)),
  18899. Expression.Constant(t3, typeof(TArg3)),
  18900. Expression.Constant(t4, typeof(TArg4)),
  18901. Expression.Constant(t5, typeof(TArg5)),
  18902. Expression.Constant(t6, typeof(TArg6)),
  18903. Expression.Constant(t7, typeof(TArg7)),
  18904. Expression.Constant(t8, typeof(TArg8)),
  18905. Expression.Constant(t9, typeof(TArg9)),
  18906. Expression.Constant(t10, typeof(TArg10)),
  18907. Expression.Constant(t11, typeof(TArg11)),
  18908. Expression.Constant(t12, typeof(TArg12)),
  18909. Expression.Constant(t13, typeof(TArg13)),
  18910. Expression.Constant(t14, typeof(TArg14)),
  18911. Expression.Constant(t15, typeof(TArg15))
  18912. )
  18913. );
  18914. }
  18915. /// <summary>
  18916. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  18917. /// </summary>
  18918. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18919. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18920. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18921. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18922. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18923. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18924. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18925. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18926. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18927. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18928. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18929. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18930. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18931. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18932. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18933. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18934. /// <param name="action">Action to convert to an asynchronous action.</param>
  18935. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18936. /// <returns>Asynchronous action.</returns>
  18937. /// <exception cref="ArgumentNullException">
  18938. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18939. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>> action, IScheduler scheduler)
  18940. {
  18941. if (provider == null)
  18942. throw new ArgumentNullException(nameof(provider));
  18943. if (action == null)
  18944. throw new ArgumentNullException(nameof(action));
  18945. if (scheduler == null)
  18946. throw new ArgumentNullException(nameof(scheduler));
  18947. #if CRIPPLED_REFLECTION
  18948. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15>>), default(IScheduler)));
  18949. #else
  18950. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TArg15));
  18951. #endif
  18952. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  18953. Expression.Invoke(
  18954. Expression.Call(
  18955. null,
  18956. m,
  18957. Expression.Constant(provider, typeof(IQbservableProvider)),
  18958. action,
  18959. Expression.Constant(scheduler, typeof(IScheduler))
  18960. ),
  18961. Expression.Constant(t1, typeof(TArg1)),
  18962. Expression.Constant(t2, typeof(TArg2)),
  18963. Expression.Constant(t3, typeof(TArg3)),
  18964. Expression.Constant(t4, typeof(TArg4)),
  18965. Expression.Constant(t5, typeof(TArg5)),
  18966. Expression.Constant(t6, typeof(TArg6)),
  18967. Expression.Constant(t7, typeof(TArg7)),
  18968. Expression.Constant(t8, typeof(TArg8)),
  18969. Expression.Constant(t9, typeof(TArg9)),
  18970. Expression.Constant(t10, typeof(TArg10)),
  18971. Expression.Constant(t11, typeof(TArg11)),
  18972. Expression.Constant(t12, typeof(TArg12)),
  18973. Expression.Constant(t13, typeof(TArg13)),
  18974. Expression.Constant(t14, typeof(TArg14)),
  18975. Expression.Constant(t15, typeof(TArg15))
  18976. )
  18977. );
  18978. }
  18979. /// <summary>
  18980. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the default scheduler.
  18981. /// </summary>
  18982. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18983. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18984. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18985. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18986. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18987. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18988. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18989. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18990. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18991. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18992. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18993. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18994. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18995. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18996. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18997. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18998. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  18999. /// <param name="action">Action to convert to an asynchronous action.</param>
  19000. /// <returns>Asynchronous action.</returns>
  19001. /// <exception cref="ArgumentNullException">
  19002. /// <paramref name="action" /> is null.</exception>
  19003. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16>> action)
  19004. {
  19005. if (provider == null)
  19006. throw new ArgumentNullException(nameof(provider));
  19007. if (action == null)
  19008. throw new ArgumentNullException(nameof(action));
  19009. #if CRIPPLED_REFLECTION
  19010. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16>>)));
  19011. #else
  19012. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TArg15), typeof(TArg16));
  19013. #endif
  19014. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  19015. Expression.Invoke(
  19016. Expression.Call(
  19017. null,
  19018. m,
  19019. Expression.Constant(provider, typeof(IQbservableProvider)),
  19020. action
  19021. ),
  19022. Expression.Constant(t1, typeof(TArg1)),
  19023. Expression.Constant(t2, typeof(TArg2)),
  19024. Expression.Constant(t3, typeof(TArg3)),
  19025. Expression.Constant(t4, typeof(TArg4)),
  19026. Expression.Constant(t5, typeof(TArg5)),
  19027. Expression.Constant(t6, typeof(TArg6)),
  19028. Expression.Constant(t7, typeof(TArg7)),
  19029. Expression.Constant(t8, typeof(TArg8)),
  19030. Expression.Constant(t9, typeof(TArg9)),
  19031. Expression.Constant(t10, typeof(TArg10)),
  19032. Expression.Constant(t11, typeof(TArg11)),
  19033. Expression.Constant(t12, typeof(TArg12)),
  19034. Expression.Constant(t13, typeof(TArg13)),
  19035. Expression.Constant(t14, typeof(TArg14)),
  19036. Expression.Constant(t15, typeof(TArg15)),
  19037. Expression.Constant(t16, typeof(TArg16))
  19038. )
  19039. );
  19040. }
  19041. /// <summary>
  19042. /// Converts the function into an asynchronous action. Each invocation of the resulting asynchronous action causes an invocation of the original synchronous action on the specified scheduler.
  19043. /// </summary>
  19044. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19045. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19046. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19047. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19048. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19049. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19050. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19051. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19052. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19053. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19054. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19055. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19056. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19057. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19058. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19059. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19060. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  19061. /// <param name="action">Action to convert to an asynchronous action.</param>
  19062. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  19063. /// <returns>Asynchronous action.</returns>
  19064. /// <exception cref="ArgumentNullException">
  19065. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  19066. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16>> action, IScheduler scheduler)
  19067. {
  19068. if (provider == null)
  19069. throw new ArgumentNullException(nameof(provider));
  19070. if (action == null)
  19071. throw new ArgumentNullException(nameof(action));
  19072. if (scheduler == null)
  19073. throw new ArgumentNullException(nameof(scheduler));
  19074. #if CRIPPLED_REFLECTION
  19075. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16>>), default(IScheduler)));
  19076. #else
  19077. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TArg15), typeof(TArg16));
  19078. #endif
  19079. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  19080. Expression.Invoke(
  19081. Expression.Call(
  19082. null,
  19083. m,
  19084. Expression.Constant(provider, typeof(IQbservableProvider)),
  19085. action,
  19086. Expression.Constant(scheduler, typeof(IScheduler))
  19087. ),
  19088. Expression.Constant(t1, typeof(TArg1)),
  19089. Expression.Constant(t2, typeof(TArg2)),
  19090. Expression.Constant(t3, typeof(TArg3)),
  19091. Expression.Constant(t4, typeof(TArg4)),
  19092. Expression.Constant(t5, typeof(TArg5)),
  19093. Expression.Constant(t6, typeof(TArg6)),
  19094. Expression.Constant(t7, typeof(TArg7)),
  19095. Expression.Constant(t8, typeof(TArg8)),
  19096. Expression.Constant(t9, typeof(TArg9)),
  19097. Expression.Constant(t10, typeof(TArg10)),
  19098. Expression.Constant(t11, typeof(TArg11)),
  19099. Expression.Constant(t12, typeof(TArg12)),
  19100. Expression.Constant(t13, typeof(TArg13)),
  19101. Expression.Constant(t14, typeof(TArg14)),
  19102. Expression.Constant(t15, typeof(TArg15)),
  19103. Expression.Constant(t16, typeof(TArg16))
  19104. )
  19105. );
  19106. }
  19107. /// <summary>
  19108. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19109. /// </summary>
  19110. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19111. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19112. /// <param name="function">Function to convert to an asynchronous function.</param>
  19113. /// <returns>Asynchronous function.</returns>
  19114. /// <exception cref="ArgumentNullException">
  19115. /// <paramref name="function" /> is null.</exception>
  19116. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  19117. {
  19118. if (provider == null)
  19119. throw new ArgumentNullException(nameof(provider));
  19120. if (function == null)
  19121. throw new ArgumentNullException(nameof(function));
  19122. #if CRIPPLED_REFLECTION
  19123. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>)));
  19124. #else
  19125. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  19126. #endif
  19127. return () => provider.CreateQuery<TResult>(
  19128. Expression.Invoke(
  19129. Expression.Call(
  19130. null,
  19131. m,
  19132. Expression.Constant(provider, typeof(IQbservableProvider)),
  19133. function
  19134. )
  19135. )
  19136. );
  19137. }
  19138. /// <summary>
  19139. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19140. /// </summary>
  19141. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19142. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19143. /// <param name="function">Function to convert to an asynchronous function.</param>
  19144. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19145. /// <returns>Asynchronous function.</returns>
  19146. /// <exception cref="ArgumentNullException">
  19147. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19148. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  19149. {
  19150. if (provider == null)
  19151. throw new ArgumentNullException(nameof(provider));
  19152. if (function == null)
  19153. throw new ArgumentNullException(nameof(function));
  19154. if (scheduler == null)
  19155. throw new ArgumentNullException(nameof(scheduler));
  19156. #if CRIPPLED_REFLECTION
  19157. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler)));
  19158. #else
  19159. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  19160. #endif
  19161. return () => provider.CreateQuery<TResult>(
  19162. Expression.Invoke(
  19163. Expression.Call(
  19164. null,
  19165. m,
  19166. Expression.Constant(provider, typeof(IQbservableProvider)),
  19167. function,
  19168. Expression.Constant(scheduler, typeof(IScheduler))
  19169. )
  19170. )
  19171. );
  19172. }
  19173. /// <summary>
  19174. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19175. /// </summary>
  19176. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19177. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19178. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19179. /// <param name="function">Function to convert to an asynchronous function.</param>
  19180. /// <returns>Asynchronous function.</returns>
  19181. /// <exception cref="ArgumentNullException">
  19182. /// <paramref name="function" /> is null.</exception>
  19183. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function)
  19184. {
  19185. if (provider == null)
  19186. throw new ArgumentNullException(nameof(provider));
  19187. if (function == null)
  19188. throw new ArgumentNullException(nameof(function));
  19189. #if CRIPPLED_REFLECTION
  19190. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>)));
  19191. #else
  19192. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19193. #endif
  19194. return (t1) => provider.CreateQuery<TResult>(
  19195. Expression.Invoke(
  19196. Expression.Call(
  19197. null,
  19198. m,
  19199. Expression.Constant(provider, typeof(IQbservableProvider)),
  19200. function
  19201. ),
  19202. Expression.Constant(t1, typeof(TArg1))
  19203. )
  19204. );
  19205. }
  19206. /// <summary>
  19207. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19208. /// </summary>
  19209. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19210. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19211. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19212. /// <param name="function">Function to convert to an asynchronous function.</param>
  19213. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19214. /// <returns>Asynchronous function.</returns>
  19215. /// <exception cref="ArgumentNullException">
  19216. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19217. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function, IScheduler scheduler)
  19218. {
  19219. if (provider == null)
  19220. throw new ArgumentNullException(nameof(provider));
  19221. if (function == null)
  19222. throw new ArgumentNullException(nameof(function));
  19223. if (scheduler == null)
  19224. throw new ArgumentNullException(nameof(scheduler));
  19225. #if CRIPPLED_REFLECTION
  19226. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>), default(IScheduler)));
  19227. #else
  19228. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19229. #endif
  19230. return (t1) => provider.CreateQuery<TResult>(
  19231. Expression.Invoke(
  19232. Expression.Call(
  19233. null,
  19234. m,
  19235. Expression.Constant(provider, typeof(IQbservableProvider)),
  19236. function,
  19237. Expression.Constant(scheduler, typeof(IScheduler))
  19238. ),
  19239. Expression.Constant(t1, typeof(TArg1))
  19240. )
  19241. );
  19242. }
  19243. /// <summary>
  19244. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19245. /// </summary>
  19246. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19247. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19248. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19249. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19250. /// <param name="function">Function to convert to an asynchronous function.</param>
  19251. /// <returns>Asynchronous function.</returns>
  19252. /// <exception cref="ArgumentNullException">
  19253. /// <paramref name="function" /> is null.</exception>
  19254. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function)
  19255. {
  19256. if (provider == null)
  19257. throw new ArgumentNullException(nameof(provider));
  19258. if (function == null)
  19259. throw new ArgumentNullException(nameof(function));
  19260. #if CRIPPLED_REFLECTION
  19261. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>)));
  19262. #else
  19263. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19264. #endif
  19265. return (t1, t2) => provider.CreateQuery<TResult>(
  19266. Expression.Invoke(
  19267. Expression.Call(
  19268. null,
  19269. m,
  19270. Expression.Constant(provider, typeof(IQbservableProvider)),
  19271. function
  19272. ),
  19273. Expression.Constant(t1, typeof(TArg1)),
  19274. Expression.Constant(t2, typeof(TArg2))
  19275. )
  19276. );
  19277. }
  19278. /// <summary>
  19279. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19280. /// </summary>
  19281. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19282. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19283. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19284. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19285. /// <param name="function">Function to convert to an asynchronous function.</param>
  19286. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19287. /// <returns>Asynchronous function.</returns>
  19288. /// <exception cref="ArgumentNullException">
  19289. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19290. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function, IScheduler scheduler)
  19291. {
  19292. if (provider == null)
  19293. throw new ArgumentNullException(nameof(provider));
  19294. if (function == null)
  19295. throw new ArgumentNullException(nameof(function));
  19296. if (scheduler == null)
  19297. throw new ArgumentNullException(nameof(scheduler));
  19298. #if CRIPPLED_REFLECTION
  19299. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>), default(IScheduler)));
  19300. #else
  19301. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19302. #endif
  19303. return (t1, t2) => provider.CreateQuery<TResult>(
  19304. Expression.Invoke(
  19305. Expression.Call(
  19306. null,
  19307. m,
  19308. Expression.Constant(provider, typeof(IQbservableProvider)),
  19309. function,
  19310. Expression.Constant(scheduler, typeof(IScheduler))
  19311. ),
  19312. Expression.Constant(t1, typeof(TArg1)),
  19313. Expression.Constant(t2, typeof(TArg2))
  19314. )
  19315. );
  19316. }
  19317. /// <summary>
  19318. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19319. /// </summary>
  19320. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19321. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19322. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19323. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19324. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19325. /// <param name="function">Function to convert to an asynchronous function.</param>
  19326. /// <returns>Asynchronous function.</returns>
  19327. /// <exception cref="ArgumentNullException">
  19328. /// <paramref name="function" /> is null.</exception>
  19329. public static Func<TArg1, TArg2, TArg3, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TResult>> function)
  19330. {
  19331. if (provider == null)
  19332. throw new ArgumentNullException(nameof(provider));
  19333. if (function == null)
  19334. throw new ArgumentNullException(nameof(function));
  19335. #if CRIPPLED_REFLECTION
  19336. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>)));
  19337. #else
  19338. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19339. #endif
  19340. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19341. Expression.Invoke(
  19342. Expression.Call(
  19343. null,
  19344. m,
  19345. Expression.Constant(provider, typeof(IQbservableProvider)),
  19346. function
  19347. ),
  19348. Expression.Constant(t1, typeof(TArg1)),
  19349. Expression.Constant(t2, typeof(TArg2)),
  19350. Expression.Constant(t3, typeof(TArg3))
  19351. )
  19352. );
  19353. }
  19354. /// <summary>
  19355. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19356. /// </summary>
  19357. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19358. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19359. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19360. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19361. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19362. /// <param name="function">Function to convert to an asynchronous function.</param>
  19363. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19364. /// <returns>Asynchronous function.</returns>
  19365. /// <exception cref="ArgumentNullException">
  19366. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19367. public static Func<TArg1, TArg2, TArg3, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TResult>> function, IScheduler scheduler)
  19368. {
  19369. if (provider == null)
  19370. throw new ArgumentNullException(nameof(provider));
  19371. if (function == null)
  19372. throw new ArgumentNullException(nameof(function));
  19373. if (scheduler == null)
  19374. throw new ArgumentNullException(nameof(scheduler));
  19375. #if CRIPPLED_REFLECTION
  19376. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>), default(IScheduler)));
  19377. #else
  19378. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19379. #endif
  19380. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19381. Expression.Invoke(
  19382. Expression.Call(
  19383. null,
  19384. m,
  19385. Expression.Constant(provider, typeof(IQbservableProvider)),
  19386. function,
  19387. Expression.Constant(scheduler, typeof(IScheduler))
  19388. ),
  19389. Expression.Constant(t1, typeof(TArg1)),
  19390. Expression.Constant(t2, typeof(TArg2)),
  19391. Expression.Constant(t3, typeof(TArg3))
  19392. )
  19393. );
  19394. }
  19395. /// <summary>
  19396. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19397. /// </summary>
  19398. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19399. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19400. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19401. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19402. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19403. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19404. /// <param name="function">Function to convert to an asynchronous function.</param>
  19405. /// <returns>Asynchronous function.</returns>
  19406. /// <exception cref="ArgumentNullException">
  19407. /// <paramref name="function" /> is null.</exception>
  19408. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>> function)
  19409. {
  19410. if (provider == null)
  19411. throw new ArgumentNullException(nameof(provider));
  19412. if (function == null)
  19413. throw new ArgumentNullException(nameof(function));
  19414. #if CRIPPLED_REFLECTION
  19415. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>)));
  19416. #else
  19417. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19418. #endif
  19419. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19420. Expression.Invoke(
  19421. Expression.Call(
  19422. null,
  19423. m,
  19424. Expression.Constant(provider, typeof(IQbservableProvider)),
  19425. function
  19426. ),
  19427. Expression.Constant(t1, typeof(TArg1)),
  19428. Expression.Constant(t2, typeof(TArg2)),
  19429. Expression.Constant(t3, typeof(TArg3)),
  19430. Expression.Constant(t4, typeof(TArg4))
  19431. )
  19432. );
  19433. }
  19434. /// <summary>
  19435. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19436. /// </summary>
  19437. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19438. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19439. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19440. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19441. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19442. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19443. /// <param name="function">Function to convert to an asynchronous function.</param>
  19444. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19445. /// <returns>Asynchronous function.</returns>
  19446. /// <exception cref="ArgumentNullException">
  19447. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19448. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>> function, IScheduler scheduler)
  19449. {
  19450. if (provider == null)
  19451. throw new ArgumentNullException(nameof(provider));
  19452. if (function == null)
  19453. throw new ArgumentNullException(nameof(function));
  19454. if (scheduler == null)
  19455. throw new ArgumentNullException(nameof(scheduler));
  19456. #if CRIPPLED_REFLECTION
  19457. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>), default(IScheduler)));
  19458. #else
  19459. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19460. #endif
  19461. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19462. Expression.Invoke(
  19463. Expression.Call(
  19464. null,
  19465. m,
  19466. Expression.Constant(provider, typeof(IQbservableProvider)),
  19467. function,
  19468. Expression.Constant(scheduler, typeof(IScheduler))
  19469. ),
  19470. Expression.Constant(t1, typeof(TArg1)),
  19471. Expression.Constant(t2, typeof(TArg2)),
  19472. Expression.Constant(t3, typeof(TArg3)),
  19473. Expression.Constant(t4, typeof(TArg4))
  19474. )
  19475. );
  19476. }
  19477. /// <summary>
  19478. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19479. /// </summary>
  19480. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19481. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19482. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19483. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19484. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19485. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19486. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19487. /// <param name="function">Function to convert to an asynchronous function.</param>
  19488. /// <returns>Asynchronous function.</returns>
  19489. /// <exception cref="ArgumentNullException">
  19490. /// <paramref name="function" /> is null.</exception>
  19491. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>> function)
  19492. {
  19493. if (provider == null)
  19494. throw new ArgumentNullException(nameof(provider));
  19495. if (function == null)
  19496. throw new ArgumentNullException(nameof(function));
  19497. #if CRIPPLED_REFLECTION
  19498. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>)));
  19499. #else
  19500. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19501. #endif
  19502. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19503. Expression.Invoke(
  19504. Expression.Call(
  19505. null,
  19506. m,
  19507. Expression.Constant(provider, typeof(IQbservableProvider)),
  19508. function
  19509. ),
  19510. Expression.Constant(t1, typeof(TArg1)),
  19511. Expression.Constant(t2, typeof(TArg2)),
  19512. Expression.Constant(t3, typeof(TArg3)),
  19513. Expression.Constant(t4, typeof(TArg4)),
  19514. Expression.Constant(t5, typeof(TArg5))
  19515. )
  19516. );
  19517. }
  19518. /// <summary>
  19519. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19520. /// </summary>
  19521. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19522. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19523. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19524. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19525. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19526. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19527. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19528. /// <param name="function">Function to convert to an asynchronous function.</param>
  19529. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19530. /// <returns>Asynchronous function.</returns>
  19531. /// <exception cref="ArgumentNullException">
  19532. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19533. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>> function, IScheduler scheduler)
  19534. {
  19535. if (provider == null)
  19536. throw new ArgumentNullException(nameof(provider));
  19537. if (function == null)
  19538. throw new ArgumentNullException(nameof(function));
  19539. if (scheduler == null)
  19540. throw new ArgumentNullException(nameof(scheduler));
  19541. #if CRIPPLED_REFLECTION
  19542. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>), default(IScheduler)));
  19543. #else
  19544. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19545. #endif
  19546. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19547. Expression.Invoke(
  19548. Expression.Call(
  19549. null,
  19550. m,
  19551. Expression.Constant(provider, typeof(IQbservableProvider)),
  19552. function,
  19553. Expression.Constant(scheduler, typeof(IScheduler))
  19554. ),
  19555. Expression.Constant(t1, typeof(TArg1)),
  19556. Expression.Constant(t2, typeof(TArg2)),
  19557. Expression.Constant(t3, typeof(TArg3)),
  19558. Expression.Constant(t4, typeof(TArg4)),
  19559. Expression.Constant(t5, typeof(TArg5))
  19560. )
  19561. );
  19562. }
  19563. /// <summary>
  19564. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19565. /// </summary>
  19566. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19567. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19568. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19569. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19570. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19571. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19572. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19573. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19574. /// <param name="function">Function to convert to an asynchronous function.</param>
  19575. /// <returns>Asynchronous function.</returns>
  19576. /// <exception cref="ArgumentNullException">
  19577. /// <paramref name="function" /> is null.</exception>
  19578. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>> function)
  19579. {
  19580. if (provider == null)
  19581. throw new ArgumentNullException(nameof(provider));
  19582. if (function == null)
  19583. throw new ArgumentNullException(nameof(function));
  19584. #if CRIPPLED_REFLECTION
  19585. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>>)));
  19586. #else
  19587. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19588. #endif
  19589. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19590. Expression.Invoke(
  19591. Expression.Call(
  19592. null,
  19593. m,
  19594. Expression.Constant(provider, typeof(IQbservableProvider)),
  19595. function
  19596. ),
  19597. Expression.Constant(t1, typeof(TArg1)),
  19598. Expression.Constant(t2, typeof(TArg2)),
  19599. Expression.Constant(t3, typeof(TArg3)),
  19600. Expression.Constant(t4, typeof(TArg4)),
  19601. Expression.Constant(t5, typeof(TArg5)),
  19602. Expression.Constant(t6, typeof(TArg6))
  19603. )
  19604. );
  19605. }
  19606. /// <summary>
  19607. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19608. /// </summary>
  19609. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19610. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19611. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19612. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19613. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19614. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19615. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19616. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19617. /// <param name="function">Function to convert to an asynchronous function.</param>
  19618. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19619. /// <returns>Asynchronous function.</returns>
  19620. /// <exception cref="ArgumentNullException">
  19621. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19622. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>> function, IScheduler scheduler)
  19623. {
  19624. if (provider == null)
  19625. throw new ArgumentNullException(nameof(provider));
  19626. if (function == null)
  19627. throw new ArgumentNullException(nameof(function));
  19628. if (scheduler == null)
  19629. throw new ArgumentNullException(nameof(scheduler));
  19630. #if CRIPPLED_REFLECTION
  19631. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>>), default(IScheduler)));
  19632. #else
  19633. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19634. #endif
  19635. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19636. Expression.Invoke(
  19637. Expression.Call(
  19638. null,
  19639. m,
  19640. Expression.Constant(provider, typeof(IQbservableProvider)),
  19641. function,
  19642. Expression.Constant(scheduler, typeof(IScheduler))
  19643. ),
  19644. Expression.Constant(t1, typeof(TArg1)),
  19645. Expression.Constant(t2, typeof(TArg2)),
  19646. Expression.Constant(t3, typeof(TArg3)),
  19647. Expression.Constant(t4, typeof(TArg4)),
  19648. Expression.Constant(t5, typeof(TArg5)),
  19649. Expression.Constant(t6, typeof(TArg6))
  19650. )
  19651. );
  19652. }
  19653. /// <summary>
  19654. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19655. /// </summary>
  19656. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19657. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19658. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19659. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19660. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19661. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19662. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19663. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19664. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19665. /// <param name="function">Function to convert to an asynchronous function.</param>
  19666. /// <returns>Asynchronous function.</returns>
  19667. /// <exception cref="ArgumentNullException">
  19668. /// <paramref name="function" /> is null.</exception>
  19669. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>> function)
  19670. {
  19671. if (provider == null)
  19672. throw new ArgumentNullException(nameof(provider));
  19673. if (function == null)
  19674. throw new ArgumentNullException(nameof(function));
  19675. #if CRIPPLED_REFLECTION
  19676. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>>)));
  19677. #else
  19678. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19679. #endif
  19680. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19681. Expression.Invoke(
  19682. Expression.Call(
  19683. null,
  19684. m,
  19685. Expression.Constant(provider, typeof(IQbservableProvider)),
  19686. function
  19687. ),
  19688. Expression.Constant(t1, typeof(TArg1)),
  19689. Expression.Constant(t2, typeof(TArg2)),
  19690. Expression.Constant(t3, typeof(TArg3)),
  19691. Expression.Constant(t4, typeof(TArg4)),
  19692. Expression.Constant(t5, typeof(TArg5)),
  19693. Expression.Constant(t6, typeof(TArg6)),
  19694. Expression.Constant(t7, typeof(TArg7))
  19695. )
  19696. );
  19697. }
  19698. /// <summary>
  19699. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19700. /// </summary>
  19701. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19702. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19703. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19704. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19705. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19706. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19707. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19708. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19709. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19710. /// <param name="function">Function to convert to an asynchronous function.</param>
  19711. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19712. /// <returns>Asynchronous function.</returns>
  19713. /// <exception cref="ArgumentNullException">
  19714. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19715. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>> function, IScheduler scheduler)
  19716. {
  19717. if (provider == null)
  19718. throw new ArgumentNullException(nameof(provider));
  19719. if (function == null)
  19720. throw new ArgumentNullException(nameof(function));
  19721. if (scheduler == null)
  19722. throw new ArgumentNullException(nameof(scheduler));
  19723. #if CRIPPLED_REFLECTION
  19724. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>>), default(IScheduler)));
  19725. #else
  19726. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19727. #endif
  19728. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19729. Expression.Invoke(
  19730. Expression.Call(
  19731. null,
  19732. m,
  19733. Expression.Constant(provider, typeof(IQbservableProvider)),
  19734. function,
  19735. Expression.Constant(scheduler, typeof(IScheduler))
  19736. ),
  19737. Expression.Constant(t1, typeof(TArg1)),
  19738. Expression.Constant(t2, typeof(TArg2)),
  19739. Expression.Constant(t3, typeof(TArg3)),
  19740. Expression.Constant(t4, typeof(TArg4)),
  19741. Expression.Constant(t5, typeof(TArg5)),
  19742. Expression.Constant(t6, typeof(TArg6)),
  19743. Expression.Constant(t7, typeof(TArg7))
  19744. )
  19745. );
  19746. }
  19747. /// <summary>
  19748. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19749. /// </summary>
  19750. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19751. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19752. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19753. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19754. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19755. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19756. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19757. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19758. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19759. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19760. /// <param name="function">Function to convert to an asynchronous function.</param>
  19761. /// <returns>Asynchronous function.</returns>
  19762. /// <exception cref="ArgumentNullException">
  19763. /// <paramref name="function" /> is null.</exception>
  19764. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>> function)
  19765. {
  19766. if (provider == null)
  19767. throw new ArgumentNullException(nameof(provider));
  19768. if (function == null)
  19769. throw new ArgumentNullException(nameof(function));
  19770. #if CRIPPLED_REFLECTION
  19771. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>>)));
  19772. #else
  19773. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19774. #endif
  19775. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19776. Expression.Invoke(
  19777. Expression.Call(
  19778. null,
  19779. m,
  19780. Expression.Constant(provider, typeof(IQbservableProvider)),
  19781. function
  19782. ),
  19783. Expression.Constant(t1, typeof(TArg1)),
  19784. Expression.Constant(t2, typeof(TArg2)),
  19785. Expression.Constant(t3, typeof(TArg3)),
  19786. Expression.Constant(t4, typeof(TArg4)),
  19787. Expression.Constant(t5, typeof(TArg5)),
  19788. Expression.Constant(t6, typeof(TArg6)),
  19789. Expression.Constant(t7, typeof(TArg7)),
  19790. Expression.Constant(t8, typeof(TArg8))
  19791. )
  19792. );
  19793. }
  19794. /// <summary>
  19795. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19796. /// </summary>
  19797. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19798. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19799. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19800. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19801. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19802. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19803. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19804. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19805. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19806. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19807. /// <param name="function">Function to convert to an asynchronous function.</param>
  19808. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19809. /// <returns>Asynchronous function.</returns>
  19810. /// <exception cref="ArgumentNullException">
  19811. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19812. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>> function, IScheduler scheduler)
  19813. {
  19814. if (provider == null)
  19815. throw new ArgumentNullException(nameof(provider));
  19816. if (function == null)
  19817. throw new ArgumentNullException(nameof(function));
  19818. if (scheduler == null)
  19819. throw new ArgumentNullException(nameof(scheduler));
  19820. #if CRIPPLED_REFLECTION
  19821. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>>), default(IScheduler)));
  19822. #else
  19823. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19824. #endif
  19825. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19826. Expression.Invoke(
  19827. Expression.Call(
  19828. null,
  19829. m,
  19830. Expression.Constant(provider, typeof(IQbservableProvider)),
  19831. function,
  19832. Expression.Constant(scheduler, typeof(IScheduler))
  19833. ),
  19834. Expression.Constant(t1, typeof(TArg1)),
  19835. Expression.Constant(t2, typeof(TArg2)),
  19836. Expression.Constant(t3, typeof(TArg3)),
  19837. Expression.Constant(t4, typeof(TArg4)),
  19838. Expression.Constant(t5, typeof(TArg5)),
  19839. Expression.Constant(t6, typeof(TArg6)),
  19840. Expression.Constant(t7, typeof(TArg7)),
  19841. Expression.Constant(t8, typeof(TArg8))
  19842. )
  19843. );
  19844. }
  19845. /// <summary>
  19846. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19847. /// </summary>
  19848. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19849. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19850. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19851. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19852. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19853. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19854. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19855. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19856. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19857. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19858. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19859. /// <param name="function">Function to convert to an asynchronous function.</param>
  19860. /// <returns>Asynchronous function.</returns>
  19861. /// <exception cref="ArgumentNullException">
  19862. /// <paramref name="function" /> is null.</exception>
  19863. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>> function)
  19864. {
  19865. if (provider == null)
  19866. throw new ArgumentNullException(nameof(provider));
  19867. if (function == null)
  19868. throw new ArgumentNullException(nameof(function));
  19869. #if CRIPPLED_REFLECTION
  19870. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>>)));
  19871. #else
  19872. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TResult));
  19873. #endif
  19874. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  19875. Expression.Invoke(
  19876. Expression.Call(
  19877. null,
  19878. m,
  19879. Expression.Constant(provider, typeof(IQbservableProvider)),
  19880. function
  19881. ),
  19882. Expression.Constant(t1, typeof(TArg1)),
  19883. Expression.Constant(t2, typeof(TArg2)),
  19884. Expression.Constant(t3, typeof(TArg3)),
  19885. Expression.Constant(t4, typeof(TArg4)),
  19886. Expression.Constant(t5, typeof(TArg5)),
  19887. Expression.Constant(t6, typeof(TArg6)),
  19888. Expression.Constant(t7, typeof(TArg7)),
  19889. Expression.Constant(t8, typeof(TArg8)),
  19890. Expression.Constant(t9, typeof(TArg9))
  19891. )
  19892. );
  19893. }
  19894. /// <summary>
  19895. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19896. /// </summary>
  19897. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19898. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19899. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19900. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19901. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19902. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19903. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19904. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19905. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19906. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19907. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19908. /// <param name="function">Function to convert to an asynchronous function.</param>
  19909. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19910. /// <returns>Asynchronous function.</returns>
  19911. /// <exception cref="ArgumentNullException">
  19912. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19913. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>> function, IScheduler scheduler)
  19914. {
  19915. if (provider == null)
  19916. throw new ArgumentNullException(nameof(provider));
  19917. if (function == null)
  19918. throw new ArgumentNullException(nameof(function));
  19919. if (scheduler == null)
  19920. throw new ArgumentNullException(nameof(scheduler));
  19921. #if CRIPPLED_REFLECTION
  19922. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>>), default(IScheduler)));
  19923. #else
  19924. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TResult));
  19925. #endif
  19926. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  19927. Expression.Invoke(
  19928. Expression.Call(
  19929. null,
  19930. m,
  19931. Expression.Constant(provider, typeof(IQbservableProvider)),
  19932. function,
  19933. Expression.Constant(scheduler, typeof(IScheduler))
  19934. ),
  19935. Expression.Constant(t1, typeof(TArg1)),
  19936. Expression.Constant(t2, typeof(TArg2)),
  19937. Expression.Constant(t3, typeof(TArg3)),
  19938. Expression.Constant(t4, typeof(TArg4)),
  19939. Expression.Constant(t5, typeof(TArg5)),
  19940. Expression.Constant(t6, typeof(TArg6)),
  19941. Expression.Constant(t7, typeof(TArg7)),
  19942. Expression.Constant(t8, typeof(TArg8)),
  19943. Expression.Constant(t9, typeof(TArg9))
  19944. )
  19945. );
  19946. }
  19947. /// <summary>
  19948. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19949. /// </summary>
  19950. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19951. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19952. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19953. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19954. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19955. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19956. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19957. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19958. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19959. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19960. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19961. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19962. /// <param name="function">Function to convert to an asynchronous function.</param>
  19963. /// <returns>Asynchronous function.</returns>
  19964. /// <exception cref="ArgumentNullException">
  19965. /// <paramref name="function" /> is null.</exception>
  19966. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>> function)
  19967. {
  19968. if (provider == null)
  19969. throw new ArgumentNullException(nameof(provider));
  19970. if (function == null)
  19971. throw new ArgumentNullException(nameof(function));
  19972. #if CRIPPLED_REFLECTION
  19973. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>>)));
  19974. #else
  19975. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TResult));
  19976. #endif
  19977. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  19978. Expression.Invoke(
  19979. Expression.Call(
  19980. null,
  19981. m,
  19982. Expression.Constant(provider, typeof(IQbservableProvider)),
  19983. function
  19984. ),
  19985. Expression.Constant(t1, typeof(TArg1)),
  19986. Expression.Constant(t2, typeof(TArg2)),
  19987. Expression.Constant(t3, typeof(TArg3)),
  19988. Expression.Constant(t4, typeof(TArg4)),
  19989. Expression.Constant(t5, typeof(TArg5)),
  19990. Expression.Constant(t6, typeof(TArg6)),
  19991. Expression.Constant(t7, typeof(TArg7)),
  19992. Expression.Constant(t8, typeof(TArg8)),
  19993. Expression.Constant(t9, typeof(TArg9)),
  19994. Expression.Constant(t10, typeof(TArg10))
  19995. )
  19996. );
  19997. }
  19998. /// <summary>
  19999. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  20000. /// </summary>
  20001. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20002. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20003. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20004. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20005. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20006. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20007. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20008. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20009. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20010. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20011. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20012. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20013. /// <param name="function">Function to convert to an asynchronous function.</param>
  20014. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20015. /// <returns>Asynchronous function.</returns>
  20016. /// <exception cref="ArgumentNullException">
  20017. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20018. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>> function, IScheduler scheduler)
  20019. {
  20020. if (provider == null)
  20021. throw new ArgumentNullException(nameof(provider));
  20022. if (function == null)
  20023. throw new ArgumentNullException(nameof(function));
  20024. if (scheduler == null)
  20025. throw new ArgumentNullException(nameof(scheduler));
  20026. #if CRIPPLED_REFLECTION
  20027. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>>), default(IScheduler)));
  20028. #else
  20029. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TResult));
  20030. #endif
  20031. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  20032. Expression.Invoke(
  20033. Expression.Call(
  20034. null,
  20035. m,
  20036. Expression.Constant(provider, typeof(IQbservableProvider)),
  20037. function,
  20038. Expression.Constant(scheduler, typeof(IScheduler))
  20039. ),
  20040. Expression.Constant(t1, typeof(TArg1)),
  20041. Expression.Constant(t2, typeof(TArg2)),
  20042. Expression.Constant(t3, typeof(TArg3)),
  20043. Expression.Constant(t4, typeof(TArg4)),
  20044. Expression.Constant(t5, typeof(TArg5)),
  20045. Expression.Constant(t6, typeof(TArg6)),
  20046. Expression.Constant(t7, typeof(TArg7)),
  20047. Expression.Constant(t8, typeof(TArg8)),
  20048. Expression.Constant(t9, typeof(TArg9)),
  20049. Expression.Constant(t10, typeof(TArg10))
  20050. )
  20051. );
  20052. }
  20053. /// <summary>
  20054. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20055. /// </summary>
  20056. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20057. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20058. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20059. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20060. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20061. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20062. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20063. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20064. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20065. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20066. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20067. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20068. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20069. /// <param name="function">Function to convert to an asynchronous function.</param>
  20070. /// <returns>Asynchronous function.</returns>
  20071. /// <exception cref="ArgumentNullException">
  20072. /// <paramref name="function" /> is null.</exception>
  20073. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>> function)
  20074. {
  20075. if (provider == null)
  20076. throw new ArgumentNullException(nameof(provider));
  20077. if (function == null)
  20078. throw new ArgumentNullException(nameof(function));
  20079. #if CRIPPLED_REFLECTION
  20080. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>>)));
  20081. #else
  20082. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TResult));
  20083. #endif
  20084. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  20085. Expression.Invoke(
  20086. Expression.Call(
  20087. null,
  20088. m,
  20089. Expression.Constant(provider, typeof(IQbservableProvider)),
  20090. function
  20091. ),
  20092. Expression.Constant(t1, typeof(TArg1)),
  20093. Expression.Constant(t2, typeof(TArg2)),
  20094. Expression.Constant(t3, typeof(TArg3)),
  20095. Expression.Constant(t4, typeof(TArg4)),
  20096. Expression.Constant(t5, typeof(TArg5)),
  20097. Expression.Constant(t6, typeof(TArg6)),
  20098. Expression.Constant(t7, typeof(TArg7)),
  20099. Expression.Constant(t8, typeof(TArg8)),
  20100. Expression.Constant(t9, typeof(TArg9)),
  20101. Expression.Constant(t10, typeof(TArg10)),
  20102. Expression.Constant(t11, typeof(TArg11))
  20103. )
  20104. );
  20105. }
  20106. /// <summary>
  20107. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  20108. /// </summary>
  20109. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20110. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20111. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20112. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20113. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20114. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20115. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20116. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20117. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20118. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20119. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20120. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20121. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20122. /// <param name="function">Function to convert to an asynchronous function.</param>
  20123. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20124. /// <returns>Asynchronous function.</returns>
  20125. /// <exception cref="ArgumentNullException">
  20126. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20127. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>> function, IScheduler scheduler)
  20128. {
  20129. if (provider == null)
  20130. throw new ArgumentNullException(nameof(provider));
  20131. if (function == null)
  20132. throw new ArgumentNullException(nameof(function));
  20133. if (scheduler == null)
  20134. throw new ArgumentNullException(nameof(scheduler));
  20135. #if CRIPPLED_REFLECTION
  20136. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>>), default(IScheduler)));
  20137. #else
  20138. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TResult));
  20139. #endif
  20140. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  20141. Expression.Invoke(
  20142. Expression.Call(
  20143. null,
  20144. m,
  20145. Expression.Constant(provider, typeof(IQbservableProvider)),
  20146. function,
  20147. Expression.Constant(scheduler, typeof(IScheduler))
  20148. ),
  20149. Expression.Constant(t1, typeof(TArg1)),
  20150. Expression.Constant(t2, typeof(TArg2)),
  20151. Expression.Constant(t3, typeof(TArg3)),
  20152. Expression.Constant(t4, typeof(TArg4)),
  20153. Expression.Constant(t5, typeof(TArg5)),
  20154. Expression.Constant(t6, typeof(TArg6)),
  20155. Expression.Constant(t7, typeof(TArg7)),
  20156. Expression.Constant(t8, typeof(TArg8)),
  20157. Expression.Constant(t9, typeof(TArg9)),
  20158. Expression.Constant(t10, typeof(TArg10)),
  20159. Expression.Constant(t11, typeof(TArg11))
  20160. )
  20161. );
  20162. }
  20163. /// <summary>
  20164. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20165. /// </summary>
  20166. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20167. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20168. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20169. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20170. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20171. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20172. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20173. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20174. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20175. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20176. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20177. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20178. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20179. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20180. /// <param name="function">Function to convert to an asynchronous function.</param>
  20181. /// <returns>Asynchronous function.</returns>
  20182. /// <exception cref="ArgumentNullException">
  20183. /// <paramref name="function" /> is null.</exception>
  20184. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>> function)
  20185. {
  20186. if (provider == null)
  20187. throw new ArgumentNullException(nameof(provider));
  20188. if (function == null)
  20189. throw new ArgumentNullException(nameof(function));
  20190. #if CRIPPLED_REFLECTION
  20191. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>>)));
  20192. #else
  20193. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TResult));
  20194. #endif
  20195. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20196. Expression.Invoke(
  20197. Expression.Call(
  20198. null,
  20199. m,
  20200. Expression.Constant(provider, typeof(IQbservableProvider)),
  20201. function
  20202. ),
  20203. Expression.Constant(t1, typeof(TArg1)),
  20204. Expression.Constant(t2, typeof(TArg2)),
  20205. Expression.Constant(t3, typeof(TArg3)),
  20206. Expression.Constant(t4, typeof(TArg4)),
  20207. Expression.Constant(t5, typeof(TArg5)),
  20208. Expression.Constant(t6, typeof(TArg6)),
  20209. Expression.Constant(t7, typeof(TArg7)),
  20210. Expression.Constant(t8, typeof(TArg8)),
  20211. Expression.Constant(t9, typeof(TArg9)),
  20212. Expression.Constant(t10, typeof(TArg10)),
  20213. Expression.Constant(t11, typeof(TArg11)),
  20214. Expression.Constant(t12, typeof(TArg12))
  20215. )
  20216. );
  20217. }
  20218. /// <summary>
  20219. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  20220. /// </summary>
  20221. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20222. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20223. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20224. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20225. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20226. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20227. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20228. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20229. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20230. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20231. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20232. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20233. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20234. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20235. /// <param name="function">Function to convert to an asynchronous function.</param>
  20236. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20237. /// <returns>Asynchronous function.</returns>
  20238. /// <exception cref="ArgumentNullException">
  20239. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20240. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>> function, IScheduler scheduler)
  20241. {
  20242. if (provider == null)
  20243. throw new ArgumentNullException(nameof(provider));
  20244. if (function == null)
  20245. throw new ArgumentNullException(nameof(function));
  20246. if (scheduler == null)
  20247. throw new ArgumentNullException(nameof(scheduler));
  20248. #if CRIPPLED_REFLECTION
  20249. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>>), default(IScheduler)));
  20250. #else
  20251. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TResult));
  20252. #endif
  20253. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20254. Expression.Invoke(
  20255. Expression.Call(
  20256. null,
  20257. m,
  20258. Expression.Constant(provider, typeof(IQbservableProvider)),
  20259. function,
  20260. Expression.Constant(scheduler, typeof(IScheduler))
  20261. ),
  20262. Expression.Constant(t1, typeof(TArg1)),
  20263. Expression.Constant(t2, typeof(TArg2)),
  20264. Expression.Constant(t3, typeof(TArg3)),
  20265. Expression.Constant(t4, typeof(TArg4)),
  20266. Expression.Constant(t5, typeof(TArg5)),
  20267. Expression.Constant(t6, typeof(TArg6)),
  20268. Expression.Constant(t7, typeof(TArg7)),
  20269. Expression.Constant(t8, typeof(TArg8)),
  20270. Expression.Constant(t9, typeof(TArg9)),
  20271. Expression.Constant(t10, typeof(TArg10)),
  20272. Expression.Constant(t11, typeof(TArg11)),
  20273. Expression.Constant(t12, typeof(TArg12))
  20274. )
  20275. );
  20276. }
  20277. /// <summary>
  20278. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20279. /// </summary>
  20280. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20281. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20282. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20283. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20284. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20285. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20286. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20287. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20288. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20289. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20290. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20291. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20292. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20293. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20294. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20295. /// <param name="function">Function to convert to an asynchronous function.</param>
  20296. /// <returns>Asynchronous function.</returns>
  20297. /// <exception cref="ArgumentNullException">
  20298. /// <paramref name="function" /> is null.</exception>
  20299. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>> function)
  20300. {
  20301. if (provider == null)
  20302. throw new ArgumentNullException(nameof(provider));
  20303. if (function == null)
  20304. throw new ArgumentNullException(nameof(function));
  20305. #if CRIPPLED_REFLECTION
  20306. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>>)));
  20307. #else
  20308. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TResult));
  20309. #endif
  20310. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20311. Expression.Invoke(
  20312. Expression.Call(
  20313. null,
  20314. m,
  20315. Expression.Constant(provider, typeof(IQbservableProvider)),
  20316. function
  20317. ),
  20318. Expression.Constant(t1, typeof(TArg1)),
  20319. Expression.Constant(t2, typeof(TArg2)),
  20320. Expression.Constant(t3, typeof(TArg3)),
  20321. Expression.Constant(t4, typeof(TArg4)),
  20322. Expression.Constant(t5, typeof(TArg5)),
  20323. Expression.Constant(t6, typeof(TArg6)),
  20324. Expression.Constant(t7, typeof(TArg7)),
  20325. Expression.Constant(t8, typeof(TArg8)),
  20326. Expression.Constant(t9, typeof(TArg9)),
  20327. Expression.Constant(t10, typeof(TArg10)),
  20328. Expression.Constant(t11, typeof(TArg11)),
  20329. Expression.Constant(t12, typeof(TArg12)),
  20330. Expression.Constant(t13, typeof(TArg13))
  20331. )
  20332. );
  20333. }
  20334. /// <summary>
  20335. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  20336. /// </summary>
  20337. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20338. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20339. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20340. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20341. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20342. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20343. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20344. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20345. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20346. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20347. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20348. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20349. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20350. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20351. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20352. /// <param name="function">Function to convert to an asynchronous function.</param>
  20353. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20354. /// <returns>Asynchronous function.</returns>
  20355. /// <exception cref="ArgumentNullException">
  20356. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20357. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>> function, IScheduler scheduler)
  20358. {
  20359. if (provider == null)
  20360. throw new ArgumentNullException(nameof(provider));
  20361. if (function == null)
  20362. throw new ArgumentNullException(nameof(function));
  20363. if (scheduler == null)
  20364. throw new ArgumentNullException(nameof(scheduler));
  20365. #if CRIPPLED_REFLECTION
  20366. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>>), default(IScheduler)));
  20367. #else
  20368. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TResult));
  20369. #endif
  20370. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20371. Expression.Invoke(
  20372. Expression.Call(
  20373. null,
  20374. m,
  20375. Expression.Constant(provider, typeof(IQbservableProvider)),
  20376. function,
  20377. Expression.Constant(scheduler, typeof(IScheduler))
  20378. ),
  20379. Expression.Constant(t1, typeof(TArg1)),
  20380. Expression.Constant(t2, typeof(TArg2)),
  20381. Expression.Constant(t3, typeof(TArg3)),
  20382. Expression.Constant(t4, typeof(TArg4)),
  20383. Expression.Constant(t5, typeof(TArg5)),
  20384. Expression.Constant(t6, typeof(TArg6)),
  20385. Expression.Constant(t7, typeof(TArg7)),
  20386. Expression.Constant(t8, typeof(TArg8)),
  20387. Expression.Constant(t9, typeof(TArg9)),
  20388. Expression.Constant(t10, typeof(TArg10)),
  20389. Expression.Constant(t11, typeof(TArg11)),
  20390. Expression.Constant(t12, typeof(TArg12)),
  20391. Expression.Constant(t13, typeof(TArg13))
  20392. )
  20393. );
  20394. }
  20395. /// <summary>
  20396. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20397. /// </summary>
  20398. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20399. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20400. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20401. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20402. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20403. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20404. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20405. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20406. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20407. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20408. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20409. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20410. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20411. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20412. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20413. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20414. /// <param name="function">Function to convert to an asynchronous function.</param>
  20415. /// <returns>Asynchronous function.</returns>
  20416. /// <exception cref="ArgumentNullException">
  20417. /// <paramref name="function" /> is null.</exception>
  20418. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>> function)
  20419. {
  20420. if (provider == null)
  20421. throw new ArgumentNullException(nameof(provider));
  20422. if (function == null)
  20423. throw new ArgumentNullException(nameof(function));
  20424. #if CRIPPLED_REFLECTION
  20425. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>>)));
  20426. #else
  20427. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TResult));
  20428. #endif
  20429. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20430. Expression.Invoke(
  20431. Expression.Call(
  20432. null,
  20433. m,
  20434. Expression.Constant(provider, typeof(IQbservableProvider)),
  20435. function
  20436. ),
  20437. Expression.Constant(t1, typeof(TArg1)),
  20438. Expression.Constant(t2, typeof(TArg2)),
  20439. Expression.Constant(t3, typeof(TArg3)),
  20440. Expression.Constant(t4, typeof(TArg4)),
  20441. Expression.Constant(t5, typeof(TArg5)),
  20442. Expression.Constant(t6, typeof(TArg6)),
  20443. Expression.Constant(t7, typeof(TArg7)),
  20444. Expression.Constant(t8, typeof(TArg8)),
  20445. Expression.Constant(t9, typeof(TArg9)),
  20446. Expression.Constant(t10, typeof(TArg10)),
  20447. Expression.Constant(t11, typeof(TArg11)),
  20448. Expression.Constant(t12, typeof(TArg12)),
  20449. Expression.Constant(t13, typeof(TArg13)),
  20450. Expression.Constant(t14, typeof(TArg14))
  20451. )
  20452. );
  20453. }
  20454. /// <summary>
  20455. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  20456. /// </summary>
  20457. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20458. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20459. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20460. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20461. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20462. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20463. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20464. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20465. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20466. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20467. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20468. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20469. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20470. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20471. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20472. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20473. /// <param name="function">Function to convert to an asynchronous function.</param>
  20474. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20475. /// <returns>Asynchronous function.</returns>
  20476. /// <exception cref="ArgumentNullException">
  20477. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20478. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>> function, IScheduler scheduler)
  20479. {
  20480. if (provider == null)
  20481. throw new ArgumentNullException(nameof(provider));
  20482. if (function == null)
  20483. throw new ArgumentNullException(nameof(function));
  20484. if (scheduler == null)
  20485. throw new ArgumentNullException(nameof(scheduler));
  20486. #if CRIPPLED_REFLECTION
  20487. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>>), default(IScheduler)));
  20488. #else
  20489. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TResult));
  20490. #endif
  20491. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20492. Expression.Invoke(
  20493. Expression.Call(
  20494. null,
  20495. m,
  20496. Expression.Constant(provider, typeof(IQbservableProvider)),
  20497. function,
  20498. Expression.Constant(scheduler, typeof(IScheduler))
  20499. ),
  20500. Expression.Constant(t1, typeof(TArg1)),
  20501. Expression.Constant(t2, typeof(TArg2)),
  20502. Expression.Constant(t3, typeof(TArg3)),
  20503. Expression.Constant(t4, typeof(TArg4)),
  20504. Expression.Constant(t5, typeof(TArg5)),
  20505. Expression.Constant(t6, typeof(TArg6)),
  20506. Expression.Constant(t7, typeof(TArg7)),
  20507. Expression.Constant(t8, typeof(TArg8)),
  20508. Expression.Constant(t9, typeof(TArg9)),
  20509. Expression.Constant(t10, typeof(TArg10)),
  20510. Expression.Constant(t11, typeof(TArg11)),
  20511. Expression.Constant(t12, typeof(TArg12)),
  20512. Expression.Constant(t13, typeof(TArg13)),
  20513. Expression.Constant(t14, typeof(TArg14))
  20514. )
  20515. );
  20516. }
  20517. /// <summary>
  20518. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20519. /// </summary>
  20520. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20521. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20522. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20523. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20524. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20525. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20526. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20527. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20528. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20529. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20530. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20531. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20532. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20533. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20534. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20535. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20536. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20537. /// <param name="function">Function to convert to an asynchronous function.</param>
  20538. /// <returns>Asynchronous function.</returns>
  20539. /// <exception cref="ArgumentNullException">
  20540. /// <paramref name="function" /> is null.</exception>
  20541. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult>> function)
  20542. {
  20543. if (provider == null)
  20544. throw new ArgumentNullException(nameof(provider));
  20545. if (function == null)
  20546. throw new ArgumentNullException(nameof(function));
  20547. #if CRIPPLED_REFLECTION
  20548. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult>>)));
  20549. #else
  20550. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TArg15), typeof(TResult));
  20551. #endif
  20552. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20553. Expression.Invoke(
  20554. Expression.Call(
  20555. null,
  20556. m,
  20557. Expression.Constant(provider, typeof(IQbservableProvider)),
  20558. function
  20559. ),
  20560. Expression.Constant(t1, typeof(TArg1)),
  20561. Expression.Constant(t2, typeof(TArg2)),
  20562. Expression.Constant(t3, typeof(TArg3)),
  20563. Expression.Constant(t4, typeof(TArg4)),
  20564. Expression.Constant(t5, typeof(TArg5)),
  20565. Expression.Constant(t6, typeof(TArg6)),
  20566. Expression.Constant(t7, typeof(TArg7)),
  20567. Expression.Constant(t8, typeof(TArg8)),
  20568. Expression.Constant(t9, typeof(TArg9)),
  20569. Expression.Constant(t10, typeof(TArg10)),
  20570. Expression.Constant(t11, typeof(TArg11)),
  20571. Expression.Constant(t12, typeof(TArg12)),
  20572. Expression.Constant(t13, typeof(TArg13)),
  20573. Expression.Constant(t14, typeof(TArg14)),
  20574. Expression.Constant(t15, typeof(TArg15))
  20575. )
  20576. );
  20577. }
  20578. /// <summary>
  20579. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  20580. /// </summary>
  20581. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20582. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20583. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20584. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20585. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20586. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20587. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20588. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20589. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20590. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20591. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20592. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20593. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20594. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20595. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20596. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20597. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20598. /// <param name="function">Function to convert to an asynchronous function.</param>
  20599. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20600. /// <returns>Asynchronous function.</returns>
  20601. /// <exception cref="ArgumentNullException">
  20602. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20603. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult>> function, IScheduler scheduler)
  20604. {
  20605. if (provider == null)
  20606. throw new ArgumentNullException(nameof(provider));
  20607. if (function == null)
  20608. throw new ArgumentNullException(nameof(function));
  20609. if (scheduler == null)
  20610. throw new ArgumentNullException(nameof(scheduler));
  20611. #if CRIPPLED_REFLECTION
  20612. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TResult>>), default(IScheduler)));
  20613. #else
  20614. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TArg15), typeof(TResult));
  20615. #endif
  20616. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20617. Expression.Invoke(
  20618. Expression.Call(
  20619. null,
  20620. m,
  20621. Expression.Constant(provider, typeof(IQbservableProvider)),
  20622. function,
  20623. Expression.Constant(scheduler, typeof(IScheduler))
  20624. ),
  20625. Expression.Constant(t1, typeof(TArg1)),
  20626. Expression.Constant(t2, typeof(TArg2)),
  20627. Expression.Constant(t3, typeof(TArg3)),
  20628. Expression.Constant(t4, typeof(TArg4)),
  20629. Expression.Constant(t5, typeof(TArg5)),
  20630. Expression.Constant(t6, typeof(TArg6)),
  20631. Expression.Constant(t7, typeof(TArg7)),
  20632. Expression.Constant(t8, typeof(TArg8)),
  20633. Expression.Constant(t9, typeof(TArg9)),
  20634. Expression.Constant(t10, typeof(TArg10)),
  20635. Expression.Constant(t11, typeof(TArg11)),
  20636. Expression.Constant(t12, typeof(TArg12)),
  20637. Expression.Constant(t13, typeof(TArg13)),
  20638. Expression.Constant(t14, typeof(TArg14)),
  20639. Expression.Constant(t15, typeof(TArg15))
  20640. )
  20641. );
  20642. }
  20643. /// <summary>
  20644. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20645. /// </summary>
  20646. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20647. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20648. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20649. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20650. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20651. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20652. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20653. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20654. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20655. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20656. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20657. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20658. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20659. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20660. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20661. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20662. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20663. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20664. /// <param name="function">Function to convert to an asynchronous function.</param>
  20665. /// <returns>Asynchronous function.</returns>
  20666. /// <exception cref="ArgumentNullException">
  20667. /// <paramref name="function" /> is null.</exception>
  20668. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>> function)
  20669. {
  20670. if (provider == null)
  20671. throw new ArgumentNullException(nameof(provider));
  20672. if (function == null)
  20673. throw new ArgumentNullException(nameof(function));
  20674. #if CRIPPLED_REFLECTION
  20675. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>>)));
  20676. #else
  20677. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TArg15), typeof(TArg16), typeof(TResult));
  20678. #endif
  20679. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20680. Expression.Invoke(
  20681. Expression.Call(
  20682. null,
  20683. m,
  20684. Expression.Constant(provider, typeof(IQbservableProvider)),
  20685. function
  20686. ),
  20687. Expression.Constant(t1, typeof(TArg1)),
  20688. Expression.Constant(t2, typeof(TArg2)),
  20689. Expression.Constant(t3, typeof(TArg3)),
  20690. Expression.Constant(t4, typeof(TArg4)),
  20691. Expression.Constant(t5, typeof(TArg5)),
  20692. Expression.Constant(t6, typeof(TArg6)),
  20693. Expression.Constant(t7, typeof(TArg7)),
  20694. Expression.Constant(t8, typeof(TArg8)),
  20695. Expression.Constant(t9, typeof(TArg9)),
  20696. Expression.Constant(t10, typeof(TArg10)),
  20697. Expression.Constant(t11, typeof(TArg11)),
  20698. Expression.Constant(t12, typeof(TArg12)),
  20699. Expression.Constant(t13, typeof(TArg13)),
  20700. Expression.Constant(t14, typeof(TArg14)),
  20701. Expression.Constant(t15, typeof(TArg15)),
  20702. Expression.Constant(t16, typeof(TArg16))
  20703. )
  20704. );
  20705. }
  20706. /// <summary>
  20707. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  20708. /// </summary>
  20709. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20710. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20711. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20712. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20713. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20714. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20715. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20716. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20717. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20718. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20719. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20720. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20721. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20722. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20723. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20724. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20725. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20726. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20727. /// <param name="function">Function to convert to an asynchronous function.</param>
  20728. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20729. /// <returns>Asynchronous function.</returns>
  20730. /// <exception cref="ArgumentNullException">
  20731. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20732. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>> function, IScheduler scheduler)
  20733. {
  20734. if (provider == null)
  20735. throw new ArgumentNullException(nameof(provider));
  20736. if (function == null)
  20737. throw new ArgumentNullException(nameof(function));
  20738. if (scheduler == null)
  20739. throw new ArgumentNullException(nameof(scheduler));
  20740. #if CRIPPLED_REFLECTION
  20741. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TArg15, TArg16, TResult>>), default(IScheduler)));
  20742. #else
  20743. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TArg15), typeof(TArg16), typeof(TResult));
  20744. #endif
  20745. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20746. Expression.Invoke(
  20747. Expression.Call(
  20748. null,
  20749. m,
  20750. Expression.Constant(provider, typeof(IQbservableProvider)),
  20751. function,
  20752. Expression.Constant(scheduler, typeof(IScheduler))
  20753. ),
  20754. Expression.Constant(t1, typeof(TArg1)),
  20755. Expression.Constant(t2, typeof(TArg2)),
  20756. Expression.Constant(t3, typeof(TArg3)),
  20757. Expression.Constant(t4, typeof(TArg4)),
  20758. Expression.Constant(t5, typeof(TArg5)),
  20759. Expression.Constant(t6, typeof(TArg6)),
  20760. Expression.Constant(t7, typeof(TArg7)),
  20761. Expression.Constant(t8, typeof(TArg8)),
  20762. Expression.Constant(t9, typeof(TArg9)),
  20763. Expression.Constant(t10, typeof(TArg10)),
  20764. Expression.Constant(t11, typeof(TArg11)),
  20765. Expression.Constant(t12, typeof(TArg12)),
  20766. Expression.Constant(t13, typeof(TArg13)),
  20767. Expression.Constant(t14, typeof(TArg14)),
  20768. Expression.Constant(t15, typeof(TArg15)),
  20769. Expression.Constant(t16, typeof(TArg16))
  20770. )
  20771. );
  20772. }
  20773. /// <summary>
  20774. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20775. /// </summary>
  20776. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20777. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20778. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20779. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  20780. /// <exception cref="ArgumentNullException">
  20781. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20782. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  20783. #if PREFERASYNC
  20784. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20785. #endif
  20786. public static Func<IQbservable<Unit>> FromAsyncPattern(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  20787. {
  20788. if (provider == null)
  20789. throw new ArgumentNullException(nameof(provider));
  20790. if (begin == null)
  20791. throw new ArgumentNullException(nameof(begin));
  20792. if (end == null)
  20793. throw new ArgumentNullException(nameof(end));
  20794. #if CRIPPLED_REFLECTION
  20795. var m = InfoOf(() => Qbservable.FromAsyncPattern(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20796. #else
  20797. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  20798. #endif
  20799. return () => provider.CreateQuery<Unit>(
  20800. Expression.Invoke(
  20801. Expression.Call(
  20802. null,
  20803. m,
  20804. Expression.Constant(provider, typeof(IQbservableProvider)),
  20805. begin,
  20806. end
  20807. )
  20808. )
  20809. );
  20810. }
  20811. /// <summary>
  20812. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20813. /// </summary>
  20814. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20815. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20816. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20817. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20818. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  20819. /// <exception cref="ArgumentNullException">
  20820. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20821. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  20822. #if PREFERASYNC
  20823. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20824. #endif
  20825. public static Func<TArg1, IQbservable<Unit>> FromAsyncPattern<TArg1>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  20826. {
  20827. if (provider == null)
  20828. throw new ArgumentNullException(nameof(provider));
  20829. if (begin == null)
  20830. throw new ArgumentNullException(nameof(begin));
  20831. if (end == null)
  20832. throw new ArgumentNullException(nameof(end));
  20833. #if CRIPPLED_REFLECTION
  20834. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20835. #else
  20836. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  20837. #endif
  20838. return (t1) => provider.CreateQuery<Unit>(
  20839. Expression.Invoke(
  20840. Expression.Call(
  20841. null,
  20842. m,
  20843. Expression.Constant(provider, typeof(IQbservableProvider)),
  20844. begin,
  20845. end
  20846. ),
  20847. Expression.Constant(t1, typeof(TArg1))
  20848. )
  20849. );
  20850. }
  20851. /// <summary>
  20852. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20853. /// </summary>
  20854. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20855. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20856. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20857. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20858. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20859. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  20860. /// <exception cref="ArgumentNullException">
  20861. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20862. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  20863. #if PREFERASYNC
  20864. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20865. #endif
  20866. public static Func<TArg1, TArg2, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  20867. {
  20868. if (provider == null)
  20869. throw new ArgumentNullException(nameof(provider));
  20870. if (begin == null)
  20871. throw new ArgumentNullException(nameof(begin));
  20872. if (end == null)
  20873. throw new ArgumentNullException(nameof(end));
  20874. #if CRIPPLED_REFLECTION
  20875. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20876. #else
  20877. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  20878. #endif
  20879. return (t1, t2) => provider.CreateQuery<Unit>(
  20880. Expression.Invoke(
  20881. Expression.Call(
  20882. null,
  20883. m,
  20884. Expression.Constant(provider, typeof(IQbservableProvider)),
  20885. begin,
  20886. end
  20887. ),
  20888. Expression.Constant(t1, typeof(TArg1)),
  20889. Expression.Constant(t2, typeof(TArg2))
  20890. )
  20891. );
  20892. }
  20893. /// <summary>
  20894. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20895. /// </summary>
  20896. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20897. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20898. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20899. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20900. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20901. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20902. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  20903. /// <exception cref="ArgumentNullException">
  20904. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20905. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  20906. #if PREFERASYNC
  20907. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20908. #endif
  20909. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  20910. {
  20911. if (provider == null)
  20912. throw new ArgumentNullException(nameof(provider));
  20913. if (begin == null)
  20914. throw new ArgumentNullException(nameof(begin));
  20915. if (end == null)
  20916. throw new ArgumentNullException(nameof(end));
  20917. #if CRIPPLED_REFLECTION
  20918. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20919. #else
  20920. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  20921. #endif
  20922. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  20923. Expression.Invoke(
  20924. Expression.Call(
  20925. null,
  20926. m,
  20927. Expression.Constant(provider, typeof(IQbservableProvider)),
  20928. begin,
  20929. end
  20930. ),
  20931. Expression.Constant(t1, typeof(TArg1)),
  20932. Expression.Constant(t2, typeof(TArg2)),
  20933. Expression.Constant(t3, typeof(TArg3))
  20934. )
  20935. );
  20936. }
  20937. /// <summary>
  20938. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20939. /// </summary>
  20940. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20941. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20942. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20943. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20944. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20945. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20946. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20947. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  20948. /// <exception cref="ArgumentNullException">
  20949. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20950. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  20951. #if PREFERASYNC
  20952. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20953. #endif
  20954. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  20955. {
  20956. if (provider == null)
  20957. throw new ArgumentNullException(nameof(provider));
  20958. if (begin == null)
  20959. throw new ArgumentNullException(nameof(begin));
  20960. if (end == null)
  20961. throw new ArgumentNullException(nameof(end));
  20962. #if CRIPPLED_REFLECTION
  20963. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20964. #else
  20965. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  20966. #endif
  20967. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  20968. Expression.Invoke(
  20969. Expression.Call(
  20970. null,
  20971. m,
  20972. Expression.Constant(provider, typeof(IQbservableProvider)),
  20973. begin,
  20974. end
  20975. ),
  20976. Expression.Constant(t1, typeof(TArg1)),
  20977. Expression.Constant(t2, typeof(TArg2)),
  20978. Expression.Constant(t3, typeof(TArg3)),
  20979. Expression.Constant(t4, typeof(TArg4))
  20980. )
  20981. );
  20982. }
  20983. /// <summary>
  20984. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20985. /// </summary>
  20986. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20987. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20988. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20989. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20990. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20991. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20992. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20993. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20994. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  20995. /// <exception cref="ArgumentNullException">
  20996. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20997. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  20998. #if PREFERASYNC
  20999. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21000. #endif
  21001. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  21002. {
  21003. if (provider == null)
  21004. throw new ArgumentNullException(nameof(provider));
  21005. if (begin == null)
  21006. throw new ArgumentNullException(nameof(begin));
  21007. if (end == null)
  21008. throw new ArgumentNullException(nameof(end));
  21009. #if CRIPPLED_REFLECTION
  21010. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21011. #else
  21012. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  21013. #endif
  21014. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  21015. Expression.Invoke(
  21016. Expression.Call(
  21017. null,
  21018. m,
  21019. Expression.Constant(provider, typeof(IQbservableProvider)),
  21020. begin,
  21021. end
  21022. ),
  21023. Expression.Constant(t1, typeof(TArg1)),
  21024. Expression.Constant(t2, typeof(TArg2)),
  21025. Expression.Constant(t3, typeof(TArg3)),
  21026. Expression.Constant(t4, typeof(TArg4)),
  21027. Expression.Constant(t5, typeof(TArg5))
  21028. )
  21029. );
  21030. }
  21031. /// <summary>
  21032. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21033. /// </summary>
  21034. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21035. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21036. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21037. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21038. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21039. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21040. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21041. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21042. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21043. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  21044. /// <exception cref="ArgumentNullException">
  21045. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21046. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21047. #if PREFERASYNC
  21048. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21049. #endif
  21050. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  21051. {
  21052. if (provider == null)
  21053. throw new ArgumentNullException(nameof(provider));
  21054. if (begin == null)
  21055. throw new ArgumentNullException(nameof(begin));
  21056. if (end == null)
  21057. throw new ArgumentNullException(nameof(end));
  21058. #if CRIPPLED_REFLECTION
  21059. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21060. #else
  21061. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  21062. #endif
  21063. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  21064. Expression.Invoke(
  21065. Expression.Call(
  21066. null,
  21067. m,
  21068. Expression.Constant(provider, typeof(IQbservableProvider)),
  21069. begin,
  21070. end
  21071. ),
  21072. Expression.Constant(t1, typeof(TArg1)),
  21073. Expression.Constant(t2, typeof(TArg2)),
  21074. Expression.Constant(t3, typeof(TArg3)),
  21075. Expression.Constant(t4, typeof(TArg4)),
  21076. Expression.Constant(t5, typeof(TArg5)),
  21077. Expression.Constant(t6, typeof(TArg6))
  21078. )
  21079. );
  21080. }
  21081. /// <summary>
  21082. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21083. /// </summary>
  21084. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21085. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21086. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21087. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21088. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21089. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21090. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21091. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21092. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21093. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21094. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  21095. /// <exception cref="ArgumentNullException">
  21096. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21097. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21098. #if PREFERASYNC
  21099. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21100. #endif
  21101. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  21102. {
  21103. if (provider == null)
  21104. throw new ArgumentNullException(nameof(provider));
  21105. if (begin == null)
  21106. throw new ArgumentNullException(nameof(begin));
  21107. if (end == null)
  21108. throw new ArgumentNullException(nameof(end));
  21109. #if CRIPPLED_REFLECTION
  21110. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21111. #else
  21112. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  21113. #endif
  21114. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  21115. Expression.Invoke(
  21116. Expression.Call(
  21117. null,
  21118. m,
  21119. Expression.Constant(provider, typeof(IQbservableProvider)),
  21120. begin,
  21121. end
  21122. ),
  21123. Expression.Constant(t1, typeof(TArg1)),
  21124. Expression.Constant(t2, typeof(TArg2)),
  21125. Expression.Constant(t3, typeof(TArg3)),
  21126. Expression.Constant(t4, typeof(TArg4)),
  21127. Expression.Constant(t5, typeof(TArg5)),
  21128. Expression.Constant(t6, typeof(TArg6)),
  21129. Expression.Constant(t7, typeof(TArg7))
  21130. )
  21131. );
  21132. }
  21133. /// <summary>
  21134. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21135. /// </summary>
  21136. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21137. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21138. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21139. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21140. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21141. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21142. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21143. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21144. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21145. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21146. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21147. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  21148. /// <exception cref="ArgumentNullException">
  21149. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21150. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21151. #if PREFERASYNC
  21152. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21153. #endif
  21154. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  21155. {
  21156. if (provider == null)
  21157. throw new ArgumentNullException(nameof(provider));
  21158. if (begin == null)
  21159. throw new ArgumentNullException(nameof(begin));
  21160. if (end == null)
  21161. throw new ArgumentNullException(nameof(end));
  21162. #if CRIPPLED_REFLECTION
  21163. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21164. #else
  21165. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  21166. #endif
  21167. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  21168. Expression.Invoke(
  21169. Expression.Call(
  21170. null,
  21171. m,
  21172. Expression.Constant(provider, typeof(IQbservableProvider)),
  21173. begin,
  21174. end
  21175. ),
  21176. Expression.Constant(t1, typeof(TArg1)),
  21177. Expression.Constant(t2, typeof(TArg2)),
  21178. Expression.Constant(t3, typeof(TArg3)),
  21179. Expression.Constant(t4, typeof(TArg4)),
  21180. Expression.Constant(t5, typeof(TArg5)),
  21181. Expression.Constant(t6, typeof(TArg6)),
  21182. Expression.Constant(t7, typeof(TArg7)),
  21183. Expression.Constant(t8, typeof(TArg8))
  21184. )
  21185. );
  21186. }
  21187. /// <summary>
  21188. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21189. /// </summary>
  21190. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21191. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21192. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21193. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21194. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21195. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21196. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21197. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21198. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21199. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21200. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21201. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21202. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  21203. /// <exception cref="ArgumentNullException">
  21204. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21205. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21206. #if PREFERASYNC
  21207. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21208. #endif
  21209. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  21210. {
  21211. if (provider == null)
  21212. throw new ArgumentNullException(nameof(provider));
  21213. if (begin == null)
  21214. throw new ArgumentNullException(nameof(begin));
  21215. if (end == null)
  21216. throw new ArgumentNullException(nameof(end));
  21217. #if CRIPPLED_REFLECTION
  21218. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21219. #else
  21220. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  21221. #endif
  21222. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  21223. Expression.Invoke(
  21224. Expression.Call(
  21225. null,
  21226. m,
  21227. Expression.Constant(provider, typeof(IQbservableProvider)),
  21228. begin,
  21229. end
  21230. ),
  21231. Expression.Constant(t1, typeof(TArg1)),
  21232. Expression.Constant(t2, typeof(TArg2)),
  21233. Expression.Constant(t3, typeof(TArg3)),
  21234. Expression.Constant(t4, typeof(TArg4)),
  21235. Expression.Constant(t5, typeof(TArg5)),
  21236. Expression.Constant(t6, typeof(TArg6)),
  21237. Expression.Constant(t7, typeof(TArg7)),
  21238. Expression.Constant(t8, typeof(TArg8)),
  21239. Expression.Constant(t9, typeof(TArg9))
  21240. )
  21241. );
  21242. }
  21243. /// <summary>
  21244. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21245. /// </summary>
  21246. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21247. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21248. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21249. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21250. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21251. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21252. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21253. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21254. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21255. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21256. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21257. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21258. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21259. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  21260. /// <exception cref="ArgumentNullException">
  21261. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21262. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21263. #if PREFERASYNC
  21264. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21265. #endif
  21266. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  21267. {
  21268. if (provider == null)
  21269. throw new ArgumentNullException(nameof(provider));
  21270. if (begin == null)
  21271. throw new ArgumentNullException(nameof(begin));
  21272. if (end == null)
  21273. throw new ArgumentNullException(nameof(end));
  21274. #if CRIPPLED_REFLECTION
  21275. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21276. #else
  21277. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10));
  21278. #endif
  21279. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  21280. Expression.Invoke(
  21281. Expression.Call(
  21282. null,
  21283. m,
  21284. Expression.Constant(provider, typeof(IQbservableProvider)),
  21285. begin,
  21286. end
  21287. ),
  21288. Expression.Constant(t1, typeof(TArg1)),
  21289. Expression.Constant(t2, typeof(TArg2)),
  21290. Expression.Constant(t3, typeof(TArg3)),
  21291. Expression.Constant(t4, typeof(TArg4)),
  21292. Expression.Constant(t5, typeof(TArg5)),
  21293. Expression.Constant(t6, typeof(TArg6)),
  21294. Expression.Constant(t7, typeof(TArg7)),
  21295. Expression.Constant(t8, typeof(TArg8)),
  21296. Expression.Constant(t9, typeof(TArg9)),
  21297. Expression.Constant(t10, typeof(TArg10))
  21298. )
  21299. );
  21300. }
  21301. /// <summary>
  21302. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21303. /// </summary>
  21304. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21305. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21306. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21307. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21308. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21309. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21310. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21311. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21312. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21313. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21314. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21315. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21316. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21317. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21318. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  21319. /// <exception cref="ArgumentNullException">
  21320. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21321. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21322. #if PREFERASYNC
  21323. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21324. #endif
  21325. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  21326. {
  21327. if (provider == null)
  21328. throw new ArgumentNullException(nameof(provider));
  21329. if (begin == null)
  21330. throw new ArgumentNullException(nameof(begin));
  21331. if (end == null)
  21332. throw new ArgumentNullException(nameof(end));
  21333. #if CRIPPLED_REFLECTION
  21334. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21335. #else
  21336. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11));
  21337. #endif
  21338. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  21339. Expression.Invoke(
  21340. Expression.Call(
  21341. null,
  21342. m,
  21343. Expression.Constant(provider, typeof(IQbservableProvider)),
  21344. begin,
  21345. end
  21346. ),
  21347. Expression.Constant(t1, typeof(TArg1)),
  21348. Expression.Constant(t2, typeof(TArg2)),
  21349. Expression.Constant(t3, typeof(TArg3)),
  21350. Expression.Constant(t4, typeof(TArg4)),
  21351. Expression.Constant(t5, typeof(TArg5)),
  21352. Expression.Constant(t6, typeof(TArg6)),
  21353. Expression.Constant(t7, typeof(TArg7)),
  21354. Expression.Constant(t8, typeof(TArg8)),
  21355. Expression.Constant(t9, typeof(TArg9)),
  21356. Expression.Constant(t10, typeof(TArg10)),
  21357. Expression.Constant(t11, typeof(TArg11))
  21358. )
  21359. );
  21360. }
  21361. /// <summary>
  21362. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21363. /// </summary>
  21364. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21365. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21366. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21367. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21368. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21369. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21370. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21371. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21372. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21373. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21374. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21375. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21376. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21377. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21378. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21379. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  21380. /// <exception cref="ArgumentNullException">
  21381. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21382. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21383. #if PREFERASYNC
  21384. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21385. #endif
  21386. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  21387. {
  21388. if (provider == null)
  21389. throw new ArgumentNullException(nameof(provider));
  21390. if (begin == null)
  21391. throw new ArgumentNullException(nameof(begin));
  21392. if (end == null)
  21393. throw new ArgumentNullException(nameof(end));
  21394. #if CRIPPLED_REFLECTION
  21395. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21396. #else
  21397. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12));
  21398. #endif
  21399. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  21400. Expression.Invoke(
  21401. Expression.Call(
  21402. null,
  21403. m,
  21404. Expression.Constant(provider, typeof(IQbservableProvider)),
  21405. begin,
  21406. end
  21407. ),
  21408. Expression.Constant(t1, typeof(TArg1)),
  21409. Expression.Constant(t2, typeof(TArg2)),
  21410. Expression.Constant(t3, typeof(TArg3)),
  21411. Expression.Constant(t4, typeof(TArg4)),
  21412. Expression.Constant(t5, typeof(TArg5)),
  21413. Expression.Constant(t6, typeof(TArg6)),
  21414. Expression.Constant(t7, typeof(TArg7)),
  21415. Expression.Constant(t8, typeof(TArg8)),
  21416. Expression.Constant(t9, typeof(TArg9)),
  21417. Expression.Constant(t10, typeof(TArg10)),
  21418. Expression.Constant(t11, typeof(TArg11)),
  21419. Expression.Constant(t12, typeof(TArg12))
  21420. )
  21421. );
  21422. }
  21423. /// <summary>
  21424. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21425. /// </summary>
  21426. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21427. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21428. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21429. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21430. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21431. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21432. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21433. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21434. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21435. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21436. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21437. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21438. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21439. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21440. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21441. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21442. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  21443. /// <exception cref="ArgumentNullException">
  21444. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21445. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21446. #if PREFERASYNC
  21447. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21448. #endif
  21449. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  21450. {
  21451. if (provider == null)
  21452. throw new ArgumentNullException(nameof(provider));
  21453. if (begin == null)
  21454. throw new ArgumentNullException(nameof(begin));
  21455. if (end == null)
  21456. throw new ArgumentNullException(nameof(end));
  21457. #if CRIPPLED_REFLECTION
  21458. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21459. #else
  21460. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13));
  21461. #endif
  21462. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  21463. Expression.Invoke(
  21464. Expression.Call(
  21465. null,
  21466. m,
  21467. Expression.Constant(provider, typeof(IQbservableProvider)),
  21468. begin,
  21469. end
  21470. ),
  21471. Expression.Constant(t1, typeof(TArg1)),
  21472. Expression.Constant(t2, typeof(TArg2)),
  21473. Expression.Constant(t3, typeof(TArg3)),
  21474. Expression.Constant(t4, typeof(TArg4)),
  21475. Expression.Constant(t5, typeof(TArg5)),
  21476. Expression.Constant(t6, typeof(TArg6)),
  21477. Expression.Constant(t7, typeof(TArg7)),
  21478. Expression.Constant(t8, typeof(TArg8)),
  21479. Expression.Constant(t9, typeof(TArg9)),
  21480. Expression.Constant(t10, typeof(TArg10)),
  21481. Expression.Constant(t11, typeof(TArg11)),
  21482. Expression.Constant(t12, typeof(TArg12)),
  21483. Expression.Constant(t13, typeof(TArg13))
  21484. )
  21485. );
  21486. }
  21487. /// <summary>
  21488. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21489. /// </summary>
  21490. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21491. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21492. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21493. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21494. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21495. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21496. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21497. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21498. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21499. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21500. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21501. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21502. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21503. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21504. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  21505. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21506. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21507. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result (represented as a Unit value) as an observable sequence.</returns>
  21508. /// <exception cref="ArgumentNullException">
  21509. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21510. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21511. #if PREFERASYNC
  21512. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21513. #endif
  21514. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  21515. {
  21516. if (provider == null)
  21517. throw new ArgumentNullException(nameof(provider));
  21518. if (begin == null)
  21519. throw new ArgumentNullException(nameof(begin));
  21520. if (end == null)
  21521. throw new ArgumentNullException(nameof(end));
  21522. #if CRIPPLED_REFLECTION
  21523. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21524. #else
  21525. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14));
  21526. #endif
  21527. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  21528. Expression.Invoke(
  21529. Expression.Call(
  21530. null,
  21531. m,
  21532. Expression.Constant(provider, typeof(IQbservableProvider)),
  21533. begin,
  21534. end
  21535. ),
  21536. Expression.Constant(t1, typeof(TArg1)),
  21537. Expression.Constant(t2, typeof(TArg2)),
  21538. Expression.Constant(t3, typeof(TArg3)),
  21539. Expression.Constant(t4, typeof(TArg4)),
  21540. Expression.Constant(t5, typeof(TArg5)),
  21541. Expression.Constant(t6, typeof(TArg6)),
  21542. Expression.Constant(t7, typeof(TArg7)),
  21543. Expression.Constant(t8, typeof(TArg8)),
  21544. Expression.Constant(t9, typeof(TArg9)),
  21545. Expression.Constant(t10, typeof(TArg10)),
  21546. Expression.Constant(t11, typeof(TArg11)),
  21547. Expression.Constant(t12, typeof(TArg12)),
  21548. Expression.Constant(t13, typeof(TArg13)),
  21549. Expression.Constant(t14, typeof(TArg14))
  21550. )
  21551. );
  21552. }
  21553. /// <summary>
  21554. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21555. /// </summary>
  21556. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21557. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21558. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21559. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21560. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21561. /// <exception cref="ArgumentNullException">
  21562. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21563. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21564. #if PREFERASYNC
  21565. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21566. #endif
  21567. public static Func<IQbservable<TResult>> FromAsyncPattern<TResult>(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  21568. {
  21569. if (provider == null)
  21570. throw new ArgumentNullException(nameof(provider));
  21571. if (begin == null)
  21572. throw new ArgumentNullException(nameof(begin));
  21573. if (end == null)
  21574. throw new ArgumentNullException(nameof(end));
  21575. #if CRIPPLED_REFLECTION
  21576. var m = InfoOf(() => Qbservable.FromAsyncPattern<TResult>(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21577. #else
  21578. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  21579. #endif
  21580. return () => provider.CreateQuery<TResult>(
  21581. Expression.Invoke(
  21582. Expression.Call(
  21583. null,
  21584. m,
  21585. Expression.Constant(provider, typeof(IQbservableProvider)),
  21586. begin,
  21587. end
  21588. )
  21589. )
  21590. );
  21591. }
  21592. /// <summary>
  21593. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21594. /// </summary>
  21595. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21596. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21597. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21598. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21599. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21600. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21601. /// <exception cref="ArgumentNullException">
  21602. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21603. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21604. #if PREFERASYNC
  21605. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21606. #endif
  21607. public static Func<TArg1, IQbservable<TResult>> FromAsyncPattern<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  21608. {
  21609. if (provider == null)
  21610. throw new ArgumentNullException(nameof(provider));
  21611. if (begin == null)
  21612. throw new ArgumentNullException(nameof(begin));
  21613. if (end == null)
  21614. throw new ArgumentNullException(nameof(end));
  21615. #if CRIPPLED_REFLECTION
  21616. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21617. #else
  21618. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  21619. #endif
  21620. return (t1) => provider.CreateQuery<TResult>(
  21621. Expression.Invoke(
  21622. Expression.Call(
  21623. null,
  21624. m,
  21625. Expression.Constant(provider, typeof(IQbservableProvider)),
  21626. begin,
  21627. end
  21628. ),
  21629. Expression.Constant(t1, typeof(TArg1))
  21630. )
  21631. );
  21632. }
  21633. /// <summary>
  21634. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21635. /// </summary>
  21636. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21637. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21638. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21639. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21640. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21641. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21642. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21643. /// <exception cref="ArgumentNullException">
  21644. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21645. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21646. #if PREFERASYNC
  21647. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21648. #endif
  21649. public static Func<TArg1, TArg2, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  21650. {
  21651. if (provider == null)
  21652. throw new ArgumentNullException(nameof(provider));
  21653. if (begin == null)
  21654. throw new ArgumentNullException(nameof(begin));
  21655. if (end == null)
  21656. throw new ArgumentNullException(nameof(end));
  21657. #if CRIPPLED_REFLECTION
  21658. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21659. #else
  21660. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  21661. #endif
  21662. return (t1, t2) => provider.CreateQuery<TResult>(
  21663. Expression.Invoke(
  21664. Expression.Call(
  21665. null,
  21666. m,
  21667. Expression.Constant(provider, typeof(IQbservableProvider)),
  21668. begin,
  21669. end
  21670. ),
  21671. Expression.Constant(t1, typeof(TArg1)),
  21672. Expression.Constant(t2, typeof(TArg2))
  21673. )
  21674. );
  21675. }
  21676. /// <summary>
  21677. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21678. /// </summary>
  21679. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21680. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21681. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21682. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21683. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21684. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21685. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21686. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21687. /// <exception cref="ArgumentNullException">
  21688. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21689. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21690. #if PREFERASYNC
  21691. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21692. #endif
  21693. public static Func<TArg1, TArg2, TArg3, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  21694. {
  21695. if (provider == null)
  21696. throw new ArgumentNullException(nameof(provider));
  21697. if (begin == null)
  21698. throw new ArgumentNullException(nameof(begin));
  21699. if (end == null)
  21700. throw new ArgumentNullException(nameof(end));
  21701. #if CRIPPLED_REFLECTION
  21702. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21703. #else
  21704. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  21705. #endif
  21706. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  21707. Expression.Invoke(
  21708. Expression.Call(
  21709. null,
  21710. m,
  21711. Expression.Constant(provider, typeof(IQbservableProvider)),
  21712. begin,
  21713. end
  21714. ),
  21715. Expression.Constant(t1, typeof(TArg1)),
  21716. Expression.Constant(t2, typeof(TArg2)),
  21717. Expression.Constant(t3, typeof(TArg3))
  21718. )
  21719. );
  21720. }
  21721. /// <summary>
  21722. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21723. /// </summary>
  21724. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21725. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21726. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21727. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21728. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21729. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21730. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21731. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21732. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21733. /// <exception cref="ArgumentNullException">
  21734. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21735. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21736. #if PREFERASYNC
  21737. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21738. #endif
  21739. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  21740. {
  21741. if (provider == null)
  21742. throw new ArgumentNullException(nameof(provider));
  21743. if (begin == null)
  21744. throw new ArgumentNullException(nameof(begin));
  21745. if (end == null)
  21746. throw new ArgumentNullException(nameof(end));
  21747. #if CRIPPLED_REFLECTION
  21748. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21749. #else
  21750. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  21751. #endif
  21752. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  21753. Expression.Invoke(
  21754. Expression.Call(
  21755. null,
  21756. m,
  21757. Expression.Constant(provider, typeof(IQbservableProvider)),
  21758. begin,
  21759. end
  21760. ),
  21761. Expression.Constant(t1, typeof(TArg1)),
  21762. Expression.Constant(t2, typeof(TArg2)),
  21763. Expression.Constant(t3, typeof(TArg3)),
  21764. Expression.Constant(t4, typeof(TArg4))
  21765. )
  21766. );
  21767. }
  21768. /// <summary>
  21769. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21770. /// </summary>
  21771. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21772. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21773. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21774. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21775. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21776. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21777. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21778. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21779. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21780. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21781. /// <exception cref="ArgumentNullException">
  21782. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21783. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21784. #if PREFERASYNC
  21785. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21786. #endif
  21787. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  21788. {
  21789. if (provider == null)
  21790. throw new ArgumentNullException(nameof(provider));
  21791. if (begin == null)
  21792. throw new ArgumentNullException(nameof(begin));
  21793. if (end == null)
  21794. throw new ArgumentNullException(nameof(end));
  21795. #if CRIPPLED_REFLECTION
  21796. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21797. #else
  21798. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  21799. #endif
  21800. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  21801. Expression.Invoke(
  21802. Expression.Call(
  21803. null,
  21804. m,
  21805. Expression.Constant(provider, typeof(IQbservableProvider)),
  21806. begin,
  21807. end
  21808. ),
  21809. Expression.Constant(t1, typeof(TArg1)),
  21810. Expression.Constant(t2, typeof(TArg2)),
  21811. Expression.Constant(t3, typeof(TArg3)),
  21812. Expression.Constant(t4, typeof(TArg4)),
  21813. Expression.Constant(t5, typeof(TArg5))
  21814. )
  21815. );
  21816. }
  21817. /// <summary>
  21818. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21819. /// </summary>
  21820. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21821. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21822. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21823. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21824. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21825. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21826. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21827. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21828. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21829. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21830. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21831. /// <exception cref="ArgumentNullException">
  21832. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21833. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21834. #if PREFERASYNC
  21835. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21836. #endif
  21837. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  21838. {
  21839. if (provider == null)
  21840. throw new ArgumentNullException(nameof(provider));
  21841. if (begin == null)
  21842. throw new ArgumentNullException(nameof(begin));
  21843. if (end == null)
  21844. throw new ArgumentNullException(nameof(end));
  21845. #if CRIPPLED_REFLECTION
  21846. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21847. #else
  21848. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  21849. #endif
  21850. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  21851. Expression.Invoke(
  21852. Expression.Call(
  21853. null,
  21854. m,
  21855. Expression.Constant(provider, typeof(IQbservableProvider)),
  21856. begin,
  21857. end
  21858. ),
  21859. Expression.Constant(t1, typeof(TArg1)),
  21860. Expression.Constant(t2, typeof(TArg2)),
  21861. Expression.Constant(t3, typeof(TArg3)),
  21862. Expression.Constant(t4, typeof(TArg4)),
  21863. Expression.Constant(t5, typeof(TArg5)),
  21864. Expression.Constant(t6, typeof(TArg6))
  21865. )
  21866. );
  21867. }
  21868. /// <summary>
  21869. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21870. /// </summary>
  21871. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21872. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21873. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21874. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21875. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21876. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21877. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21878. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21879. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21880. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21881. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21882. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21883. /// <exception cref="ArgumentNullException">
  21884. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21885. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21886. #if PREFERASYNC
  21887. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21888. #endif
  21889. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  21890. {
  21891. if (provider == null)
  21892. throw new ArgumentNullException(nameof(provider));
  21893. if (begin == null)
  21894. throw new ArgumentNullException(nameof(begin));
  21895. if (end == null)
  21896. throw new ArgumentNullException(nameof(end));
  21897. #if CRIPPLED_REFLECTION
  21898. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21899. #else
  21900. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  21901. #endif
  21902. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  21903. Expression.Invoke(
  21904. Expression.Call(
  21905. null,
  21906. m,
  21907. Expression.Constant(provider, typeof(IQbservableProvider)),
  21908. begin,
  21909. end
  21910. ),
  21911. Expression.Constant(t1, typeof(TArg1)),
  21912. Expression.Constant(t2, typeof(TArg2)),
  21913. Expression.Constant(t3, typeof(TArg3)),
  21914. Expression.Constant(t4, typeof(TArg4)),
  21915. Expression.Constant(t5, typeof(TArg5)),
  21916. Expression.Constant(t6, typeof(TArg6)),
  21917. Expression.Constant(t7, typeof(TArg7))
  21918. )
  21919. );
  21920. }
  21921. /// <summary>
  21922. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21923. /// </summary>
  21924. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21925. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21926. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21927. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21928. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21929. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21930. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21931. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21932. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21933. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21934. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21935. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21936. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21937. /// <exception cref="ArgumentNullException">
  21938. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21939. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21940. #if PREFERASYNC
  21941. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21942. #endif
  21943. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  21944. {
  21945. if (provider == null)
  21946. throw new ArgumentNullException(nameof(provider));
  21947. if (begin == null)
  21948. throw new ArgumentNullException(nameof(begin));
  21949. if (end == null)
  21950. throw new ArgumentNullException(nameof(end));
  21951. #if CRIPPLED_REFLECTION
  21952. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21953. #else
  21954. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  21955. #endif
  21956. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  21957. Expression.Invoke(
  21958. Expression.Call(
  21959. null,
  21960. m,
  21961. Expression.Constant(provider, typeof(IQbservableProvider)),
  21962. begin,
  21963. end
  21964. ),
  21965. Expression.Constant(t1, typeof(TArg1)),
  21966. Expression.Constant(t2, typeof(TArg2)),
  21967. Expression.Constant(t3, typeof(TArg3)),
  21968. Expression.Constant(t4, typeof(TArg4)),
  21969. Expression.Constant(t5, typeof(TArg5)),
  21970. Expression.Constant(t6, typeof(TArg6)),
  21971. Expression.Constant(t7, typeof(TArg7)),
  21972. Expression.Constant(t8, typeof(TArg8))
  21973. )
  21974. );
  21975. }
  21976. /// <summary>
  21977. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21978. /// </summary>
  21979. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21980. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21981. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21982. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21983. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21984. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21985. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21986. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21987. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21988. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21989. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21990. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21991. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21992. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21993. /// <exception cref="ArgumentNullException">
  21994. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21995. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  21996. #if PREFERASYNC
  21997. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21998. #endif
  21999. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  22000. {
  22001. if (provider == null)
  22002. throw new ArgumentNullException(nameof(provider));
  22003. if (begin == null)
  22004. throw new ArgumentNullException(nameof(begin));
  22005. if (end == null)
  22006. throw new ArgumentNullException(nameof(end));
  22007. #if CRIPPLED_REFLECTION
  22008. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  22009. #else
  22010. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TResult));
  22011. #endif
  22012. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  22013. Expression.Invoke(
  22014. Expression.Call(
  22015. null,
  22016. m,
  22017. Expression.Constant(provider, typeof(IQbservableProvider)),
  22018. begin,
  22019. end
  22020. ),
  22021. Expression.Constant(t1, typeof(TArg1)),
  22022. Expression.Constant(t2, typeof(TArg2)),
  22023. Expression.Constant(t3, typeof(TArg3)),
  22024. Expression.Constant(t4, typeof(TArg4)),
  22025. Expression.Constant(t5, typeof(TArg5)),
  22026. Expression.Constant(t6, typeof(TArg6)),
  22027. Expression.Constant(t7, typeof(TArg7)),
  22028. Expression.Constant(t8, typeof(TArg8)),
  22029. Expression.Constant(t9, typeof(TArg9))
  22030. )
  22031. );
  22032. }
  22033. /// <summary>
  22034. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22035. /// </summary>
  22036. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22037. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22038. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22039. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22040. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22041. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22042. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22043. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22044. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22045. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22046. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22047. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22048. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22049. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22050. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22051. /// <exception cref="ArgumentNullException">
  22052. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22053. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  22054. #if PREFERASYNC
  22055. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22056. #endif
  22057. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  22058. {
  22059. if (provider == null)
  22060. throw new ArgumentNullException(nameof(provider));
  22061. if (begin == null)
  22062. throw new ArgumentNullException(nameof(begin));
  22063. if (end == null)
  22064. throw new ArgumentNullException(nameof(end));
  22065. #if CRIPPLED_REFLECTION
  22066. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  22067. #else
  22068. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TResult));
  22069. #endif
  22070. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  22071. Expression.Invoke(
  22072. Expression.Call(
  22073. null,
  22074. m,
  22075. Expression.Constant(provider, typeof(IQbservableProvider)),
  22076. begin,
  22077. end
  22078. ),
  22079. Expression.Constant(t1, typeof(TArg1)),
  22080. Expression.Constant(t2, typeof(TArg2)),
  22081. Expression.Constant(t3, typeof(TArg3)),
  22082. Expression.Constant(t4, typeof(TArg4)),
  22083. Expression.Constant(t5, typeof(TArg5)),
  22084. Expression.Constant(t6, typeof(TArg6)),
  22085. Expression.Constant(t7, typeof(TArg7)),
  22086. Expression.Constant(t8, typeof(TArg8)),
  22087. Expression.Constant(t9, typeof(TArg9)),
  22088. Expression.Constant(t10, typeof(TArg10))
  22089. )
  22090. );
  22091. }
  22092. /// <summary>
  22093. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22094. /// </summary>
  22095. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22096. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22097. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22098. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22099. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22100. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22101. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22102. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22103. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22104. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22105. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22106. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22107. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22108. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22109. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22110. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22111. /// <exception cref="ArgumentNullException">
  22112. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22113. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  22114. #if PREFERASYNC
  22115. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22116. #endif
  22117. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  22118. {
  22119. if (provider == null)
  22120. throw new ArgumentNullException(nameof(provider));
  22121. if (begin == null)
  22122. throw new ArgumentNullException(nameof(begin));
  22123. if (end == null)
  22124. throw new ArgumentNullException(nameof(end));
  22125. #if CRIPPLED_REFLECTION
  22126. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  22127. #else
  22128. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TResult));
  22129. #endif
  22130. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  22131. Expression.Invoke(
  22132. Expression.Call(
  22133. null,
  22134. m,
  22135. Expression.Constant(provider, typeof(IQbservableProvider)),
  22136. begin,
  22137. end
  22138. ),
  22139. Expression.Constant(t1, typeof(TArg1)),
  22140. Expression.Constant(t2, typeof(TArg2)),
  22141. Expression.Constant(t3, typeof(TArg3)),
  22142. Expression.Constant(t4, typeof(TArg4)),
  22143. Expression.Constant(t5, typeof(TArg5)),
  22144. Expression.Constant(t6, typeof(TArg6)),
  22145. Expression.Constant(t7, typeof(TArg7)),
  22146. Expression.Constant(t8, typeof(TArg8)),
  22147. Expression.Constant(t9, typeof(TArg9)),
  22148. Expression.Constant(t10, typeof(TArg10)),
  22149. Expression.Constant(t11, typeof(TArg11))
  22150. )
  22151. );
  22152. }
  22153. /// <summary>
  22154. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22155. /// </summary>
  22156. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22157. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22158. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22159. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22160. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22161. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22162. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22163. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22164. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22165. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22166. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22167. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22168. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22169. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22170. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22171. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22172. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22173. /// <exception cref="ArgumentNullException">
  22174. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22175. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  22176. #if PREFERASYNC
  22177. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22178. #endif
  22179. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  22180. {
  22181. if (provider == null)
  22182. throw new ArgumentNullException(nameof(provider));
  22183. if (begin == null)
  22184. throw new ArgumentNullException(nameof(begin));
  22185. if (end == null)
  22186. throw new ArgumentNullException(nameof(end));
  22187. #if CRIPPLED_REFLECTION
  22188. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  22189. #else
  22190. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TResult));
  22191. #endif
  22192. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  22193. Expression.Invoke(
  22194. Expression.Call(
  22195. null,
  22196. m,
  22197. Expression.Constant(provider, typeof(IQbservableProvider)),
  22198. begin,
  22199. end
  22200. ),
  22201. Expression.Constant(t1, typeof(TArg1)),
  22202. Expression.Constant(t2, typeof(TArg2)),
  22203. Expression.Constant(t3, typeof(TArg3)),
  22204. Expression.Constant(t4, typeof(TArg4)),
  22205. Expression.Constant(t5, typeof(TArg5)),
  22206. Expression.Constant(t6, typeof(TArg6)),
  22207. Expression.Constant(t7, typeof(TArg7)),
  22208. Expression.Constant(t8, typeof(TArg8)),
  22209. Expression.Constant(t9, typeof(TArg9)),
  22210. Expression.Constant(t10, typeof(TArg10)),
  22211. Expression.Constant(t11, typeof(TArg11)),
  22212. Expression.Constant(t12, typeof(TArg12))
  22213. )
  22214. );
  22215. }
  22216. /// <summary>
  22217. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22218. /// </summary>
  22219. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22220. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22221. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22222. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22223. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22224. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22225. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22226. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22227. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22228. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22229. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22230. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22231. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22232. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22233. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22234. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22235. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22236. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22237. /// <exception cref="ArgumentNullException">
  22238. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22239. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  22240. #if PREFERASYNC
  22241. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22242. #endif
  22243. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  22244. {
  22245. if (provider == null)
  22246. throw new ArgumentNullException(nameof(provider));
  22247. if (begin == null)
  22248. throw new ArgumentNullException(nameof(begin));
  22249. if (end == null)
  22250. throw new ArgumentNullException(nameof(end));
  22251. #if CRIPPLED_REFLECTION
  22252. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  22253. #else
  22254. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TResult));
  22255. #endif
  22256. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  22257. Expression.Invoke(
  22258. Expression.Call(
  22259. null,
  22260. m,
  22261. Expression.Constant(provider, typeof(IQbservableProvider)),
  22262. begin,
  22263. end
  22264. ),
  22265. Expression.Constant(t1, typeof(TArg1)),
  22266. Expression.Constant(t2, typeof(TArg2)),
  22267. Expression.Constant(t3, typeof(TArg3)),
  22268. Expression.Constant(t4, typeof(TArg4)),
  22269. Expression.Constant(t5, typeof(TArg5)),
  22270. Expression.Constant(t6, typeof(TArg6)),
  22271. Expression.Constant(t7, typeof(TArg7)),
  22272. Expression.Constant(t8, typeof(TArg8)),
  22273. Expression.Constant(t9, typeof(TArg9)),
  22274. Expression.Constant(t10, typeof(TArg10)),
  22275. Expression.Constant(t11, typeof(TArg11)),
  22276. Expression.Constant(t12, typeof(TArg12)),
  22277. Expression.Constant(t13, typeof(TArg13))
  22278. )
  22279. );
  22280. }
  22281. /// <summary>
  22282. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22283. /// </summary>
  22284. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22285. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22286. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22287. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22288. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22289. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22290. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22291. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22292. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22293. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22294. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22295. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22296. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22297. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22298. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  22299. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22300. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22301. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22302. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22303. /// <exception cref="ArgumentNullException">
  22304. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22305. /// <remarks>Each invocation of the resulting function will cause the asynchronous operation to be started. Subscription to the resulting sequence has no observable side-effect, and each subscription will produce the asynchronous operation's result.</remarks>
  22306. #if PREFERASYNC
  22307. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22308. #endif
  22309. public static Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, IQbservable<TResult>> FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  22310. {
  22311. if (provider == null)
  22312. throw new ArgumentNullException(nameof(provider));
  22313. if (begin == null)
  22314. throw new ArgumentNullException(nameof(begin));
  22315. if (end == null)
  22316. throw new ArgumentNullException(nameof(end));
  22317. #if CRIPPLED_REFLECTION
  22318. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7, TArg8, TArg9, TArg10, TArg11, TArg12, TArg13, TArg14, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  22319. #else
  22320. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9), typeof(TArg10), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TResult));
  22321. #endif
  22322. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  22323. Expression.Invoke(
  22324. Expression.Call(
  22325. null,
  22326. m,
  22327. Expression.Constant(provider, typeof(IQbservableProvider)),
  22328. begin,
  22329. end
  22330. ),
  22331. Expression.Constant(t1, typeof(TArg1)),
  22332. Expression.Constant(t2, typeof(TArg2)),
  22333. Expression.Constant(t3, typeof(TArg3)),
  22334. Expression.Constant(t4, typeof(TArg4)),
  22335. Expression.Constant(t5, typeof(TArg5)),
  22336. Expression.Constant(t6, typeof(TArg6)),
  22337. Expression.Constant(t7, typeof(TArg7)),
  22338. Expression.Constant(t8, typeof(TArg8)),
  22339. Expression.Constant(t9, typeof(TArg9)),
  22340. Expression.Constant(t10, typeof(TArg10)),
  22341. Expression.Constant(t11, typeof(TArg11)),
  22342. Expression.Constant(t12, typeof(TArg12)),
  22343. Expression.Constant(t13, typeof(TArg13)),
  22344. Expression.Constant(t14, typeof(TArg14))
  22345. )
  22346. );
  22347. }
  22348. }
  22349. }
  22350. #pragma warning restore 1591