Qbservable.Generated.cs 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544
  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.Reactive.Concurrency;
  7. using System.Collections.Generic;
  8. using System.Diagnostics.CodeAnalysis;
  9. using System.Linq;
  10. using System.Linq.Expressions;
  11. using System.Reflection;
  12. using System.Threading;
  13. using System.Threading.Tasks;
  14. using System.Reactive.Subjects;
  15. namespace System.Reactive.Linq
  16. {
  17. [ExcludeFromCodeCoverage]
  18. public static partial class Qbservable
  19. {
  20. /// <summary>
  21. /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence.
  22. /// 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})" />.
  23. /// </summary>
  24. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  25. /// <param name="source">An observable sequence to aggregate over.</param>
  26. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  27. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  28. /// <exception cref="ArgumentNullException">
  29. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  30. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  31. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  32. public static IQbservable<TSource> Aggregate<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  33. {
  34. if (source == null)
  35. throw new ArgumentNullException(nameof(source));
  36. if (accumulator == null)
  37. throw new ArgumentNullException(nameof(accumulator));
  38. return source.Provider.CreateQuery<TSource>(
  39. Expression.Call(
  40. null,
  41. #if CRIPPLED_REFLECTION
  42. InfoOf(() => Qbservable.Aggregate<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  43. #else
  44. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  45. #endif
  46. source.Expression,
  47. accumulator
  48. )
  49. );
  50. }
  51. /// <summary>
  52. /// 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.
  53. /// 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})" />.
  54. /// </summary>
  55. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  56. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  57. /// <param name="source">An observable sequence to aggregate over.</param>
  58. /// <param name="seed">The initial accumulator value.</param>
  59. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  60. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  61. /// <exception cref="ArgumentNullException">
  62. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  63. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  64. public static IQbservable<TAccumulate> Aggregate<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  65. {
  66. if (source == null)
  67. throw new ArgumentNullException(nameof(source));
  68. if (accumulator == null)
  69. throw new ArgumentNullException(nameof(accumulator));
  70. return source.Provider.CreateQuery<TAccumulate>(
  71. Expression.Call(
  72. null,
  73. #if CRIPPLED_REFLECTION
  74. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  75. #else
  76. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  77. #endif
  78. source.Expression,
  79. Expression.Constant(seed, typeof(TAccumulate)),
  80. accumulator
  81. )
  82. );
  83. }
  84. /// <summary>
  85. /// 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,
  86. /// and the specified result selector function is used to select the result value.
  87. /// </summary>
  88. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  89. /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam>
  90. /// <typeparam name="TResult">The type of the resulting value.</typeparam>
  91. /// <param name="source">An observable sequence to aggregate over.</param>
  92. /// <param name="seed">The initial accumulator value.</param>
  93. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  94. /// <param name="resultSelector">A function to transform the final accumulator value into the result value.</param>
  95. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  96. /// <exception cref="ArgumentNullException">
  97. /// <paramref name="source" /> or <paramref name="accumulator" /> or <paramref name="resultSelector" /> is null.</exception>
  98. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  99. 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)
  100. {
  101. if (source == null)
  102. throw new ArgumentNullException(nameof(source));
  103. if (accumulator == null)
  104. throw new ArgumentNullException(nameof(accumulator));
  105. if (resultSelector == null)
  106. throw new ArgumentNullException(nameof(resultSelector));
  107. return source.Provider.CreateQuery<TResult>(
  108. Expression.Call(
  109. null,
  110. #if CRIPPLED_REFLECTION
  111. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate, TResult>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>), default(Expression<Func<TAccumulate, TResult>>))),
  112. #else
  113. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)),
  114. #endif
  115. source.Expression,
  116. Expression.Constant(seed, typeof(TAccumulate)),
  117. accumulator,
  118. resultSelector
  119. )
  120. );
  121. }
  122. /// <summary>
  123. /// Determines whether all elements of an observable sequence satisfy a condition.
  124. /// </summary>
  125. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  126. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  127. /// <param name="predicate">A function to test each element for a condition.</param>
  128. /// <returns>An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.</returns>
  129. /// <exception cref="ArgumentNullException">
  130. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  131. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  132. public static IQbservable<bool> All<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  133. {
  134. if (source == null)
  135. throw new ArgumentNullException(nameof(source));
  136. if (predicate == null)
  137. throw new ArgumentNullException(nameof(predicate));
  138. return source.Provider.CreateQuery<bool>(
  139. Expression.Call(
  140. null,
  141. #if CRIPPLED_REFLECTION
  142. InfoOf(() => Qbservable.All<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  143. #else
  144. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  145. #endif
  146. source.Expression,
  147. predicate
  148. )
  149. );
  150. }
  151. /// <summary>
  152. /// Propagates the observable sequence that reacts first.
  153. /// </summary>
  154. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  155. /// <param name="first">First observable sequence.</param>
  156. /// <param name="second">Second observable sequence.</param>
  157. /// <returns>An observable sequence that surfaces either of the given sequences, whichever reacted first.</returns>
  158. /// <exception cref="ArgumentNullException">
  159. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  160. public static IQbservable<TSource> Amb<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  161. {
  162. if (first == null)
  163. throw new ArgumentNullException(nameof(first));
  164. if (second == null)
  165. throw new ArgumentNullException(nameof(second));
  166. return first.Provider.CreateQuery<TSource>(
  167. Expression.Call(
  168. null,
  169. #if CRIPPLED_REFLECTION
  170. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  171. #else
  172. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  173. #endif
  174. first.Expression,
  175. GetSourceExpression(second)
  176. )
  177. );
  178. }
  179. /// <summary>
  180. /// Propagates the observable sequence that reacts first.
  181. /// </summary>
  182. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  183. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  184. /// <param name="sources">Observable sources competing to react first.</param>
  185. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  186. /// <exception cref="ArgumentNullException">
  187. /// <paramref name="sources" /> is null.</exception>
  188. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  189. {
  190. if (provider == null)
  191. throw new ArgumentNullException(nameof(provider));
  192. if (sources == null)
  193. throw new ArgumentNullException(nameof(sources));
  194. return provider.CreateQuery<TSource>(
  195. Expression.Call(
  196. null,
  197. #if CRIPPLED_REFLECTION
  198. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  199. #else
  200. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  201. #endif
  202. Expression.Constant(provider, typeof(IQbservableProvider)),
  203. GetSourceExpression(sources)
  204. )
  205. );
  206. }
  207. /// <summary>
  208. /// Propagates the observable sequence that reacts first.
  209. /// </summary>
  210. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  211. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  212. /// <param name="sources">Observable sources competing to react first.</param>
  213. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  214. /// <exception cref="ArgumentNullException">
  215. /// <paramref name="sources" /> is null.</exception>
  216. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  217. {
  218. if (provider == null)
  219. throw new ArgumentNullException(nameof(provider));
  220. if (sources == null)
  221. throw new ArgumentNullException(nameof(sources));
  222. return provider.CreateQuery<TSource>(
  223. Expression.Call(
  224. null,
  225. #if CRIPPLED_REFLECTION
  226. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  227. #else
  228. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  229. #endif
  230. Expression.Constant(provider, typeof(IQbservableProvider)),
  231. GetSourceExpression(sources)
  232. )
  233. );
  234. }
  235. /// <summary>
  236. /// Determines whether an observable sequence contains any elements.
  237. /// </summary>
  238. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  239. /// <param name="source">An observable sequence to check for non-emptiness.</param>
  240. /// <returns>An observable sequence containing a single element determining whether the source sequence contains any elements.</returns>
  241. /// <exception cref="ArgumentNullException">
  242. /// <paramref name="source" /> is null.</exception>
  243. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  244. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source)
  245. {
  246. if (source == null)
  247. throw new ArgumentNullException(nameof(source));
  248. return source.Provider.CreateQuery<bool>(
  249. Expression.Call(
  250. null,
  251. #if CRIPPLED_REFLECTION
  252. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>))),
  253. #else
  254. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  255. #endif
  256. source.Expression
  257. )
  258. );
  259. }
  260. /// <summary>
  261. /// Determines whether any element of an observable sequence satisfies a condition.
  262. /// </summary>
  263. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  264. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  265. /// <param name="predicate">A function to test each element for a condition.</param>
  266. /// <returns>An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate.</returns>
  267. /// <exception cref="ArgumentNullException">
  268. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  269. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  270. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  271. {
  272. if (source == null)
  273. throw new ArgumentNullException(nameof(source));
  274. if (predicate == null)
  275. throw new ArgumentNullException(nameof(predicate));
  276. return source.Provider.CreateQuery<bool>(
  277. Expression.Call(
  278. null,
  279. #if CRIPPLED_REFLECTION
  280. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  281. #else
  282. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  283. #endif
  284. source.Expression,
  285. predicate
  286. )
  287. );
  288. }
  289. /// <summary>
  290. /// Append a value to an observable sequence.
  291. /// </summary>
  292. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  293. /// <param name="source">Source sequence to append the value to.</param>
  294. /// <param name="value">Value to append to the specified sequence.</param>
  295. /// <returns>The source sequence appended with the specified value.</returns>
  296. /// <exception cref="ArgumentNullException">
  297. /// <paramref name="source" /> is null.</exception>
  298. public static IQbservable<TSource> Append<TSource>(this IQbservable<TSource> source, TSource value)
  299. {
  300. if (source == null)
  301. throw new ArgumentNullException(nameof(source));
  302. return source.Provider.CreateQuery<TSource>(
  303. Expression.Call(
  304. null,
  305. #if CRIPPLED_REFLECTION
  306. InfoOf(() => Qbservable.Append<TSource>(default(IQbservable<TSource>), default(TSource))),
  307. #else
  308. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  309. #endif
  310. source.Expression,
  311. Expression.Constant(value, typeof(TSource))
  312. )
  313. );
  314. }
  315. /// <summary>
  316. /// Append a value to an observable sequence.
  317. /// </summary>
  318. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  319. /// <param name="source">Source sequence to append the value to.</param>
  320. /// <param name="value">Value to append to the specified sequence.</param>
  321. /// <param name="scheduler">Scheduler to emit the append values on.</param>
  322. /// <returns>The source sequence appended with the specified value.</returns>
  323. /// <exception cref="ArgumentNullException">
  324. /// <paramref name="source" /> is null.</exception>
  325. public static IQbservable<TSource> Append<TSource>(this IQbservable<TSource> source, TSource value, IScheduler scheduler)
  326. {
  327. if (source == null)
  328. throw new ArgumentNullException(nameof(source));
  329. if (scheduler == null)
  330. throw new ArgumentNullException(nameof(scheduler));
  331. return source.Provider.CreateQuery<TSource>(
  332. Expression.Call(
  333. null,
  334. #if CRIPPLED_REFLECTION
  335. InfoOf(() => Qbservable.Append<TSource>(default(IQbservable<TSource>), default(TSource), default(IScheduler))),
  336. #else
  337. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  338. #endif
  339. source.Expression,
  340. Expression.Constant(value, typeof(TSource)),
  341. Expression.Constant(scheduler, typeof(IScheduler))
  342. )
  343. );
  344. }
  345. /// <summary>
  346. /// Automatically connect the upstream IConnectableObservable at most once when the
  347. /// specified number of IObservers have subscribed to this IObservable.
  348. /// </summary>
  349. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  350. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  351. /// <param name="source">Connectable observable sequence.</param>
  352. /// <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>
  353. /// <param name="onConnect">If not null, the connection's IDisposable is provided to it.</param>
  354. /// <returns>An observable sequence that connects to the source at most once when the given number of observers have subscribed to it.</returns>
  355. /// <exception cref="ArgumentNullException">
  356. /// <paramref name="source" /> is null.</exception>
  357. public static IQbservable<TSource> AutoConnect<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, int minObservers, Expression<Action<IDisposable>> onConnect)
  358. {
  359. if (provider == null)
  360. throw new ArgumentNullException(nameof(provider));
  361. if (source == null)
  362. throw new ArgumentNullException(nameof(source));
  363. if (onConnect == null)
  364. throw new ArgumentNullException(nameof(onConnect));
  365. return provider.CreateQuery<TSource>(
  366. Expression.Call(
  367. null,
  368. #if CRIPPLED_REFLECTION
  369. InfoOf(() => Qbservable.AutoConnect<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(int), default(Expression<Action<IDisposable>>))),
  370. #else
  371. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  372. #endif
  373. Expression.Constant(provider, typeof(IQbservableProvider)),
  374. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  375. Expression.Constant(minObservers, typeof(int)),
  376. onConnect
  377. )
  378. );
  379. }
  380. /// <summary>
  381. /// Computes the average of an observable sequence of <see cref="Decimal" /> values.
  382. /// </summary>
  383. /// <param name="source">A sequence of <see cref="Decimal" /> values to calculate the average of.</param>
  384. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  385. /// <exception cref="ArgumentNullException">
  386. /// <paramref name="source" /> is null.</exception>
  387. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  388. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  389. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  390. public static IQbservable<decimal> Average(this IQbservable<decimal> source)
  391. {
  392. if (source == null)
  393. throw new ArgumentNullException(nameof(source));
  394. return source.Provider.CreateQuery<decimal>(
  395. Expression.Call(
  396. null,
  397. #if CRIPPLED_REFLECTION
  398. InfoOf(() => Qbservable.Average(default(IQbservable<decimal>))),
  399. #else
  400. (MethodInfo)MethodInfo.GetCurrentMethod(),
  401. #endif
  402. source.Expression
  403. )
  404. );
  405. }
  406. /// <summary>
  407. /// Computes the average of an observable sequence of <see cref="double" /> values.
  408. /// </summary>
  409. /// <param name="source">A sequence of <see cref="double" /> values to calculate the average of.</param>
  410. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  411. /// <exception cref="ArgumentNullException">
  412. /// <paramref name="source" /> is null.</exception>
  413. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  414. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  415. public static IQbservable<double> Average(this IQbservable<double> source)
  416. {
  417. if (source == null)
  418. throw new ArgumentNullException(nameof(source));
  419. return source.Provider.CreateQuery<double>(
  420. Expression.Call(
  421. null,
  422. #if CRIPPLED_REFLECTION
  423. InfoOf(() => Qbservable.Average(default(IQbservable<double>))),
  424. #else
  425. (MethodInfo)MethodInfo.GetCurrentMethod(),
  426. #endif
  427. source.Expression
  428. )
  429. );
  430. }
  431. /// <summary>
  432. /// Computes the average of an observable sequence of <see cref="int" /> values.
  433. /// </summary>
  434. /// <param name="source">A sequence of <see cref="int" /> values to calculate the average of.</param>
  435. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  436. /// <exception cref="ArgumentNullException">
  437. /// <paramref name="source" /> is null.</exception>
  438. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  439. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  440. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  441. public static IQbservable<double> Average(this IQbservable<int> source)
  442. {
  443. if (source == null)
  444. throw new ArgumentNullException(nameof(source));
  445. return source.Provider.CreateQuery<double>(
  446. Expression.Call(
  447. null,
  448. #if CRIPPLED_REFLECTION
  449. InfoOf(() => Qbservable.Average(default(IQbservable<int>))),
  450. #else
  451. (MethodInfo)MethodInfo.GetCurrentMethod(),
  452. #endif
  453. source.Expression
  454. )
  455. );
  456. }
  457. /// <summary>
  458. /// Computes the average of an observable sequence of <see cref="long" /> values.
  459. /// </summary>
  460. /// <param name="source">A sequence of <see cref="long" /> values to calculate the average of.</param>
  461. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  462. /// <exception cref="ArgumentNullException">
  463. /// <paramref name="source" /> is null.</exception>
  464. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  465. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  466. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  467. public static IQbservable<double> Average(this IQbservable<long> source)
  468. {
  469. if (source == null)
  470. throw new ArgumentNullException(nameof(source));
  471. return source.Provider.CreateQuery<double>(
  472. Expression.Call(
  473. null,
  474. #if CRIPPLED_REFLECTION
  475. InfoOf(() => Qbservable.Average(default(IQbservable<long>))),
  476. #else
  477. (MethodInfo)MethodInfo.GetCurrentMethod(),
  478. #endif
  479. source.Expression
  480. )
  481. );
  482. }
  483. /// <summary>
  484. /// Computes the average of an observable sequence of nullable <see cref="Decimal" /> values.
  485. /// </summary>
  486. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to calculate the average of.</param>
  487. /// <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>
  488. /// <exception cref="ArgumentNullException">
  489. /// <paramref name="source" /> is null.</exception>
  490. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  491. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  492. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  493. public static IQbservable<decimal?> Average(this IQbservable<decimal?> source)
  494. {
  495. if (source == null)
  496. throw new ArgumentNullException(nameof(source));
  497. return source.Provider.CreateQuery<decimal?>(
  498. Expression.Call(
  499. null,
  500. #if CRIPPLED_REFLECTION
  501. InfoOf(() => Qbservable.Average(default(IQbservable<decimal?>))),
  502. #else
  503. (MethodInfo)MethodInfo.GetCurrentMethod(),
  504. #endif
  505. source.Expression
  506. )
  507. );
  508. }
  509. /// <summary>
  510. /// Computes the average of an observable sequence of nullable <see cref="double" /> values.
  511. /// </summary>
  512. /// <param name="source">A sequence of nullable <see cref="double" /> values to calculate the average of.</param>
  513. /// <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>
  514. /// <exception cref="ArgumentNullException">
  515. /// <paramref name="source" /> is null.</exception>
  516. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  517. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  518. public static IQbservable<double?> Average(this IQbservable<double?> source)
  519. {
  520. if (source == null)
  521. throw new ArgumentNullException(nameof(source));
  522. return source.Provider.CreateQuery<double?>(
  523. Expression.Call(
  524. null,
  525. #if CRIPPLED_REFLECTION
  526. InfoOf(() => Qbservable.Average(default(IQbservable<double?>))),
  527. #else
  528. (MethodInfo)MethodInfo.GetCurrentMethod(),
  529. #endif
  530. source.Expression
  531. )
  532. );
  533. }
  534. /// <summary>
  535. /// Computes the average of an observable sequence of nullable <see cref="int" /> values.
  536. /// </summary>
  537. /// <param name="source">A sequence of nullable <see cref="int" /> values to calculate the average of.</param>
  538. /// <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>
  539. /// <exception cref="ArgumentNullException">
  540. /// <paramref name="source" /> is null.</exception>
  541. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  542. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  543. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  544. public static IQbservable<double?> Average(this IQbservable<int?> source)
  545. {
  546. if (source == null)
  547. throw new ArgumentNullException(nameof(source));
  548. return source.Provider.CreateQuery<double?>(
  549. Expression.Call(
  550. null,
  551. #if CRIPPLED_REFLECTION
  552. InfoOf(() => Qbservable.Average(default(IQbservable<int?>))),
  553. #else
  554. (MethodInfo)MethodInfo.GetCurrentMethod(),
  555. #endif
  556. source.Expression
  557. )
  558. );
  559. }
  560. /// <summary>
  561. /// Computes the average of an observable sequence of nullable <see cref="long" /> values.
  562. /// </summary>
  563. /// <param name="source">A sequence of nullable <see cref="long" /> values to calculate the average of.</param>
  564. /// <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>
  565. /// <exception cref="ArgumentNullException">
  566. /// <paramref name="source" /> is null.</exception>
  567. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  568. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  569. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  570. public static IQbservable<double?> Average(this IQbservable<long?> source)
  571. {
  572. if (source == null)
  573. throw new ArgumentNullException(nameof(source));
  574. return source.Provider.CreateQuery<double?>(
  575. Expression.Call(
  576. null,
  577. #if CRIPPLED_REFLECTION
  578. InfoOf(() => Qbservable.Average(default(IQbservable<long?>))),
  579. #else
  580. (MethodInfo)MethodInfo.GetCurrentMethod(),
  581. #endif
  582. source.Expression
  583. )
  584. );
  585. }
  586. /// <summary>
  587. /// Computes the average of an observable sequence of nullable <see cref="Single" /> values.
  588. /// </summary>
  589. /// <param name="source">A sequence of nullable <see cref="Single" /> values to calculate the average of.</param>
  590. /// <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>
  591. /// <exception cref="ArgumentNullException">
  592. /// <paramref name="source" /> is null.</exception>
  593. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  594. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  595. public static IQbservable<float?> Average(this IQbservable<float?> source)
  596. {
  597. if (source == null)
  598. throw new ArgumentNullException(nameof(source));
  599. return source.Provider.CreateQuery<float?>(
  600. Expression.Call(
  601. null,
  602. #if CRIPPLED_REFLECTION
  603. InfoOf(() => Qbservable.Average(default(IQbservable<float?>))),
  604. #else
  605. (MethodInfo)MethodInfo.GetCurrentMethod(),
  606. #endif
  607. source.Expression
  608. )
  609. );
  610. }
  611. /// <summary>
  612. /// Computes the average of an observable sequence of <see cref="Single" /> values.
  613. /// </summary>
  614. /// <param name="source">A sequence of <see cref="Single" /> values to calculate the average of.</param>
  615. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  616. /// <exception cref="ArgumentNullException">
  617. /// <paramref name="source" /> is null.</exception>
  618. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  619. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  620. public static IQbservable<float> Average(this IQbservable<float> source)
  621. {
  622. if (source == null)
  623. throw new ArgumentNullException(nameof(source));
  624. return source.Provider.CreateQuery<float>(
  625. Expression.Call(
  626. null,
  627. #if CRIPPLED_REFLECTION
  628. InfoOf(() => Qbservable.Average(default(IQbservable<float>))),
  629. #else
  630. (MethodInfo)MethodInfo.GetCurrentMethod(),
  631. #endif
  632. source.Expression
  633. )
  634. );
  635. }
  636. /// <summary>
  637. /// 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.
  638. /// </summary>
  639. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  640. /// <param name="source">A sequence of values to calculate the average of.</param>
  641. /// <param name="selector">A transform function to apply to each element.</param>
  642. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  643. /// <exception cref="ArgumentNullException">
  644. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  645. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  646. /// <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>
  647. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  648. public static IQbservable<decimal> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  649. {
  650. if (source == null)
  651. throw new ArgumentNullException(nameof(source));
  652. if (selector == null)
  653. throw new ArgumentNullException(nameof(selector));
  654. return source.Provider.CreateQuery<decimal>(
  655. Expression.Call(
  656. null,
  657. #if CRIPPLED_REFLECTION
  658. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  659. #else
  660. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  661. #endif
  662. source.Expression,
  663. selector
  664. )
  665. );
  666. }
  667. /// <summary>
  668. /// 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.
  669. /// </summary>
  670. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  671. /// <param name="source">A sequence of values to calculate the average of.</param>
  672. /// <param name="selector">A transform function to apply to each element.</param>
  673. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  674. /// <exception cref="ArgumentNullException">
  675. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  676. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  677. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  678. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  679. {
  680. if (source == null)
  681. throw new ArgumentNullException(nameof(source));
  682. if (selector == null)
  683. throw new ArgumentNullException(nameof(selector));
  684. return source.Provider.CreateQuery<double>(
  685. Expression.Call(
  686. null,
  687. #if CRIPPLED_REFLECTION
  688. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  689. #else
  690. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  691. #endif
  692. source.Expression,
  693. selector
  694. )
  695. );
  696. }
  697. /// <summary>
  698. /// 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.
  699. /// </summary>
  700. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  701. /// <param name="source">A sequence of values to calculate the average of.</param>
  702. /// <param name="selector">A transform function to apply to each element.</param>
  703. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  704. /// <exception cref="ArgumentNullException">
  705. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  706. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  707. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  708. public static IQbservable<float> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  709. {
  710. if (source == null)
  711. throw new ArgumentNullException(nameof(source));
  712. if (selector == null)
  713. throw new ArgumentNullException(nameof(selector));
  714. return source.Provider.CreateQuery<float>(
  715. Expression.Call(
  716. null,
  717. #if CRIPPLED_REFLECTION
  718. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  719. #else
  720. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  721. #endif
  722. source.Expression,
  723. selector
  724. )
  725. );
  726. }
  727. /// <summary>
  728. /// 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.
  729. /// </summary>
  730. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  731. /// <param name="source">A sequence of values to calculate the average of.</param>
  732. /// <param name="selector">A transform function to apply to each element.</param>
  733. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  734. /// <exception cref="ArgumentNullException">
  735. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  736. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  737. /// <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>
  738. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  739. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  740. {
  741. if (source == null)
  742. throw new ArgumentNullException(nameof(source));
  743. if (selector == null)
  744. throw new ArgumentNullException(nameof(selector));
  745. return source.Provider.CreateQuery<double>(
  746. Expression.Call(
  747. null,
  748. #if CRIPPLED_REFLECTION
  749. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  750. #else
  751. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  752. #endif
  753. source.Expression,
  754. selector
  755. )
  756. );
  757. }
  758. /// <summary>
  759. /// 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.
  760. /// </summary>
  761. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  762. /// <param name="source">A sequence of values to calculate the average of.</param>
  763. /// <param name="selector">A transform function to apply to each element.</param>
  764. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  765. /// <exception cref="ArgumentNullException">
  766. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  767. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  768. /// <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>
  769. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  770. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  771. {
  772. if (source == null)
  773. throw new ArgumentNullException(nameof(source));
  774. if (selector == null)
  775. throw new ArgumentNullException(nameof(selector));
  776. return source.Provider.CreateQuery<double>(
  777. Expression.Call(
  778. null,
  779. #if CRIPPLED_REFLECTION
  780. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  781. #else
  782. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  783. #endif
  784. source.Expression,
  785. selector
  786. )
  787. );
  788. }
  789. /// <summary>
  790. /// 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.
  791. /// </summary>
  792. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  793. /// <param name="source">A sequence of values to calculate the average of.</param>
  794. /// <param name="selector">A transform function to apply to each element.</param>
  795. /// <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>
  796. /// <exception cref="ArgumentNullException">
  797. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  798. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  799. /// <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>
  800. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  801. public static IQbservable<decimal?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  802. {
  803. if (source == null)
  804. throw new ArgumentNullException(nameof(source));
  805. if (selector == null)
  806. throw new ArgumentNullException(nameof(selector));
  807. return source.Provider.CreateQuery<decimal?>(
  808. Expression.Call(
  809. null,
  810. #if CRIPPLED_REFLECTION
  811. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  812. #else
  813. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  814. #endif
  815. source.Expression,
  816. selector
  817. )
  818. );
  819. }
  820. /// <summary>
  821. /// 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.
  822. /// </summary>
  823. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  824. /// <param name="source">A sequence of values to calculate the average of.</param>
  825. /// <param name="selector">A transform function to apply to each element.</param>
  826. /// <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>
  827. /// <exception cref="ArgumentNullException">
  828. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  829. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  830. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  831. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  832. {
  833. if (source == null)
  834. throw new ArgumentNullException(nameof(source));
  835. if (selector == null)
  836. throw new ArgumentNullException(nameof(selector));
  837. return source.Provider.CreateQuery<double?>(
  838. Expression.Call(
  839. null,
  840. #if CRIPPLED_REFLECTION
  841. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  842. #else
  843. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  844. #endif
  845. source.Expression,
  846. selector
  847. )
  848. );
  849. }
  850. /// <summary>
  851. /// 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.
  852. /// </summary>
  853. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  854. /// <param name="source">A sequence of values to calculate the average of.</param>
  855. /// <param name="selector">A transform function to apply to each element.</param>
  856. /// <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>
  857. /// <exception cref="ArgumentNullException">
  858. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  859. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  860. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  861. public static IQbservable<float?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  862. {
  863. if (source == null)
  864. throw new ArgumentNullException(nameof(source));
  865. if (selector == null)
  866. throw new ArgumentNullException(nameof(selector));
  867. return source.Provider.CreateQuery<float?>(
  868. Expression.Call(
  869. null,
  870. #if CRIPPLED_REFLECTION
  871. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  872. #else
  873. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  874. #endif
  875. source.Expression,
  876. selector
  877. )
  878. );
  879. }
  880. /// <summary>
  881. /// 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.
  882. /// </summary>
  883. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  884. /// <param name="source">A sequence of values to calculate the average of.</param>
  885. /// <param name="selector">A transform function to apply to each element.</param>
  886. /// <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>
  887. /// <exception cref="ArgumentNullException">
  888. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  889. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  890. /// <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>
  891. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  892. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  893. {
  894. if (source == null)
  895. throw new ArgumentNullException(nameof(source));
  896. if (selector == null)
  897. throw new ArgumentNullException(nameof(selector));
  898. return source.Provider.CreateQuery<double?>(
  899. Expression.Call(
  900. null,
  901. #if CRIPPLED_REFLECTION
  902. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  903. #else
  904. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  905. #endif
  906. source.Expression,
  907. selector
  908. )
  909. );
  910. }
  911. /// <summary>
  912. /// 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.
  913. /// </summary>
  914. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  915. /// <param name="source">A sequence of values to calculate the average of.</param>
  916. /// <param name="selector">A transform function to apply to each element.</param>
  917. /// <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>
  918. /// <exception cref="ArgumentNullException">
  919. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  920. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  921. /// <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>
  922. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  923. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  924. {
  925. if (source == null)
  926. throw new ArgumentNullException(nameof(source));
  927. if (selector == null)
  928. throw new ArgumentNullException(nameof(selector));
  929. return source.Provider.CreateQuery<double?>(
  930. Expression.Call(
  931. null,
  932. #if CRIPPLED_REFLECTION
  933. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  934. #else
  935. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  936. #endif
  937. source.Expression,
  938. selector
  939. )
  940. );
  941. }
  942. /// <summary>
  943. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on element count information.
  944. /// </summary>
  945. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  946. /// <param name="source">Source sequence to produce buffers over.</param>
  947. /// <param name="count">Length of each buffer.</param>
  948. /// <returns>An observable sequence of buffers.</returns>
  949. /// <exception cref="ArgumentNullException">
  950. /// <paramref name="source" /> is null.</exception>
  951. /// <exception cref="ArgumentOutOfRangeException">
  952. /// <paramref name="count" /> is less than or equal to zero.</exception>
  953. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count)
  954. {
  955. if (source == null)
  956. throw new ArgumentNullException(nameof(source));
  957. return source.Provider.CreateQuery<IList<TSource>>(
  958. Expression.Call(
  959. null,
  960. #if CRIPPLED_REFLECTION
  961. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int))),
  962. #else
  963. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  964. #endif
  965. source.Expression,
  966. Expression.Constant(count, typeof(int))
  967. )
  968. );
  969. }
  970. /// <summary>
  971. /// Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
  972. /// </summary>
  973. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  974. /// <param name="source">Source sequence to produce buffers over.</param>
  975. /// <param name="count">Length of each buffer.</param>
  976. /// <param name="skip">Number of elements to skip between creation of consecutive buffers.</param>
  977. /// <returns>An observable sequence of buffers.</returns>
  978. /// <exception cref="ArgumentNullException">
  979. /// <paramref name="source" /> is null.</exception>
  980. /// <exception cref="ArgumentOutOfRangeException">
  981. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  982. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count, int skip)
  983. {
  984. if (source == null)
  985. throw new ArgumentNullException(nameof(source));
  986. return source.Provider.CreateQuery<IList<TSource>>(
  987. Expression.Call(
  988. null,
  989. #if CRIPPLED_REFLECTION
  990. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  991. #else
  992. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  993. #endif
  994. source.Expression,
  995. Expression.Constant(count, typeof(int)),
  996. Expression.Constant(skip, typeof(int))
  997. )
  998. );
  999. }
  1000. /// <summary>
  1001. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information.
  1002. /// </summary>
  1003. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1004. /// <param name="source">Source sequence to produce buffers over.</param>
  1005. /// <param name="timeSpan">Length of each buffer.</param>
  1006. /// <returns>An observable sequence of buffers.</returns>
  1007. /// <exception cref="ArgumentNullException">
  1008. /// <paramref name="source" /> is null.</exception>
  1009. /// <exception cref="ArgumentOutOfRangeException">
  1010. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1011. /// <remarks>
  1012. /// 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.
  1013. /// 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
  1014. /// 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.
  1015. /// </remarks>
  1016. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  1017. {
  1018. if (source == null)
  1019. throw new ArgumentNullException(nameof(source));
  1020. return source.Provider.CreateQuery<IList<TSource>>(
  1021. Expression.Call(
  1022. null,
  1023. #if CRIPPLED_REFLECTION
  1024. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  1025. #else
  1026. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1027. #endif
  1028. source.Expression,
  1029. Expression.Constant(timeSpan, typeof(TimeSpan))
  1030. )
  1031. );
  1032. }
  1033. /// <summary>
  1034. /// 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.
  1035. /// 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.
  1036. /// </summary>
  1037. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1038. /// <param name="source">Source sequence to produce buffers over.</param>
  1039. /// <param name="timeSpan">Maximum time length of a window.</param>
  1040. /// <param name="count">Maximum element count of a window.</param>
  1041. /// <returns>An observable sequence of buffers.</returns>
  1042. /// <exception cref="ArgumentNullException">
  1043. /// <paramref name="source" /> is null.</exception>
  1044. /// <exception cref="ArgumentOutOfRangeException">
  1045. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  1046. /// <remarks>
  1047. /// 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.
  1048. /// 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
  1049. /// 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.
  1050. /// </remarks>
  1051. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  1052. {
  1053. if (source == null)
  1054. throw new ArgumentNullException(nameof(source));
  1055. return source.Provider.CreateQuery<IList<TSource>>(
  1056. Expression.Call(
  1057. null,
  1058. #if CRIPPLED_REFLECTION
  1059. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  1060. #else
  1061. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1062. #endif
  1063. source.Expression,
  1064. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1065. Expression.Constant(count, typeof(int))
  1066. )
  1067. );
  1068. }
  1069. /// <summary>
  1070. /// 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.
  1071. /// 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.
  1072. /// </summary>
  1073. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1074. /// <param name="source">Source sequence to produce buffers over.</param>
  1075. /// <param name="timeSpan">Maximum time length of a buffer.</param>
  1076. /// <param name="count">Maximum element count of a buffer.</param>
  1077. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1078. /// <returns>An observable sequence of buffers.</returns>
  1079. /// <exception cref="ArgumentNullException">
  1080. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1081. /// <exception cref="ArgumentOutOfRangeException">
  1082. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  1083. /// <remarks>
  1084. /// 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.
  1085. /// 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
  1086. /// 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.
  1087. /// </remarks>
  1088. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  1089. {
  1090. if (source == null)
  1091. throw new ArgumentNullException(nameof(source));
  1092. if (scheduler == null)
  1093. throw new ArgumentNullException(nameof(scheduler));
  1094. return source.Provider.CreateQuery<IList<TSource>>(
  1095. Expression.Call(
  1096. null,
  1097. #if CRIPPLED_REFLECTION
  1098. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  1099. #else
  1100. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1101. #endif
  1102. source.Expression,
  1103. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1104. Expression.Constant(count, typeof(int)),
  1105. Expression.Constant(scheduler, typeof(IScheduler))
  1106. )
  1107. );
  1108. }
  1109. /// <summary>
  1110. /// 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.
  1111. /// </summary>
  1112. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1113. /// <param name="source">Source sequence to produce buffers over.</param>
  1114. /// <param name="timeSpan">Length of each buffer.</param>
  1115. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1116. /// <returns>An observable sequence of buffers.</returns>
  1117. /// <exception cref="ArgumentNullException">
  1118. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1119. /// <exception cref="ArgumentOutOfRangeException">
  1120. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1121. /// <remarks>
  1122. /// 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.
  1123. /// 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
  1124. /// 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.
  1125. /// </remarks>
  1126. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  1127. {
  1128. if (source == null)
  1129. throw new ArgumentNullException(nameof(source));
  1130. if (scheduler == null)
  1131. throw new ArgumentNullException(nameof(scheduler));
  1132. return source.Provider.CreateQuery<IList<TSource>>(
  1133. Expression.Call(
  1134. null,
  1135. #if CRIPPLED_REFLECTION
  1136. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  1137. #else
  1138. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1139. #endif
  1140. source.Expression,
  1141. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1142. Expression.Constant(scheduler, typeof(IScheduler))
  1143. )
  1144. );
  1145. }
  1146. /// <summary>
  1147. /// Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
  1148. /// </summary>
  1149. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1150. /// <param name="source">Source sequence to produce buffers over.</param>
  1151. /// <param name="timeSpan">Length of each buffer.</param>
  1152. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1153. /// <returns>An observable sequence of buffers.</returns>
  1154. /// <exception cref="ArgumentNullException">
  1155. /// <paramref name="source" /> is null.</exception>
  1156. /// <exception cref="ArgumentOutOfRangeException">
  1157. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1158. /// <remarks>
  1159. /// <para>
  1160. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1161. /// 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
  1162. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1163. /// </para>
  1164. /// <para>
  1165. /// 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.
  1166. /// 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,
  1167. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1168. /// </para>
  1169. /// </remarks>
  1170. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  1171. {
  1172. if (source == null)
  1173. throw new ArgumentNullException(nameof(source));
  1174. return source.Provider.CreateQuery<IList<TSource>>(
  1175. Expression.Call(
  1176. null,
  1177. #if CRIPPLED_REFLECTION
  1178. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  1179. #else
  1180. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1181. #endif
  1182. source.Expression,
  1183. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1184. Expression.Constant(timeShift, typeof(TimeSpan))
  1185. )
  1186. );
  1187. }
  1188. /// <summary>
  1189. /// 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.
  1190. /// </summary>
  1191. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1192. /// <param name="source">Source sequence to produce buffers over.</param>
  1193. /// <param name="timeSpan">Length of each buffer.</param>
  1194. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1195. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1196. /// <returns>An observable sequence of buffers.</returns>
  1197. /// <exception cref="ArgumentNullException">
  1198. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1199. /// <exception cref="ArgumentOutOfRangeException">
  1200. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1201. /// <remarks>
  1202. /// <para>
  1203. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1204. /// 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
  1205. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1206. /// </para>
  1207. /// <para>
  1208. /// 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.
  1209. /// 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,
  1210. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1211. /// </para>
  1212. /// </remarks>
  1213. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  1214. {
  1215. if (source == null)
  1216. throw new ArgumentNullException(nameof(source));
  1217. if (scheduler == null)
  1218. throw new ArgumentNullException(nameof(scheduler));
  1219. return source.Provider.CreateQuery<IList<TSource>>(
  1220. Expression.Call(
  1221. null,
  1222. #if CRIPPLED_REFLECTION
  1223. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  1224. #else
  1225. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1226. #endif
  1227. source.Expression,
  1228. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1229. Expression.Constant(timeShift, typeof(TimeSpan)),
  1230. Expression.Constant(scheduler, typeof(IScheduler))
  1231. )
  1232. );
  1233. }
  1234. /// <summary>
  1235. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  1236. /// </summary>
  1237. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1238. /// <typeparam name="TBufferBoundary">The type of the elements in the sequences indicating buffer boundary events.</typeparam>
  1239. /// <param name="source">Source sequence to produce buffers over.</param>
  1240. /// <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>
  1241. /// <returns>An observable sequence of buffers.</returns>
  1242. /// <exception cref="ArgumentNullException">
  1243. /// <paramref name="source" /> or <paramref name="bufferBoundaries" /> is null.</exception>
  1244. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferBoundary>(this IQbservable<TSource> source, IObservable<TBufferBoundary> bufferBoundaries)
  1245. {
  1246. if (source == null)
  1247. throw new ArgumentNullException(nameof(source));
  1248. if (bufferBoundaries == null)
  1249. throw new ArgumentNullException(nameof(bufferBoundaries));
  1250. return source.Provider.CreateQuery<IList<TSource>>(
  1251. Expression.Call(
  1252. null,
  1253. #if CRIPPLED_REFLECTION
  1254. InfoOf(() => Qbservable.Buffer<TSource, TBufferBoundary>(default(IQbservable<TSource>), default(IObservable<TBufferBoundary>))),
  1255. #else
  1256. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferBoundary)),
  1257. #endif
  1258. source.Expression,
  1259. GetSourceExpression(bufferBoundaries)
  1260. )
  1261. );
  1262. }
  1263. /// <summary>
  1264. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  1265. /// </summary>
  1266. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1267. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1268. /// <param name="source">Source sequence to produce buffers over.</param>
  1269. /// <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>
  1270. /// <returns>An observable sequence of buffers.</returns>
  1271. /// <exception cref="ArgumentNullException">
  1272. /// <paramref name="source" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1273. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TBufferClosing>>> bufferClosingSelector)
  1274. {
  1275. if (source == null)
  1276. throw new ArgumentNullException(nameof(source));
  1277. if (bufferClosingSelector == null)
  1278. throw new ArgumentNullException(nameof(bufferClosingSelector));
  1279. return source.Provider.CreateQuery<IList<TSource>>(
  1280. Expression.Call(
  1281. null,
  1282. #if CRIPPLED_REFLECTION
  1283. InfoOf(() => Qbservable.Buffer<TSource, TBufferClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TBufferClosing>>>))),
  1284. #else
  1285. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferClosing)),
  1286. #endif
  1287. source.Expression,
  1288. bufferClosingSelector
  1289. )
  1290. );
  1291. }
  1292. /// <summary>
  1293. /// Projects each element of an observable sequence into zero or more buffers.
  1294. /// </summary>
  1295. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1296. /// <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>
  1297. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1298. /// <param name="source">Source sequence to produce buffers over.</param>
  1299. /// <param name="bufferOpenings">Observable sequence whose elements denote the creation of new buffers.</param>
  1300. /// <param name="bufferClosingSelector">A function invoked to define the closing of each produced buffer.</param>
  1301. /// <returns>An observable sequence of buffers.</returns>
  1302. /// <exception cref="ArgumentNullException">
  1303. /// <paramref name="source" /> or <paramref name="bufferOpenings" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1304. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferOpening, TBufferClosing>(this IQbservable<TSource> source, IObservable<TBufferOpening> bufferOpenings, Expression<Func<TBufferOpening, IObservable<TBufferClosing>>> bufferClosingSelector)
  1305. {
  1306. if (source == null)
  1307. throw new ArgumentNullException(nameof(source));
  1308. if (bufferOpenings == null)
  1309. throw new ArgumentNullException(nameof(bufferOpenings));
  1310. if (bufferClosingSelector == null)
  1311. throw new ArgumentNullException(nameof(bufferClosingSelector));
  1312. return source.Provider.CreateQuery<IList<TSource>>(
  1313. Expression.Call(
  1314. null,
  1315. #if CRIPPLED_REFLECTION
  1316. InfoOf(() => Qbservable.Buffer<TSource, TBufferOpening, TBufferClosing>(default(IQbservable<TSource>), default(IObservable<TBufferOpening>), default(Expression<Func<TBufferOpening, IObservable<TBufferClosing>>>))),
  1317. #else
  1318. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferOpening), typeof(TBufferClosing)),
  1319. #endif
  1320. source.Expression,
  1321. GetSourceExpression(bufferOpenings),
  1322. bufferClosingSelector
  1323. )
  1324. );
  1325. }
  1326. /// <summary>
  1327. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing an empty sequence if no match is found.
  1328. /// </summary>
  1329. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1330. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1331. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1332. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1333. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1334. /// <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>
  1335. /// <exception cref="ArgumentNullException">
  1336. /// <paramref name="selector" /> or <paramref name="sources" /> is null.</exception>
  1337. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources)
  1338. {
  1339. if (provider == null)
  1340. throw new ArgumentNullException(nameof(provider));
  1341. if (selector == null)
  1342. throw new ArgumentNullException(nameof(selector));
  1343. if (sources == null)
  1344. throw new ArgumentNullException(nameof(sources));
  1345. return provider.CreateQuery<TResult>(
  1346. Expression.Call(
  1347. null,
  1348. #if CRIPPLED_REFLECTION
  1349. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>))),
  1350. #else
  1351. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1352. #endif
  1353. Expression.Constant(provider, typeof(IQbservableProvider)),
  1354. selector,
  1355. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>))
  1356. )
  1357. );
  1358. }
  1359. /// <summary>
  1360. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing <paramref name="defaultSource" /> if no match is found.
  1361. /// </summary>
  1362. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1363. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1364. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1365. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1366. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1367. /// <param name="defaultSource">Default source to select in case no matching source in <paramref name="sources" /> is found.</param>
  1368. /// <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>
  1369. /// <exception cref="ArgumentNullException">
  1370. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="defaultSource" /> is null.</exception>
  1371. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IObservable<TResult> defaultSource)
  1372. {
  1373. if (provider == null)
  1374. throw new ArgumentNullException(nameof(provider));
  1375. if (selector == null)
  1376. throw new ArgumentNullException(nameof(selector));
  1377. if (sources == null)
  1378. throw new ArgumentNullException(nameof(sources));
  1379. if (defaultSource == null)
  1380. throw new ArgumentNullException(nameof(defaultSource));
  1381. return provider.CreateQuery<TResult>(
  1382. Expression.Call(
  1383. null,
  1384. #if CRIPPLED_REFLECTION
  1385. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IObservable<TResult>))),
  1386. #else
  1387. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1388. #endif
  1389. Expression.Constant(provider, typeof(IQbservableProvider)),
  1390. selector,
  1391. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1392. GetSourceExpression(defaultSource)
  1393. )
  1394. );
  1395. }
  1396. /// <summary>
  1397. /// 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.
  1398. /// </summary>
  1399. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1400. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1401. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1402. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1403. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1404. /// <param name="scheduler">Scheduler to generate an empty sequence on in case no matching source in <paramref name="sources" /> is found.</param>
  1405. /// <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>
  1406. /// <exception cref="ArgumentNullException">
  1407. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  1408. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IScheduler scheduler)
  1409. {
  1410. if (provider == null)
  1411. throw new ArgumentNullException(nameof(provider));
  1412. if (selector == null)
  1413. throw new ArgumentNullException(nameof(selector));
  1414. if (sources == null)
  1415. throw new ArgumentNullException(nameof(sources));
  1416. if (scheduler == null)
  1417. throw new ArgumentNullException(nameof(scheduler));
  1418. return provider.CreateQuery<TResult>(
  1419. Expression.Call(
  1420. null,
  1421. #if CRIPPLED_REFLECTION
  1422. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IScheduler))),
  1423. #else
  1424. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1425. #endif
  1426. Expression.Constant(provider, typeof(IQbservableProvider)),
  1427. selector,
  1428. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1429. Expression.Constant(scheduler, typeof(IScheduler))
  1430. )
  1431. );
  1432. }
  1433. /// <summary>
  1434. /// Converts the elements of an observable sequence to the specified type.
  1435. /// </summary>
  1436. /// <typeparam name="TResult">The type to convert the elements in the source sequence to.</typeparam>
  1437. /// <param name="source">The observable sequence that contains the elements to be converted.</param>
  1438. /// <returns>An observable sequence that contains each element of the source sequence converted to the specified type.</returns>
  1439. /// <exception cref="ArgumentNullException">
  1440. /// <paramref name="source" /> is null.</exception>
  1441. public static IQbservable<TResult> Cast<TResult>(this IQbservable<object> source)
  1442. {
  1443. if (source == null)
  1444. throw new ArgumentNullException(nameof(source));
  1445. return source.Provider.CreateQuery<TResult>(
  1446. Expression.Call(
  1447. null,
  1448. #if CRIPPLED_REFLECTION
  1449. InfoOf(() => Qbservable.Cast<TResult>(default(IQbservable<object>))),
  1450. #else
  1451. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  1452. #endif
  1453. source.Expression
  1454. )
  1455. );
  1456. }
  1457. /// <summary>
  1458. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1459. /// </summary>
  1460. /// <typeparam name="TSource">The type of the elements in the source sequence and handler sequence.</typeparam>
  1461. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  1462. /// <param name="second">Second observable sequence used to produce results when an error occurred in the first sequence.</param>
  1463. /// <returns>An observable sequence containing the first sequence's elements, followed by the elements of the second sequence in case an exception occurred.</returns>
  1464. /// <exception cref="ArgumentNullException">
  1465. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  1466. public static IQbservable<TSource> Catch<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  1467. {
  1468. if (first == null)
  1469. throw new ArgumentNullException(nameof(first));
  1470. if (second == null)
  1471. throw new ArgumentNullException(nameof(second));
  1472. return first.Provider.CreateQuery<TSource>(
  1473. Expression.Call(
  1474. null,
  1475. #if CRIPPLED_REFLECTION
  1476. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  1477. #else
  1478. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1479. #endif
  1480. first.Expression,
  1481. GetSourceExpression(second)
  1482. )
  1483. );
  1484. }
  1485. /// <summary>
  1486. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1487. /// </summary>
  1488. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1489. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1490. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1491. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1492. /// <exception cref="ArgumentNullException">
  1493. /// <paramref name="sources" /> is null.</exception>
  1494. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1495. {
  1496. if (provider == null)
  1497. throw new ArgumentNullException(nameof(provider));
  1498. if (sources == null)
  1499. throw new ArgumentNullException(nameof(sources));
  1500. return provider.CreateQuery<TSource>(
  1501. Expression.Call(
  1502. null,
  1503. #if CRIPPLED_REFLECTION
  1504. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1505. #else
  1506. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1507. #endif
  1508. Expression.Constant(provider, typeof(IQbservableProvider)),
  1509. GetSourceExpression(sources)
  1510. )
  1511. );
  1512. }
  1513. /// <summary>
  1514. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1515. /// </summary>
  1516. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1517. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1518. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1519. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1520. /// <exception cref="ArgumentNullException">
  1521. /// <paramref name="sources" /> is null.</exception>
  1522. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1523. {
  1524. if (provider == null)
  1525. throw new ArgumentNullException(nameof(provider));
  1526. if (sources == null)
  1527. throw new ArgumentNullException(nameof(sources));
  1528. return provider.CreateQuery<TSource>(
  1529. Expression.Call(
  1530. null,
  1531. #if CRIPPLED_REFLECTION
  1532. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1533. #else
  1534. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1535. #endif
  1536. Expression.Constant(provider, typeof(IQbservableProvider)),
  1537. GetSourceExpression(sources)
  1538. )
  1539. );
  1540. }
  1541. /// <summary>
  1542. /// Continues an observable sequence that is terminated by an exception of the specified type with the observable sequence produced by the handler.
  1543. /// </summary>
  1544. /// <typeparam name="TSource">The type of the elements in the source sequence and sequences returned by the exception handler function.</typeparam>
  1545. /// <typeparam name="TException">The type of the exception to catch and handle. Needs to derive from <see cref="Exception" />.</typeparam>
  1546. /// <param name="source">Source sequence.</param>
  1547. /// <param name="handler">Exception handler function, producing another observable sequence.</param>
  1548. /// <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>
  1549. /// <exception cref="ArgumentNullException">
  1550. /// <paramref name="source" /> or <paramref name="handler" /> is null.</exception>
  1551. public static IQbservable<TSource> Catch<TSource, TException>(this IQbservable<TSource> source, Expression<Func<TException, IObservable<TSource>>> handler)
  1552. where TException : Exception
  1553. {
  1554. if (source == null)
  1555. throw new ArgumentNullException(nameof(source));
  1556. if (handler == null)
  1557. throw new ArgumentNullException(nameof(handler));
  1558. return source.Provider.CreateQuery<TSource>(
  1559. Expression.Call(
  1560. null,
  1561. #if CRIPPLED_REFLECTION
  1562. InfoOf(() => Qbservable.Catch<TSource, TException>(default(IQbservable<TSource>), default(Expression<Func<TException, IObservable<TSource>>>))),
  1563. #else
  1564. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)),
  1565. #endif
  1566. source.Expression,
  1567. handler
  1568. )
  1569. );
  1570. }
  1571. /// <summary>
  1572. /// Produces an enumerable sequence of consecutive (possibly empty) chunks of the source sequence.
  1573. /// </summary>
  1574. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1575. /// <param name="source">Source observable sequence.</param>
  1576. /// <returns>The enumerable sequence that returns consecutive (possibly empty) chunks upon each iteration.</returns>
  1577. /// <exception cref="ArgumentNullException">
  1578. /// <paramref name="source" /> is null.</exception>
  1579. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1580. public static IQueryable<IList<TSource>> Chunkify<TSource>(this IQbservable<TSource> source)
  1581. {
  1582. if (source == null)
  1583. throw new ArgumentNullException(nameof(source));
  1584. return ((IQueryProvider)source.Provider).CreateQuery<IList<TSource>>(
  1585. Expression.Call(
  1586. null,
  1587. #if CRIPPLED_REFLECTION
  1588. InfoOf(() => Qbservable.Chunkify<TSource>(default(IQbservable<TSource>))),
  1589. #else
  1590. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1591. #endif
  1592. source.Expression
  1593. )
  1594. );
  1595. }
  1596. /// <summary>
  1597. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1598. /// </summary>
  1599. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1600. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1601. /// <param name="source">Source observable sequence.</param>
  1602. /// <param name="getInitialCollector">Factory to create the initial collector object.</param>
  1603. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1604. /// <param name="getNewCollector">Factory to replace the current collector by a new collector.</param>
  1605. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1606. /// <exception cref="ArgumentNullException">
  1607. /// <paramref name="source" /> or <paramref name="getInitialCollector" /> or <paramref name="merge" /> or <paramref name="getNewCollector" /> is null.</exception>
  1608. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1609. 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)
  1610. {
  1611. if (source == null)
  1612. throw new ArgumentNullException(nameof(source));
  1613. if (getInitialCollector == null)
  1614. throw new ArgumentNullException(nameof(getInitialCollector));
  1615. if (merge == null)
  1616. throw new ArgumentNullException(nameof(merge));
  1617. if (getNewCollector == null)
  1618. throw new ArgumentNullException(nameof(getNewCollector));
  1619. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1620. Expression.Call(
  1621. null,
  1622. #if CRIPPLED_REFLECTION
  1623. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>), default(Expression<Func<TResult, TResult>>))),
  1624. #else
  1625. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1626. #endif
  1627. source.Expression,
  1628. getInitialCollector,
  1629. merge,
  1630. getNewCollector
  1631. )
  1632. );
  1633. }
  1634. /// <summary>
  1635. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1636. /// </summary>
  1637. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1638. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1639. /// <param name="source">Source observable sequence.</param>
  1640. /// <param name="newCollector">Factory to create a new collector object.</param>
  1641. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1642. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1643. /// <exception cref="ArgumentNullException">
  1644. /// <paramref name="source" /> or <paramref name="newCollector" /> or <paramref name="merge" /> is null.</exception>
  1645. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1646. public static IQueryable<TResult> Collect<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TResult>> newCollector, Expression<Func<TResult, TSource, TResult>> merge)
  1647. {
  1648. if (source == null)
  1649. throw new ArgumentNullException(nameof(source));
  1650. if (newCollector == null)
  1651. throw new ArgumentNullException(nameof(newCollector));
  1652. if (merge == null)
  1653. throw new ArgumentNullException(nameof(merge));
  1654. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1655. Expression.Call(
  1656. null,
  1657. #if CRIPPLED_REFLECTION
  1658. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>))),
  1659. #else
  1660. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1661. #endif
  1662. source.Expression,
  1663. newCollector,
  1664. merge
  1665. )
  1666. );
  1667. }
  1668. /// <summary>
  1669. /// 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.
  1670. /// </summary>
  1671. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1672. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1673. /// <param name="sources">Observable sources.</param>
  1674. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1675. /// <exception cref="ArgumentNullException">
  1676. /// <paramref name="sources" /> is null.</exception>
  1677. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1678. {
  1679. if (provider == null)
  1680. throw new ArgumentNullException(nameof(provider));
  1681. if (sources == null)
  1682. throw new ArgumentNullException(nameof(sources));
  1683. return provider.CreateQuery<IList<TSource>>(
  1684. Expression.Call(
  1685. null,
  1686. #if CRIPPLED_REFLECTION
  1687. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1688. #else
  1689. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1690. #endif
  1691. Expression.Constant(provider, typeof(IQbservableProvider)),
  1692. GetSourceExpression(sources)
  1693. )
  1694. );
  1695. }
  1696. /// <summary>
  1697. /// 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.
  1698. /// </summary>
  1699. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1700. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1701. /// <param name="sources">Observable sources.</param>
  1702. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1703. /// <exception cref="ArgumentNullException">
  1704. /// <paramref name="sources" /> is null.</exception>
  1705. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1706. {
  1707. if (provider == null)
  1708. throw new ArgumentNullException(nameof(provider));
  1709. if (sources == null)
  1710. throw new ArgumentNullException(nameof(sources));
  1711. return provider.CreateQuery<IList<TSource>>(
  1712. Expression.Call(
  1713. null,
  1714. #if CRIPPLED_REFLECTION
  1715. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1716. #else
  1717. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1718. #endif
  1719. Expression.Constant(provider, typeof(IQbservableProvider)),
  1720. GetSourceExpression(sources)
  1721. )
  1722. );
  1723. }
  1724. /// <summary>
  1725. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1726. /// </summary>
  1727. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1728. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  1729. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1730. /// <param name="sources">Observable sources.</param>
  1731. /// <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>
  1732. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1733. /// <exception cref="ArgumentNullException">
  1734. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  1735. public static IQbservable<TResult> CombineLatest<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  1736. {
  1737. if (provider == null)
  1738. throw new ArgumentNullException(nameof(provider));
  1739. if (sources == null)
  1740. throw new ArgumentNullException(nameof(sources));
  1741. if (resultSelector == null)
  1742. throw new ArgumentNullException(nameof(resultSelector));
  1743. return provider.CreateQuery<TResult>(
  1744. Expression.Call(
  1745. null,
  1746. #if CRIPPLED_REFLECTION
  1747. InfoOf(() => Qbservable.CombineLatest<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  1748. #else
  1749. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1750. #endif
  1751. Expression.Constant(provider, typeof(IQbservableProvider)),
  1752. GetSourceExpression(sources),
  1753. resultSelector
  1754. )
  1755. );
  1756. }
  1757. /// <summary>
  1758. /// Merges two observable sequences into one observable sequence by using the selector function whenever one of the observable sequences produces an element.
  1759. /// </summary>
  1760. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1761. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1762. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1763. /// <param name="first">First observable source.</param>
  1764. /// <param name="second">Second observable source.</param>
  1765. /// <param name="resultSelector">Function to invoke whenever either of the sources produces an element.</param>
  1766. /// <returns>An observable sequence containing the result of combining elements of both sources using the specified result selector function.</returns>
  1767. /// <exception cref="ArgumentNullException">
  1768. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  1769. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  1770. {
  1771. if (first == null)
  1772. throw new ArgumentNullException(nameof(first));
  1773. if (second == null)
  1774. throw new ArgumentNullException(nameof(second));
  1775. if (resultSelector == null)
  1776. throw new ArgumentNullException(nameof(resultSelector));
  1777. return first.Provider.CreateQuery<TResult>(
  1778. Expression.Call(
  1779. null,
  1780. #if CRIPPLED_REFLECTION
  1781. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  1782. #else
  1783. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  1784. #endif
  1785. first.Expression,
  1786. GetSourceExpression(second),
  1787. resultSelector
  1788. )
  1789. );
  1790. }
  1791. /// <summary>
  1792. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1793. /// </summary>
  1794. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1795. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1796. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1797. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1798. /// <param name="source1">First observable source.</param>
  1799. /// <param name="source2">Second observable source.</param>
  1800. /// <param name="source3">Third observable source.</param>
  1801. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1802. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1803. /// <exception cref="ArgumentNullException">
  1804. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  1805. 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)
  1806. {
  1807. if (source1 == null)
  1808. throw new ArgumentNullException(nameof(source1));
  1809. if (source2 == null)
  1810. throw new ArgumentNullException(nameof(source2));
  1811. if (source3 == null)
  1812. throw new ArgumentNullException(nameof(source3));
  1813. if (resultSelector == null)
  1814. throw new ArgumentNullException(nameof(resultSelector));
  1815. return source1.Provider.CreateQuery<TResult>(
  1816. Expression.Call(
  1817. null,
  1818. #if CRIPPLED_REFLECTION
  1819. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  1820. #else
  1821. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  1822. #endif
  1823. source1.Expression,
  1824. GetSourceExpression(source2),
  1825. GetSourceExpression(source3),
  1826. resultSelector
  1827. )
  1828. );
  1829. }
  1830. /// <summary>
  1831. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1832. /// </summary>
  1833. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1834. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1835. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1836. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1837. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1838. /// <param name="source1">First observable source.</param>
  1839. /// <param name="source2">Second observable source.</param>
  1840. /// <param name="source3">Third observable source.</param>
  1841. /// <param name="source4">Fourth observable source.</param>
  1842. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1843. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1844. /// <exception cref="ArgumentNullException">
  1845. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  1846. 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)
  1847. {
  1848. if (source1 == null)
  1849. throw new ArgumentNullException(nameof(source1));
  1850. if (source2 == null)
  1851. throw new ArgumentNullException(nameof(source2));
  1852. if (source3 == null)
  1853. throw new ArgumentNullException(nameof(source3));
  1854. if (source4 == null)
  1855. throw new ArgumentNullException(nameof(source4));
  1856. if (resultSelector == null)
  1857. throw new ArgumentNullException(nameof(resultSelector));
  1858. return source1.Provider.CreateQuery<TResult>(
  1859. Expression.Call(
  1860. null,
  1861. #if CRIPPLED_REFLECTION
  1862. 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>>))),
  1863. #else
  1864. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  1865. #endif
  1866. source1.Expression,
  1867. GetSourceExpression(source2),
  1868. GetSourceExpression(source3),
  1869. GetSourceExpression(source4),
  1870. resultSelector
  1871. )
  1872. );
  1873. }
  1874. /// <summary>
  1875. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1876. /// </summary>
  1877. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1878. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1879. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1880. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1881. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1882. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1883. /// <param name="source1">First observable source.</param>
  1884. /// <param name="source2">Second observable source.</param>
  1885. /// <param name="source3">Third observable source.</param>
  1886. /// <param name="source4">Fourth observable source.</param>
  1887. /// <param name="source5">Fifth observable source.</param>
  1888. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1889. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1890. /// <exception cref="ArgumentNullException">
  1891. /// <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>
  1892. 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)
  1893. {
  1894. if (source1 == null)
  1895. throw new ArgumentNullException(nameof(source1));
  1896. if (source2 == null)
  1897. throw new ArgumentNullException(nameof(source2));
  1898. if (source3 == null)
  1899. throw new ArgumentNullException(nameof(source3));
  1900. if (source4 == null)
  1901. throw new ArgumentNullException(nameof(source4));
  1902. if (source5 == null)
  1903. throw new ArgumentNullException(nameof(source5));
  1904. if (resultSelector == null)
  1905. throw new ArgumentNullException(nameof(resultSelector));
  1906. return source1.Provider.CreateQuery<TResult>(
  1907. Expression.Call(
  1908. null,
  1909. #if CRIPPLED_REFLECTION
  1910. 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>>))),
  1911. #else
  1912. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  1913. #endif
  1914. source1.Expression,
  1915. GetSourceExpression(source2),
  1916. GetSourceExpression(source3),
  1917. GetSourceExpression(source4),
  1918. GetSourceExpression(source5),
  1919. resultSelector
  1920. )
  1921. );
  1922. }
  1923. /// <summary>
  1924. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1925. /// </summary>
  1926. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1927. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1928. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1929. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1930. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1931. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1932. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1933. /// <param name="source1">First observable source.</param>
  1934. /// <param name="source2">Second observable source.</param>
  1935. /// <param name="source3">Third observable source.</param>
  1936. /// <param name="source4">Fourth observable source.</param>
  1937. /// <param name="source5">Fifth observable source.</param>
  1938. /// <param name="source6">Sixth observable source.</param>
  1939. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1940. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1941. /// <exception cref="ArgumentNullException">
  1942. /// <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>
  1943. 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)
  1944. {
  1945. if (source1 == null)
  1946. throw new ArgumentNullException(nameof(source1));
  1947. if (source2 == null)
  1948. throw new ArgumentNullException(nameof(source2));
  1949. if (source3 == null)
  1950. throw new ArgumentNullException(nameof(source3));
  1951. if (source4 == null)
  1952. throw new ArgumentNullException(nameof(source4));
  1953. if (source5 == null)
  1954. throw new ArgumentNullException(nameof(source5));
  1955. if (source6 == null)
  1956. throw new ArgumentNullException(nameof(source6));
  1957. if (resultSelector == null)
  1958. throw new ArgumentNullException(nameof(resultSelector));
  1959. return source1.Provider.CreateQuery<TResult>(
  1960. Expression.Call(
  1961. null,
  1962. #if CRIPPLED_REFLECTION
  1963. 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>>))),
  1964. #else
  1965. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  1966. #endif
  1967. source1.Expression,
  1968. GetSourceExpression(source2),
  1969. GetSourceExpression(source3),
  1970. GetSourceExpression(source4),
  1971. GetSourceExpression(source5),
  1972. GetSourceExpression(source6),
  1973. resultSelector
  1974. )
  1975. );
  1976. }
  1977. /// <summary>
  1978. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1979. /// </summary>
  1980. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1981. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1982. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1983. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1984. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1985. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1986. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  1987. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1988. /// <param name="source1">First observable source.</param>
  1989. /// <param name="source2">Second observable source.</param>
  1990. /// <param name="source3">Third observable source.</param>
  1991. /// <param name="source4">Fourth observable source.</param>
  1992. /// <param name="source5">Fifth observable source.</param>
  1993. /// <param name="source6">Sixth observable source.</param>
  1994. /// <param name="source7">Seventh observable source.</param>
  1995. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1996. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1997. /// <exception cref="ArgumentNullException">
  1998. /// <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>
  1999. 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)
  2000. {
  2001. if (source1 == null)
  2002. throw new ArgumentNullException(nameof(source1));
  2003. if (source2 == null)
  2004. throw new ArgumentNullException(nameof(source2));
  2005. if (source3 == null)
  2006. throw new ArgumentNullException(nameof(source3));
  2007. if (source4 == null)
  2008. throw new ArgumentNullException(nameof(source4));
  2009. if (source5 == null)
  2010. throw new ArgumentNullException(nameof(source5));
  2011. if (source6 == null)
  2012. throw new ArgumentNullException(nameof(source6));
  2013. if (source7 == null)
  2014. throw new ArgumentNullException(nameof(source7));
  2015. if (resultSelector == null)
  2016. throw new ArgumentNullException(nameof(resultSelector));
  2017. return source1.Provider.CreateQuery<TResult>(
  2018. Expression.Call(
  2019. null,
  2020. #if CRIPPLED_REFLECTION
  2021. 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>>))),
  2022. #else
  2023. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  2024. #endif
  2025. source1.Expression,
  2026. GetSourceExpression(source2),
  2027. GetSourceExpression(source3),
  2028. GetSourceExpression(source4),
  2029. GetSourceExpression(source5),
  2030. GetSourceExpression(source6),
  2031. GetSourceExpression(source7),
  2032. resultSelector
  2033. )
  2034. );
  2035. }
  2036. /// <summary>
  2037. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2038. /// </summary>
  2039. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2040. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2041. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2042. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2043. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2044. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2045. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2046. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2047. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2048. /// <param name="source1">First observable source.</param>
  2049. /// <param name="source2">Second observable source.</param>
  2050. /// <param name="source3">Third observable source.</param>
  2051. /// <param name="source4">Fourth observable source.</param>
  2052. /// <param name="source5">Fifth observable source.</param>
  2053. /// <param name="source6">Sixth observable source.</param>
  2054. /// <param name="source7">Seventh observable source.</param>
  2055. /// <param name="source8">Eighth observable source.</param>
  2056. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2057. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2058. /// <exception cref="ArgumentNullException">
  2059. /// <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>
  2060. 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)
  2061. {
  2062. if (source1 == null)
  2063. throw new ArgumentNullException(nameof(source1));
  2064. if (source2 == null)
  2065. throw new ArgumentNullException(nameof(source2));
  2066. if (source3 == null)
  2067. throw new ArgumentNullException(nameof(source3));
  2068. if (source4 == null)
  2069. throw new ArgumentNullException(nameof(source4));
  2070. if (source5 == null)
  2071. throw new ArgumentNullException(nameof(source5));
  2072. if (source6 == null)
  2073. throw new ArgumentNullException(nameof(source6));
  2074. if (source7 == null)
  2075. throw new ArgumentNullException(nameof(source7));
  2076. if (source8 == null)
  2077. throw new ArgumentNullException(nameof(source8));
  2078. if (resultSelector == null)
  2079. throw new ArgumentNullException(nameof(resultSelector));
  2080. return source1.Provider.CreateQuery<TResult>(
  2081. Expression.Call(
  2082. null,
  2083. #if CRIPPLED_REFLECTION
  2084. 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>>))),
  2085. #else
  2086. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  2087. #endif
  2088. source1.Expression,
  2089. GetSourceExpression(source2),
  2090. GetSourceExpression(source3),
  2091. GetSourceExpression(source4),
  2092. GetSourceExpression(source5),
  2093. GetSourceExpression(source6),
  2094. GetSourceExpression(source7),
  2095. GetSourceExpression(source8),
  2096. resultSelector
  2097. )
  2098. );
  2099. }
  2100. /// <summary>
  2101. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2102. /// </summary>
  2103. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2104. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2105. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2106. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2107. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2108. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2109. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2110. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2111. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2112. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2113. /// <param name="source1">First observable source.</param>
  2114. /// <param name="source2">Second observable source.</param>
  2115. /// <param name="source3">Third observable source.</param>
  2116. /// <param name="source4">Fourth observable source.</param>
  2117. /// <param name="source5">Fifth observable source.</param>
  2118. /// <param name="source6">Sixth observable source.</param>
  2119. /// <param name="source7">Seventh observable source.</param>
  2120. /// <param name="source8">Eighth observable source.</param>
  2121. /// <param name="source9">Ninth observable source.</param>
  2122. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2123. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2124. /// <exception cref="ArgumentNullException">
  2125. /// <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>
  2126. 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)
  2127. {
  2128. if (source1 == null)
  2129. throw new ArgumentNullException(nameof(source1));
  2130. if (source2 == null)
  2131. throw new ArgumentNullException(nameof(source2));
  2132. if (source3 == null)
  2133. throw new ArgumentNullException(nameof(source3));
  2134. if (source4 == null)
  2135. throw new ArgumentNullException(nameof(source4));
  2136. if (source5 == null)
  2137. throw new ArgumentNullException(nameof(source5));
  2138. if (source6 == null)
  2139. throw new ArgumentNullException(nameof(source6));
  2140. if (source7 == null)
  2141. throw new ArgumentNullException(nameof(source7));
  2142. if (source8 == null)
  2143. throw new ArgumentNullException(nameof(source8));
  2144. if (source9 == null)
  2145. throw new ArgumentNullException(nameof(source9));
  2146. if (resultSelector == null)
  2147. throw new ArgumentNullException(nameof(resultSelector));
  2148. return source1.Provider.CreateQuery<TResult>(
  2149. Expression.Call(
  2150. null,
  2151. #if CRIPPLED_REFLECTION
  2152. 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>>))),
  2153. #else
  2154. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  2155. #endif
  2156. source1.Expression,
  2157. GetSourceExpression(source2),
  2158. GetSourceExpression(source3),
  2159. GetSourceExpression(source4),
  2160. GetSourceExpression(source5),
  2161. GetSourceExpression(source6),
  2162. GetSourceExpression(source7),
  2163. GetSourceExpression(source8),
  2164. GetSourceExpression(source9),
  2165. resultSelector
  2166. )
  2167. );
  2168. }
  2169. /// <summary>
  2170. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2171. /// </summary>
  2172. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2173. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2174. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2175. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2176. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2177. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2178. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2179. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2180. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2181. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2182. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2183. /// <param name="source1">First observable source.</param>
  2184. /// <param name="source2">Second observable source.</param>
  2185. /// <param name="source3">Third observable source.</param>
  2186. /// <param name="source4">Fourth observable source.</param>
  2187. /// <param name="source5">Fifth observable source.</param>
  2188. /// <param name="source6">Sixth observable source.</param>
  2189. /// <param name="source7">Seventh observable source.</param>
  2190. /// <param name="source8">Eighth observable source.</param>
  2191. /// <param name="source9">Ninth observable source.</param>
  2192. /// <param name="source10">Tenth observable source.</param>
  2193. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2194. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2195. /// <exception cref="ArgumentNullException">
  2196. /// <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>
  2197. 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)
  2198. {
  2199. if (source1 == null)
  2200. throw new ArgumentNullException(nameof(source1));
  2201. if (source2 == null)
  2202. throw new ArgumentNullException(nameof(source2));
  2203. if (source3 == null)
  2204. throw new ArgumentNullException(nameof(source3));
  2205. if (source4 == null)
  2206. throw new ArgumentNullException(nameof(source4));
  2207. if (source5 == null)
  2208. throw new ArgumentNullException(nameof(source5));
  2209. if (source6 == null)
  2210. throw new ArgumentNullException(nameof(source6));
  2211. if (source7 == null)
  2212. throw new ArgumentNullException(nameof(source7));
  2213. if (source8 == null)
  2214. throw new ArgumentNullException(nameof(source8));
  2215. if (source9 == null)
  2216. throw new ArgumentNullException(nameof(source9));
  2217. if (source10 == null)
  2218. throw new ArgumentNullException(nameof(source10));
  2219. if (resultSelector == null)
  2220. throw new ArgumentNullException(nameof(resultSelector));
  2221. return source1.Provider.CreateQuery<TResult>(
  2222. Expression.Call(
  2223. null,
  2224. #if CRIPPLED_REFLECTION
  2225. 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>>))),
  2226. #else
  2227. ((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)),
  2228. #endif
  2229. source1.Expression,
  2230. GetSourceExpression(source2),
  2231. GetSourceExpression(source3),
  2232. GetSourceExpression(source4),
  2233. GetSourceExpression(source5),
  2234. GetSourceExpression(source6),
  2235. GetSourceExpression(source7),
  2236. GetSourceExpression(source8),
  2237. GetSourceExpression(source9),
  2238. GetSourceExpression(source10),
  2239. resultSelector
  2240. )
  2241. );
  2242. }
  2243. /// <summary>
  2244. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2245. /// </summary>
  2246. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2247. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2248. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2249. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2250. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2251. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2252. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2253. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2254. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2255. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2256. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2257. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2258. /// <param name="source1">First observable source.</param>
  2259. /// <param name="source2">Second observable source.</param>
  2260. /// <param name="source3">Third observable source.</param>
  2261. /// <param name="source4">Fourth observable source.</param>
  2262. /// <param name="source5">Fifth observable source.</param>
  2263. /// <param name="source6">Sixth observable source.</param>
  2264. /// <param name="source7">Seventh observable source.</param>
  2265. /// <param name="source8">Eighth observable source.</param>
  2266. /// <param name="source9">Ninth observable source.</param>
  2267. /// <param name="source10">Tenth observable source.</param>
  2268. /// <param name="source11">Eleventh observable source.</param>
  2269. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2270. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2271. /// <exception cref="ArgumentNullException">
  2272. /// <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>
  2273. 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)
  2274. {
  2275. if (source1 == null)
  2276. throw new ArgumentNullException(nameof(source1));
  2277. if (source2 == null)
  2278. throw new ArgumentNullException(nameof(source2));
  2279. if (source3 == null)
  2280. throw new ArgumentNullException(nameof(source3));
  2281. if (source4 == null)
  2282. throw new ArgumentNullException(nameof(source4));
  2283. if (source5 == null)
  2284. throw new ArgumentNullException(nameof(source5));
  2285. if (source6 == null)
  2286. throw new ArgumentNullException(nameof(source6));
  2287. if (source7 == null)
  2288. throw new ArgumentNullException(nameof(source7));
  2289. if (source8 == null)
  2290. throw new ArgumentNullException(nameof(source8));
  2291. if (source9 == null)
  2292. throw new ArgumentNullException(nameof(source9));
  2293. if (source10 == null)
  2294. throw new ArgumentNullException(nameof(source10));
  2295. if (source11 == null)
  2296. throw new ArgumentNullException(nameof(source11));
  2297. if (resultSelector == null)
  2298. throw new ArgumentNullException(nameof(resultSelector));
  2299. return source1.Provider.CreateQuery<TResult>(
  2300. Expression.Call(
  2301. null,
  2302. #if CRIPPLED_REFLECTION
  2303. 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>>))),
  2304. #else
  2305. ((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)),
  2306. #endif
  2307. source1.Expression,
  2308. GetSourceExpression(source2),
  2309. GetSourceExpression(source3),
  2310. GetSourceExpression(source4),
  2311. GetSourceExpression(source5),
  2312. GetSourceExpression(source6),
  2313. GetSourceExpression(source7),
  2314. GetSourceExpression(source8),
  2315. GetSourceExpression(source9),
  2316. GetSourceExpression(source10),
  2317. GetSourceExpression(source11),
  2318. resultSelector
  2319. )
  2320. );
  2321. }
  2322. /// <summary>
  2323. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2324. /// </summary>
  2325. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2326. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2327. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2328. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2329. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2330. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2331. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2332. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2333. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2334. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2335. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2336. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2337. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2338. /// <param name="source1">First observable source.</param>
  2339. /// <param name="source2">Second observable source.</param>
  2340. /// <param name="source3">Third observable source.</param>
  2341. /// <param name="source4">Fourth observable source.</param>
  2342. /// <param name="source5">Fifth observable source.</param>
  2343. /// <param name="source6">Sixth observable source.</param>
  2344. /// <param name="source7">Seventh observable source.</param>
  2345. /// <param name="source8">Eighth observable source.</param>
  2346. /// <param name="source9">Ninth observable source.</param>
  2347. /// <param name="source10">Tenth observable source.</param>
  2348. /// <param name="source11">Eleventh observable source.</param>
  2349. /// <param name="source12">Twelfth observable source.</param>
  2350. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2351. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2352. /// <exception cref="ArgumentNullException">
  2353. /// <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>
  2354. 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)
  2355. {
  2356. if (source1 == null)
  2357. throw new ArgumentNullException(nameof(source1));
  2358. if (source2 == null)
  2359. throw new ArgumentNullException(nameof(source2));
  2360. if (source3 == null)
  2361. throw new ArgumentNullException(nameof(source3));
  2362. if (source4 == null)
  2363. throw new ArgumentNullException(nameof(source4));
  2364. if (source5 == null)
  2365. throw new ArgumentNullException(nameof(source5));
  2366. if (source6 == null)
  2367. throw new ArgumentNullException(nameof(source6));
  2368. if (source7 == null)
  2369. throw new ArgumentNullException(nameof(source7));
  2370. if (source8 == null)
  2371. throw new ArgumentNullException(nameof(source8));
  2372. if (source9 == null)
  2373. throw new ArgumentNullException(nameof(source9));
  2374. if (source10 == null)
  2375. throw new ArgumentNullException(nameof(source10));
  2376. if (source11 == null)
  2377. throw new ArgumentNullException(nameof(source11));
  2378. if (source12 == null)
  2379. throw new ArgumentNullException(nameof(source12));
  2380. if (resultSelector == null)
  2381. throw new ArgumentNullException(nameof(resultSelector));
  2382. return source1.Provider.CreateQuery<TResult>(
  2383. Expression.Call(
  2384. null,
  2385. #if CRIPPLED_REFLECTION
  2386. 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>>))),
  2387. #else
  2388. ((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)),
  2389. #endif
  2390. source1.Expression,
  2391. GetSourceExpression(source2),
  2392. GetSourceExpression(source3),
  2393. GetSourceExpression(source4),
  2394. GetSourceExpression(source5),
  2395. GetSourceExpression(source6),
  2396. GetSourceExpression(source7),
  2397. GetSourceExpression(source8),
  2398. GetSourceExpression(source9),
  2399. GetSourceExpression(source10),
  2400. GetSourceExpression(source11),
  2401. GetSourceExpression(source12),
  2402. resultSelector
  2403. )
  2404. );
  2405. }
  2406. /// <summary>
  2407. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2408. /// </summary>
  2409. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2410. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2411. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2412. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2413. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2414. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2415. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2416. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2417. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2418. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2419. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2420. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2421. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2422. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2423. /// <param name="source1">First observable source.</param>
  2424. /// <param name="source2">Second observable source.</param>
  2425. /// <param name="source3">Third observable source.</param>
  2426. /// <param name="source4">Fourth observable source.</param>
  2427. /// <param name="source5">Fifth observable source.</param>
  2428. /// <param name="source6">Sixth observable source.</param>
  2429. /// <param name="source7">Seventh observable source.</param>
  2430. /// <param name="source8">Eighth observable source.</param>
  2431. /// <param name="source9">Ninth observable source.</param>
  2432. /// <param name="source10">Tenth observable source.</param>
  2433. /// <param name="source11">Eleventh observable source.</param>
  2434. /// <param name="source12">Twelfth observable source.</param>
  2435. /// <param name="source13">Thirteenth observable source.</param>
  2436. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2437. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2438. /// <exception cref="ArgumentNullException">
  2439. /// <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>
  2440. 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)
  2441. {
  2442. if (source1 == null)
  2443. throw new ArgumentNullException(nameof(source1));
  2444. if (source2 == null)
  2445. throw new ArgumentNullException(nameof(source2));
  2446. if (source3 == null)
  2447. throw new ArgumentNullException(nameof(source3));
  2448. if (source4 == null)
  2449. throw new ArgumentNullException(nameof(source4));
  2450. if (source5 == null)
  2451. throw new ArgumentNullException(nameof(source5));
  2452. if (source6 == null)
  2453. throw new ArgumentNullException(nameof(source6));
  2454. if (source7 == null)
  2455. throw new ArgumentNullException(nameof(source7));
  2456. if (source8 == null)
  2457. throw new ArgumentNullException(nameof(source8));
  2458. if (source9 == null)
  2459. throw new ArgumentNullException(nameof(source9));
  2460. if (source10 == null)
  2461. throw new ArgumentNullException(nameof(source10));
  2462. if (source11 == null)
  2463. throw new ArgumentNullException(nameof(source11));
  2464. if (source12 == null)
  2465. throw new ArgumentNullException(nameof(source12));
  2466. if (source13 == null)
  2467. throw new ArgumentNullException(nameof(source13));
  2468. if (resultSelector == null)
  2469. throw new ArgumentNullException(nameof(resultSelector));
  2470. return source1.Provider.CreateQuery<TResult>(
  2471. Expression.Call(
  2472. null,
  2473. #if CRIPPLED_REFLECTION
  2474. 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>>))),
  2475. #else
  2476. ((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)),
  2477. #endif
  2478. source1.Expression,
  2479. GetSourceExpression(source2),
  2480. GetSourceExpression(source3),
  2481. GetSourceExpression(source4),
  2482. GetSourceExpression(source5),
  2483. GetSourceExpression(source6),
  2484. GetSourceExpression(source7),
  2485. GetSourceExpression(source8),
  2486. GetSourceExpression(source9),
  2487. GetSourceExpression(source10),
  2488. GetSourceExpression(source11),
  2489. GetSourceExpression(source12),
  2490. GetSourceExpression(source13),
  2491. resultSelector
  2492. )
  2493. );
  2494. }
  2495. /// <summary>
  2496. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2497. /// </summary>
  2498. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2499. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2500. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2501. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2502. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2503. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2504. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2505. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2506. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2507. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2508. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2509. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2510. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2511. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2512. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2513. /// <param name="source1">First observable source.</param>
  2514. /// <param name="source2">Second observable source.</param>
  2515. /// <param name="source3">Third observable source.</param>
  2516. /// <param name="source4">Fourth observable source.</param>
  2517. /// <param name="source5">Fifth observable source.</param>
  2518. /// <param name="source6">Sixth observable source.</param>
  2519. /// <param name="source7">Seventh observable source.</param>
  2520. /// <param name="source8">Eighth observable source.</param>
  2521. /// <param name="source9">Ninth observable source.</param>
  2522. /// <param name="source10">Tenth observable source.</param>
  2523. /// <param name="source11">Eleventh observable source.</param>
  2524. /// <param name="source12">Twelfth observable source.</param>
  2525. /// <param name="source13">Thirteenth observable source.</param>
  2526. /// <param name="source14">Fourteenth observable source.</param>
  2527. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2528. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2529. /// <exception cref="ArgumentNullException">
  2530. /// <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>
  2531. 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)
  2532. {
  2533. if (source1 == null)
  2534. throw new ArgumentNullException(nameof(source1));
  2535. if (source2 == null)
  2536. throw new ArgumentNullException(nameof(source2));
  2537. if (source3 == null)
  2538. throw new ArgumentNullException(nameof(source3));
  2539. if (source4 == null)
  2540. throw new ArgumentNullException(nameof(source4));
  2541. if (source5 == null)
  2542. throw new ArgumentNullException(nameof(source5));
  2543. if (source6 == null)
  2544. throw new ArgumentNullException(nameof(source6));
  2545. if (source7 == null)
  2546. throw new ArgumentNullException(nameof(source7));
  2547. if (source8 == null)
  2548. throw new ArgumentNullException(nameof(source8));
  2549. if (source9 == null)
  2550. throw new ArgumentNullException(nameof(source9));
  2551. if (source10 == null)
  2552. throw new ArgumentNullException(nameof(source10));
  2553. if (source11 == null)
  2554. throw new ArgumentNullException(nameof(source11));
  2555. if (source12 == null)
  2556. throw new ArgumentNullException(nameof(source12));
  2557. if (source13 == null)
  2558. throw new ArgumentNullException(nameof(source13));
  2559. if (source14 == null)
  2560. throw new ArgumentNullException(nameof(source14));
  2561. if (resultSelector == null)
  2562. throw new ArgumentNullException(nameof(resultSelector));
  2563. return source1.Provider.CreateQuery<TResult>(
  2564. Expression.Call(
  2565. null,
  2566. #if CRIPPLED_REFLECTION
  2567. 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>>))),
  2568. #else
  2569. ((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)),
  2570. #endif
  2571. source1.Expression,
  2572. GetSourceExpression(source2),
  2573. GetSourceExpression(source3),
  2574. GetSourceExpression(source4),
  2575. GetSourceExpression(source5),
  2576. GetSourceExpression(source6),
  2577. GetSourceExpression(source7),
  2578. GetSourceExpression(source8),
  2579. GetSourceExpression(source9),
  2580. GetSourceExpression(source10),
  2581. GetSourceExpression(source11),
  2582. GetSourceExpression(source12),
  2583. GetSourceExpression(source13),
  2584. GetSourceExpression(source14),
  2585. resultSelector
  2586. )
  2587. );
  2588. }
  2589. /// <summary>
  2590. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2591. /// </summary>
  2592. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2593. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2594. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2595. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2596. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2597. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2598. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2599. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2600. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2601. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2602. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2603. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2604. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2605. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2606. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2607. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2608. /// <param name="source1">First observable source.</param>
  2609. /// <param name="source2">Second observable source.</param>
  2610. /// <param name="source3">Third observable source.</param>
  2611. /// <param name="source4">Fourth observable source.</param>
  2612. /// <param name="source5">Fifth observable source.</param>
  2613. /// <param name="source6">Sixth observable source.</param>
  2614. /// <param name="source7">Seventh observable source.</param>
  2615. /// <param name="source8">Eighth observable source.</param>
  2616. /// <param name="source9">Ninth observable source.</param>
  2617. /// <param name="source10">Tenth observable source.</param>
  2618. /// <param name="source11">Eleventh observable source.</param>
  2619. /// <param name="source12">Twelfth observable source.</param>
  2620. /// <param name="source13">Thirteenth observable source.</param>
  2621. /// <param name="source14">Fourteenth observable source.</param>
  2622. /// <param name="source15">Fifteenth observable source.</param>
  2623. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2624. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2625. /// <exception cref="ArgumentNullException">
  2626. /// <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>
  2627. 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)
  2628. {
  2629. if (source1 == null)
  2630. throw new ArgumentNullException(nameof(source1));
  2631. if (source2 == null)
  2632. throw new ArgumentNullException(nameof(source2));
  2633. if (source3 == null)
  2634. throw new ArgumentNullException(nameof(source3));
  2635. if (source4 == null)
  2636. throw new ArgumentNullException(nameof(source4));
  2637. if (source5 == null)
  2638. throw new ArgumentNullException(nameof(source5));
  2639. if (source6 == null)
  2640. throw new ArgumentNullException(nameof(source6));
  2641. if (source7 == null)
  2642. throw new ArgumentNullException(nameof(source7));
  2643. if (source8 == null)
  2644. throw new ArgumentNullException(nameof(source8));
  2645. if (source9 == null)
  2646. throw new ArgumentNullException(nameof(source9));
  2647. if (source10 == null)
  2648. throw new ArgumentNullException(nameof(source10));
  2649. if (source11 == null)
  2650. throw new ArgumentNullException(nameof(source11));
  2651. if (source12 == null)
  2652. throw new ArgumentNullException(nameof(source12));
  2653. if (source13 == null)
  2654. throw new ArgumentNullException(nameof(source13));
  2655. if (source14 == null)
  2656. throw new ArgumentNullException(nameof(source14));
  2657. if (source15 == null)
  2658. throw new ArgumentNullException(nameof(source15));
  2659. if (resultSelector == null)
  2660. throw new ArgumentNullException(nameof(resultSelector));
  2661. return source1.Provider.CreateQuery<TResult>(
  2662. Expression.Call(
  2663. null,
  2664. #if CRIPPLED_REFLECTION
  2665. 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>>))),
  2666. #else
  2667. ((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)),
  2668. #endif
  2669. source1.Expression,
  2670. GetSourceExpression(source2),
  2671. GetSourceExpression(source3),
  2672. GetSourceExpression(source4),
  2673. GetSourceExpression(source5),
  2674. GetSourceExpression(source6),
  2675. GetSourceExpression(source7),
  2676. GetSourceExpression(source8),
  2677. GetSourceExpression(source9),
  2678. GetSourceExpression(source10),
  2679. GetSourceExpression(source11),
  2680. GetSourceExpression(source12),
  2681. GetSourceExpression(source13),
  2682. GetSourceExpression(source14),
  2683. GetSourceExpression(source15),
  2684. resultSelector
  2685. )
  2686. );
  2687. }
  2688. /// <summary>
  2689. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2690. /// </summary>
  2691. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2692. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2693. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2694. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2695. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2696. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2697. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2698. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2699. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2700. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2701. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2702. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2703. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2704. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2705. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2706. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  2707. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2708. /// <param name="source1">First observable source.</param>
  2709. /// <param name="source2">Second observable source.</param>
  2710. /// <param name="source3">Third observable source.</param>
  2711. /// <param name="source4">Fourth observable source.</param>
  2712. /// <param name="source5">Fifth observable source.</param>
  2713. /// <param name="source6">Sixth observable source.</param>
  2714. /// <param name="source7">Seventh observable source.</param>
  2715. /// <param name="source8">Eighth observable source.</param>
  2716. /// <param name="source9">Ninth observable source.</param>
  2717. /// <param name="source10">Tenth observable source.</param>
  2718. /// <param name="source11">Eleventh observable source.</param>
  2719. /// <param name="source12">Twelfth observable source.</param>
  2720. /// <param name="source13">Thirteenth observable source.</param>
  2721. /// <param name="source14">Fourteenth observable source.</param>
  2722. /// <param name="source15">Fifteenth observable source.</param>
  2723. /// <param name="source16">Sixteenth observable source.</param>
  2724. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2725. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2726. /// <exception cref="ArgumentNullException">
  2727. /// <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>
  2728. 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)
  2729. {
  2730. if (source1 == null)
  2731. throw new ArgumentNullException(nameof(source1));
  2732. if (source2 == null)
  2733. throw new ArgumentNullException(nameof(source2));
  2734. if (source3 == null)
  2735. throw new ArgumentNullException(nameof(source3));
  2736. if (source4 == null)
  2737. throw new ArgumentNullException(nameof(source4));
  2738. if (source5 == null)
  2739. throw new ArgumentNullException(nameof(source5));
  2740. if (source6 == null)
  2741. throw new ArgumentNullException(nameof(source6));
  2742. if (source7 == null)
  2743. throw new ArgumentNullException(nameof(source7));
  2744. if (source8 == null)
  2745. throw new ArgumentNullException(nameof(source8));
  2746. if (source9 == null)
  2747. throw new ArgumentNullException(nameof(source9));
  2748. if (source10 == null)
  2749. throw new ArgumentNullException(nameof(source10));
  2750. if (source11 == null)
  2751. throw new ArgumentNullException(nameof(source11));
  2752. if (source12 == null)
  2753. throw new ArgumentNullException(nameof(source12));
  2754. if (source13 == null)
  2755. throw new ArgumentNullException(nameof(source13));
  2756. if (source14 == null)
  2757. throw new ArgumentNullException(nameof(source14));
  2758. if (source15 == null)
  2759. throw new ArgumentNullException(nameof(source15));
  2760. if (source16 == null)
  2761. throw new ArgumentNullException(nameof(source16));
  2762. if (resultSelector == null)
  2763. throw new ArgumentNullException(nameof(resultSelector));
  2764. return source1.Provider.CreateQuery<TResult>(
  2765. Expression.Call(
  2766. null,
  2767. #if CRIPPLED_REFLECTION
  2768. 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>>))),
  2769. #else
  2770. ((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)),
  2771. #endif
  2772. source1.Expression,
  2773. GetSourceExpression(source2),
  2774. GetSourceExpression(source3),
  2775. GetSourceExpression(source4),
  2776. GetSourceExpression(source5),
  2777. GetSourceExpression(source6),
  2778. GetSourceExpression(source7),
  2779. GetSourceExpression(source8),
  2780. GetSourceExpression(source9),
  2781. GetSourceExpression(source10),
  2782. GetSourceExpression(source11),
  2783. GetSourceExpression(source12),
  2784. GetSourceExpression(source13),
  2785. GetSourceExpression(source14),
  2786. GetSourceExpression(source15),
  2787. GetSourceExpression(source16),
  2788. resultSelector
  2789. )
  2790. );
  2791. }
  2792. /// <summary>
  2793. /// Concatenates the second observable sequence to the first observable sequence upon successful termination of the first.
  2794. /// </summary>
  2795. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2796. /// <param name="first">First observable sequence.</param>
  2797. /// <param name="second">Second observable sequence.</param>
  2798. /// <returns>An observable sequence that contains the elements of the first sequence, followed by those of the second the sequence.</returns>
  2799. /// <exception cref="ArgumentNullException">
  2800. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  2801. public static IQbservable<TSource> Concat<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  2802. {
  2803. if (first == null)
  2804. throw new ArgumentNullException(nameof(first));
  2805. if (second == null)
  2806. throw new ArgumentNullException(nameof(second));
  2807. return first.Provider.CreateQuery<TSource>(
  2808. Expression.Call(
  2809. null,
  2810. #if CRIPPLED_REFLECTION
  2811. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  2812. #else
  2813. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2814. #endif
  2815. first.Expression,
  2816. GetSourceExpression(second)
  2817. )
  2818. );
  2819. }
  2820. /// <summary>
  2821. /// Concatenates all of the specified observable sequences, as long as the previous observable sequence terminated successfully.
  2822. /// </summary>
  2823. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  2824. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2825. /// <param name="sources">Observable sequences to concatenate.</param>
  2826. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2827. /// <exception cref="ArgumentNullException">
  2828. /// <paramref name="sources" /> is null.</exception>
  2829. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  2830. {
  2831. if (provider == null)
  2832. throw new ArgumentNullException(nameof(provider));
  2833. if (sources == null)
  2834. throw new ArgumentNullException(nameof(sources));
  2835. return provider.CreateQuery<TSource>(
  2836. Expression.Call(
  2837. null,
  2838. #if CRIPPLED_REFLECTION
  2839. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  2840. #else
  2841. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2842. #endif
  2843. Expression.Constant(provider, typeof(IQbservableProvider)),
  2844. GetSourceExpression(sources)
  2845. )
  2846. );
  2847. }
  2848. /// <summary>
  2849. /// Concatenates all observable sequences in the given enumerable sequence, as long as the previous observable sequence terminated successfully.
  2850. /// </summary>
  2851. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  2852. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2853. /// <param name="sources">Observable sequences to concatenate.</param>
  2854. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2855. /// <exception cref="ArgumentNullException">
  2856. /// <paramref name="sources" /> is null.</exception>
  2857. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  2858. {
  2859. if (provider == null)
  2860. throw new ArgumentNullException(nameof(provider));
  2861. if (sources == null)
  2862. throw new ArgumentNullException(nameof(sources));
  2863. return provider.CreateQuery<TSource>(
  2864. Expression.Call(
  2865. null,
  2866. #if CRIPPLED_REFLECTION
  2867. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  2868. #else
  2869. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2870. #endif
  2871. Expression.Constant(provider, typeof(IQbservableProvider)),
  2872. GetSourceExpression(sources)
  2873. )
  2874. );
  2875. }
  2876. /// <summary>
  2877. /// Concatenates all inner observable sequences, as long as the previous observable sequence terminated successfully.
  2878. /// </summary>
  2879. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2880. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  2881. /// <returns>An observable sequence that contains the elements of each observed inner sequence, in sequential order.</returns>
  2882. /// <exception cref="ArgumentNullException">
  2883. /// <paramref name="sources" /> is null.</exception>
  2884. public static IQbservable<TSource> Concat<TSource>(this IQbservable<IObservable<TSource>> sources)
  2885. {
  2886. if (sources == null)
  2887. throw new ArgumentNullException(nameof(sources));
  2888. return sources.Provider.CreateQuery<TSource>(
  2889. Expression.Call(
  2890. null,
  2891. #if CRIPPLED_REFLECTION
  2892. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<IObservable<TSource>>))),
  2893. #else
  2894. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2895. #endif
  2896. sources.Expression
  2897. )
  2898. );
  2899. }
  2900. /// <summary>
  2901. /// Concatenates all task results, as long as the previous task terminated successfully.
  2902. /// </summary>
  2903. /// <typeparam name="TSource">The type of the results produced by the tasks.</typeparam>
  2904. /// <param name="sources">Observable sequence of tasks.</param>
  2905. /// <returns>An observable sequence that contains the results of each task, in sequential order.</returns>
  2906. /// <exception cref="ArgumentNullException">
  2907. /// <paramref name="sources" /> is null.</exception>
  2908. /// <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>
  2909. public static IQbservable<TSource> Concat<TSource>(this IQbservable<Task<TSource>> sources)
  2910. {
  2911. if (sources == null)
  2912. throw new ArgumentNullException(nameof(sources));
  2913. return sources.Provider.CreateQuery<TSource>(
  2914. Expression.Call(
  2915. null,
  2916. #if CRIPPLED_REFLECTION
  2917. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<Task<TSource>>))),
  2918. #else
  2919. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2920. #endif
  2921. sources.Expression
  2922. )
  2923. );
  2924. }
  2925. /// <summary>
  2926. /// Determines whether an observable sequence contains a specified element by using the default equality comparer.
  2927. /// </summary>
  2928. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2929. /// <param name="source">An observable sequence in which to locate a value.</param>
  2930. /// <param name="value">The value to locate in the source sequence.</param>
  2931. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2932. /// <exception cref="ArgumentNullException">
  2933. /// <paramref name="source" /> is null.</exception>
  2934. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2935. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value)
  2936. {
  2937. if (source == null)
  2938. throw new ArgumentNullException(nameof(source));
  2939. return source.Provider.CreateQuery<bool>(
  2940. Expression.Call(
  2941. null,
  2942. #if CRIPPLED_REFLECTION
  2943. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource))),
  2944. #else
  2945. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2946. #endif
  2947. source.Expression,
  2948. Expression.Constant(value, typeof(TSource))
  2949. )
  2950. );
  2951. }
  2952. /// <summary>
  2953. /// Determines whether an observable sequence contains a specified element by using a specified System.Collections.Generic.IEqualityComparer{T}.
  2954. /// </summary>
  2955. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2956. /// <param name="source">An observable sequence in which to locate a value.</param>
  2957. /// <param name="value">The value to locate in the source sequence.</param>
  2958. /// <param name="comparer">An equality comparer to compare elements.</param>
  2959. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2960. /// <exception cref="ArgumentNullException">
  2961. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  2962. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2963. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
  2964. {
  2965. if (source == null)
  2966. throw new ArgumentNullException(nameof(source));
  2967. if (comparer == null)
  2968. throw new ArgumentNullException(nameof(comparer));
  2969. return source.Provider.CreateQuery<bool>(
  2970. Expression.Call(
  2971. null,
  2972. #if CRIPPLED_REFLECTION
  2973. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource), default(IEqualityComparer<TSource>))),
  2974. #else
  2975. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2976. #endif
  2977. source.Expression,
  2978. Expression.Constant(value, typeof(TSource)),
  2979. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  2980. )
  2981. );
  2982. }
  2983. /// <summary>
  2984. /// Returns an observable sequence containing an <see cref="int" /> that represents the total number of elements in an observable sequence.
  2985. /// </summary>
  2986. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2987. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  2988. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  2989. /// <exception cref="ArgumentNullException">
  2990. /// <paramref name="source" /> is null.</exception>
  2991. /// <exception cref="OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  2992. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2993. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source)
  2994. {
  2995. if (source == null)
  2996. throw new ArgumentNullException(nameof(source));
  2997. return source.Provider.CreateQuery<int>(
  2998. Expression.Call(
  2999. null,
  3000. #if CRIPPLED_REFLECTION
  3001. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>))),
  3002. #else
  3003. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3004. #endif
  3005. source.Expression
  3006. )
  3007. );
  3008. }
  3009. /// <summary>
  3010. /// Returns an observable sequence containing an <see cref="int" /> that represents how many elements in the specified observable sequence satisfy a condition.
  3011. /// </summary>
  3012. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3013. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  3014. /// <param name="predicate">A function to test each element for a condition.</param>
  3015. /// <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>
  3016. /// <exception cref="ArgumentNullException">
  3017. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  3018. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  3019. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  3020. {
  3021. if (source == null)
  3022. throw new ArgumentNullException(nameof(source));
  3023. if (predicate == null)
  3024. throw new ArgumentNullException(nameof(predicate));
  3025. return source.Provider.CreateQuery<int>(
  3026. Expression.Call(
  3027. null,
  3028. #if CRIPPLED_REFLECTION
  3029. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  3030. #else
  3031. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3032. #endif
  3033. source.Expression,
  3034. predicate
  3035. )
  3036. );
  3037. }
  3038. /// <summary>
  3039. /// Creates an observable sequence from a specified Subscribe method implementation.
  3040. /// </summary>
  3041. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3042. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3043. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method.</param>
  3044. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3045. /// <exception cref="ArgumentNullException">
  3046. /// <paramref name="subscribe" /> is null.</exception>
  3047. /// <remarks>
  3048. /// Use of this operator is preferred over manual implementation of the <see cref="IObservable{T}" /> interface. In case
  3049. /// you need a type implementing <see cref="IObservable{T}" /> rather than an anonymous implementation, consider using
  3050. /// the <see cref="T:System.Reactive.ObservableBase`1" /> abstract base class.
  3051. /// </remarks>
  3052. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, IDisposable>> subscribe)
  3053. {
  3054. if (provider == null)
  3055. throw new ArgumentNullException(nameof(provider));
  3056. if (subscribe == null)
  3057. throw new ArgumentNullException(nameof(subscribe));
  3058. return provider.CreateQuery<TResult>(
  3059. Expression.Call(
  3060. null,
  3061. #if CRIPPLED_REFLECTION
  3062. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, IDisposable>>))),
  3063. #else
  3064. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3065. #endif
  3066. Expression.Constant(provider, typeof(IQbservableProvider)),
  3067. subscribe
  3068. )
  3069. );
  3070. }
  3071. /// <summary>
  3072. /// Creates an observable sequence from a specified Subscribe method implementation.
  3073. /// </summary>
  3074. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3075. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3076. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable.</param>
  3077. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3078. /// <exception cref="ArgumentNullException">
  3079. /// <paramref name="subscribe" /> is null.</exception>
  3080. /// <remarks>
  3081. /// Use of this operator is preferred over manual implementation of the <see cref="IObservable{T}" /> interface. In case
  3082. /// you need a type implementing <see cref="IObservable{T}" /> rather than an anonymous implementation, consider using
  3083. /// the <see cref="T:System.Reactive.ObservableBase`1" /> abstract base class.
  3084. /// </remarks>
  3085. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Action>> subscribe)
  3086. {
  3087. if (provider == null)
  3088. throw new ArgumentNullException(nameof(provider));
  3089. if (subscribe == null)
  3090. throw new ArgumentNullException(nameof(subscribe));
  3091. return provider.CreateQuery<TResult>(
  3092. Expression.Call(
  3093. null,
  3094. #if CRIPPLED_REFLECTION
  3095. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Action>>))),
  3096. #else
  3097. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3098. #endif
  3099. Expression.Constant(provider, typeof(IQbservableProvider)),
  3100. subscribe
  3101. )
  3102. );
  3103. }
  3104. /// <summary>
  3105. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3106. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3107. /// </summary>
  3108. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3109. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3110. /// <param name="subscribeAsync">Asynchronous method used to produce elements.</param>
  3111. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3112. /// <exception cref="ArgumentNullException">
  3113. /// <paramref name="subscribeAsync" /> is null.</exception>
  3114. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3115. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3116. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task>> subscribeAsync)
  3117. {
  3118. if (provider == null)
  3119. throw new ArgumentNullException(nameof(provider));
  3120. if (subscribeAsync == null)
  3121. throw new ArgumentNullException(nameof(subscribeAsync));
  3122. return provider.CreateQuery<TResult>(
  3123. Expression.Call(
  3124. null,
  3125. #if CRIPPLED_REFLECTION
  3126. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task>>))),
  3127. #else
  3128. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3129. #endif
  3130. Expression.Constant(provider, typeof(IQbservableProvider)),
  3131. subscribeAsync
  3132. )
  3133. );
  3134. }
  3135. /// <summary>
  3136. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3137. /// </summary>
  3138. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3139. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3140. /// <param name="subscribeAsync">Asynchronous method used to produce elements.</param>
  3141. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3142. /// <exception cref="ArgumentNullException">
  3143. /// <paramref name="subscribeAsync" /> is null.</exception>
  3144. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3145. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task>> subscribeAsync)
  3146. {
  3147. if (provider == null)
  3148. throw new ArgumentNullException(nameof(provider));
  3149. if (subscribeAsync == null)
  3150. throw new ArgumentNullException(nameof(subscribeAsync));
  3151. return provider.CreateQuery<TResult>(
  3152. Expression.Call(
  3153. null,
  3154. #if CRIPPLED_REFLECTION
  3155. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task>>))),
  3156. #else
  3157. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3158. #endif
  3159. Expression.Constant(provider, typeof(IQbservableProvider)),
  3160. subscribeAsync
  3161. )
  3162. );
  3163. }
  3164. /// <summary>
  3165. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3166. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3167. /// </summary>
  3168. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3169. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3170. /// <param name="subscribeAsync">Asynchronous method used to implement the resulting sequence's Subscribe method.</param>
  3171. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3172. /// <exception cref="ArgumentNullException">
  3173. /// <paramref name="subscribeAsync" /> is null.</exception>
  3174. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3175. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3176. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task<IDisposable>>> subscribeAsync)
  3177. {
  3178. if (provider == null)
  3179. throw new ArgumentNullException(nameof(provider));
  3180. if (subscribeAsync == null)
  3181. throw new ArgumentNullException(nameof(subscribeAsync));
  3182. return provider.CreateQuery<TResult>(
  3183. Expression.Call(
  3184. null,
  3185. #if CRIPPLED_REFLECTION
  3186. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task<IDisposable>>>))),
  3187. #else
  3188. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3189. #endif
  3190. Expression.Constant(provider, typeof(IQbservableProvider)),
  3191. subscribeAsync
  3192. )
  3193. );
  3194. }
  3195. /// <summary>
  3196. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3197. /// </summary>
  3198. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3199. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3200. /// <param name="subscribeAsync">Asynchronous method used to implement the resulting sequence's Subscribe method.</param>
  3201. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3202. /// <exception cref="ArgumentNullException">
  3203. /// <paramref name="subscribeAsync" /> is null.</exception>
  3204. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3205. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task<IDisposable>>> subscribeAsync)
  3206. {
  3207. if (provider == null)
  3208. throw new ArgumentNullException(nameof(provider));
  3209. if (subscribeAsync == null)
  3210. throw new ArgumentNullException(nameof(subscribeAsync));
  3211. return provider.CreateQuery<TResult>(
  3212. Expression.Call(
  3213. null,
  3214. #if CRIPPLED_REFLECTION
  3215. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task<IDisposable>>>))),
  3216. #else
  3217. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3218. #endif
  3219. Expression.Constant(provider, typeof(IQbservableProvider)),
  3220. subscribeAsync
  3221. )
  3222. );
  3223. }
  3224. /// <summary>
  3225. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3226. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3227. /// </summary>
  3228. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3229. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3230. /// <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>
  3231. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3232. /// <exception cref="ArgumentNullException">
  3233. /// <paramref name="subscribeAsync" /> is null.</exception>
  3234. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3235. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3236. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task<Action>>> subscribeAsync)
  3237. {
  3238. if (provider == null)
  3239. throw new ArgumentNullException(nameof(provider));
  3240. if (subscribeAsync == null)
  3241. throw new ArgumentNullException(nameof(subscribeAsync));
  3242. return provider.CreateQuery<TResult>(
  3243. Expression.Call(
  3244. null,
  3245. #if CRIPPLED_REFLECTION
  3246. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task<Action>>>))),
  3247. #else
  3248. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3249. #endif
  3250. Expression.Constant(provider, typeof(IQbservableProvider)),
  3251. subscribeAsync
  3252. )
  3253. );
  3254. }
  3255. /// <summary>
  3256. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3257. /// </summary>
  3258. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3259. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3260. /// <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>
  3261. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3262. /// <exception cref="ArgumentNullException">
  3263. /// <paramref name="subscribeAsync" /> is null.</exception>
  3264. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3265. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task<Action>>> subscribeAsync)
  3266. {
  3267. if (provider == null)
  3268. throw new ArgumentNullException(nameof(provider));
  3269. if (subscribeAsync == null)
  3270. throw new ArgumentNullException(nameof(subscribeAsync));
  3271. return provider.CreateQuery<TResult>(
  3272. Expression.Call(
  3273. null,
  3274. #if CRIPPLED_REFLECTION
  3275. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task<Action>>>))),
  3276. #else
  3277. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3278. #endif
  3279. Expression.Constant(provider, typeof(IQbservableProvider)),
  3280. subscribeAsync
  3281. )
  3282. );
  3283. }
  3284. /// <summary>
  3285. /// Returns the elements of the specified sequence or the type parameter's default value in a singleton sequence if the sequence is empty.
  3286. /// </summary>
  3287. /// <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>
  3288. /// <param name="source">The sequence to return a default value for if it is empty.</param>
  3289. /// <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>
  3290. /// <exception cref="ArgumentNullException">
  3291. /// <paramref name="source" /> is null.</exception>
  3292. public static IQbservable<TSource> DefaultIfEmpty<TSource>(this IQbservable<TSource> source)
  3293. {
  3294. if (source == null)
  3295. throw new ArgumentNullException(nameof(source));
  3296. return source.Provider.CreateQuery<TSource>(
  3297. Expression.Call(
  3298. null,
  3299. #if CRIPPLED_REFLECTION
  3300. InfoOf(() => Qbservable.DefaultIfEmpty<TSource>(default(IQbservable<TSource>))),
  3301. #else
  3302. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3303. #endif
  3304. source.Expression
  3305. )
  3306. );
  3307. }
  3308. /// <summary>
  3309. /// Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
  3310. /// </summary>
  3311. /// <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>
  3312. /// <param name="source">The sequence to return the specified value for if it is empty.</param>
  3313. /// <param name="defaultValue">The value to return if the sequence is empty.</param>
  3314. /// <returns>An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.</returns>
  3315. /// <exception cref="ArgumentNullException">
  3316. /// <paramref name="source" /> is null.</exception>
  3317. public static IQbservable<TSource> DefaultIfEmpty<TSource>(this IQbservable<TSource> source, TSource defaultValue)
  3318. {
  3319. if (source == null)
  3320. throw new ArgumentNullException(nameof(source));
  3321. return source.Provider.CreateQuery<TSource>(
  3322. Expression.Call(
  3323. null,
  3324. #if CRIPPLED_REFLECTION
  3325. InfoOf(() => Qbservable.DefaultIfEmpty<TSource>(default(IQbservable<TSource>), default(TSource))),
  3326. #else
  3327. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3328. #endif
  3329. source.Expression,
  3330. Expression.Constant(defaultValue, typeof(TSource))
  3331. )
  3332. );
  3333. }
  3334. /// <summary>
  3335. /// Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
  3336. /// </summary>
  3337. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3338. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3339. /// <param name="observableFactory">Observable factory function to invoke for each observer that subscribes to the resulting sequence.</param>
  3340. /// <returns>An observable sequence whose observers trigger an invocation of the given observable factory function.</returns>
  3341. /// <exception cref="ArgumentNullException">
  3342. /// <paramref name="observableFactory" /> is null.</exception>
  3343. public static IQbservable<TResult> Defer<TResult>(this IQbservableProvider provider, Expression<Func<IObservable<TResult>>> observableFactory)
  3344. {
  3345. if (provider == null)
  3346. throw new ArgumentNullException(nameof(provider));
  3347. if (observableFactory == null)
  3348. throw new ArgumentNullException(nameof(observableFactory));
  3349. return provider.CreateQuery<TResult>(
  3350. Expression.Call(
  3351. null,
  3352. #if CRIPPLED_REFLECTION
  3353. InfoOf(() => Qbservable.Defer<TResult>(default(IQbservableProvider), default(Expression<Func<IObservable<TResult>>>))),
  3354. #else
  3355. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3356. #endif
  3357. Expression.Constant(provider, typeof(IQbservableProvider)),
  3358. observableFactory
  3359. )
  3360. );
  3361. }
  3362. /// <summary>
  3363. /// Returns an observable sequence that starts the specified asynchronous factory function whenever a new observer subscribes.
  3364. /// </summary>
  3365. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3366. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3367. /// <param name="observableFactoryAsync">Asynchronous factory function to start for each observer that subscribes to the resulting sequence.</param>
  3368. /// <returns>An observable sequence whose observers trigger the given asynchronous observable factory function to be started.</returns>
  3369. /// <exception cref="ArgumentNullException">
  3370. /// <paramref name="observableFactoryAsync" /> is null.</exception>
  3371. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3372. public static IQbservable<TResult> Defer<TResult>(this IQbservableProvider provider, Expression<Func<Task<IObservable<TResult>>>> observableFactoryAsync)
  3373. {
  3374. if (provider == null)
  3375. throw new ArgumentNullException(nameof(provider));
  3376. if (observableFactoryAsync == null)
  3377. throw new ArgumentNullException(nameof(observableFactoryAsync));
  3378. return provider.CreateQuery<TResult>(
  3379. Expression.Call(
  3380. null,
  3381. #if CRIPPLED_REFLECTION
  3382. InfoOf(() => Qbservable.Defer<TResult>(default(IQbservableProvider), default(Expression<Func<Task<IObservable<TResult>>>>))),
  3383. #else
  3384. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3385. #endif
  3386. Expression.Constant(provider, typeof(IQbservableProvider)),
  3387. observableFactoryAsync
  3388. )
  3389. );
  3390. }
  3391. /// <summary>
  3392. /// Returns an observable sequence that starts the specified cancellable asynchronous factory function whenever a new observer subscribes.
  3393. /// The CancellationToken passed to the asynchronous factory function is tied to the returned disposable subscription, allowing best-effort cancellation.
  3394. /// </summary>
  3395. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3396. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3397. /// <param name="observableFactoryAsync">Asynchronous factory function to start for each observer that subscribes to the resulting sequence.</param>
  3398. /// <returns>An observable sequence whose observers trigger the given asynchronous observable factory function to be started.</returns>
  3399. /// <exception cref="ArgumentNullException">
  3400. /// <paramref name="observableFactoryAsync" /> is null.</exception>
  3401. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3402. /// <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>
  3403. public static IQbservable<TResult> DeferAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  3404. {
  3405. if (provider == null)
  3406. throw new ArgumentNullException(nameof(provider));
  3407. if (observableFactoryAsync == null)
  3408. throw new ArgumentNullException(nameof(observableFactoryAsync));
  3409. return provider.CreateQuery<TResult>(
  3410. Expression.Call(
  3411. null,
  3412. #if CRIPPLED_REFLECTION
  3413. InfoOf(() => Qbservable.DeferAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<IObservable<TResult>>>>))),
  3414. #else
  3415. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3416. #endif
  3417. Expression.Constant(provider, typeof(IQbservableProvider)),
  3418. observableFactoryAsync
  3419. )
  3420. );
  3421. }
  3422. /// <summary>
  3423. /// Time shifts the observable sequence to start propagating notifications at the specified absolute time.
  3424. /// The relative time intervals between the values are preserved.
  3425. /// </summary>
  3426. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3427. /// <param name="source">Source sequence to delay values for.</param>
  3428. /// <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>
  3429. /// <returns>Time-shifted sequence.</returns>
  3430. /// <exception cref="ArgumentNullException">
  3431. /// <paramref name="source" /> is null.</exception>
  3432. /// <remarks>
  3433. /// <para>
  3434. /// 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.
  3435. /// </para>
  3436. /// <para>
  3437. /// Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
  3438. /// </para>
  3439. /// <para>
  3440. /// 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.
  3441. /// 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>.
  3442. /// </para>
  3443. /// </remarks>
  3444. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  3445. {
  3446. if (source == null)
  3447. throw new ArgumentNullException(nameof(source));
  3448. return source.Provider.CreateQuery<TSource>(
  3449. Expression.Call(
  3450. null,
  3451. #if CRIPPLED_REFLECTION
  3452. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  3453. #else
  3454. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3455. #endif
  3456. source.Expression,
  3457. Expression.Constant(dueTime, typeof(DateTimeOffset))
  3458. )
  3459. );
  3460. }
  3461. /// <summary>
  3462. /// Time shifts the observable sequence to start propagating notifications at the specified absolute time, using the specified scheduler to run timers.
  3463. /// The relative time intervals between the values are preserved.
  3464. /// </summary>
  3465. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3466. /// <param name="source">Source sequence to delay values for.</param>
  3467. /// <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>
  3468. /// <param name="scheduler">Scheduler to run the delay timers on.</param>
  3469. /// <returns>Time-shifted sequence.</returns>
  3470. /// <exception cref="ArgumentNullException">
  3471. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3472. /// <remarks>
  3473. /// <para>
  3474. /// 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.
  3475. /// </para>
  3476. /// <para>
  3477. /// Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
  3478. /// </para>
  3479. /// <para>
  3480. /// 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.
  3481. /// 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>.
  3482. /// </para>
  3483. /// </remarks>
  3484. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  3485. {
  3486. if (source == null)
  3487. throw new ArgumentNullException(nameof(source));
  3488. if (scheduler == null)
  3489. throw new ArgumentNullException(nameof(scheduler));
  3490. return source.Provider.CreateQuery<TSource>(
  3491. Expression.Call(
  3492. null,
  3493. #if CRIPPLED_REFLECTION
  3494. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  3495. #else
  3496. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3497. #endif
  3498. source.Expression,
  3499. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  3500. Expression.Constant(scheduler, typeof(IScheduler))
  3501. )
  3502. );
  3503. }
  3504. /// <summary>
  3505. /// Time shifts the observable sequence by the specified relative time duration.
  3506. /// The relative time intervals between the values are preserved.
  3507. /// </summary>
  3508. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3509. /// <param name="source">Source sequence to delay values for.</param>
  3510. /// <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>
  3511. /// <returns>Time-shifted sequence.</returns>
  3512. /// <exception cref="ArgumentNullException">
  3513. /// <paramref name="source" /> is null.</exception>
  3514. /// <exception cref="ArgumentOutOfRangeException">
  3515. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3516. /// <remarks>
  3517. /// <para>
  3518. /// 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.
  3519. /// </para>
  3520. /// <para>
  3521. /// Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
  3522. /// </para>
  3523. /// <para>
  3524. /// 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.
  3525. /// 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>.
  3526. /// </para>
  3527. /// </remarks>
  3528. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  3529. {
  3530. if (source == null)
  3531. throw new ArgumentNullException(nameof(source));
  3532. return source.Provider.CreateQuery<TSource>(
  3533. Expression.Call(
  3534. null,
  3535. #if CRIPPLED_REFLECTION
  3536. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  3537. #else
  3538. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3539. #endif
  3540. source.Expression,
  3541. Expression.Constant(dueTime, typeof(TimeSpan))
  3542. )
  3543. );
  3544. }
  3545. /// <summary>
  3546. /// Time shifts the observable sequence by the specified relative time duration, using the specified scheduler to run timers.
  3547. /// The relative time intervals between the values are preserved.
  3548. /// </summary>
  3549. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3550. /// <param name="source">Source sequence to delay values for.</param>
  3551. /// <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>
  3552. /// <param name="scheduler">Scheduler to run the delay timers on.</param>
  3553. /// <returns>Time-shifted sequence.</returns>
  3554. /// <exception cref="ArgumentNullException">
  3555. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3556. /// <exception cref="ArgumentOutOfRangeException">
  3557. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3558. /// <remarks>
  3559. /// <para>
  3560. /// 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.
  3561. /// </para>
  3562. /// <para>
  3563. /// Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
  3564. /// </para>
  3565. /// <para>
  3566. /// 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.
  3567. /// </para>
  3568. /// <para>
  3569. /// 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.
  3570. /// 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>.
  3571. /// </para>
  3572. /// </remarks>
  3573. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  3574. {
  3575. if (source == null)
  3576. throw new ArgumentNullException(nameof(source));
  3577. if (scheduler == null)
  3578. throw new ArgumentNullException(nameof(scheduler));
  3579. return source.Provider.CreateQuery<TSource>(
  3580. Expression.Call(
  3581. null,
  3582. #if CRIPPLED_REFLECTION
  3583. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  3584. #else
  3585. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3586. #endif
  3587. source.Expression,
  3588. Expression.Constant(dueTime, typeof(TimeSpan)),
  3589. Expression.Constant(scheduler, typeof(IScheduler))
  3590. )
  3591. );
  3592. }
  3593. /// <summary>
  3594. /// Time shifts the observable sequence based on a delay selector function for each element.
  3595. /// </summary>
  3596. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3597. /// <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>
  3598. /// <param name="source">Source sequence to delay values for.</param>
  3599. /// <param name="delayDurationSelector">Selector function to retrieve a sequence indicating the delay for each given element.</param>
  3600. /// <returns>Time-shifted sequence.</returns>
  3601. /// <exception cref="ArgumentNullException">
  3602. /// <paramref name="source" /> or <paramref name="delayDurationSelector" /> is null.</exception>
  3603. public static IQbservable<TSource> Delay<TSource, TDelay>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TDelay>>> delayDurationSelector)
  3604. {
  3605. if (source == null)
  3606. throw new ArgumentNullException(nameof(source));
  3607. if (delayDurationSelector == null)
  3608. throw new ArgumentNullException(nameof(delayDurationSelector));
  3609. return source.Provider.CreateQuery<TSource>(
  3610. Expression.Call(
  3611. null,
  3612. #if CRIPPLED_REFLECTION
  3613. InfoOf(() => Qbservable.Delay<TSource, TDelay>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TDelay>>>))),
  3614. #else
  3615. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TDelay)),
  3616. #endif
  3617. source.Expression,
  3618. delayDurationSelector
  3619. )
  3620. );
  3621. }
  3622. /// <summary>
  3623. /// Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
  3624. /// </summary>
  3625. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3626. /// <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>
  3627. /// <param name="source">Source sequence to delay values for.</param>
  3628. /// <param name="subscriptionDelay">Sequence indicating the delay for the subscription to the source.</param>
  3629. /// <param name="delayDurationSelector">Selector function to retrieve a sequence indicating the delay for each given element.</param>
  3630. /// <returns>Time-shifted sequence.</returns>
  3631. /// <exception cref="ArgumentNullException">
  3632. /// <paramref name="source" /> or <paramref name="subscriptionDelay" /> or <paramref name="delayDurationSelector" /> is null.</exception>
  3633. public static IQbservable<TSource> Delay<TSource, TDelay>(this IQbservable<TSource> source, IObservable<TDelay> subscriptionDelay, Expression<Func<TSource, IObservable<TDelay>>> delayDurationSelector)
  3634. {
  3635. if (source == null)
  3636. throw new ArgumentNullException(nameof(source));
  3637. if (subscriptionDelay == null)
  3638. throw new ArgumentNullException(nameof(subscriptionDelay));
  3639. if (delayDurationSelector == null)
  3640. throw new ArgumentNullException(nameof(delayDurationSelector));
  3641. return source.Provider.CreateQuery<TSource>(
  3642. Expression.Call(
  3643. null,
  3644. #if CRIPPLED_REFLECTION
  3645. InfoOf(() => Qbservable.Delay<TSource, TDelay>(default(IQbservable<TSource>), default(IObservable<TDelay>), default(Expression<Func<TSource, IObservable<TDelay>>>))),
  3646. #else
  3647. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TDelay)),
  3648. #endif
  3649. source.Expression,
  3650. GetSourceExpression(subscriptionDelay),
  3651. delayDurationSelector
  3652. )
  3653. );
  3654. }
  3655. /// <summary>
  3656. /// Time shifts the observable sequence by delaying the subscription to the specified absolute time.
  3657. /// </summary>
  3658. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3659. /// <param name="source">Source sequence to delay subscription for.</param>
  3660. /// <param name="dueTime">Absolute time to perform the subscription at.</param>
  3661. /// <returns>Time-shifted sequence.</returns>
  3662. /// <exception cref="ArgumentNullException">
  3663. /// <paramref name="source" /> is null.</exception>
  3664. /// <remarks>
  3665. /// <para>
  3666. /// 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.
  3667. /// </para>
  3668. /// <para>
  3669. /// The side-effects of subscribing to the source sequence will be run on the default scheduler. Observer callbacks will not be affected.
  3670. /// </para>
  3671. /// </remarks>
  3672. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  3673. {
  3674. if (source == null)
  3675. throw new ArgumentNullException(nameof(source));
  3676. return source.Provider.CreateQuery<TSource>(
  3677. Expression.Call(
  3678. null,
  3679. #if CRIPPLED_REFLECTION
  3680. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  3681. #else
  3682. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3683. #endif
  3684. source.Expression,
  3685. Expression.Constant(dueTime, typeof(DateTimeOffset))
  3686. )
  3687. );
  3688. }
  3689. /// <summary>
  3690. /// Time shifts the observable sequence by delaying the subscription to the specified absolute time, using the specified scheduler to run timers.
  3691. /// </summary>
  3692. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3693. /// <param name="source">Source sequence to delay subscription for.</param>
  3694. /// <param name="dueTime">Absolute time to perform the subscription at.</param>
  3695. /// <param name="scheduler">Scheduler to run the subscription delay timer on.</param>
  3696. /// <returns>Time-shifted sequence.</returns>
  3697. /// <exception cref="ArgumentNullException">
  3698. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3699. /// <remarks>
  3700. /// <para>
  3701. /// 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.
  3702. /// </para>
  3703. /// <para>
  3704. /// The side-effects of subscribing to the source sequence will be run on the specified scheduler. Observer callbacks will not be affected.
  3705. /// </para>
  3706. /// </remarks>
  3707. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  3708. {
  3709. if (source == null)
  3710. throw new ArgumentNullException(nameof(source));
  3711. if (scheduler == null)
  3712. throw new ArgumentNullException(nameof(scheduler));
  3713. return source.Provider.CreateQuery<TSource>(
  3714. Expression.Call(
  3715. null,
  3716. #if CRIPPLED_REFLECTION
  3717. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  3718. #else
  3719. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3720. #endif
  3721. source.Expression,
  3722. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  3723. Expression.Constant(scheduler, typeof(IScheduler))
  3724. )
  3725. );
  3726. }
  3727. /// <summary>
  3728. /// Time shifts the observable sequence by delaying the subscription with the specified relative time duration.
  3729. /// </summary>
  3730. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3731. /// <param name="source">Source sequence to delay subscription for.</param>
  3732. /// <param name="dueTime">Relative time shift of the subscription.</param>
  3733. /// <returns>Time-shifted sequence.</returns>
  3734. /// <exception cref="ArgumentNullException">
  3735. /// <paramref name="source" /> is null.</exception>
  3736. /// <exception cref="ArgumentOutOfRangeException">
  3737. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3738. /// <remarks>
  3739. /// <para>
  3740. /// 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.
  3741. /// </para>
  3742. /// <para>
  3743. /// The side-effects of subscribing to the source sequence will be run on the default scheduler. Observer callbacks will not be affected.
  3744. /// </para>
  3745. /// </remarks>
  3746. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  3747. {
  3748. if (source == null)
  3749. throw new ArgumentNullException(nameof(source));
  3750. return source.Provider.CreateQuery<TSource>(
  3751. Expression.Call(
  3752. null,
  3753. #if CRIPPLED_REFLECTION
  3754. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  3755. #else
  3756. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3757. #endif
  3758. source.Expression,
  3759. Expression.Constant(dueTime, typeof(TimeSpan))
  3760. )
  3761. );
  3762. }
  3763. /// <summary>
  3764. /// Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.
  3765. /// </summary>
  3766. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3767. /// <param name="source">Source sequence to delay subscription for.</param>
  3768. /// <param name="dueTime">Relative time shift of the subscription.</param>
  3769. /// <param name="scheduler">Scheduler to run the subscription delay timer on.</param>
  3770. /// <returns>Time-shifted sequence.</returns>
  3771. /// <exception cref="ArgumentNullException">
  3772. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3773. /// <exception cref="ArgumentOutOfRangeException">
  3774. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3775. /// <remarks>
  3776. /// <para>
  3777. /// 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.
  3778. /// </para>
  3779. /// <para>
  3780. /// The side-effects of subscribing to the source sequence will be run on the specified scheduler. Observer callbacks will not be affected.
  3781. /// </para>
  3782. /// </remarks>
  3783. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  3784. {
  3785. if (source == null)
  3786. throw new ArgumentNullException(nameof(source));
  3787. if (scheduler == null)
  3788. throw new ArgumentNullException(nameof(scheduler));
  3789. return source.Provider.CreateQuery<TSource>(
  3790. Expression.Call(
  3791. null,
  3792. #if CRIPPLED_REFLECTION
  3793. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  3794. #else
  3795. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3796. #endif
  3797. source.Expression,
  3798. Expression.Constant(dueTime, typeof(TimeSpan)),
  3799. Expression.Constant(scheduler, typeof(IScheduler))
  3800. )
  3801. );
  3802. }
  3803. /// <summary>
  3804. /// Dematerializes the explicit notification values of an observable sequence as implicit notifications.
  3805. /// </summary>
  3806. /// <typeparam name="TSource">The type of the elements materialized in the source sequence notification objects.</typeparam>
  3807. /// <param name="source">An observable sequence containing explicit notification values which have to be turned into implicit notifications.</param>
  3808. /// <returns>An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.</returns>
  3809. /// <exception cref="ArgumentNullException">
  3810. /// <paramref name="source" /> is null.</exception>
  3811. public static IQbservable<TSource> Dematerialize<TSource>(this IQbservable<Notification<TSource>> source)
  3812. {
  3813. if (source == null)
  3814. throw new ArgumentNullException(nameof(source));
  3815. return source.Provider.CreateQuery<TSource>(
  3816. Expression.Call(
  3817. null,
  3818. #if CRIPPLED_REFLECTION
  3819. InfoOf(() => Qbservable.Dematerialize<TSource>(default(IQbservable<Notification<TSource>>))),
  3820. #else
  3821. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3822. #endif
  3823. source.Expression
  3824. )
  3825. );
  3826. }
  3827. /// <summary>
  3828. /// Returns an observable sequence that contains only distinct elements.
  3829. /// </summary>
  3830. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3831. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3832. /// <returns>An observable sequence only containing the distinct elements from the source sequence.</returns>
  3833. /// <exception cref="ArgumentNullException">
  3834. /// <paramref name="source" /> is null.</exception>
  3835. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3836. public static IQbservable<TSource> Distinct<TSource>(this IQbservable<TSource> source)
  3837. {
  3838. if (source == null)
  3839. throw new ArgumentNullException(nameof(source));
  3840. return source.Provider.CreateQuery<TSource>(
  3841. Expression.Call(
  3842. null,
  3843. #if CRIPPLED_REFLECTION
  3844. InfoOf(() => Qbservable.Distinct<TSource>(default(IQbservable<TSource>))),
  3845. #else
  3846. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3847. #endif
  3848. source.Expression
  3849. )
  3850. );
  3851. }
  3852. /// <summary>
  3853. /// Returns an observable sequence that contains only distinct elements according to the comparer.
  3854. /// </summary>
  3855. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3856. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3857. /// <param name="comparer">Equality comparer for source elements.</param>
  3858. /// <returns>An observable sequence only containing the distinct elements from the source sequence.</returns>
  3859. /// <exception cref="ArgumentNullException">
  3860. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  3861. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3862. public static IQbservable<TSource> Distinct<TSource>(this IQbservable<TSource> source, IEqualityComparer<TSource> comparer)
  3863. {
  3864. if (source == null)
  3865. throw new ArgumentNullException(nameof(source));
  3866. if (comparer == null)
  3867. throw new ArgumentNullException(nameof(comparer));
  3868. return source.Provider.CreateQuery<TSource>(
  3869. Expression.Call(
  3870. null,
  3871. #if CRIPPLED_REFLECTION
  3872. InfoOf(() => Qbservable.Distinct<TSource>(default(IQbservable<TSource>), default(IEqualityComparer<TSource>))),
  3873. #else
  3874. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3875. #endif
  3876. source.Expression,
  3877. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  3878. )
  3879. );
  3880. }
  3881. /// <summary>
  3882. /// Returns an observable sequence that contains only distinct elements according to the keySelector.
  3883. /// </summary>
  3884. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3885. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3886. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3887. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3888. /// <returns>An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.</returns>
  3889. /// <exception cref="ArgumentNullException">
  3890. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  3891. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3892. public static IQbservable<TSource> Distinct<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  3893. {
  3894. if (source == null)
  3895. throw new ArgumentNullException(nameof(source));
  3896. if (keySelector == null)
  3897. throw new ArgumentNullException(nameof(keySelector));
  3898. return source.Provider.CreateQuery<TSource>(
  3899. Expression.Call(
  3900. null,
  3901. #if CRIPPLED_REFLECTION
  3902. InfoOf(() => Qbservable.Distinct<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  3903. #else
  3904. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3905. #endif
  3906. source.Expression,
  3907. keySelector
  3908. )
  3909. );
  3910. }
  3911. /// <summary>
  3912. /// Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.
  3913. /// </summary>
  3914. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3915. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3916. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3917. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3918. /// <param name="comparer">Equality comparer for source elements.</param>
  3919. /// <returns>An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.</returns>
  3920. /// <exception cref="ArgumentNullException">
  3921. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  3922. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3923. public static IQbservable<TSource> Distinct<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  3924. {
  3925. if (source == null)
  3926. throw new ArgumentNullException(nameof(source));
  3927. if (keySelector == null)
  3928. throw new ArgumentNullException(nameof(keySelector));
  3929. if (comparer == null)
  3930. throw new ArgumentNullException(nameof(comparer));
  3931. return source.Provider.CreateQuery<TSource>(
  3932. Expression.Call(
  3933. null,
  3934. #if CRIPPLED_REFLECTION
  3935. InfoOf(() => Qbservable.Distinct<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  3936. #else
  3937. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3938. #endif
  3939. source.Expression,
  3940. keySelector,
  3941. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  3942. )
  3943. );
  3944. }
  3945. /// <summary>
  3946. /// Returns an observable sequence that contains only distinct contiguous elements.
  3947. /// </summary>
  3948. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3949. /// <param name="source">An observable sequence to retain distinct contiguous elements for.</param>
  3950. /// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
  3951. /// <exception cref="ArgumentNullException">
  3952. /// <paramref name="source" /> is null.</exception>
  3953. public static IQbservable<TSource> DistinctUntilChanged<TSource>(this IQbservable<TSource> source)
  3954. {
  3955. if (source == null)
  3956. throw new ArgumentNullException(nameof(source));
  3957. return source.Provider.CreateQuery<TSource>(
  3958. Expression.Call(
  3959. null,
  3960. #if CRIPPLED_REFLECTION
  3961. InfoOf(() => Qbservable.DistinctUntilChanged<TSource>(default(IQbservable<TSource>))),
  3962. #else
  3963. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3964. #endif
  3965. source.Expression
  3966. )
  3967. );
  3968. }
  3969. /// <summary>
  3970. /// Returns an observable sequence that contains only distinct contiguous elements according to the comparer.
  3971. /// </summary>
  3972. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3973. /// <param name="source">An observable sequence to retain distinct contiguous elements for.</param>
  3974. /// <param name="comparer">Equality comparer for source elements.</param>
  3975. /// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
  3976. /// <exception cref="ArgumentNullException">
  3977. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  3978. public static IQbservable<TSource> DistinctUntilChanged<TSource>(this IQbservable<TSource> source, IEqualityComparer<TSource> comparer)
  3979. {
  3980. if (source == null)
  3981. throw new ArgumentNullException(nameof(source));
  3982. if (comparer == null)
  3983. throw new ArgumentNullException(nameof(comparer));
  3984. return source.Provider.CreateQuery<TSource>(
  3985. Expression.Call(
  3986. null,
  3987. #if CRIPPLED_REFLECTION
  3988. InfoOf(() => Qbservable.DistinctUntilChanged<TSource>(default(IQbservable<TSource>), default(IEqualityComparer<TSource>))),
  3989. #else
  3990. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3991. #endif
  3992. source.Expression,
  3993. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  3994. )
  3995. );
  3996. }
  3997. /// <summary>
  3998. /// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector.
  3999. /// </summary>
  4000. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4001. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  4002. /// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
  4003. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  4004. /// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
  4005. /// <exception cref="ArgumentNullException">
  4006. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  4007. public static IQbservable<TSource> DistinctUntilChanged<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  4008. {
  4009. if (source == null)
  4010. throw new ArgumentNullException(nameof(source));
  4011. if (keySelector == null)
  4012. throw new ArgumentNullException(nameof(keySelector));
  4013. return source.Provider.CreateQuery<TSource>(
  4014. Expression.Call(
  4015. null,
  4016. #if CRIPPLED_REFLECTION
  4017. InfoOf(() => Qbservable.DistinctUntilChanged<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  4018. #else
  4019. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  4020. #endif
  4021. source.Expression,
  4022. keySelector
  4023. )
  4024. );
  4025. }
  4026. /// <summary>
  4027. /// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
  4028. /// </summary>
  4029. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4030. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  4031. /// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
  4032. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  4033. /// <param name="comparer">Equality comparer for computed key values.</param>
  4034. /// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
  4035. /// <exception cref="ArgumentNullException">
  4036. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  4037. public static IQbservable<TSource> DistinctUntilChanged<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  4038. {
  4039. if (source == null)
  4040. throw new ArgumentNullException(nameof(source));
  4041. if (keySelector == null)
  4042. throw new ArgumentNullException(nameof(keySelector));
  4043. if (comparer == null)
  4044. throw new ArgumentNullException(nameof(comparer));
  4045. return source.Provider.CreateQuery<TSource>(
  4046. Expression.Call(
  4047. null,
  4048. #if CRIPPLED_REFLECTION
  4049. InfoOf(() => Qbservable.DistinctUntilChanged<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  4050. #else
  4051. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  4052. #endif
  4053. source.Expression,
  4054. keySelector,
  4055. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  4056. )
  4057. );
  4058. }
  4059. /// <summary>
  4060. /// Invokes the observer's methods for each message in the source sequence.
  4061. /// 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.
  4062. /// </summary>
  4063. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4064. /// <param name="source">Source sequence.</param>
  4065. /// <param name="observer">Observer whose methods to invoke as part of the source sequence's observation.</param>
  4066. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4067. /// <exception cref="ArgumentNullException">
  4068. /// <paramref name="source" /> or <paramref name="observer" /> is null.</exception>
  4069. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, IObserver<TSource> observer)
  4070. {
  4071. if (source == null)
  4072. throw new ArgumentNullException(nameof(source));
  4073. if (observer == null)
  4074. throw new ArgumentNullException(nameof(observer));
  4075. return source.Provider.CreateQuery<TSource>(
  4076. Expression.Call(
  4077. null,
  4078. #if CRIPPLED_REFLECTION
  4079. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(IObserver<TSource>))),
  4080. #else
  4081. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4082. #endif
  4083. source.Expression,
  4084. Expression.Constant(observer, typeof(IObserver<TSource>))
  4085. )
  4086. );
  4087. }
  4088. /// <summary>
  4089. /// Invokes an action for each element in the observable sequence, and propagates all observer messages through the result sequence.
  4090. /// 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.
  4091. /// </summary>
  4092. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4093. /// <param name="source">Source sequence.</param>
  4094. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4095. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4096. /// <exception cref="ArgumentNullException">
  4097. /// <paramref name="source" /> or <paramref name="onNext" /> is null.</exception>
  4098. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext)
  4099. {
  4100. if (source == null)
  4101. throw new ArgumentNullException(nameof(source));
  4102. if (onNext == null)
  4103. throw new ArgumentNullException(nameof(onNext));
  4104. return source.Provider.CreateQuery<TSource>(
  4105. Expression.Call(
  4106. null,
  4107. #if CRIPPLED_REFLECTION
  4108. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>))),
  4109. #else
  4110. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4111. #endif
  4112. source.Expression,
  4113. onNext
  4114. )
  4115. );
  4116. }
  4117. /// <summary>
  4118. /// Invokes an action for each element in the observable sequence and invokes an action upon graceful termination of the observable sequence.
  4119. /// 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.
  4120. /// </summary>
  4121. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4122. /// <param name="source">Source sequence.</param>
  4123. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4124. /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
  4125. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4126. /// <exception cref="ArgumentNullException">
  4127. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onCompleted" /> is null.</exception>
  4128. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action> onCompleted)
  4129. {
  4130. if (source == null)
  4131. throw new ArgumentNullException(nameof(source));
  4132. if (onNext == null)
  4133. throw new ArgumentNullException(nameof(onNext));
  4134. if (onCompleted == null)
  4135. throw new ArgumentNullException(nameof(onCompleted));
  4136. return source.Provider.CreateQuery<TSource>(
  4137. Expression.Call(
  4138. null,
  4139. #if CRIPPLED_REFLECTION
  4140. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action>))),
  4141. #else
  4142. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4143. #endif
  4144. source.Expression,
  4145. onNext,
  4146. onCompleted
  4147. )
  4148. );
  4149. }
  4150. /// <summary>
  4151. /// Invokes an action for each element in the observable sequence and invokes an action upon exceptional termination of the observable sequence.
  4152. /// 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.
  4153. /// </summary>
  4154. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4155. /// <param name="source">Source sequence.</param>
  4156. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4157. /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
  4158. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4159. /// <exception cref="ArgumentNullException">
  4160. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> is null.</exception>
  4161. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError)
  4162. {
  4163. if (source == null)
  4164. throw new ArgumentNullException(nameof(source));
  4165. if (onNext == null)
  4166. throw new ArgumentNullException(nameof(onNext));
  4167. if (onError == null)
  4168. throw new ArgumentNullException(nameof(onError));
  4169. return source.Provider.CreateQuery<TSource>(
  4170. Expression.Call(
  4171. null,
  4172. #if CRIPPLED_REFLECTION
  4173. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>))),
  4174. #else
  4175. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4176. #endif
  4177. source.Expression,
  4178. onNext,
  4179. onError
  4180. )
  4181. );
  4182. }
  4183. /// <summary>
  4184. /// Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
  4185. /// 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.
  4186. /// </summary>
  4187. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4188. /// <param name="source">Source sequence.</param>
  4189. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4190. /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
  4191. /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
  4192. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4193. /// <exception cref="ArgumentNullException">
  4194. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  4195. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError, Expression<Action> onCompleted)
  4196. {
  4197. if (source == null)
  4198. throw new ArgumentNullException(nameof(source));
  4199. if (onNext == null)
  4200. throw new ArgumentNullException(nameof(onNext));
  4201. if (onError == null)
  4202. throw new ArgumentNullException(nameof(onError));
  4203. if (onCompleted == null)
  4204. throw new ArgumentNullException(nameof(onCompleted));
  4205. return source.Provider.CreateQuery<TSource>(
  4206. Expression.Call(
  4207. null,
  4208. #if CRIPPLED_REFLECTION
  4209. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>), default(Expression<Action>))),
  4210. #else
  4211. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4212. #endif
  4213. source.Expression,
  4214. onNext,
  4215. onError,
  4216. onCompleted
  4217. )
  4218. );
  4219. }
  4220. /// <summary>
  4221. /// 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.
  4222. /// </summary>
  4223. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4224. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  4225. /// <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>
  4226. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  4227. /// <exception cref="ArgumentNullException">
  4228. /// <paramref name="source" /> or <paramref name="condition" /> is null.</exception>
  4229. public static IQbservable<TSource> DoWhile<TSource>(this IQbservable<TSource> source, Expression<Func<bool>> condition)
  4230. {
  4231. if (source == null)
  4232. throw new ArgumentNullException(nameof(source));
  4233. if (condition == null)
  4234. throw new ArgumentNullException(nameof(condition));
  4235. return source.Provider.CreateQuery<TSource>(
  4236. Expression.Call(
  4237. null,
  4238. #if CRIPPLED_REFLECTION
  4239. InfoOf(() => Qbservable.DoWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<bool>>))),
  4240. #else
  4241. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4242. #endif
  4243. source.Expression,
  4244. condition
  4245. )
  4246. );
  4247. }
  4248. /// <summary>
  4249. /// Returns the element at a specified index in a sequence.
  4250. /// </summary>
  4251. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4252. /// <param name="source">Observable sequence to return the element from.</param>
  4253. /// <param name="index">The zero-based index of the element to retrieve.</param>
  4254. /// <returns>An observable sequence that produces the element at the specified position in the source sequence.</returns>
  4255. /// <exception cref="ArgumentNullException">
  4256. /// <paramref name="source" /> is null.</exception>
  4257. /// <exception cref="ArgumentOutOfRangeException">
  4258. /// <paramref name="index" /> is less than zero.</exception>
  4259. /// <exception cref="ArgumentOutOfRangeException">(Asynchronous) <paramref name="index" /> is greater than or equal to the number of elements in the source sequence.</exception>
  4260. public static IQbservable<TSource> ElementAt<TSource>(this IQbservable<TSource> source, int index)
  4261. {
  4262. if (source == null)
  4263. throw new ArgumentNullException(nameof(source));
  4264. return source.Provider.CreateQuery<TSource>(
  4265. Expression.Call(
  4266. null,
  4267. #if CRIPPLED_REFLECTION
  4268. InfoOf(() => Qbservable.ElementAt<TSource>(default(IQbservable<TSource>), default(int))),
  4269. #else
  4270. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4271. #endif
  4272. source.Expression,
  4273. Expression.Constant(index, typeof(int))
  4274. )
  4275. );
  4276. }
  4277. /// <summary>
  4278. /// Returns the element at a specified index in a sequence or a default value if the index is out of range.
  4279. /// </summary>
  4280. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4281. /// <param name="source">Observable sequence to return the element from.</param>
  4282. /// <param name="index">The zero-based index of the element to retrieve.</param>
  4283. /// <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>
  4284. /// <exception cref="ArgumentNullException">
  4285. /// <paramref name="source" /> is null.</exception>
  4286. /// <exception cref="ArgumentOutOfRangeException">
  4287. /// <paramref name="index" /> is less than zero.</exception>
  4288. public static IQbservable<TSource> ElementAtOrDefault<TSource>(this IQbservable<TSource> source, int index)
  4289. {
  4290. if (source == null)
  4291. throw new ArgumentNullException(nameof(source));
  4292. return source.Provider.CreateQuery<TSource>(
  4293. Expression.Call(
  4294. null,
  4295. #if CRIPPLED_REFLECTION
  4296. InfoOf(() => Qbservable.ElementAtOrDefault<TSource>(default(IQbservable<TSource>), default(int))),
  4297. #else
  4298. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4299. #endif
  4300. source.Expression,
  4301. Expression.Constant(index, typeof(int))
  4302. )
  4303. );
  4304. }
  4305. /// <summary>
  4306. /// Returns an empty observable sequence.
  4307. /// </summary>
  4308. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4309. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4310. /// <returns>An observable sequence with no elements.</returns>
  4311. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider)
  4312. {
  4313. if (provider == null)
  4314. throw new ArgumentNullException(nameof(provider));
  4315. return provider.CreateQuery<TResult>(
  4316. Expression.Call(
  4317. null,
  4318. #if CRIPPLED_REFLECTION
  4319. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider))),
  4320. #else
  4321. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4322. #endif
  4323. Expression.Constant(provider, typeof(IQbservableProvider))
  4324. )
  4325. );
  4326. }
  4327. /// <summary>
  4328. /// Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
  4329. /// </summary>
  4330. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4331. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4332. /// <param name="scheduler">Scheduler to send the termination call on.</param>
  4333. /// <returns>An observable sequence with no elements.</returns>
  4334. /// <exception cref="ArgumentNullException">
  4335. /// <paramref name="scheduler" /> is null.</exception>
  4336. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, IScheduler scheduler)
  4337. {
  4338. if (provider == null)
  4339. throw new ArgumentNullException(nameof(provider));
  4340. if (scheduler == null)
  4341. throw new ArgumentNullException(nameof(scheduler));
  4342. return provider.CreateQuery<TResult>(
  4343. Expression.Call(
  4344. null,
  4345. #if CRIPPLED_REFLECTION
  4346. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(IScheduler))),
  4347. #else
  4348. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4349. #endif
  4350. Expression.Constant(provider, typeof(IQbservableProvider)),
  4351. Expression.Constant(scheduler, typeof(IScheduler))
  4352. )
  4353. );
  4354. }
  4355. /// <summary>
  4356. /// Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
  4357. /// </summary>
  4358. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4359. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4360. /// <param name="scheduler">Scheduler to send the termination call on.</param>
  4361. /// <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>
  4362. /// <returns>An observable sequence with no elements.</returns>
  4363. /// <exception cref="ArgumentNullException">
  4364. /// <paramref name="scheduler" /> is null.</exception>
  4365. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, IScheduler scheduler, TResult witness)
  4366. {
  4367. if (provider == null)
  4368. throw new ArgumentNullException(nameof(provider));
  4369. if (scheduler == null)
  4370. throw new ArgumentNullException(nameof(scheduler));
  4371. return provider.CreateQuery<TResult>(
  4372. Expression.Call(
  4373. null,
  4374. #if CRIPPLED_REFLECTION
  4375. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(IScheduler), default(TResult))),
  4376. #else
  4377. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4378. #endif
  4379. Expression.Constant(provider, typeof(IQbservableProvider)),
  4380. Expression.Constant(scheduler, typeof(IScheduler)),
  4381. Expression.Constant(witness, typeof(TResult))
  4382. )
  4383. );
  4384. }
  4385. /// <summary>
  4386. /// Returns an empty observable sequence.
  4387. /// </summary>
  4388. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4389. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4390. /// <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>
  4391. /// <returns>An observable sequence with no elements.</returns>
  4392. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, TResult witness)
  4393. {
  4394. if (provider == null)
  4395. throw new ArgumentNullException(nameof(provider));
  4396. return provider.CreateQuery<TResult>(
  4397. Expression.Call(
  4398. null,
  4399. #if CRIPPLED_REFLECTION
  4400. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(TResult))),
  4401. #else
  4402. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4403. #endif
  4404. Expression.Constant(provider, typeof(IQbservableProvider)),
  4405. Expression.Constant(witness, typeof(TResult))
  4406. )
  4407. );
  4408. }
  4409. /// <summary>
  4410. /// Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
  4411. /// </summary>
  4412. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4413. /// <param name="source">Source sequence.</param>
  4414. /// <param name="finallyAction">Action to invoke after the source observable sequence terminates.</param>
  4415. /// <returns>Source sequence with the action-invoking termination behavior applied.</returns>
  4416. /// <exception cref="ArgumentNullException">
  4417. /// <paramref name="source" /> or <paramref name="finallyAction" /> is null.</exception>
  4418. public static IQbservable<TSource> Finally<TSource>(this IQbservable<TSource> source, Expression<Action> finallyAction)
  4419. {
  4420. if (source == null)
  4421. throw new ArgumentNullException(nameof(source));
  4422. if (finallyAction == null)
  4423. throw new ArgumentNullException(nameof(finallyAction));
  4424. return source.Provider.CreateQuery<TSource>(
  4425. Expression.Call(
  4426. null,
  4427. #if CRIPPLED_REFLECTION
  4428. InfoOf(() => Qbservable.Finally<TSource>(default(IQbservable<TSource>), default(Expression<Action>))),
  4429. #else
  4430. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4431. #endif
  4432. source.Expression,
  4433. finallyAction
  4434. )
  4435. );
  4436. }
  4437. /// <summary>
  4438. /// Returns the first element of an observable sequence.
  4439. /// </summary>
  4440. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4441. /// <param name="source">Source observable sequence.</param>
  4442. /// <returns>Sequence containing the first element in the observable sequence.</returns>
  4443. /// <exception cref="ArgumentNullException">
  4444. /// <paramref name="source" /> is null.</exception>
  4445. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  4446. public static IQbservable<TSource> FirstAsync<TSource>(this IQbservable<TSource> source)
  4447. {
  4448. if (source == null)
  4449. throw new ArgumentNullException(nameof(source));
  4450. return source.Provider.CreateQuery<TSource>(
  4451. Expression.Call(
  4452. null,
  4453. #if CRIPPLED_REFLECTION
  4454. InfoOf(() => Qbservable.FirstAsync<TSource>(default(IQbservable<TSource>))),
  4455. #else
  4456. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4457. #endif
  4458. source.Expression
  4459. )
  4460. );
  4461. }
  4462. /// <summary>
  4463. /// Returns the first element of an observable sequence that satisfies the condition in the predicate.
  4464. /// </summary>
  4465. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4466. /// <param name="source">Source observable sequence.</param>
  4467. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  4468. /// <returns>Sequence containing the first element in the observable sequence that satisfies the condition in the predicate.</returns>
  4469. /// <exception cref="ArgumentNullException">
  4470. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  4471. /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  4472. public static IQbservable<TSource> FirstAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  4473. {
  4474. if (source == null)
  4475. throw new ArgumentNullException(nameof(source));
  4476. if (predicate == null)
  4477. throw new ArgumentNullException(nameof(predicate));
  4478. return source.Provider.CreateQuery<TSource>(
  4479. Expression.Call(
  4480. null,
  4481. #if CRIPPLED_REFLECTION
  4482. InfoOf(() => Qbservable.FirstAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  4483. #else
  4484. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4485. #endif
  4486. source.Expression,
  4487. predicate
  4488. )
  4489. );
  4490. }
  4491. /// <summary>
  4492. /// Returns the first element of an observable sequence, or a default value if no such element exists.
  4493. /// </summary>
  4494. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4495. /// <param name="source">Source observable sequence.</param>
  4496. /// <returns>Sequence containing the first element in the observable sequence, or a default value if no such element exists.</returns>
  4497. /// <exception cref="ArgumentNullException">
  4498. /// <paramref name="source" /> is null.</exception>
  4499. public static IQbservable<TSource> FirstOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  4500. {
  4501. if (source == null)
  4502. throw new ArgumentNullException(nameof(source));
  4503. return source.Provider.CreateQuery<TSource>(
  4504. Expression.Call(
  4505. null,
  4506. #if CRIPPLED_REFLECTION
  4507. InfoOf(() => Qbservable.FirstOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  4508. #else
  4509. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4510. #endif
  4511. source.Expression
  4512. )
  4513. );
  4514. }
  4515. /// <summary>
  4516. /// Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  4517. /// </summary>
  4518. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4519. /// <param name="source">Source observable sequence.</param>
  4520. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  4521. /// <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>
  4522. /// <exception cref="ArgumentNullException">
  4523. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  4524. public static IQbservable<TSource> FirstOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  4525. {
  4526. if (source == null)
  4527. throw new ArgumentNullException(nameof(source));
  4528. if (predicate == null)
  4529. throw new ArgumentNullException(nameof(predicate));
  4530. return source.Provider.CreateQuery<TSource>(
  4531. Expression.Call(
  4532. null,
  4533. #if CRIPPLED_REFLECTION
  4534. InfoOf(() => Qbservable.FirstOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  4535. #else
  4536. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4537. #endif
  4538. source.Expression,
  4539. predicate
  4540. )
  4541. );
  4542. }
  4543. /// <summary>
  4544. /// Concatenates the observable sequences obtained by running the <paramref name="resultSelector" /> for each element in the given enumerable <paramref name="source" />.
  4545. /// </summary>
  4546. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4547. /// <typeparam name="TSource">The type of the elements in the enumerable source sequence.</typeparam>
  4548. /// <typeparam name="TResult">The type of the elements in the observable result sequence.</typeparam>
  4549. /// <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>
  4550. /// <param name="resultSelector">Function to select an observable source for each element in the <paramref name="source" />.</param>
  4551. /// <returns>The observable sequence obtained by concatenating the sources returned by <paramref name="resultSelector" /> for each element in the <paramref name="source" />.</returns>
  4552. /// <exception cref="ArgumentNullException">
  4553. /// <paramref name="source" /> or <paramref name="resultSelector" /> is null.</exception>
  4554. public static IQbservable<TResult> For<TSource, TResult>(this IQbservableProvider provider, IEnumerable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> resultSelector)
  4555. {
  4556. if (provider == null)
  4557. throw new ArgumentNullException(nameof(provider));
  4558. if (source == null)
  4559. throw new ArgumentNullException(nameof(source));
  4560. if (resultSelector == null)
  4561. throw new ArgumentNullException(nameof(resultSelector));
  4562. return provider.CreateQuery<TResult>(
  4563. Expression.Call(
  4564. null,
  4565. #if CRIPPLED_REFLECTION
  4566. InfoOf(() => Qbservable.For<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  4567. #else
  4568. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  4569. #endif
  4570. Expression.Constant(provider, typeof(IQbservableProvider)),
  4571. GetSourceExpression(source),
  4572. resultSelector
  4573. )
  4574. );
  4575. }
  4576. /// <summary>
  4577. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4578. /// </summary>
  4579. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4580. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4581. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4582. /// <exception cref="ArgumentNullException">
  4583. /// <paramref name="actionAsync" /> is null.</exception>
  4584. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  4585. {
  4586. if (provider == null)
  4587. throw new ArgumentNullException(nameof(provider));
  4588. if (actionAsync == null)
  4589. throw new ArgumentNullException(nameof(actionAsync));
  4590. return provider.CreateQuery<Unit>(
  4591. Expression.Call(
  4592. null,
  4593. #if CRIPPLED_REFLECTION
  4594. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  4595. #else
  4596. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4597. #endif
  4598. Expression.Constant(provider, typeof(IQbservableProvider)),
  4599. actionAsync
  4600. )
  4601. );
  4602. }
  4603. /// <summary>
  4604. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4605. /// </summary>
  4606. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4607. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4608. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4609. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4610. /// <exception cref="ArgumentNullException">
  4611. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4612. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync, IScheduler scheduler)
  4613. {
  4614. if (provider == null)
  4615. throw new ArgumentNullException(nameof(provider));
  4616. if (actionAsync == null)
  4617. throw new ArgumentNullException(nameof(actionAsync));
  4618. if (scheduler == null)
  4619. throw new ArgumentNullException(nameof(scheduler));
  4620. return provider.CreateQuery<Unit>(
  4621. Expression.Call(
  4622. null,
  4623. #if CRIPPLED_REFLECTION
  4624. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<Task>>), default(IScheduler))),
  4625. #else
  4626. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4627. #endif
  4628. Expression.Constant(provider, typeof(IQbservableProvider)),
  4629. actionAsync,
  4630. Expression.Constant(scheduler, typeof(IScheduler))
  4631. )
  4632. );
  4633. }
  4634. /// <summary>
  4635. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4636. /// 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.
  4637. /// </summary>
  4638. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4639. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4640. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4641. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4642. /// <exception cref="ArgumentNullException">
  4643. /// <paramref name="actionAsync" /> is null.</exception>
  4644. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  4645. {
  4646. if (provider == null)
  4647. throw new ArgumentNullException(nameof(provider));
  4648. if (actionAsync == null)
  4649. throw new ArgumentNullException(nameof(actionAsync));
  4650. return provider.CreateQuery<Unit>(
  4651. Expression.Call(
  4652. null,
  4653. #if CRIPPLED_REFLECTION
  4654. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  4655. #else
  4656. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4657. #endif
  4658. Expression.Constant(provider, typeof(IQbservableProvider)),
  4659. actionAsync
  4660. )
  4661. );
  4662. }
  4663. /// <summary>
  4664. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4665. /// 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.
  4666. /// </summary>
  4667. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4668. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4669. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4670. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4671. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4672. /// <exception cref="ArgumentNullException">
  4673. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4674. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync, IScheduler scheduler)
  4675. {
  4676. if (provider == null)
  4677. throw new ArgumentNullException(nameof(provider));
  4678. if (actionAsync == null)
  4679. throw new ArgumentNullException(nameof(actionAsync));
  4680. if (scheduler == null)
  4681. throw new ArgumentNullException(nameof(scheduler));
  4682. return provider.CreateQuery<Unit>(
  4683. Expression.Call(
  4684. null,
  4685. #if CRIPPLED_REFLECTION
  4686. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>), default(IScheduler))),
  4687. #else
  4688. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4689. #endif
  4690. Expression.Constant(provider, typeof(IQbservableProvider)),
  4691. actionAsync,
  4692. Expression.Constant(scheduler, typeof(IScheduler))
  4693. )
  4694. );
  4695. }
  4696. /// <summary>
  4697. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4698. /// </summary>
  4699. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4700. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4701. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4702. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4703. /// <exception cref="ArgumentNullException">
  4704. /// <paramref name="functionAsync" /> is null.</exception>
  4705. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  4706. {
  4707. if (provider == null)
  4708. throw new ArgumentNullException(nameof(provider));
  4709. if (functionAsync == null)
  4710. throw new ArgumentNullException(nameof(functionAsync));
  4711. return provider.CreateQuery<TResult>(
  4712. Expression.Call(
  4713. null,
  4714. #if CRIPPLED_REFLECTION
  4715. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  4716. #else
  4717. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4718. #endif
  4719. Expression.Constant(provider, typeof(IQbservableProvider)),
  4720. functionAsync
  4721. )
  4722. );
  4723. }
  4724. /// <summary>
  4725. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4726. /// 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.
  4727. /// </summary>
  4728. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4729. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4730. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4731. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4732. /// <exception cref="ArgumentNullException">
  4733. /// <paramref name="functionAsync" /> is null.</exception>
  4734. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4735. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  4736. {
  4737. if (provider == null)
  4738. throw new ArgumentNullException(nameof(provider));
  4739. if (functionAsync == null)
  4740. throw new ArgumentNullException(nameof(functionAsync));
  4741. return provider.CreateQuery<TResult>(
  4742. Expression.Call(
  4743. null,
  4744. #if CRIPPLED_REFLECTION
  4745. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  4746. #else
  4747. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4748. #endif
  4749. Expression.Constant(provider, typeof(IQbservableProvider)),
  4750. functionAsync
  4751. )
  4752. );
  4753. }
  4754. /// <summary>
  4755. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4756. /// </summary>
  4757. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4758. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4759. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4760. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4761. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4762. /// <exception cref="ArgumentNullException">
  4763. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4764. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync, IScheduler scheduler)
  4765. {
  4766. if (provider == null)
  4767. throw new ArgumentNullException(nameof(provider));
  4768. if (functionAsync == null)
  4769. throw new ArgumentNullException(nameof(functionAsync));
  4770. if (scheduler == null)
  4771. throw new ArgumentNullException(nameof(scheduler));
  4772. return provider.CreateQuery<TResult>(
  4773. Expression.Call(
  4774. null,
  4775. #if CRIPPLED_REFLECTION
  4776. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>), default(IScheduler))),
  4777. #else
  4778. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4779. #endif
  4780. Expression.Constant(provider, typeof(IQbservableProvider)),
  4781. functionAsync,
  4782. Expression.Constant(scheduler, typeof(IScheduler))
  4783. )
  4784. );
  4785. }
  4786. /// <summary>
  4787. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4788. /// 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.
  4789. /// </summary>
  4790. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4791. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4792. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4793. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4794. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4795. /// <exception cref="ArgumentNullException">
  4796. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4797. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4798. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync, IScheduler scheduler)
  4799. {
  4800. if (provider == null)
  4801. throw new ArgumentNullException(nameof(provider));
  4802. if (functionAsync == null)
  4803. throw new ArgumentNullException(nameof(functionAsync));
  4804. if (scheduler == null)
  4805. throw new ArgumentNullException(nameof(scheduler));
  4806. return provider.CreateQuery<TResult>(
  4807. Expression.Call(
  4808. null,
  4809. #if CRIPPLED_REFLECTION
  4810. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>), default(IScheduler))),
  4811. #else
  4812. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4813. #endif
  4814. Expression.Constant(provider, typeof(IQbservableProvider)),
  4815. functionAsync,
  4816. Expression.Constant(scheduler, typeof(IScheduler))
  4817. )
  4818. );
  4819. }
  4820. /// <summary>
  4821. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4822. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4823. /// </summary>
  4824. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4825. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4826. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4827. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4828. /// <exception cref="ArgumentNullException">
  4829. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4830. /// <remarks>
  4831. /// <para>
  4832. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4833. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4834. /// </para>
  4835. /// <para>
  4836. /// 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.
  4837. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4838. /// </para>
  4839. /// <para>
  4840. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4841. /// making the Subscribe or Dispose call, respectively.
  4842. /// </para>
  4843. /// <para>
  4844. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4845. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4846. /// more concise and easier to understand.
  4847. /// </para>
  4848. /// </remarks>
  4849. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4850. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler)
  4851. {
  4852. if (provider == null)
  4853. throw new ArgumentNullException(nameof(provider));
  4854. if (addHandler == null)
  4855. throw new ArgumentNullException(nameof(addHandler));
  4856. if (removeHandler == null)
  4857. throw new ArgumentNullException(nameof(removeHandler));
  4858. return provider.CreateQuery<Unit>(
  4859. Expression.Call(
  4860. null,
  4861. #if CRIPPLED_REFLECTION
  4862. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>))),
  4863. #else
  4864. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4865. #endif
  4866. Expression.Constant(provider, typeof(IQbservableProvider)),
  4867. addHandler,
  4868. removeHandler
  4869. )
  4870. );
  4871. }
  4872. /// <summary>
  4873. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4874. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4875. /// </summary>
  4876. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4877. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4878. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4879. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4880. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4881. /// <exception cref="ArgumentNullException">
  4882. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4883. /// <remarks>
  4884. /// <para>
  4885. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4886. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4887. /// </para>
  4888. /// <para>
  4889. /// 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
  4890. /// accessed from the same context, as required by some UI frameworks.
  4891. /// </para>
  4892. /// <para>
  4893. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4894. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4895. /// parameter. For more information, see the remarks section on those overloads.
  4896. /// </para>
  4897. /// </remarks>
  4898. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4899. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler, IScheduler scheduler)
  4900. {
  4901. if (provider == null)
  4902. throw new ArgumentNullException(nameof(provider));
  4903. if (addHandler == null)
  4904. throw new ArgumentNullException(nameof(addHandler));
  4905. if (removeHandler == null)
  4906. throw new ArgumentNullException(nameof(removeHandler));
  4907. if (scheduler == null)
  4908. throw new ArgumentNullException(nameof(scheduler));
  4909. return provider.CreateQuery<Unit>(
  4910. Expression.Call(
  4911. null,
  4912. #if CRIPPLED_REFLECTION
  4913. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>), default(IScheduler))),
  4914. #else
  4915. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4916. #endif
  4917. Expression.Constant(provider, typeof(IQbservableProvider)),
  4918. addHandler,
  4919. removeHandler,
  4920. Expression.Constant(scheduler, typeof(IScheduler))
  4921. )
  4922. );
  4923. }
  4924. /// <summary>
  4925. /// 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.
  4926. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4927. /// </summary>
  4928. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4929. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4930. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4931. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4932. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4933. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4934. /// <exception cref="ArgumentNullException">
  4935. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4936. /// <remarks>
  4937. /// <para>
  4938. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4939. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4940. /// </para>
  4941. /// <para>
  4942. /// 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.
  4943. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4944. /// </para>
  4945. /// <para>
  4946. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4947. /// making the Subscribe or Dispose call, respectively.
  4948. /// </para>
  4949. /// <para>
  4950. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4951. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4952. /// more concise and easier to understand.
  4953. /// </para>
  4954. /// </remarks>
  4955. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4956. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  4957. {
  4958. if (provider == null)
  4959. throw new ArgumentNullException(nameof(provider));
  4960. if (addHandler == null)
  4961. throw new ArgumentNullException(nameof(addHandler));
  4962. if (removeHandler == null)
  4963. throw new ArgumentNullException(nameof(removeHandler));
  4964. return provider.CreateQuery<TEventArgs>(
  4965. Expression.Call(
  4966. null,
  4967. #if CRIPPLED_REFLECTION
  4968. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  4969. #else
  4970. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4971. #endif
  4972. Expression.Constant(provider, typeof(IQbservableProvider)),
  4973. addHandler,
  4974. removeHandler
  4975. )
  4976. );
  4977. }
  4978. /// <summary>
  4979. /// 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.
  4980. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4981. /// </summary>
  4982. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4983. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4984. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4985. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4986. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4987. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4988. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4989. /// <exception cref="ArgumentNullException">
  4990. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4991. /// <remarks>
  4992. /// <para>
  4993. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4994. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4995. /// </para>
  4996. /// <para>
  4997. /// 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
  4998. /// accessed from the same context, as required by some UI frameworks.
  4999. /// </para>
  5000. /// <para>
  5001. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5002. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5003. /// parameter. For more information, see the remarks section on those overloads.
  5004. /// </para>
  5005. /// </remarks>
  5006. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5007. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5008. {
  5009. if (provider == null)
  5010. throw new ArgumentNullException(nameof(provider));
  5011. if (addHandler == null)
  5012. throw new ArgumentNullException(nameof(addHandler));
  5013. if (removeHandler == null)
  5014. throw new ArgumentNullException(nameof(removeHandler));
  5015. if (scheduler == null)
  5016. throw new ArgumentNullException(nameof(scheduler));
  5017. return provider.CreateQuery<TEventArgs>(
  5018. Expression.Call(
  5019. null,
  5020. #if CRIPPLED_REFLECTION
  5021. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5022. #else
  5023. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5024. #endif
  5025. Expression.Constant(provider, typeof(IQbservableProvider)),
  5026. addHandler,
  5027. removeHandler,
  5028. Expression.Constant(scheduler, typeof(IScheduler))
  5029. )
  5030. );
  5031. }
  5032. /// <summary>
  5033. /// 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.
  5034. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5035. /// </summary>
  5036. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5037. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5038. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5039. /// <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>
  5040. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5041. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5042. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5043. /// <exception cref="ArgumentNullException">
  5044. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5045. /// <remarks>
  5046. /// <para>
  5047. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5048. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5049. /// </para>
  5050. /// <para>
  5051. /// 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.
  5052. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5053. /// </para>
  5054. /// <para>
  5055. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  5056. /// making the Subscribe or Dispose call, respectively.
  5057. /// </para>
  5058. /// <para>
  5059. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5060. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5061. /// more concise and easier to understand.
  5062. /// </para>
  5063. /// </remarks>
  5064. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5065. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5066. {
  5067. if (provider == null)
  5068. throw new ArgumentNullException(nameof(provider));
  5069. if (conversion == null)
  5070. throw new ArgumentNullException(nameof(conversion));
  5071. if (addHandler == null)
  5072. throw new ArgumentNullException(nameof(addHandler));
  5073. if (removeHandler == null)
  5074. throw new ArgumentNullException(nameof(removeHandler));
  5075. return provider.CreateQuery<TEventArgs>(
  5076. Expression.Call(
  5077. null,
  5078. #if CRIPPLED_REFLECTION
  5079. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5080. #else
  5081. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5082. #endif
  5083. Expression.Constant(provider, typeof(IQbservableProvider)),
  5084. conversion,
  5085. addHandler,
  5086. removeHandler
  5087. )
  5088. );
  5089. }
  5090. /// <summary>
  5091. /// 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.
  5092. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5093. /// </summary>
  5094. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5095. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5096. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5097. /// <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>
  5098. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5099. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5100. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5101. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5102. /// <exception cref="ArgumentNullException">
  5103. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5104. /// <remarks>
  5105. /// <para>
  5106. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5107. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5108. /// </para>
  5109. /// <para>
  5110. /// 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
  5111. /// accessed from the same context, as required by some UI frameworks.
  5112. /// </para>
  5113. /// <para>
  5114. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5115. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5116. /// parameter. For more information, see the remarks section on those overloads.
  5117. /// </para>
  5118. /// </remarks>
  5119. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5120. 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)
  5121. {
  5122. if (provider == null)
  5123. throw new ArgumentNullException(nameof(provider));
  5124. if (conversion == null)
  5125. throw new ArgumentNullException(nameof(conversion));
  5126. if (addHandler == null)
  5127. throw new ArgumentNullException(nameof(addHandler));
  5128. if (removeHandler == null)
  5129. throw new ArgumentNullException(nameof(removeHandler));
  5130. if (scheduler == null)
  5131. throw new ArgumentNullException(nameof(scheduler));
  5132. return provider.CreateQuery<TEventArgs>(
  5133. Expression.Call(
  5134. null,
  5135. #if CRIPPLED_REFLECTION
  5136. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5137. #else
  5138. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5139. #endif
  5140. Expression.Constant(provider, typeof(IQbservableProvider)),
  5141. conversion,
  5142. addHandler,
  5143. removeHandler,
  5144. Expression.Constant(scheduler, typeof(IScheduler))
  5145. )
  5146. );
  5147. }
  5148. /// <summary>
  5149. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5150. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5151. /// </summary>
  5152. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5153. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5154. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5155. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5156. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5157. /// <exception cref="ArgumentNullException">
  5158. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5159. /// <remarks>
  5160. /// <para>
  5161. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5162. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5163. /// </para>
  5164. /// <para>
  5165. /// 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.
  5166. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5167. /// </para>
  5168. /// <para>
  5169. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  5170. /// making the Subscribe or Dispose call, respectively.
  5171. /// </para>
  5172. /// <para>
  5173. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5174. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5175. /// more concise and easier to understand.
  5176. /// </para>
  5177. /// </remarks>
  5178. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5179. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler)
  5180. {
  5181. if (provider == null)
  5182. throw new ArgumentNullException(nameof(provider));
  5183. if (addHandler == null)
  5184. throw new ArgumentNullException(nameof(addHandler));
  5185. if (removeHandler == null)
  5186. throw new ArgumentNullException(nameof(removeHandler));
  5187. return provider.CreateQuery<TEventArgs>(
  5188. Expression.Call(
  5189. null,
  5190. #if CRIPPLED_REFLECTION
  5191. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>))),
  5192. #else
  5193. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5194. #endif
  5195. Expression.Constant(provider, typeof(IQbservableProvider)),
  5196. addHandler,
  5197. removeHandler
  5198. )
  5199. );
  5200. }
  5201. /// <summary>
  5202. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5203. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5204. /// </summary>
  5205. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5206. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5207. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5208. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5209. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5210. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5211. /// <exception cref="ArgumentNullException">
  5212. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5213. /// <remarks>
  5214. /// <para>
  5215. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5216. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5217. /// </para>
  5218. /// <para>
  5219. /// 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
  5220. /// accessed from the same context, as required by some UI frameworks.
  5221. /// </para>
  5222. /// <para>
  5223. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5224. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5225. /// parameter. For more information, see the remarks section on those overloads.
  5226. /// </para>
  5227. /// </remarks>
  5228. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5229. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler, IScheduler scheduler)
  5230. {
  5231. if (provider == null)
  5232. throw new ArgumentNullException(nameof(provider));
  5233. if (addHandler == null)
  5234. throw new ArgumentNullException(nameof(addHandler));
  5235. if (removeHandler == null)
  5236. throw new ArgumentNullException(nameof(removeHandler));
  5237. if (scheduler == null)
  5238. throw new ArgumentNullException(nameof(scheduler));
  5239. return provider.CreateQuery<TEventArgs>(
  5240. Expression.Call(
  5241. null,
  5242. #if CRIPPLED_REFLECTION
  5243. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>), default(IScheduler))),
  5244. #else
  5245. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5246. #endif
  5247. Expression.Constant(provider, typeof(IQbservableProvider)),
  5248. addHandler,
  5249. removeHandler,
  5250. Expression.Constant(scheduler, typeof(IScheduler))
  5251. )
  5252. );
  5253. }
  5254. /// <summary>
  5255. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler" />, to an observable sequence.
  5256. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5257. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5258. /// </summary>
  5259. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5260. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5261. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5262. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5263. /// <exception cref="ArgumentNullException">
  5264. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5265. /// <remarks>
  5266. /// <para>
  5267. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5268. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5269. /// </para>
  5270. /// <para>
  5271. /// 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.
  5272. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5273. /// </para>
  5274. /// <para>
  5275. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5276. /// making the Subscribe or Dispose call, respectively.
  5277. /// </para>
  5278. /// <para>
  5279. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5280. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5281. /// more concise and easier to understand.
  5282. /// </para>
  5283. /// </remarks>
  5284. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5285. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)
  5286. {
  5287. if (provider == null)
  5288. throw new ArgumentNullException(nameof(provider));
  5289. if (addHandler == null)
  5290. throw new ArgumentNullException(nameof(addHandler));
  5291. if (removeHandler == null)
  5292. throw new ArgumentNullException(nameof(removeHandler));
  5293. return provider.CreateQuery<EventPattern<object>>(
  5294. Expression.Call(
  5295. null,
  5296. #if CRIPPLED_REFLECTION
  5297. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>))),
  5298. #else
  5299. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5300. #endif
  5301. Expression.Constant(provider, typeof(IQbservableProvider)),
  5302. addHandler,
  5303. removeHandler
  5304. )
  5305. );
  5306. }
  5307. /// <summary>
  5308. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler" />, to an observable sequence.
  5309. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5310. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5311. /// </summary>
  5312. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5313. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5314. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5315. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5316. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5317. /// <exception cref="ArgumentNullException">
  5318. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5319. /// <remarks>
  5320. /// <para>
  5321. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5322. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5323. /// </para>
  5324. /// <para>
  5325. /// 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
  5326. /// accessed from the same context, as required by some UI frameworks.
  5327. /// </para>
  5328. /// <para>
  5329. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5330. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5331. /// parameter. For more information, see the remarks section on those overloads.
  5332. /// </para>
  5333. /// </remarks>
  5334. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5335. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)
  5336. {
  5337. if (provider == null)
  5338. throw new ArgumentNullException(nameof(provider));
  5339. if (addHandler == null)
  5340. throw new ArgumentNullException(nameof(addHandler));
  5341. if (removeHandler == null)
  5342. throw new ArgumentNullException(nameof(removeHandler));
  5343. if (scheduler == null)
  5344. throw new ArgumentNullException(nameof(scheduler));
  5345. return provider.CreateQuery<EventPattern<object>>(
  5346. Expression.Call(
  5347. null,
  5348. #if CRIPPLED_REFLECTION
  5349. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>), default(IScheduler))),
  5350. #else
  5351. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5352. #endif
  5353. Expression.Constant(provider, typeof(IQbservableProvider)),
  5354. addHandler,
  5355. removeHandler,
  5356. Expression.Constant(scheduler, typeof(IScheduler))
  5357. )
  5358. );
  5359. }
  5360. /// <summary>
  5361. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5362. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5363. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5364. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5365. /// </summary>
  5366. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5367. /// <param name="target">Object instance that exposes the event to convert.</param>
  5368. /// <param name="eventName">Name of the event to convert.</param>
  5369. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5370. /// <exception cref="ArgumentNullException">
  5371. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  5372. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5373. /// <remarks>
  5374. /// <para>
  5375. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5376. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5377. /// </para>
  5378. /// <para>
  5379. /// 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.
  5380. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5381. /// </para>
  5382. /// <para>
  5383. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5384. /// making the Subscribe or Dispose call, respectively.
  5385. /// </para>
  5386. /// <para>
  5387. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5388. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5389. /// more concise and easier to understand.
  5390. /// </para>
  5391. /// </remarks>
  5392. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5393. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)
  5394. {
  5395. if (provider == null)
  5396. throw new ArgumentNullException(nameof(provider));
  5397. if (target == null)
  5398. throw new ArgumentNullException(nameof(target));
  5399. if (eventName == null)
  5400. throw new ArgumentNullException(nameof(eventName));
  5401. return provider.CreateQuery<EventPattern<object>>(
  5402. Expression.Call(
  5403. null,
  5404. #if CRIPPLED_REFLECTION
  5405. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string))),
  5406. #else
  5407. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5408. #endif
  5409. Expression.Constant(provider, typeof(IQbservableProvider)),
  5410. Expression.Constant(target, typeof(object)),
  5411. Expression.Constant(eventName, typeof(string))
  5412. )
  5413. );
  5414. }
  5415. /// <summary>
  5416. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5417. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5418. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5419. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5420. /// </summary>
  5421. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5422. /// <param name="target">Object instance that exposes the event to convert.</param>
  5423. /// <param name="eventName">Name of the event to convert.</param>
  5424. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5425. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5426. /// <exception cref="ArgumentNullException">
  5427. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5428. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5429. /// <remarks>
  5430. /// <para>
  5431. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5432. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5433. /// </para>
  5434. /// <para>
  5435. /// 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
  5436. /// accessed from the same context, as required by some UI frameworks.
  5437. /// </para>
  5438. /// <para>
  5439. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5440. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5441. /// parameter. For more information, see the remarks section on those overloads.
  5442. /// </para>
  5443. /// </remarks>
  5444. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5445. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  5446. {
  5447. if (provider == null)
  5448. throw new ArgumentNullException(nameof(provider));
  5449. if (target == null)
  5450. throw new ArgumentNullException(nameof(target));
  5451. if (eventName == null)
  5452. throw new ArgumentNullException(nameof(eventName));
  5453. if (scheduler == null)
  5454. throw new ArgumentNullException(nameof(scheduler));
  5455. return provider.CreateQuery<EventPattern<object>>(
  5456. Expression.Call(
  5457. null,
  5458. #if CRIPPLED_REFLECTION
  5459. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  5460. #else
  5461. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5462. #endif
  5463. Expression.Constant(provider, typeof(IQbservableProvider)),
  5464. Expression.Constant(target, typeof(object)),
  5465. Expression.Constant(eventName, typeof(string)),
  5466. Expression.Constant(scheduler, typeof(IScheduler))
  5467. )
  5468. );
  5469. }
  5470. /// <summary>
  5471. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5472. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5473. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5474. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5475. /// </summary>
  5476. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5477. /// <param name="type">Type that exposes the static event to convert.</param>
  5478. /// <param name="eventName">Name of the event to convert.</param>
  5479. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5480. /// <exception cref="ArgumentNullException">
  5481. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  5482. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5483. /// <remarks>
  5484. /// <para>
  5485. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5486. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5487. /// </para>
  5488. /// <para>
  5489. /// 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.
  5490. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5491. /// </para>
  5492. /// <para>
  5493. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5494. /// making the Subscribe or Dispose call, respectively.
  5495. /// </para>
  5496. /// <para>
  5497. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5498. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5499. /// more concise and easier to understand.
  5500. /// </para>
  5501. /// </remarks>
  5502. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5503. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)
  5504. {
  5505. if (provider == null)
  5506. throw new ArgumentNullException(nameof(provider));
  5507. if (type == null)
  5508. throw new ArgumentNullException(nameof(type));
  5509. if (eventName == null)
  5510. throw new ArgumentNullException(nameof(eventName));
  5511. return provider.CreateQuery<EventPattern<object>>(
  5512. Expression.Call(
  5513. null,
  5514. #if CRIPPLED_REFLECTION
  5515. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string))),
  5516. #else
  5517. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5518. #endif
  5519. Expression.Constant(provider, typeof(IQbservableProvider)),
  5520. Expression.Constant(type, typeof(Type)),
  5521. Expression.Constant(eventName, typeof(string))
  5522. )
  5523. );
  5524. }
  5525. /// <summary>
  5526. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5527. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5528. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5529. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5530. /// </summary>
  5531. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5532. /// <param name="type">Type that exposes the static event to convert.</param>
  5533. /// <param name="eventName">Name of the event to convert.</param>
  5534. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5535. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5536. /// <exception cref="ArgumentNullException">
  5537. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5538. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5539. /// <remarks>
  5540. /// <para>
  5541. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5542. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5543. /// </para>
  5544. /// <para>
  5545. /// 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
  5546. /// accessed from the same context, as required by some UI frameworks.
  5547. /// </para>
  5548. /// <para>
  5549. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5550. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5551. /// parameter. For more information, see the remarks section on those overloads.
  5552. /// </para>
  5553. /// </remarks>
  5554. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5555. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  5556. {
  5557. if (provider == null)
  5558. throw new ArgumentNullException(nameof(provider));
  5559. if (type == null)
  5560. throw new ArgumentNullException(nameof(type));
  5561. if (eventName == null)
  5562. throw new ArgumentNullException(nameof(eventName));
  5563. if (scheduler == null)
  5564. throw new ArgumentNullException(nameof(scheduler));
  5565. return provider.CreateQuery<EventPattern<object>>(
  5566. Expression.Call(
  5567. null,
  5568. #if CRIPPLED_REFLECTION
  5569. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  5570. #else
  5571. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5572. #endif
  5573. Expression.Constant(provider, typeof(IQbservableProvider)),
  5574. Expression.Constant(type, typeof(Type)),
  5575. Expression.Constant(eventName, typeof(string)),
  5576. Expression.Constant(scheduler, typeof(IScheduler))
  5577. )
  5578. );
  5579. }
  5580. /// <summary>
  5581. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5582. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5583. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5584. /// </summary>
  5585. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5586. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5587. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5588. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5589. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5590. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5591. /// <exception cref="ArgumentNullException">
  5592. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5593. /// <remarks>
  5594. /// <para>
  5595. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5596. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5597. /// </para>
  5598. /// <para>
  5599. /// 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.
  5600. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5601. /// </para>
  5602. /// <para>
  5603. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5604. /// making the Subscribe or Dispose call, respectively.
  5605. /// </para>
  5606. /// <para>
  5607. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5608. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5609. /// more concise and easier to understand.
  5610. /// </para>
  5611. /// </remarks>
  5612. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5613. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5614. {
  5615. if (provider == null)
  5616. throw new ArgumentNullException(nameof(provider));
  5617. if (addHandler == null)
  5618. throw new ArgumentNullException(nameof(addHandler));
  5619. if (removeHandler == null)
  5620. throw new ArgumentNullException(nameof(removeHandler));
  5621. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5622. Expression.Call(
  5623. null,
  5624. #if CRIPPLED_REFLECTION
  5625. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5626. #else
  5627. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5628. #endif
  5629. Expression.Constant(provider, typeof(IQbservableProvider)),
  5630. addHandler,
  5631. removeHandler
  5632. )
  5633. );
  5634. }
  5635. /// <summary>
  5636. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5637. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5638. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5639. /// </summary>
  5640. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5641. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5642. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5643. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5644. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5645. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5646. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5647. /// <exception cref="ArgumentNullException">
  5648. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5649. /// <remarks>
  5650. /// <para>
  5651. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5652. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5653. /// </para>
  5654. /// <para>
  5655. /// 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
  5656. /// accessed from the same context, as required by some UI frameworks.
  5657. /// </para>
  5658. /// <para>
  5659. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5660. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5661. /// parameter. For more information, see the remarks section on those overloads.
  5662. /// </para>
  5663. /// </remarks>
  5664. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5665. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5666. {
  5667. if (provider == null)
  5668. throw new ArgumentNullException(nameof(provider));
  5669. if (addHandler == null)
  5670. throw new ArgumentNullException(nameof(addHandler));
  5671. if (removeHandler == null)
  5672. throw new ArgumentNullException(nameof(removeHandler));
  5673. if (scheduler == null)
  5674. throw new ArgumentNullException(nameof(scheduler));
  5675. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5676. Expression.Call(
  5677. null,
  5678. #if CRIPPLED_REFLECTION
  5679. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5680. #else
  5681. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5682. #endif
  5683. Expression.Constant(provider, typeof(IQbservableProvider)),
  5684. addHandler,
  5685. removeHandler,
  5686. Expression.Constant(scheduler, typeof(IScheduler))
  5687. )
  5688. );
  5689. }
  5690. /// <summary>
  5691. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5692. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5693. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5694. /// </summary>
  5695. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5696. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5697. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5698. /// <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>
  5699. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5700. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5701. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5702. /// <exception cref="ArgumentNullException">
  5703. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5704. /// <remarks>
  5705. /// <para>
  5706. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5707. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5708. /// </para>
  5709. /// <para>
  5710. /// 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.
  5711. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5712. /// </para>
  5713. /// <para>
  5714. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5715. /// making the Subscribe or Dispose call, respectively.
  5716. /// </para>
  5717. /// <para>
  5718. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5719. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5720. /// more concise and easier to understand.
  5721. /// </para>
  5722. /// </remarks>
  5723. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5724. 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)
  5725. {
  5726. if (provider == null)
  5727. throw new ArgumentNullException(nameof(provider));
  5728. if (conversion == null)
  5729. throw new ArgumentNullException(nameof(conversion));
  5730. if (addHandler == null)
  5731. throw new ArgumentNullException(nameof(addHandler));
  5732. if (removeHandler == null)
  5733. throw new ArgumentNullException(nameof(removeHandler));
  5734. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5735. Expression.Call(
  5736. null,
  5737. #if CRIPPLED_REFLECTION
  5738. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5739. #else
  5740. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5741. #endif
  5742. Expression.Constant(provider, typeof(IQbservableProvider)),
  5743. conversion,
  5744. addHandler,
  5745. removeHandler
  5746. )
  5747. );
  5748. }
  5749. /// <summary>
  5750. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5751. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5752. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5753. /// </summary>
  5754. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5755. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5756. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5757. /// <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>
  5758. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5759. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5760. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5761. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5762. /// <exception cref="ArgumentNullException">
  5763. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5764. /// <remarks>
  5765. /// <para>
  5766. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5767. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5768. /// </para>
  5769. /// <para>
  5770. /// 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
  5771. /// accessed from the same context, as required by some UI frameworks.
  5772. /// </para>
  5773. /// <para>
  5774. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5775. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5776. /// parameter. For more information, see the remarks section on those overloads.
  5777. /// </para>
  5778. /// </remarks>
  5779. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5780. 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)
  5781. {
  5782. if (provider == null)
  5783. throw new ArgumentNullException(nameof(provider));
  5784. if (conversion == null)
  5785. throw new ArgumentNullException(nameof(conversion));
  5786. if (addHandler == null)
  5787. throw new ArgumentNullException(nameof(addHandler));
  5788. if (removeHandler == null)
  5789. throw new ArgumentNullException(nameof(removeHandler));
  5790. if (scheduler == null)
  5791. throw new ArgumentNullException(nameof(scheduler));
  5792. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5793. Expression.Call(
  5794. null,
  5795. #if CRIPPLED_REFLECTION
  5796. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5797. #else
  5798. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5799. #endif
  5800. Expression.Constant(provider, typeof(IQbservableProvider)),
  5801. conversion,
  5802. addHandler,
  5803. removeHandler,
  5804. Expression.Constant(scheduler, typeof(IScheduler))
  5805. )
  5806. );
  5807. }
  5808. /// <summary>
  5809. /// 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.
  5810. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5811. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5812. /// </summary>
  5813. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5814. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5815. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  5816. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5817. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5818. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5819. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5820. /// <exception cref="ArgumentNullException">
  5821. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5822. /// <remarks>
  5823. /// <para>
  5824. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5825. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5826. /// </para>
  5827. /// <para>
  5828. /// 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.
  5829. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5830. /// </para>
  5831. /// <para>
  5832. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5833. /// making the Subscribe or Dispose call, respectively.
  5834. /// </para>
  5835. /// <para>
  5836. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5837. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5838. /// more concise and easier to understand.
  5839. /// </para>
  5840. /// </remarks>
  5841. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5842. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5843. {
  5844. if (provider == null)
  5845. throw new ArgumentNullException(nameof(provider));
  5846. if (addHandler == null)
  5847. throw new ArgumentNullException(nameof(addHandler));
  5848. if (removeHandler == null)
  5849. throw new ArgumentNullException(nameof(removeHandler));
  5850. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  5851. Expression.Call(
  5852. null,
  5853. #if CRIPPLED_REFLECTION
  5854. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5855. #else
  5856. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  5857. #endif
  5858. Expression.Constant(provider, typeof(IQbservableProvider)),
  5859. addHandler,
  5860. removeHandler
  5861. )
  5862. );
  5863. }
  5864. /// <summary>
  5865. /// 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.
  5866. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5867. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5868. /// </summary>
  5869. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5870. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5871. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  5872. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5873. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5874. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5875. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5876. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5877. /// <exception cref="ArgumentNullException">
  5878. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5879. /// <remarks>
  5880. /// <para>
  5881. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5882. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5883. /// </para>
  5884. /// <para>
  5885. /// 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
  5886. /// accessed from the same context, as required by some UI frameworks.
  5887. /// </para>
  5888. /// <para>
  5889. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5890. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5891. /// parameter. For more information, see the remarks section on those overloads.
  5892. /// </para>
  5893. /// </remarks>
  5894. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5895. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5896. {
  5897. if (provider == null)
  5898. throw new ArgumentNullException(nameof(provider));
  5899. if (addHandler == null)
  5900. throw new ArgumentNullException(nameof(addHandler));
  5901. if (removeHandler == null)
  5902. throw new ArgumentNullException(nameof(removeHandler));
  5903. if (scheduler == null)
  5904. throw new ArgumentNullException(nameof(scheduler));
  5905. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  5906. Expression.Call(
  5907. null,
  5908. #if CRIPPLED_REFLECTION
  5909. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5910. #else
  5911. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  5912. #endif
  5913. Expression.Constant(provider, typeof(IQbservableProvider)),
  5914. addHandler,
  5915. removeHandler,
  5916. Expression.Constant(scheduler, typeof(IScheduler))
  5917. )
  5918. );
  5919. }
  5920. /// <summary>
  5921. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5922. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5923. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5924. /// </summary>
  5925. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5926. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5927. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5928. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5929. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5930. /// <remarks>
  5931. /// <para>
  5932. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5933. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5934. /// </para>
  5935. /// <para>
  5936. /// 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.
  5937. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5938. /// </para>
  5939. /// <para>
  5940. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5941. /// making the Subscribe or Dispose call, respectively.
  5942. /// </para>
  5943. /// <para>
  5944. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5945. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5946. /// more concise and easier to understand.
  5947. /// </para>
  5948. /// </remarks>
  5949. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5950. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler)
  5951. {
  5952. if (provider == null)
  5953. throw new ArgumentNullException(nameof(provider));
  5954. if (addHandler == null)
  5955. throw new ArgumentNullException(nameof(addHandler));
  5956. if (removeHandler == null)
  5957. throw new ArgumentNullException(nameof(removeHandler));
  5958. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5959. Expression.Call(
  5960. null,
  5961. #if CRIPPLED_REFLECTION
  5962. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>))),
  5963. #else
  5964. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5965. #endif
  5966. Expression.Constant(provider, typeof(IQbservableProvider)),
  5967. addHandler,
  5968. removeHandler
  5969. )
  5970. );
  5971. }
  5972. /// <summary>
  5973. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5974. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5975. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5976. /// </summary>
  5977. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5978. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5979. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5980. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5981. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5982. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5983. /// <remarks>
  5984. /// <para>
  5985. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5986. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5987. /// </para>
  5988. /// <para>
  5989. /// 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
  5990. /// accessed from the same context, as required by some UI frameworks.
  5991. /// </para>
  5992. /// <para>
  5993. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5994. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5995. /// parameter. For more information, see the remarks section on those overloads.
  5996. /// </para>
  5997. /// </remarks>
  5998. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5999. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler, IScheduler scheduler)
  6000. {
  6001. if (provider == null)
  6002. throw new ArgumentNullException(nameof(provider));
  6003. if (addHandler == null)
  6004. throw new ArgumentNullException(nameof(addHandler));
  6005. if (removeHandler == null)
  6006. throw new ArgumentNullException(nameof(removeHandler));
  6007. if (scheduler == null)
  6008. throw new ArgumentNullException(nameof(scheduler));
  6009. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6010. Expression.Call(
  6011. null,
  6012. #if CRIPPLED_REFLECTION
  6013. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>), default(IScheduler))),
  6014. #else
  6015. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6016. #endif
  6017. Expression.Constant(provider, typeof(IQbservableProvider)),
  6018. addHandler,
  6019. removeHandler,
  6020. Expression.Constant(scheduler, typeof(IScheduler))
  6021. )
  6022. );
  6023. }
  6024. /// <summary>
  6025. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6026. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6027. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6028. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6029. /// </summary>
  6030. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6031. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6032. /// <param name="target">Object instance that exposes the event to convert.</param>
  6033. /// <param name="eventName">Name of the event to convert.</param>
  6034. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6035. /// <exception cref="ArgumentNullException">
  6036. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6037. /// <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>
  6038. /// <remarks>
  6039. /// <para>
  6040. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6041. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6042. /// </para>
  6043. /// <para>
  6044. /// 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.
  6045. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6046. /// </para>
  6047. /// <para>
  6048. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6049. /// making the Subscribe or Dispose call, respectively.
  6050. /// </para>
  6051. /// <para>
  6052. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6053. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6054. /// more concise and easier to understand.
  6055. /// </para>
  6056. /// </remarks>
  6057. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6058. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6059. {
  6060. if (provider == null)
  6061. throw new ArgumentNullException(nameof(provider));
  6062. if (target == null)
  6063. throw new ArgumentNullException(nameof(target));
  6064. if (eventName == null)
  6065. throw new ArgumentNullException(nameof(eventName));
  6066. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6067. Expression.Call(
  6068. null,
  6069. #if CRIPPLED_REFLECTION
  6070. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6071. #else
  6072. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6073. #endif
  6074. Expression.Constant(provider, typeof(IQbservableProvider)),
  6075. Expression.Constant(target, typeof(object)),
  6076. Expression.Constant(eventName, typeof(string))
  6077. )
  6078. );
  6079. }
  6080. /// <summary>
  6081. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6082. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6083. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6084. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6085. /// </summary>
  6086. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6087. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6088. /// <param name="target">Object instance that exposes the event to convert.</param>
  6089. /// <param name="eventName">Name of the event to convert.</param>
  6090. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6091. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6092. /// <exception cref="ArgumentNullException">
  6093. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6094. /// <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>
  6095. /// <remarks>
  6096. /// <para>
  6097. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6098. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6099. /// </para>
  6100. /// <para>
  6101. /// 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
  6102. /// accessed from the same context, as required by some UI frameworks.
  6103. /// </para>
  6104. /// <para>
  6105. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6106. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6107. /// parameter. For more information, see the remarks section on those overloads.
  6108. /// </para>
  6109. /// </remarks>
  6110. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6111. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6112. {
  6113. if (provider == null)
  6114. throw new ArgumentNullException(nameof(provider));
  6115. if (target == null)
  6116. throw new ArgumentNullException(nameof(target));
  6117. if (eventName == null)
  6118. throw new ArgumentNullException(nameof(eventName));
  6119. if (scheduler == null)
  6120. throw new ArgumentNullException(nameof(scheduler));
  6121. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6122. Expression.Call(
  6123. null,
  6124. #if CRIPPLED_REFLECTION
  6125. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6126. #else
  6127. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6128. #endif
  6129. Expression.Constant(provider, typeof(IQbservableProvider)),
  6130. Expression.Constant(target, typeof(object)),
  6131. Expression.Constant(eventName, typeof(string)),
  6132. Expression.Constant(scheduler, typeof(IScheduler))
  6133. )
  6134. );
  6135. }
  6136. /// <summary>
  6137. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6138. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6139. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6140. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6141. /// </summary>
  6142. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6143. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6144. /// <param name="type">Type that exposes the static event to convert.</param>
  6145. /// <param name="eventName">Name of the event to convert.</param>
  6146. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6147. /// <exception cref="ArgumentNullException">
  6148. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6149. /// <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>
  6150. /// <remarks>
  6151. /// <para>
  6152. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6153. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6154. /// </para>
  6155. /// <para>
  6156. /// 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.
  6157. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6158. /// </para>
  6159. /// <para>
  6160. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6161. /// making the Subscribe or Dispose call, respectively.
  6162. /// </para>
  6163. /// <para>
  6164. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6165. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6166. /// more concise and easier to understand.
  6167. /// </para>
  6168. /// </remarks>
  6169. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6170. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6171. {
  6172. if (provider == null)
  6173. throw new ArgumentNullException(nameof(provider));
  6174. if (type == null)
  6175. throw new ArgumentNullException(nameof(type));
  6176. if (eventName == null)
  6177. throw new ArgumentNullException(nameof(eventName));
  6178. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6179. Expression.Call(
  6180. null,
  6181. #if CRIPPLED_REFLECTION
  6182. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6183. #else
  6184. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6185. #endif
  6186. Expression.Constant(provider, typeof(IQbservableProvider)),
  6187. Expression.Constant(type, typeof(Type)),
  6188. Expression.Constant(eventName, typeof(string))
  6189. )
  6190. );
  6191. }
  6192. /// <summary>
  6193. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6194. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6195. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6196. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6197. /// </summary>
  6198. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6199. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6200. /// <param name="type">Type that exposes the static event to convert.</param>
  6201. /// <param name="eventName">Name of the event to convert.</param>
  6202. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6203. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6204. /// <exception cref="ArgumentNullException">
  6205. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6206. /// <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>
  6207. /// <remarks>
  6208. /// <para>
  6209. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6210. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6211. /// </para>
  6212. /// <para>
  6213. /// 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
  6214. /// accessed from the same context, as required by some UI frameworks.
  6215. /// </para>
  6216. /// <para>
  6217. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6218. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6219. /// parameter. For more information, see the remarks section on those overloads.
  6220. /// </para>
  6221. /// </remarks>
  6222. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6223. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6224. {
  6225. if (provider == null)
  6226. throw new ArgumentNullException(nameof(provider));
  6227. if (type == null)
  6228. throw new ArgumentNullException(nameof(type));
  6229. if (eventName == null)
  6230. throw new ArgumentNullException(nameof(eventName));
  6231. if (scheduler == null)
  6232. throw new ArgumentNullException(nameof(scheduler));
  6233. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6234. Expression.Call(
  6235. null,
  6236. #if CRIPPLED_REFLECTION
  6237. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6238. #else
  6239. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6240. #endif
  6241. Expression.Constant(provider, typeof(IQbservableProvider)),
  6242. Expression.Constant(type, typeof(Type)),
  6243. Expression.Constant(eventName, typeof(string)),
  6244. Expression.Constant(scheduler, typeof(IScheduler))
  6245. )
  6246. );
  6247. }
  6248. /// <summary>
  6249. /// 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.
  6250. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6251. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6252. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6253. /// </summary>
  6254. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6255. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6256. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6257. /// <param name="target">Object instance that exposes the event to convert.</param>
  6258. /// <param name="eventName">Name of the event to convert.</param>
  6259. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6260. /// <exception cref="ArgumentNullException">
  6261. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6262. /// <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>
  6263. /// <remarks>
  6264. /// <para>
  6265. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6266. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6267. /// </para>
  6268. /// <para>
  6269. /// 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.
  6270. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6271. /// </para>
  6272. /// <para>
  6273. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6274. /// making the Subscribe or Dispose call, respectively.
  6275. /// </para>
  6276. /// <para>
  6277. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6278. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6279. /// more concise and easier to understand.
  6280. /// </para>
  6281. /// </remarks>
  6282. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6283. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6284. {
  6285. if (provider == null)
  6286. throw new ArgumentNullException(nameof(provider));
  6287. if (target == null)
  6288. throw new ArgumentNullException(nameof(target));
  6289. if (eventName == null)
  6290. throw new ArgumentNullException(nameof(eventName));
  6291. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6292. Expression.Call(
  6293. null,
  6294. #if CRIPPLED_REFLECTION
  6295. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6296. #else
  6297. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6298. #endif
  6299. Expression.Constant(provider, typeof(IQbservableProvider)),
  6300. Expression.Constant(target, typeof(object)),
  6301. Expression.Constant(eventName, typeof(string))
  6302. )
  6303. );
  6304. }
  6305. /// <summary>
  6306. /// 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.
  6307. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6308. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6309. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6310. /// </summary>
  6311. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6312. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6313. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6314. /// <param name="target">Object instance that exposes the event to convert.</param>
  6315. /// <param name="eventName">Name of the event to convert.</param>
  6316. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6317. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6318. /// <exception cref="ArgumentNullException">
  6319. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6320. /// <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>
  6321. /// <remarks>
  6322. /// <para>
  6323. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6324. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6325. /// </para>
  6326. /// <para>
  6327. /// 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
  6328. /// accessed from the same context, as required by some UI frameworks.
  6329. /// </para>
  6330. /// <para>
  6331. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6332. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6333. /// parameter. For more information, see the remarks section on those overloads.
  6334. /// </para>
  6335. /// </remarks>
  6336. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6337. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6338. {
  6339. if (provider == null)
  6340. throw new ArgumentNullException(nameof(provider));
  6341. if (target == null)
  6342. throw new ArgumentNullException(nameof(target));
  6343. if (eventName == null)
  6344. throw new ArgumentNullException(nameof(eventName));
  6345. if (scheduler == null)
  6346. throw new ArgumentNullException(nameof(scheduler));
  6347. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6348. Expression.Call(
  6349. null,
  6350. #if CRIPPLED_REFLECTION
  6351. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6352. #else
  6353. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6354. #endif
  6355. Expression.Constant(provider, typeof(IQbservableProvider)),
  6356. Expression.Constant(target, typeof(object)),
  6357. Expression.Constant(eventName, typeof(string)),
  6358. Expression.Constant(scheduler, typeof(IScheduler))
  6359. )
  6360. );
  6361. }
  6362. /// <summary>
  6363. /// 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.
  6364. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6365. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6366. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6367. /// </summary>
  6368. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6369. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6370. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6371. /// <param name="type">Type that exposes the static event to convert.</param>
  6372. /// <param name="eventName">Name of the event to convert.</param>
  6373. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6374. /// <exception cref="ArgumentNullException">
  6375. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6376. /// <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>
  6377. /// <remarks>
  6378. /// <para>
  6379. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6380. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6381. /// </para>
  6382. /// <para>
  6383. /// 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.
  6384. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6385. /// </para>
  6386. /// <para>
  6387. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6388. /// making the Subscribe or Dispose call, respectively.
  6389. /// </para>
  6390. /// <para>
  6391. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6392. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6393. /// more concise and easier to understand.
  6394. /// </para>
  6395. /// </remarks>
  6396. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6397. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6398. {
  6399. if (provider == null)
  6400. throw new ArgumentNullException(nameof(provider));
  6401. if (type == null)
  6402. throw new ArgumentNullException(nameof(type));
  6403. if (eventName == null)
  6404. throw new ArgumentNullException(nameof(eventName));
  6405. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6406. Expression.Call(
  6407. null,
  6408. #if CRIPPLED_REFLECTION
  6409. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6410. #else
  6411. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6412. #endif
  6413. Expression.Constant(provider, typeof(IQbservableProvider)),
  6414. Expression.Constant(type, typeof(Type)),
  6415. Expression.Constant(eventName, typeof(string))
  6416. )
  6417. );
  6418. }
  6419. /// <summary>
  6420. /// 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.
  6421. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6422. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6423. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6424. /// </summary>
  6425. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6426. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6427. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6428. /// <param name="type">Type that exposes the static event to convert.</param>
  6429. /// <param name="eventName">Name of the event to convert.</param>
  6430. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6431. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6432. /// <exception cref="ArgumentNullException">
  6433. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6434. /// <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>
  6435. /// <remarks>
  6436. /// <para>
  6437. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6438. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6439. /// </para>
  6440. /// <para>
  6441. /// 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
  6442. /// accessed from the same context, as required by some UI frameworks.
  6443. /// </para>
  6444. /// <para>
  6445. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6446. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6447. /// parameter. For more information, see the remarks section on those overloads.
  6448. /// </para>
  6449. /// </remarks>
  6450. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6451. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6452. {
  6453. if (provider == null)
  6454. throw new ArgumentNullException(nameof(provider));
  6455. if (type == null)
  6456. throw new ArgumentNullException(nameof(type));
  6457. if (eventName == null)
  6458. throw new ArgumentNullException(nameof(eventName));
  6459. if (scheduler == null)
  6460. throw new ArgumentNullException(nameof(scheduler));
  6461. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6462. Expression.Call(
  6463. null,
  6464. #if CRIPPLED_REFLECTION
  6465. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6466. #else
  6467. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6468. #endif
  6469. Expression.Constant(provider, typeof(IQbservableProvider)),
  6470. Expression.Constant(type, typeof(Type)),
  6471. Expression.Constant(eventName, typeof(string)),
  6472. Expression.Constant(scheduler, typeof(IScheduler))
  6473. )
  6474. );
  6475. }
  6476. /// <summary>
  6477. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements.
  6478. /// </summary>
  6479. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6480. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6481. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6482. /// <param name="initialState">Initial state.</param>
  6483. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6484. /// <param name="iterate">Iteration step function.</param>
  6485. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6486. /// <returns>The generated sequence.</returns>
  6487. /// <exception cref="ArgumentNullException">
  6488. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> is null.</exception>
  6489. 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)
  6490. {
  6491. if (provider == null)
  6492. throw new ArgumentNullException(nameof(provider));
  6493. if (condition == null)
  6494. throw new ArgumentNullException(nameof(condition));
  6495. if (iterate == null)
  6496. throw new ArgumentNullException(nameof(iterate));
  6497. if (resultSelector == null)
  6498. throw new ArgumentNullException(nameof(resultSelector));
  6499. return provider.CreateQuery<TResult>(
  6500. Expression.Call(
  6501. null,
  6502. #if CRIPPLED_REFLECTION
  6503. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>))),
  6504. #else
  6505. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6506. #endif
  6507. Expression.Constant(provider, typeof(IQbservableProvider)),
  6508. Expression.Constant(initialState, typeof(TState)),
  6509. condition,
  6510. iterate,
  6511. resultSelector
  6512. )
  6513. );
  6514. }
  6515. /// <summary>
  6516. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
  6517. /// </summary>
  6518. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6519. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6520. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6521. /// <param name="initialState">Initial state.</param>
  6522. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6523. /// <param name="iterate">Iteration step function.</param>
  6524. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6525. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6526. /// <returns>The generated sequence.</returns>
  6527. /// <exception cref="ArgumentNullException">
  6528. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6529. 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)
  6530. {
  6531. if (provider == null)
  6532. throw new ArgumentNullException(nameof(provider));
  6533. if (condition == null)
  6534. throw new ArgumentNullException(nameof(condition));
  6535. if (iterate == null)
  6536. throw new ArgumentNullException(nameof(iterate));
  6537. if (resultSelector == null)
  6538. throw new ArgumentNullException(nameof(resultSelector));
  6539. if (scheduler == null)
  6540. throw new ArgumentNullException(nameof(scheduler));
  6541. return provider.CreateQuery<TResult>(
  6542. Expression.Call(
  6543. null,
  6544. #if CRIPPLED_REFLECTION
  6545. 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))),
  6546. #else
  6547. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6548. #endif
  6549. Expression.Constant(provider, typeof(IQbservableProvider)),
  6550. Expression.Constant(initialState, typeof(TState)),
  6551. condition,
  6552. iterate,
  6553. resultSelector,
  6554. Expression.Constant(scheduler, typeof(IScheduler))
  6555. )
  6556. );
  6557. }
  6558. /// <summary>
  6559. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6560. /// </summary>
  6561. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6562. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6563. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6564. /// <param name="initialState">Initial state.</param>
  6565. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6566. /// <param name="iterate">Iteration step function.</param>
  6567. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6568. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6569. /// <returns>The generated sequence.</returns>
  6570. /// <exception cref="ArgumentNullException">
  6571. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6572. 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)
  6573. {
  6574. if (provider == null)
  6575. throw new ArgumentNullException(nameof(provider));
  6576. if (condition == null)
  6577. throw new ArgumentNullException(nameof(condition));
  6578. if (iterate == null)
  6579. throw new ArgumentNullException(nameof(iterate));
  6580. if (resultSelector == null)
  6581. throw new ArgumentNullException(nameof(resultSelector));
  6582. if (timeSelector == null)
  6583. throw new ArgumentNullException(nameof(timeSelector));
  6584. return provider.CreateQuery<TResult>(
  6585. Expression.Call(
  6586. null,
  6587. #if CRIPPLED_REFLECTION
  6588. 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>>))),
  6589. #else
  6590. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6591. #endif
  6592. Expression.Constant(provider, typeof(IQbservableProvider)),
  6593. Expression.Constant(initialState, typeof(TState)),
  6594. condition,
  6595. iterate,
  6596. resultSelector,
  6597. timeSelector
  6598. )
  6599. );
  6600. }
  6601. /// <summary>
  6602. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6603. /// </summary>
  6604. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6605. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6606. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6607. /// <param name="initialState">Initial state.</param>
  6608. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6609. /// <param name="iterate">Iteration step function.</param>
  6610. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6611. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6612. /// <returns>The generated sequence.</returns>
  6613. /// <exception cref="ArgumentNullException">
  6614. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6615. 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)
  6616. {
  6617. if (provider == null)
  6618. throw new ArgumentNullException(nameof(provider));
  6619. if (condition == null)
  6620. throw new ArgumentNullException(nameof(condition));
  6621. if (iterate == null)
  6622. throw new ArgumentNullException(nameof(iterate));
  6623. if (resultSelector == null)
  6624. throw new ArgumentNullException(nameof(resultSelector));
  6625. if (timeSelector == null)
  6626. throw new ArgumentNullException(nameof(timeSelector));
  6627. return provider.CreateQuery<TResult>(
  6628. Expression.Call(
  6629. null,
  6630. #if CRIPPLED_REFLECTION
  6631. 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>>))),
  6632. #else
  6633. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6634. #endif
  6635. Expression.Constant(provider, typeof(IQbservableProvider)),
  6636. Expression.Constant(initialState, typeof(TState)),
  6637. condition,
  6638. iterate,
  6639. resultSelector,
  6640. timeSelector
  6641. )
  6642. );
  6643. }
  6644. /// <summary>
  6645. /// 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.
  6646. /// </summary>
  6647. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6648. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6649. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6650. /// <param name="initialState">Initial state.</param>
  6651. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6652. /// <param name="iterate">Iteration step function.</param>
  6653. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6654. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6655. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6656. /// <returns>The generated sequence.</returns>
  6657. /// <exception cref="ArgumentNullException">
  6658. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6659. 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)
  6660. {
  6661. if (provider == null)
  6662. throw new ArgumentNullException(nameof(provider));
  6663. if (condition == null)
  6664. throw new ArgumentNullException(nameof(condition));
  6665. if (iterate == null)
  6666. throw new ArgumentNullException(nameof(iterate));
  6667. if (resultSelector == null)
  6668. throw new ArgumentNullException(nameof(resultSelector));
  6669. if (timeSelector == null)
  6670. throw new ArgumentNullException(nameof(timeSelector));
  6671. if (scheduler == null)
  6672. throw new ArgumentNullException(nameof(scheduler));
  6673. return provider.CreateQuery<TResult>(
  6674. Expression.Call(
  6675. null,
  6676. #if CRIPPLED_REFLECTION
  6677. 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))),
  6678. #else
  6679. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6680. #endif
  6681. Expression.Constant(provider, typeof(IQbservableProvider)),
  6682. Expression.Constant(initialState, typeof(TState)),
  6683. condition,
  6684. iterate,
  6685. resultSelector,
  6686. timeSelector,
  6687. Expression.Constant(scheduler, typeof(IScheduler))
  6688. )
  6689. );
  6690. }
  6691. /// <summary>
  6692. /// 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.
  6693. /// </summary>
  6694. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6695. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6696. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6697. /// <param name="initialState">Initial state.</param>
  6698. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6699. /// <param name="iterate">Iteration step function.</param>
  6700. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6701. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6702. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6703. /// <returns>The generated sequence.</returns>
  6704. /// <exception cref="ArgumentNullException">
  6705. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6706. 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)
  6707. {
  6708. if (provider == null)
  6709. throw new ArgumentNullException(nameof(provider));
  6710. if (condition == null)
  6711. throw new ArgumentNullException(nameof(condition));
  6712. if (iterate == null)
  6713. throw new ArgumentNullException(nameof(iterate));
  6714. if (resultSelector == null)
  6715. throw new ArgumentNullException(nameof(resultSelector));
  6716. if (timeSelector == null)
  6717. throw new ArgumentNullException(nameof(timeSelector));
  6718. if (scheduler == null)
  6719. throw new ArgumentNullException(nameof(scheduler));
  6720. return provider.CreateQuery<TResult>(
  6721. Expression.Call(
  6722. null,
  6723. #if CRIPPLED_REFLECTION
  6724. 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))),
  6725. #else
  6726. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6727. #endif
  6728. Expression.Constant(provider, typeof(IQbservableProvider)),
  6729. Expression.Constant(initialState, typeof(TState)),
  6730. condition,
  6731. iterate,
  6732. resultSelector,
  6733. timeSelector,
  6734. Expression.Constant(scheduler, typeof(IScheduler))
  6735. )
  6736. );
  6737. }
  6738. /// <summary>
  6739. /// Groups the elements of an observable sequence according to a specified key selector function.
  6740. /// </summary>
  6741. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6742. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6743. /// <param name="source">An observable sequence whose elements to group.</param>
  6744. /// <param name="keySelector">A function to extract the key for each element.</param>
  6745. /// <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>
  6746. /// <exception cref="ArgumentNullException">
  6747. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  6748. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  6749. {
  6750. if (source == null)
  6751. throw new ArgumentNullException(nameof(source));
  6752. if (keySelector == null)
  6753. throw new ArgumentNullException(nameof(keySelector));
  6754. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6755. Expression.Call(
  6756. null,
  6757. #if CRIPPLED_REFLECTION
  6758. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  6759. #else
  6760. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6761. #endif
  6762. source.Expression,
  6763. keySelector
  6764. )
  6765. );
  6766. }
  6767. /// <summary>
  6768. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  6769. /// </summary>
  6770. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6771. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6772. /// <param name="source">An observable sequence whose elements to group.</param>
  6773. /// <param name="keySelector">A function to extract the key for each element.</param>
  6774. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6775. /// <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>
  6776. /// <exception cref="ArgumentNullException">
  6777. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  6778. /// <exception cref="ArgumentOutOfRangeException">
  6779. /// <paramref name="capacity" /> is less than 0.</exception>
  6780. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity)
  6781. {
  6782. if (source == null)
  6783. throw new ArgumentNullException(nameof(source));
  6784. if (keySelector == null)
  6785. throw new ArgumentNullException(nameof(keySelector));
  6786. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6787. Expression.Call(
  6788. null,
  6789. #if CRIPPLED_REFLECTION
  6790. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int))),
  6791. #else
  6792. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6793. #endif
  6794. source.Expression,
  6795. keySelector,
  6796. Expression.Constant(capacity, typeof(int))
  6797. )
  6798. );
  6799. }
  6800. /// <summary>
  6801. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  6802. /// </summary>
  6803. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6804. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6805. /// <param name="source">An observable sequence whose elements to group.</param>
  6806. /// <param name="keySelector">A function to extract the key for each element.</param>
  6807. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6808. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6809. /// <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>
  6810. /// <exception cref="ArgumentNullException">
  6811. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  6812. /// <exception cref="ArgumentOutOfRangeException">
  6813. /// <paramref name="capacity" /> is less than 0.</exception>
  6814. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity, IEqualityComparer<TKey> comparer)
  6815. {
  6816. if (source == null)
  6817. throw new ArgumentNullException(nameof(source));
  6818. if (keySelector == null)
  6819. throw new ArgumentNullException(nameof(keySelector));
  6820. if (comparer == null)
  6821. throw new ArgumentNullException(nameof(comparer));
  6822. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6823. Expression.Call(
  6824. null,
  6825. #if CRIPPLED_REFLECTION
  6826. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int), default(IEqualityComparer<TKey>))),
  6827. #else
  6828. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6829. #endif
  6830. source.Expression,
  6831. keySelector,
  6832. Expression.Constant(capacity, typeof(int)),
  6833. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6834. )
  6835. );
  6836. }
  6837. /// <summary>
  6838. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  6839. /// </summary>
  6840. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6841. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6842. /// <param name="source">An observable sequence whose elements to group.</param>
  6843. /// <param name="keySelector">A function to extract the key for each element.</param>
  6844. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6845. /// <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>
  6846. /// <exception cref="ArgumentNullException">
  6847. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  6848. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  6849. {
  6850. if (source == null)
  6851. throw new ArgumentNullException(nameof(source));
  6852. if (keySelector == null)
  6853. throw new ArgumentNullException(nameof(keySelector));
  6854. if (comparer == null)
  6855. throw new ArgumentNullException(nameof(comparer));
  6856. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6857. Expression.Call(
  6858. null,
  6859. #if CRIPPLED_REFLECTION
  6860. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  6861. #else
  6862. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6863. #endif
  6864. source.Expression,
  6865. keySelector,
  6866. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6867. )
  6868. );
  6869. }
  6870. /// <summary>
  6871. /// Groups the elements of an observable sequence and selects the resulting elements by using a specified function.
  6872. /// </summary>
  6873. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6874. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6875. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6876. /// <param name="source">An observable sequence whose elements to group.</param>
  6877. /// <param name="keySelector">A function to extract the key for each element.</param>
  6878. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6879. /// <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>
  6880. /// <exception cref="ArgumentNullException">
  6881. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  6882. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  6883. {
  6884. if (source == null)
  6885. throw new ArgumentNullException(nameof(source));
  6886. if (keySelector == null)
  6887. throw new ArgumentNullException(nameof(keySelector));
  6888. if (elementSelector == null)
  6889. throw new ArgumentNullException(nameof(elementSelector));
  6890. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6891. Expression.Call(
  6892. null,
  6893. #if CRIPPLED_REFLECTION
  6894. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  6895. #else
  6896. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6897. #endif
  6898. source.Expression,
  6899. keySelector,
  6900. elementSelector
  6901. )
  6902. );
  6903. }
  6904. /// <summary>
  6905. /// Groups the elements of an observable sequence with the specified initial capacity and selects the resulting elements by using a specified function.
  6906. /// </summary>
  6907. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6908. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6909. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6910. /// <param name="source">An observable sequence whose elements to group.</param>
  6911. /// <param name="keySelector">A function to extract the key for each element.</param>
  6912. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6913. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6914. /// <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>
  6915. /// <exception cref="ArgumentNullException">
  6916. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  6917. /// <exception cref="ArgumentOutOfRangeException">
  6918. /// <paramref name="capacity" /> is less than 0.</exception>
  6919. 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)
  6920. {
  6921. if (source == null)
  6922. throw new ArgumentNullException(nameof(source));
  6923. if (keySelector == null)
  6924. throw new ArgumentNullException(nameof(keySelector));
  6925. if (elementSelector == null)
  6926. throw new ArgumentNullException(nameof(elementSelector));
  6927. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6928. Expression.Call(
  6929. null,
  6930. #if CRIPPLED_REFLECTION
  6931. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int))),
  6932. #else
  6933. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6934. #endif
  6935. source.Expression,
  6936. keySelector,
  6937. elementSelector,
  6938. Expression.Constant(capacity, typeof(int))
  6939. )
  6940. );
  6941. }
  6942. /// <summary>
  6943. /// 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.
  6944. /// </summary>
  6945. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6946. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6947. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6948. /// <param name="source">An observable sequence whose elements to group.</param>
  6949. /// <param name="keySelector">A function to extract the key for each element.</param>
  6950. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6951. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6952. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6953. /// <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>
  6954. /// <exception cref="ArgumentNullException">
  6955. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  6956. /// <exception cref="ArgumentOutOfRangeException">
  6957. /// <paramref name="capacity" /> is less than 0.</exception>
  6958. 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)
  6959. {
  6960. if (source == null)
  6961. throw new ArgumentNullException(nameof(source));
  6962. if (keySelector == null)
  6963. throw new ArgumentNullException(nameof(keySelector));
  6964. if (elementSelector == null)
  6965. throw new ArgumentNullException(nameof(elementSelector));
  6966. if (comparer == null)
  6967. throw new ArgumentNullException(nameof(comparer));
  6968. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6969. Expression.Call(
  6970. null,
  6971. #if CRIPPLED_REFLECTION
  6972. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int), default(IEqualityComparer<TKey>))),
  6973. #else
  6974. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6975. #endif
  6976. source.Expression,
  6977. keySelector,
  6978. elementSelector,
  6979. Expression.Constant(capacity, typeof(int)),
  6980. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6981. )
  6982. );
  6983. }
  6984. /// <summary>
  6985. /// 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.
  6986. /// </summary>
  6987. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6988. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6989. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6990. /// <param name="source">An observable sequence whose elements to group.</param>
  6991. /// <param name="keySelector">A function to extract the key for each element.</param>
  6992. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6993. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6994. /// <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>
  6995. /// <exception cref="ArgumentNullException">
  6996. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  6997. 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)
  6998. {
  6999. if (source == null)
  7000. throw new ArgumentNullException(nameof(source));
  7001. if (keySelector == null)
  7002. throw new ArgumentNullException(nameof(keySelector));
  7003. if (elementSelector == null)
  7004. throw new ArgumentNullException(nameof(elementSelector));
  7005. if (comparer == null)
  7006. throw new ArgumentNullException(nameof(comparer));
  7007. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7008. Expression.Call(
  7009. null,
  7010. #if CRIPPLED_REFLECTION
  7011. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  7012. #else
  7013. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7014. #endif
  7015. source.Expression,
  7016. keySelector,
  7017. elementSelector,
  7018. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7019. )
  7020. );
  7021. }
  7022. /// <summary>
  7023. /// Groups the elements of an observable sequence according to a specified key selector function.
  7024. /// 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
  7025. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7026. /// </summary>
  7027. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7028. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7029. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7030. /// <param name="source">An observable sequence whose elements to group.</param>
  7031. /// <param name="keySelector">A function to extract the key for each element.</param>
  7032. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7033. /// <returns>
  7034. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7035. /// 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.
  7036. /// </returns>
  7037. /// <exception cref="ArgumentNullException">
  7038. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7039. 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)
  7040. {
  7041. if (source == null)
  7042. throw new ArgumentNullException(nameof(source));
  7043. if (keySelector == null)
  7044. throw new ArgumentNullException(nameof(keySelector));
  7045. if (durationSelector == null)
  7046. throw new ArgumentNullException(nameof(durationSelector));
  7047. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7048. Expression.Call(
  7049. null,
  7050. #if CRIPPLED_REFLECTION
  7051. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>))),
  7052. #else
  7053. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7054. #endif
  7055. source.Expression,
  7056. keySelector,
  7057. durationSelector
  7058. )
  7059. );
  7060. }
  7061. /// <summary>
  7062. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  7063. /// 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
  7064. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7065. /// </summary>
  7066. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7067. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7068. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7069. /// <param name="source">An observable sequence whose elements to group.</param>
  7070. /// <param name="keySelector">A function to extract the key for each element.</param>
  7071. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7072. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7073. /// <returns>
  7074. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7075. /// 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.
  7076. /// </returns>
  7077. /// <exception cref="ArgumentNullException">
  7078. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7079. /// <exception cref="ArgumentOutOfRangeException">
  7080. /// <paramref name="capacity" /> is less than 0.</exception>
  7081. 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)
  7082. {
  7083. if (source == null)
  7084. throw new ArgumentNullException(nameof(source));
  7085. if (keySelector == null)
  7086. throw new ArgumentNullException(nameof(keySelector));
  7087. if (durationSelector == null)
  7088. throw new ArgumentNullException(nameof(durationSelector));
  7089. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7090. Expression.Call(
  7091. null,
  7092. #if CRIPPLED_REFLECTION
  7093. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(int))),
  7094. #else
  7095. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7096. #endif
  7097. source.Expression,
  7098. keySelector,
  7099. durationSelector,
  7100. Expression.Constant(capacity, typeof(int))
  7101. )
  7102. );
  7103. }
  7104. /// <summary>
  7105. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  7106. /// 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
  7107. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7108. /// </summary>
  7109. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7110. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7111. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7112. /// <param name="source">An observable sequence whose elements to group.</param>
  7113. /// <param name="keySelector">A function to extract the key for each element.</param>
  7114. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7115. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7116. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7117. /// <returns>
  7118. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7119. /// 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.
  7120. /// </returns>
  7121. /// <exception cref="ArgumentNullException">
  7122. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7123. /// <exception cref="ArgumentOutOfRangeException">
  7124. /// <paramref name="capacity" /> is less than 0.</exception>
  7125. 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)
  7126. {
  7127. if (source == null)
  7128. throw new ArgumentNullException(nameof(source));
  7129. if (keySelector == null)
  7130. throw new ArgumentNullException(nameof(keySelector));
  7131. if (durationSelector == null)
  7132. throw new ArgumentNullException(nameof(durationSelector));
  7133. if (comparer == null)
  7134. throw new ArgumentNullException(nameof(comparer));
  7135. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7136. Expression.Call(
  7137. null,
  7138. #if CRIPPLED_REFLECTION
  7139. 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>))),
  7140. #else
  7141. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7142. #endif
  7143. source.Expression,
  7144. keySelector,
  7145. durationSelector,
  7146. Expression.Constant(capacity, typeof(int)),
  7147. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7148. )
  7149. );
  7150. }
  7151. /// <summary>
  7152. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  7153. /// 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
  7154. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7155. /// </summary>
  7156. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7157. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7158. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7159. /// <param name="source">An observable sequence whose elements to group.</param>
  7160. /// <param name="keySelector">A function to extract the key for each element.</param>
  7161. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7162. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7163. /// <returns>
  7164. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7165. /// 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.
  7166. /// </returns>
  7167. /// <exception cref="ArgumentNullException">
  7168. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7169. 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)
  7170. {
  7171. if (source == null)
  7172. throw new ArgumentNullException(nameof(source));
  7173. if (keySelector == null)
  7174. throw new ArgumentNullException(nameof(keySelector));
  7175. if (durationSelector == null)
  7176. throw new ArgumentNullException(nameof(durationSelector));
  7177. if (comparer == null)
  7178. throw new ArgumentNullException(nameof(comparer));
  7179. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7180. Expression.Call(
  7181. null,
  7182. #if CRIPPLED_REFLECTION
  7183. 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>))),
  7184. #else
  7185. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7186. #endif
  7187. source.Expression,
  7188. keySelector,
  7189. durationSelector,
  7190. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7191. )
  7192. );
  7193. }
  7194. /// <summary>
  7195. /// Groups the elements of an observable sequence according to a specified key selector function and selects the resulting elements by using a specified function.
  7196. /// 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
  7197. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7198. /// </summary>
  7199. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7200. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7201. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7202. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7203. /// <param name="source">An observable sequence whose elements to group.</param>
  7204. /// <param name="keySelector">A function to extract the key for each element.</param>
  7205. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7206. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7207. /// <returns>
  7208. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7209. /// 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.
  7210. /// </returns>
  7211. /// <exception cref="ArgumentNullException">
  7212. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7213. 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)
  7214. {
  7215. if (source == null)
  7216. throw new ArgumentNullException(nameof(source));
  7217. if (keySelector == null)
  7218. throw new ArgumentNullException(nameof(keySelector));
  7219. if (elementSelector == null)
  7220. throw new ArgumentNullException(nameof(elementSelector));
  7221. if (durationSelector == null)
  7222. throw new ArgumentNullException(nameof(durationSelector));
  7223. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7224. Expression.Call(
  7225. null,
  7226. #if CRIPPLED_REFLECTION
  7227. 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>>>))),
  7228. #else
  7229. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7230. #endif
  7231. source.Expression,
  7232. keySelector,
  7233. elementSelector,
  7234. durationSelector
  7235. )
  7236. );
  7237. }
  7238. /// <summary>
  7239. /// 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.
  7240. /// 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
  7241. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7242. /// </summary>
  7243. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7244. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7245. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7246. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7247. /// <param name="source">An observable sequence whose elements to group.</param>
  7248. /// <param name="keySelector">A function to extract the key for each element.</param>
  7249. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7250. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7251. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7252. /// <returns>
  7253. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7254. /// 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.
  7255. /// </returns>
  7256. /// <exception cref="ArgumentNullException">
  7257. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7258. /// <exception cref="ArgumentOutOfRangeException">
  7259. /// <paramref name="capacity" /> is less than 0.</exception>
  7260. 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)
  7261. {
  7262. if (source == null)
  7263. throw new ArgumentNullException(nameof(source));
  7264. if (keySelector == null)
  7265. throw new ArgumentNullException(nameof(keySelector));
  7266. if (elementSelector == null)
  7267. throw new ArgumentNullException(nameof(elementSelector));
  7268. if (durationSelector == null)
  7269. throw new ArgumentNullException(nameof(durationSelector));
  7270. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7271. Expression.Call(
  7272. null,
  7273. #if CRIPPLED_REFLECTION
  7274. 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))),
  7275. #else
  7276. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7277. #endif
  7278. source.Expression,
  7279. keySelector,
  7280. elementSelector,
  7281. durationSelector,
  7282. Expression.Constant(capacity, typeof(int))
  7283. )
  7284. );
  7285. }
  7286. /// <summary>
  7287. /// 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.
  7288. /// 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
  7289. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7290. /// </summary>
  7291. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7292. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7293. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7294. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7295. /// <param name="source">An observable sequence whose elements to group.</param>
  7296. /// <param name="keySelector">A function to extract the key for each element.</param>
  7297. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7298. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7299. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7300. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7301. /// <returns>
  7302. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7303. /// 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.
  7304. /// </returns>
  7305. /// <exception cref="ArgumentNullException">
  7306. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7307. /// <exception cref="ArgumentOutOfRangeException">
  7308. /// <paramref name="capacity" /> is less than 0.</exception>
  7309. 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)
  7310. {
  7311. if (source == null)
  7312. throw new ArgumentNullException(nameof(source));
  7313. if (keySelector == null)
  7314. throw new ArgumentNullException(nameof(keySelector));
  7315. if (elementSelector == null)
  7316. throw new ArgumentNullException(nameof(elementSelector));
  7317. if (durationSelector == null)
  7318. throw new ArgumentNullException(nameof(durationSelector));
  7319. if (comparer == null)
  7320. throw new ArgumentNullException(nameof(comparer));
  7321. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7322. Expression.Call(
  7323. null,
  7324. #if CRIPPLED_REFLECTION
  7325. 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>))),
  7326. #else
  7327. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7328. #endif
  7329. source.Expression,
  7330. keySelector,
  7331. elementSelector,
  7332. durationSelector,
  7333. Expression.Constant(capacity, typeof(int)),
  7334. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7335. )
  7336. );
  7337. }
  7338. /// <summary>
  7339. /// 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.
  7340. /// 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
  7341. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7342. /// </summary>
  7343. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7344. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7345. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7346. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7347. /// <param name="source">An observable sequence whose elements to group.</param>
  7348. /// <param name="keySelector">A function to extract the key for each element.</param>
  7349. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7350. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7351. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7352. /// <returns>
  7353. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7354. /// 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.
  7355. /// </returns>
  7356. /// <exception cref="ArgumentNullException">
  7357. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7358. 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)
  7359. {
  7360. if (source == null)
  7361. throw new ArgumentNullException(nameof(source));
  7362. if (keySelector == null)
  7363. throw new ArgumentNullException(nameof(keySelector));
  7364. if (elementSelector == null)
  7365. throw new ArgumentNullException(nameof(elementSelector));
  7366. if (durationSelector == null)
  7367. throw new ArgumentNullException(nameof(durationSelector));
  7368. if (comparer == null)
  7369. throw new ArgumentNullException(nameof(comparer));
  7370. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7371. Expression.Call(
  7372. null,
  7373. #if CRIPPLED_REFLECTION
  7374. 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>))),
  7375. #else
  7376. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7377. #endif
  7378. source.Expression,
  7379. keySelector,
  7380. elementSelector,
  7381. durationSelector,
  7382. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7383. )
  7384. );
  7385. }
  7386. /// <summary>
  7387. /// Correlates the elements of two sequences based on overlapping durations, and groups the results.
  7388. /// </summary>
  7389. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7390. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7391. /// <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>
  7392. /// <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>
  7393. /// <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>
  7394. /// <param name="left">The left observable sequence to join elements for.</param>
  7395. /// <param name="right">The right observable sequence to join elements for.</param>
  7396. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7397. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7398. /// <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>
  7399. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7400. /// <exception cref="ArgumentNullException">
  7401. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7402. 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)
  7403. {
  7404. if (left == null)
  7405. throw new ArgumentNullException(nameof(left));
  7406. if (right == null)
  7407. throw new ArgumentNullException(nameof(right));
  7408. if (leftDurationSelector == null)
  7409. throw new ArgumentNullException(nameof(leftDurationSelector));
  7410. if (rightDurationSelector == null)
  7411. throw new ArgumentNullException(nameof(rightDurationSelector));
  7412. if (resultSelector == null)
  7413. throw new ArgumentNullException(nameof(resultSelector));
  7414. return left.Provider.CreateQuery<TResult>(
  7415. Expression.Call(
  7416. null,
  7417. #if CRIPPLED_REFLECTION
  7418. 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>>))),
  7419. #else
  7420. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7421. #endif
  7422. left.Expression,
  7423. GetSourceExpression(right),
  7424. leftDurationSelector,
  7425. rightDurationSelector,
  7426. resultSelector
  7427. )
  7428. );
  7429. }
  7430. /// <summary>
  7431. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence.
  7432. /// </summary>
  7433. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7434. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7435. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7436. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7437. /// <returns>
  7438. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7439. /// <exception cref="ArgumentNullException">
  7440. /// <paramref name="condition" /> or <paramref name="thenSource" /> is null.</exception>
  7441. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource)
  7442. {
  7443. if (provider == null)
  7444. throw new ArgumentNullException(nameof(provider));
  7445. if (condition == null)
  7446. throw new ArgumentNullException(nameof(condition));
  7447. if (thenSource == null)
  7448. throw new ArgumentNullException(nameof(thenSource));
  7449. return provider.CreateQuery<TResult>(
  7450. Expression.Call(
  7451. null,
  7452. #if CRIPPLED_REFLECTION
  7453. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>))),
  7454. #else
  7455. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7456. #endif
  7457. Expression.Constant(provider, typeof(IQbservableProvider)),
  7458. condition,
  7459. GetSourceExpression(thenSource)
  7460. )
  7461. );
  7462. }
  7463. /// <summary>
  7464. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, select the <paramref name="elseSource" /> sequence.
  7465. /// </summary>
  7466. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7467. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7468. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7469. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7470. /// <param name="elseSource">Sequence returned in case <paramref name="condition" /> evaluates false.</param>
  7471. /// <returns>
  7472. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; <paramref name="elseSource" /> otherwise.</returns>
  7473. /// <exception cref="ArgumentNullException">
  7474. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="elseSource" /> is null.</exception>
  7475. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IObservable<TResult> elseSource)
  7476. {
  7477. if (provider == null)
  7478. throw new ArgumentNullException(nameof(provider));
  7479. if (condition == null)
  7480. throw new ArgumentNullException(nameof(condition));
  7481. if (thenSource == null)
  7482. throw new ArgumentNullException(nameof(thenSource));
  7483. if (elseSource == null)
  7484. throw new ArgumentNullException(nameof(elseSource));
  7485. return provider.CreateQuery<TResult>(
  7486. Expression.Call(
  7487. null,
  7488. #if CRIPPLED_REFLECTION
  7489. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IObservable<TResult>))),
  7490. #else
  7491. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7492. #endif
  7493. Expression.Constant(provider, typeof(IQbservableProvider)),
  7494. condition,
  7495. GetSourceExpression(thenSource),
  7496. GetSourceExpression(elseSource)
  7497. )
  7498. );
  7499. }
  7500. /// <summary>
  7501. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence generated on the specified scheduler.
  7502. /// </summary>
  7503. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7504. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7505. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7506. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7507. /// <param name="scheduler">Scheduler to generate an empty sequence on in case <paramref name="condition" /> evaluates false.</param>
  7508. /// <returns>
  7509. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7510. /// <exception cref="ArgumentNullException">
  7511. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="scheduler" /> is null.</exception>
  7512. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IScheduler scheduler)
  7513. {
  7514. if (provider == null)
  7515. throw new ArgumentNullException(nameof(provider));
  7516. if (condition == null)
  7517. throw new ArgumentNullException(nameof(condition));
  7518. if (thenSource == null)
  7519. throw new ArgumentNullException(nameof(thenSource));
  7520. if (scheduler == null)
  7521. throw new ArgumentNullException(nameof(scheduler));
  7522. return provider.CreateQuery<TResult>(
  7523. Expression.Call(
  7524. null,
  7525. #if CRIPPLED_REFLECTION
  7526. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IScheduler))),
  7527. #else
  7528. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7529. #endif
  7530. Expression.Constant(provider, typeof(IQbservableProvider)),
  7531. condition,
  7532. GetSourceExpression(thenSource),
  7533. Expression.Constant(scheduler, typeof(IScheduler))
  7534. )
  7535. );
  7536. }
  7537. /// <summary>
  7538. /// Ignores all elements in an observable sequence leaving only the termination messages.
  7539. /// </summary>
  7540. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7541. /// <param name="source">Source sequence.</param>
  7542. /// <returns>An empty observable sequence that signals termination, successful or exceptional, of the source sequence.</returns>
  7543. /// <exception cref="ArgumentNullException">
  7544. /// <paramref name="source" /> is null.</exception>
  7545. public static IQbservable<TSource> IgnoreElements<TSource>(this IQbservable<TSource> source)
  7546. {
  7547. if (source == null)
  7548. throw new ArgumentNullException(nameof(source));
  7549. return source.Provider.CreateQuery<TSource>(
  7550. Expression.Call(
  7551. null,
  7552. #if CRIPPLED_REFLECTION
  7553. InfoOf(() => Qbservable.IgnoreElements<TSource>(default(IQbservable<TSource>))),
  7554. #else
  7555. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7556. #endif
  7557. source.Expression
  7558. )
  7559. );
  7560. }
  7561. /// <summary>
  7562. /// Returns an observable sequence that produces a value after each period.
  7563. /// </summary>
  7564. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7565. /// <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>
  7566. /// <returns>An observable sequence that produces a value after each period.</returns>
  7567. /// <exception cref="ArgumentOutOfRangeException">
  7568. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7569. /// <remarks>
  7570. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7571. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7572. /// 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
  7573. /// <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})" />
  7574. /// operator instead.
  7575. /// </remarks>
  7576. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period)
  7577. {
  7578. if (provider == null)
  7579. throw new ArgumentNullException(nameof(provider));
  7580. return provider.CreateQuery<long>(
  7581. Expression.Call(
  7582. null,
  7583. #if CRIPPLED_REFLECTION
  7584. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan))),
  7585. #else
  7586. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7587. #endif
  7588. Expression.Constant(provider, typeof(IQbservableProvider)),
  7589. Expression.Constant(period, typeof(TimeSpan))
  7590. )
  7591. );
  7592. }
  7593. /// <summary>
  7594. /// Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.
  7595. /// </summary>
  7596. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7597. /// <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>
  7598. /// <param name="scheduler">Scheduler to run the timer on.</param>
  7599. /// <returns>An observable sequence that produces a value after each period.</returns>
  7600. /// <exception cref="ArgumentOutOfRangeException">
  7601. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7602. /// <exception cref="ArgumentNullException">
  7603. /// <paramref name="scheduler" /> is null.</exception>
  7604. /// <remarks>
  7605. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7606. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7607. /// 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
  7608. /// <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)" />
  7609. /// operator instead.
  7610. /// </remarks>
  7611. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period, IScheduler scheduler)
  7612. {
  7613. if (provider == null)
  7614. throw new ArgumentNullException(nameof(provider));
  7615. if (scheduler == null)
  7616. throw new ArgumentNullException(nameof(scheduler));
  7617. return provider.CreateQuery<long>(
  7618. Expression.Call(
  7619. null,
  7620. #if CRIPPLED_REFLECTION
  7621. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  7622. #else
  7623. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7624. #endif
  7625. Expression.Constant(provider, typeof(IQbservableProvider)),
  7626. Expression.Constant(period, typeof(TimeSpan)),
  7627. Expression.Constant(scheduler, typeof(IScheduler))
  7628. )
  7629. );
  7630. }
  7631. /// <summary>
  7632. /// Determines whether an observable sequence is empty.
  7633. /// </summary>
  7634. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7635. /// <param name="source">An observable sequence to check for emptiness.</param>
  7636. /// <returns>An observable sequence containing a single element determining whether the source sequence is empty.</returns>
  7637. /// <exception cref="ArgumentNullException">
  7638. /// <paramref name="source" /> is null.</exception>
  7639. public static IQbservable<bool> IsEmpty<TSource>(this IQbservable<TSource> source)
  7640. {
  7641. if (source == null)
  7642. throw new ArgumentNullException(nameof(source));
  7643. return source.Provider.CreateQuery<bool>(
  7644. Expression.Call(
  7645. null,
  7646. #if CRIPPLED_REFLECTION
  7647. InfoOf(() => Qbservable.IsEmpty<TSource>(default(IQbservable<TSource>))),
  7648. #else
  7649. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7650. #endif
  7651. source.Expression
  7652. )
  7653. );
  7654. }
  7655. /// <summary>
  7656. /// Correlates the elements of two sequences based on overlapping durations.
  7657. /// </summary>
  7658. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7659. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7660. /// <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>
  7661. /// <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>
  7662. /// <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>
  7663. /// <param name="left">The left observable sequence to join elements for.</param>
  7664. /// <param name="right">The right observable sequence to join elements for.</param>
  7665. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7666. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7667. /// <param name="resultSelector">A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences.</param>
  7668. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7669. /// <exception cref="ArgumentNullException">
  7670. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7671. 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)
  7672. {
  7673. if (left == null)
  7674. throw new ArgumentNullException(nameof(left));
  7675. if (right == null)
  7676. throw new ArgumentNullException(nameof(right));
  7677. if (leftDurationSelector == null)
  7678. throw new ArgumentNullException(nameof(leftDurationSelector));
  7679. if (rightDurationSelector == null)
  7680. throw new ArgumentNullException(nameof(rightDurationSelector));
  7681. if (resultSelector == null)
  7682. throw new ArgumentNullException(nameof(resultSelector));
  7683. return left.Provider.CreateQuery<TResult>(
  7684. Expression.Call(
  7685. null,
  7686. #if CRIPPLED_REFLECTION
  7687. 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>>))),
  7688. #else
  7689. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7690. #endif
  7691. left.Expression,
  7692. GetSourceExpression(right),
  7693. leftDurationSelector,
  7694. rightDurationSelector,
  7695. resultSelector
  7696. )
  7697. );
  7698. }
  7699. /// <summary>
  7700. /// Returns the last element of an observable sequence.
  7701. /// </summary>
  7702. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7703. /// <param name="source">Source observable sequence.</param>
  7704. /// <returns>Sequence containing the last element in the observable sequence.</returns>
  7705. /// <exception cref="ArgumentNullException">
  7706. /// <paramref name="source" /> is null.</exception>
  7707. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  7708. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source)
  7709. {
  7710. if (source == null)
  7711. throw new ArgumentNullException(nameof(source));
  7712. return source.Provider.CreateQuery<TSource>(
  7713. Expression.Call(
  7714. null,
  7715. #if CRIPPLED_REFLECTION
  7716. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>))),
  7717. #else
  7718. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7719. #endif
  7720. source.Expression
  7721. )
  7722. );
  7723. }
  7724. /// <summary>
  7725. /// Returns the last element of an observable sequence that satisfies the condition in the predicate.
  7726. /// </summary>
  7727. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7728. /// <param name="source">Source observable sequence.</param>
  7729. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7730. /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.</returns>
  7731. /// <exception cref="ArgumentNullException">
  7732. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7733. /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  7734. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7735. {
  7736. if (source == null)
  7737. throw new ArgumentNullException(nameof(source));
  7738. if (predicate == null)
  7739. throw new ArgumentNullException(nameof(predicate));
  7740. return source.Provider.CreateQuery<TSource>(
  7741. Expression.Call(
  7742. null,
  7743. #if CRIPPLED_REFLECTION
  7744. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7745. #else
  7746. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7747. #endif
  7748. source.Expression,
  7749. predicate
  7750. )
  7751. );
  7752. }
  7753. /// <summary>
  7754. /// Returns the last element of an observable sequence, or a default value if no such element exists.
  7755. /// </summary>
  7756. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7757. /// <param name="source">Source observable sequence.</param>
  7758. /// <returns>Sequence containing the last element in the observable sequence, or a default value if no such element exists.</returns>
  7759. /// <exception cref="ArgumentNullException">
  7760. /// <paramref name="source" /> is null.</exception>
  7761. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  7762. {
  7763. if (source == null)
  7764. throw new ArgumentNullException(nameof(source));
  7765. return source.Provider.CreateQuery<TSource>(
  7766. Expression.Call(
  7767. null,
  7768. #if CRIPPLED_REFLECTION
  7769. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  7770. #else
  7771. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7772. #endif
  7773. source.Expression
  7774. )
  7775. );
  7776. }
  7777. /// <summary>
  7778. /// Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  7779. /// </summary>
  7780. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7781. /// <param name="source">Source observable sequence.</param>
  7782. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7783. /// <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>
  7784. /// <exception cref="ArgumentNullException">
  7785. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7786. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7787. {
  7788. if (source == null)
  7789. throw new ArgumentNullException(nameof(source));
  7790. if (predicate == null)
  7791. throw new ArgumentNullException(nameof(predicate));
  7792. return source.Provider.CreateQuery<TSource>(
  7793. Expression.Call(
  7794. null,
  7795. #if CRIPPLED_REFLECTION
  7796. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7797. #else
  7798. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7799. #endif
  7800. source.Expression,
  7801. predicate
  7802. )
  7803. );
  7804. }
  7805. /// <summary>
  7806. /// Returns an enumerable sequence whose enumeration returns the latest observed element in the source observable sequence.
  7807. /// Enumerators on the resulting sequence will never produce the same element repeatedly, and will block until the next element becomes available.
  7808. /// </summary>
  7809. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7810. /// <param name="source">Source observable sequence.</param>
  7811. /// <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>
  7812. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  7813. public static IQueryable<TSource> Latest<TSource>(this IQbservable<TSource> source)
  7814. {
  7815. if (source == null)
  7816. throw new ArgumentNullException(nameof(source));
  7817. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  7818. Expression.Call(
  7819. null,
  7820. #if CRIPPLED_REFLECTION
  7821. InfoOf(() => Qbservable.Latest<TSource>(default(IQbservable<TSource>))),
  7822. #else
  7823. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7824. #endif
  7825. source.Expression
  7826. )
  7827. );
  7828. }
  7829. /// <summary>
  7830. /// Returns an observable sequence containing an <see cref="long" /> that represents the total number of elements in an observable sequence.
  7831. /// </summary>
  7832. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7833. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  7834. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  7835. /// <exception cref="ArgumentNullException">
  7836. /// <paramref name="source" /> is null.</exception>
  7837. /// <exception cref="OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  7838. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7839. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source)
  7840. {
  7841. if (source == null)
  7842. throw new ArgumentNullException(nameof(source));
  7843. return source.Provider.CreateQuery<long>(
  7844. Expression.Call(
  7845. null,
  7846. #if CRIPPLED_REFLECTION
  7847. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>))),
  7848. #else
  7849. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7850. #endif
  7851. source.Expression
  7852. )
  7853. );
  7854. }
  7855. /// <summary>
  7856. /// Returns an observable sequence containing an <see cref="long" /> that represents how many elements in the specified observable sequence satisfy a condition.
  7857. /// </summary>
  7858. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7859. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  7860. /// <param name="predicate">A function to test each element for a condition.</param>
  7861. /// <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>
  7862. /// <exception cref="ArgumentNullException">
  7863. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7864. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7865. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7866. {
  7867. if (source == null)
  7868. throw new ArgumentNullException(nameof(source));
  7869. if (predicate == null)
  7870. throw new ArgumentNullException(nameof(predicate));
  7871. return source.Provider.CreateQuery<long>(
  7872. Expression.Call(
  7873. null,
  7874. #if CRIPPLED_REFLECTION
  7875. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7876. #else
  7877. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7878. #endif
  7879. source.Expression,
  7880. predicate
  7881. )
  7882. );
  7883. }
  7884. /// <summary>
  7885. /// Materializes the implicit notifications of an observable sequence as explicit notification values.
  7886. /// </summary>
  7887. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7888. /// <param name="source">An observable sequence to get notification values for.</param>
  7889. /// <returns>An observable sequence containing the materialized notification values from the source sequence.</returns>
  7890. /// <exception cref="ArgumentNullException">
  7891. /// <paramref name="source" /> is null.</exception>
  7892. public static IQbservable<Notification<TSource>> Materialize<TSource>(this IQbservable<TSource> source)
  7893. {
  7894. if (source == null)
  7895. throw new ArgumentNullException(nameof(source));
  7896. return source.Provider.CreateQuery<Notification<TSource>>(
  7897. Expression.Call(
  7898. null,
  7899. #if CRIPPLED_REFLECTION
  7900. InfoOf(() => Qbservable.Materialize<TSource>(default(IQbservable<TSource>))),
  7901. #else
  7902. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7903. #endif
  7904. source.Expression
  7905. )
  7906. );
  7907. }
  7908. /// <summary>
  7909. /// Returns the maximum value in an observable sequence of <see cref="Decimal" /> values.
  7910. /// </summary>
  7911. /// <param name="source">A sequence of <see cref="Decimal" /> values to determine the maximum value of.</param>
  7912. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7913. /// <exception cref="ArgumentNullException">
  7914. /// <paramref name="source" /> is null.</exception>
  7915. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7916. public static IQbservable<decimal> Max(this IQbservable<decimal> source)
  7917. {
  7918. if (source == null)
  7919. throw new ArgumentNullException(nameof(source));
  7920. return source.Provider.CreateQuery<decimal>(
  7921. Expression.Call(
  7922. null,
  7923. #if CRIPPLED_REFLECTION
  7924. InfoOf(() => Qbservable.Max(default(IQbservable<decimal>))),
  7925. #else
  7926. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7927. #endif
  7928. source.Expression
  7929. )
  7930. );
  7931. }
  7932. /// <summary>
  7933. /// Returns the maximum value in an observable sequence of <see cref="double" /> values.
  7934. /// </summary>
  7935. /// <param name="source">A sequence of <see cref="double" /> values to determine the maximum value of.</param>
  7936. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7937. /// <exception cref="ArgumentNullException">
  7938. /// <paramref name="source" /> is null.</exception>
  7939. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7940. public static IQbservable<double> Max(this IQbservable<double> source)
  7941. {
  7942. if (source == null)
  7943. throw new ArgumentNullException(nameof(source));
  7944. return source.Provider.CreateQuery<double>(
  7945. Expression.Call(
  7946. null,
  7947. #if CRIPPLED_REFLECTION
  7948. InfoOf(() => Qbservable.Max(default(IQbservable<double>))),
  7949. #else
  7950. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7951. #endif
  7952. source.Expression
  7953. )
  7954. );
  7955. }
  7956. /// <summary>
  7957. /// Returns the maximum value in an observable sequence of <see cref="int" /> values.
  7958. /// </summary>
  7959. /// <param name="source">A sequence of <see cref="int" /> values to determine the maximum value of.</param>
  7960. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7961. /// <exception cref="ArgumentNullException">
  7962. /// <paramref name="source" /> is null.</exception>
  7963. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7964. public static IQbservable<int> Max(this IQbservable<int> source)
  7965. {
  7966. if (source == null)
  7967. throw new ArgumentNullException(nameof(source));
  7968. return source.Provider.CreateQuery<int>(
  7969. Expression.Call(
  7970. null,
  7971. #if CRIPPLED_REFLECTION
  7972. InfoOf(() => Qbservable.Max(default(IQbservable<int>))),
  7973. #else
  7974. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7975. #endif
  7976. source.Expression
  7977. )
  7978. );
  7979. }
  7980. /// <summary>
  7981. /// Returns the maximum value in an observable sequence of <see cref="long" /> values.
  7982. /// </summary>
  7983. /// <param name="source">A sequence of <see cref="long" /> values to determine the maximum value of.</param>
  7984. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7985. /// <exception cref="ArgumentNullException">
  7986. /// <paramref name="source" /> is null.</exception>
  7987. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7988. public static IQbservable<long> Max(this IQbservable<long> source)
  7989. {
  7990. if (source == null)
  7991. throw new ArgumentNullException(nameof(source));
  7992. return source.Provider.CreateQuery<long>(
  7993. Expression.Call(
  7994. null,
  7995. #if CRIPPLED_REFLECTION
  7996. InfoOf(() => Qbservable.Max(default(IQbservable<long>))),
  7997. #else
  7998. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7999. #endif
  8000. source.Expression
  8001. )
  8002. );
  8003. }
  8004. /// <summary>
  8005. /// Returns the maximum value in an observable sequence of nullable <see cref="Decimal" /> values.
  8006. /// </summary>
  8007. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to determine the maximum value of.</param>
  8008. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8009. /// <exception cref="ArgumentNullException">
  8010. /// <paramref name="source" /> is null.</exception>
  8011. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8012. public static IQbservable<decimal?> Max(this IQbservable<decimal?> source)
  8013. {
  8014. if (source == null)
  8015. throw new ArgumentNullException(nameof(source));
  8016. return source.Provider.CreateQuery<decimal?>(
  8017. Expression.Call(
  8018. null,
  8019. #if CRIPPLED_REFLECTION
  8020. InfoOf(() => Qbservable.Max(default(IQbservable<decimal?>))),
  8021. #else
  8022. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8023. #endif
  8024. source.Expression
  8025. )
  8026. );
  8027. }
  8028. /// <summary>
  8029. /// Returns the maximum value in an observable sequence of nullable <see cref="double" /> values.
  8030. /// </summary>
  8031. /// <param name="source">A sequence of nullable <see cref="double" /> values to determine the maximum value of.</param>
  8032. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8033. /// <exception cref="ArgumentNullException">
  8034. /// <paramref name="source" /> is null.</exception>
  8035. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8036. public static IQbservable<double?> Max(this IQbservable<double?> source)
  8037. {
  8038. if (source == null)
  8039. throw new ArgumentNullException(nameof(source));
  8040. return source.Provider.CreateQuery<double?>(
  8041. Expression.Call(
  8042. null,
  8043. #if CRIPPLED_REFLECTION
  8044. InfoOf(() => Qbservable.Max(default(IQbservable<double?>))),
  8045. #else
  8046. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8047. #endif
  8048. source.Expression
  8049. )
  8050. );
  8051. }
  8052. /// <summary>
  8053. /// Returns the maximum value in an observable sequence of nullable <see cref="int" /> values.
  8054. /// </summary>
  8055. /// <param name="source">A sequence of nullable <see cref="int" /> values to determine the maximum value of.</param>
  8056. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8057. /// <exception cref="ArgumentNullException">
  8058. /// <paramref name="source" /> is null.</exception>
  8059. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8060. public static IQbservable<int?> Max(this IQbservable<int?> source)
  8061. {
  8062. if (source == null)
  8063. throw new ArgumentNullException(nameof(source));
  8064. return source.Provider.CreateQuery<int?>(
  8065. Expression.Call(
  8066. null,
  8067. #if CRIPPLED_REFLECTION
  8068. InfoOf(() => Qbservable.Max(default(IQbservable<int?>))),
  8069. #else
  8070. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8071. #endif
  8072. source.Expression
  8073. )
  8074. );
  8075. }
  8076. /// <summary>
  8077. /// Returns the maximum value in an observable sequence of nullable <see cref="long" /> values.
  8078. /// </summary>
  8079. /// <param name="source">A sequence of nullable <see cref="long" /> values to determine the maximum value of.</param>
  8080. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8081. /// <exception cref="ArgumentNullException">
  8082. /// <paramref name="source" /> is null.</exception>
  8083. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8084. public static IQbservable<long?> Max(this IQbservable<long?> source)
  8085. {
  8086. if (source == null)
  8087. throw new ArgumentNullException(nameof(source));
  8088. return source.Provider.CreateQuery<long?>(
  8089. Expression.Call(
  8090. null,
  8091. #if CRIPPLED_REFLECTION
  8092. InfoOf(() => Qbservable.Max(default(IQbservable<long?>))),
  8093. #else
  8094. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8095. #endif
  8096. source.Expression
  8097. )
  8098. );
  8099. }
  8100. /// <summary>
  8101. /// Returns the maximum value in an observable sequence of nullable <see cref="Single" /> values.
  8102. /// </summary>
  8103. /// <param name="source">A sequence of nullable <see cref="Single" /> values to determine the maximum value of.</param>
  8104. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8105. /// <exception cref="ArgumentNullException">
  8106. /// <paramref name="source" /> is null.</exception>
  8107. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8108. public static IQbservable<float?> Max(this IQbservable<float?> source)
  8109. {
  8110. if (source == null)
  8111. throw new ArgumentNullException(nameof(source));
  8112. return source.Provider.CreateQuery<float?>(
  8113. Expression.Call(
  8114. null,
  8115. #if CRIPPLED_REFLECTION
  8116. InfoOf(() => Qbservable.Max(default(IQbservable<float?>))),
  8117. #else
  8118. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8119. #endif
  8120. source.Expression
  8121. )
  8122. );
  8123. }
  8124. /// <summary>
  8125. /// Returns the maximum value in an observable sequence of <see cref="Single" /> values.
  8126. /// </summary>
  8127. /// <param name="source">A sequence of <see cref="Single" /> values to determine the maximum value of.</param>
  8128. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8129. /// <exception cref="ArgumentNullException">
  8130. /// <paramref name="source" /> is null.</exception>
  8131. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8132. public static IQbservable<float> Max(this IQbservable<float> source)
  8133. {
  8134. if (source == null)
  8135. throw new ArgumentNullException(nameof(source));
  8136. return source.Provider.CreateQuery<float>(
  8137. Expression.Call(
  8138. null,
  8139. #if CRIPPLED_REFLECTION
  8140. InfoOf(() => Qbservable.Max(default(IQbservable<float>))),
  8141. #else
  8142. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8143. #endif
  8144. source.Expression
  8145. )
  8146. );
  8147. }
  8148. /// <summary>
  8149. /// Returns the maximum element in an observable sequence.
  8150. /// </summary>
  8151. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8152. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8153. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8154. /// <exception cref="ArgumentNullException">
  8155. /// <paramref name="source" /> is null.</exception>
  8156. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8157. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source)
  8158. {
  8159. if (source == null)
  8160. throw new ArgumentNullException(nameof(source));
  8161. return source.Provider.CreateQuery<TSource>(
  8162. Expression.Call(
  8163. null,
  8164. #if CRIPPLED_REFLECTION
  8165. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>))),
  8166. #else
  8167. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8168. #endif
  8169. source.Expression
  8170. )
  8171. );
  8172. }
  8173. /// <summary>
  8174. /// Returns the maximum value in an observable sequence according to the specified comparer.
  8175. /// </summary>
  8176. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8177. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8178. /// <param name="comparer">Comparer used to compare elements.</param>
  8179. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8180. /// <exception cref="ArgumentNullException">
  8181. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  8182. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8183. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  8184. {
  8185. if (source == null)
  8186. throw new ArgumentNullException(nameof(source));
  8187. if (comparer == null)
  8188. throw new ArgumentNullException(nameof(comparer));
  8189. return source.Provider.CreateQuery<TSource>(
  8190. Expression.Call(
  8191. null,
  8192. #if CRIPPLED_REFLECTION
  8193. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  8194. #else
  8195. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8196. #endif
  8197. source.Expression,
  8198. Expression.Constant(comparer, typeof(IComparer<TSource>))
  8199. )
  8200. );
  8201. }
  8202. /// <summary>
  8203. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="double" /> value.
  8204. /// </summary>
  8205. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8206. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8207. /// <param name="selector">A transform function to apply to each element.</param>
  8208. /// <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>
  8209. /// <exception cref="ArgumentNullException">
  8210. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8211. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8212. public static IQbservable<double> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  8213. {
  8214. if (source == null)
  8215. throw new ArgumentNullException(nameof(source));
  8216. if (selector == null)
  8217. throw new ArgumentNullException(nameof(selector));
  8218. return source.Provider.CreateQuery<double>(
  8219. Expression.Call(
  8220. null,
  8221. #if CRIPPLED_REFLECTION
  8222. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  8223. #else
  8224. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8225. #endif
  8226. source.Expression,
  8227. selector
  8228. )
  8229. );
  8230. }
  8231. /// <summary>
  8232. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="Single" /> value.
  8233. /// </summary>
  8234. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8235. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8236. /// <param name="selector">A transform function to apply to each element.</param>
  8237. /// <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>
  8238. /// <exception cref="ArgumentNullException">
  8239. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8240. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8241. public static IQbservable<float> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  8242. {
  8243. if (source == null)
  8244. throw new ArgumentNullException(nameof(source));
  8245. if (selector == null)
  8246. throw new ArgumentNullException(nameof(selector));
  8247. return source.Provider.CreateQuery<float>(
  8248. Expression.Call(
  8249. null,
  8250. #if CRIPPLED_REFLECTION
  8251. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  8252. #else
  8253. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8254. #endif
  8255. source.Expression,
  8256. selector
  8257. )
  8258. );
  8259. }
  8260. /// <summary>
  8261. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="Decimal" /> value.
  8262. /// </summary>
  8263. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8264. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8265. /// <param name="selector">A transform function to apply to each element.</param>
  8266. /// <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>
  8267. /// <exception cref="ArgumentNullException">
  8268. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8269. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8270. public static IQbservable<decimal> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  8271. {
  8272. if (source == null)
  8273. throw new ArgumentNullException(nameof(source));
  8274. if (selector == null)
  8275. throw new ArgumentNullException(nameof(selector));
  8276. return source.Provider.CreateQuery<decimal>(
  8277. Expression.Call(
  8278. null,
  8279. #if CRIPPLED_REFLECTION
  8280. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  8281. #else
  8282. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8283. #endif
  8284. source.Expression,
  8285. selector
  8286. )
  8287. );
  8288. }
  8289. /// <summary>
  8290. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="int" /> value.
  8291. /// </summary>
  8292. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8293. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8294. /// <param name="selector">A transform function to apply to each element.</param>
  8295. /// <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>
  8296. /// <exception cref="ArgumentNullException">
  8297. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8298. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8299. public static IQbservable<int> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  8300. {
  8301. if (source == null)
  8302. throw new ArgumentNullException(nameof(source));
  8303. if (selector == null)
  8304. throw new ArgumentNullException(nameof(selector));
  8305. return source.Provider.CreateQuery<int>(
  8306. Expression.Call(
  8307. null,
  8308. #if CRIPPLED_REFLECTION
  8309. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  8310. #else
  8311. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8312. #endif
  8313. source.Expression,
  8314. selector
  8315. )
  8316. );
  8317. }
  8318. /// <summary>
  8319. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="long" /> value.
  8320. /// </summary>
  8321. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8322. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8323. /// <param name="selector">A transform function to apply to each element.</param>
  8324. /// <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>
  8325. /// <exception cref="ArgumentNullException">
  8326. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8327. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8328. public static IQbservable<long> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  8329. {
  8330. if (source == null)
  8331. throw new ArgumentNullException(nameof(source));
  8332. if (selector == null)
  8333. throw new ArgumentNullException(nameof(selector));
  8334. return source.Provider.CreateQuery<long>(
  8335. Expression.Call(
  8336. null,
  8337. #if CRIPPLED_REFLECTION
  8338. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  8339. #else
  8340. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8341. #endif
  8342. source.Expression,
  8343. selector
  8344. )
  8345. );
  8346. }
  8347. /// <summary>
  8348. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="double" /> value.
  8349. /// </summary>
  8350. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8351. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8352. /// <param name="selector">A transform function to apply to each element.</param>
  8353. /// <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>
  8354. /// <exception cref="ArgumentNullException">
  8355. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8356. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8357. public static IQbservable<double?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  8358. {
  8359. if (source == null)
  8360. throw new ArgumentNullException(nameof(source));
  8361. if (selector == null)
  8362. throw new ArgumentNullException(nameof(selector));
  8363. return source.Provider.CreateQuery<double?>(
  8364. Expression.Call(
  8365. null,
  8366. #if CRIPPLED_REFLECTION
  8367. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  8368. #else
  8369. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8370. #endif
  8371. source.Expression,
  8372. selector
  8373. )
  8374. );
  8375. }
  8376. /// <summary>
  8377. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="Single" /> value.
  8378. /// </summary>
  8379. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8380. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8381. /// <param name="selector">A transform function to apply to each element.</param>
  8382. /// <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>
  8383. /// <exception cref="ArgumentNullException">
  8384. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8385. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8386. public static IQbservable<float?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  8387. {
  8388. if (source == null)
  8389. throw new ArgumentNullException(nameof(source));
  8390. if (selector == null)
  8391. throw new ArgumentNullException(nameof(selector));
  8392. return source.Provider.CreateQuery<float?>(
  8393. Expression.Call(
  8394. null,
  8395. #if CRIPPLED_REFLECTION
  8396. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  8397. #else
  8398. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8399. #endif
  8400. source.Expression,
  8401. selector
  8402. )
  8403. );
  8404. }
  8405. /// <summary>
  8406. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="Decimal" /> value.
  8407. /// </summary>
  8408. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8409. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8410. /// <param name="selector">A transform function to apply to each element.</param>
  8411. /// <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>
  8412. /// <exception cref="ArgumentNullException">
  8413. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8414. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8415. public static IQbservable<decimal?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  8416. {
  8417. if (source == null)
  8418. throw new ArgumentNullException(nameof(source));
  8419. if (selector == null)
  8420. throw new ArgumentNullException(nameof(selector));
  8421. return source.Provider.CreateQuery<decimal?>(
  8422. Expression.Call(
  8423. null,
  8424. #if CRIPPLED_REFLECTION
  8425. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  8426. #else
  8427. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8428. #endif
  8429. source.Expression,
  8430. selector
  8431. )
  8432. );
  8433. }
  8434. /// <summary>
  8435. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="int" /> value.
  8436. /// </summary>
  8437. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8438. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8439. /// <param name="selector">A transform function to apply to each element.</param>
  8440. /// <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>
  8441. /// <exception cref="ArgumentNullException">
  8442. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8443. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8444. public static IQbservable<int?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  8445. {
  8446. if (source == null)
  8447. throw new ArgumentNullException(nameof(source));
  8448. if (selector == null)
  8449. throw new ArgumentNullException(nameof(selector));
  8450. return source.Provider.CreateQuery<int?>(
  8451. Expression.Call(
  8452. null,
  8453. #if CRIPPLED_REFLECTION
  8454. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  8455. #else
  8456. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8457. #endif
  8458. source.Expression,
  8459. selector
  8460. )
  8461. );
  8462. }
  8463. /// <summary>
  8464. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="long" /> value.
  8465. /// </summary>
  8466. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8467. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8468. /// <param name="selector">A transform function to apply to each element.</param>
  8469. /// <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>
  8470. /// <exception cref="ArgumentNullException">
  8471. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8472. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8473. public static IQbservable<long?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  8474. {
  8475. if (source == null)
  8476. throw new ArgumentNullException(nameof(source));
  8477. if (selector == null)
  8478. throw new ArgumentNullException(nameof(selector));
  8479. return source.Provider.CreateQuery<long?>(
  8480. Expression.Call(
  8481. null,
  8482. #if CRIPPLED_REFLECTION
  8483. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  8484. #else
  8485. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8486. #endif
  8487. source.Expression,
  8488. selector
  8489. )
  8490. );
  8491. }
  8492. /// <summary>
  8493. /// Invokes a transform function on each element of a sequence and returns the maximum value.
  8494. /// </summary>
  8495. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8496. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8497. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  8498. /// <param name="selector">A transform function to apply to each element.</param>
  8499. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8500. /// <exception cref="ArgumentNullException">
  8501. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8502. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8503. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  8504. {
  8505. if (source == null)
  8506. throw new ArgumentNullException(nameof(source));
  8507. if (selector == null)
  8508. throw new ArgumentNullException(nameof(selector));
  8509. return source.Provider.CreateQuery<TResult>(
  8510. Expression.Call(
  8511. null,
  8512. #if CRIPPLED_REFLECTION
  8513. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  8514. #else
  8515. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8516. #endif
  8517. source.Expression,
  8518. selector
  8519. )
  8520. );
  8521. }
  8522. /// <summary>
  8523. /// Invokes a transform function on each element of a sequence and returns the maximum value according to the specified comparer.
  8524. /// </summary>
  8525. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8526. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8527. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  8528. /// <param name="selector">A transform function to apply to each element.</param>
  8529. /// <param name="comparer">Comparer used to compare elements.</param>
  8530. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8531. /// <exception cref="ArgumentNullException">
  8532. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  8533. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8534. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  8535. {
  8536. if (source == null)
  8537. throw new ArgumentNullException(nameof(source));
  8538. if (selector == null)
  8539. throw new ArgumentNullException(nameof(selector));
  8540. if (comparer == null)
  8541. throw new ArgumentNullException(nameof(comparer));
  8542. return source.Provider.CreateQuery<TResult>(
  8543. Expression.Call(
  8544. null,
  8545. #if CRIPPLED_REFLECTION
  8546. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  8547. #else
  8548. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8549. #endif
  8550. source.Expression,
  8551. selector,
  8552. Expression.Constant(comparer, typeof(IComparer<TResult>))
  8553. )
  8554. );
  8555. }
  8556. /// <summary>
  8557. /// Returns the elements in an observable sequence with the maximum key value.
  8558. /// </summary>
  8559. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8560. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8561. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8562. /// <param name="keySelector">Key selector function.</param>
  8563. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8564. /// <exception cref="ArgumentNullException">
  8565. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  8566. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8567. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  8568. {
  8569. if (source == null)
  8570. throw new ArgumentNullException(nameof(source));
  8571. if (keySelector == null)
  8572. throw new ArgumentNullException(nameof(keySelector));
  8573. return source.Provider.CreateQuery<IList<TSource>>(
  8574. Expression.Call(
  8575. null,
  8576. #if CRIPPLED_REFLECTION
  8577. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  8578. #else
  8579. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8580. #endif
  8581. source.Expression,
  8582. keySelector
  8583. )
  8584. );
  8585. }
  8586. /// <summary>
  8587. /// Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
  8588. /// </summary>
  8589. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8590. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8591. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8592. /// <param name="keySelector">Key selector function.</param>
  8593. /// <param name="comparer">Comparer used to compare key values.</param>
  8594. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8595. /// <exception cref="ArgumentNullException">
  8596. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  8597. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8598. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  8599. {
  8600. if (source == null)
  8601. throw new ArgumentNullException(nameof(source));
  8602. if (keySelector == null)
  8603. throw new ArgumentNullException(nameof(keySelector));
  8604. if (comparer == null)
  8605. throw new ArgumentNullException(nameof(comparer));
  8606. return source.Provider.CreateQuery<IList<TSource>>(
  8607. Expression.Call(
  8608. null,
  8609. #if CRIPPLED_REFLECTION
  8610. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  8611. #else
  8612. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8613. #endif
  8614. source.Expression,
  8615. keySelector,
  8616. Expression.Constant(comparer, typeof(IComparer<TKey>))
  8617. )
  8618. );
  8619. }
  8620. /// <summary>
  8621. /// Merges elements from two observable sequences into a single observable sequence.
  8622. /// </summary>
  8623. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8624. /// <param name="first">First observable sequence.</param>
  8625. /// <param name="second">Second observable sequence.</param>
  8626. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8627. /// <exception cref="ArgumentNullException">
  8628. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  8629. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  8630. {
  8631. if (first == null)
  8632. throw new ArgumentNullException(nameof(first));
  8633. if (second == null)
  8634. throw new ArgumentNullException(nameof(second));
  8635. return first.Provider.CreateQuery<TSource>(
  8636. Expression.Call(
  8637. null,
  8638. #if CRIPPLED_REFLECTION
  8639. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  8640. #else
  8641. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8642. #endif
  8643. first.Expression,
  8644. GetSourceExpression(second)
  8645. )
  8646. );
  8647. }
  8648. /// <summary>
  8649. /// Merges elements from two observable sequences into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  8650. /// </summary>
  8651. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8652. /// <param name="first">First observable sequence.</param>
  8653. /// <param name="second">Second observable sequence.</param>
  8654. /// <param name="scheduler">Scheduler used to introduce concurrency for making subscriptions to the given sequences.</param>
  8655. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8656. /// <exception cref="ArgumentNullException">
  8657. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="scheduler" /> is null.</exception>
  8658. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IScheduler scheduler)
  8659. {
  8660. if (first == null)
  8661. throw new ArgumentNullException(nameof(first));
  8662. if (second == null)
  8663. throw new ArgumentNullException(nameof(second));
  8664. if (scheduler == null)
  8665. throw new ArgumentNullException(nameof(scheduler));
  8666. return first.Provider.CreateQuery<TSource>(
  8667. Expression.Call(
  8668. null,
  8669. #if CRIPPLED_REFLECTION
  8670. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IScheduler))),
  8671. #else
  8672. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8673. #endif
  8674. first.Expression,
  8675. GetSourceExpression(second),
  8676. Expression.Constant(scheduler, typeof(IScheduler))
  8677. )
  8678. );
  8679. }
  8680. /// <summary>
  8681. /// 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.
  8682. /// </summary>
  8683. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8684. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8685. /// <param name="sources">Observable sequences.</param>
  8686. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8687. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8688. /// <exception cref="ArgumentNullException">
  8689. /// <paramref name="scheduler" /> or <paramref name="sources" /> is null.</exception>
  8690. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IScheduler scheduler, params IObservable<TSource>[] sources)
  8691. {
  8692. if (provider == null)
  8693. throw new ArgumentNullException(nameof(provider));
  8694. if (scheduler == null)
  8695. throw new ArgumentNullException(nameof(scheduler));
  8696. if (sources == null)
  8697. throw new ArgumentNullException(nameof(sources));
  8698. return provider.CreateQuery<TSource>(
  8699. Expression.Call(
  8700. null,
  8701. #if CRIPPLED_REFLECTION
  8702. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IScheduler), default(IObservable<TSource>[]))),
  8703. #else
  8704. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8705. #endif
  8706. Expression.Constant(provider, typeof(IQbservableProvider)),
  8707. Expression.Constant(scheduler, typeof(IScheduler)),
  8708. GetSourceExpression(sources)
  8709. )
  8710. );
  8711. }
  8712. /// <summary>
  8713. /// Merges elements from all inner observable sequences into a single observable sequence.
  8714. /// </summary>
  8715. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8716. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8717. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8718. /// <exception cref="ArgumentNullException">
  8719. /// <paramref name="sources" /> is null.</exception>
  8720. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources)
  8721. {
  8722. if (sources == null)
  8723. throw new ArgumentNullException(nameof(sources));
  8724. return sources.Provider.CreateQuery<TSource>(
  8725. Expression.Call(
  8726. null,
  8727. #if CRIPPLED_REFLECTION
  8728. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>))),
  8729. #else
  8730. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8731. #endif
  8732. sources.Expression
  8733. )
  8734. );
  8735. }
  8736. /// <summary>
  8737. /// Merges results from all source tasks into a single observable sequence.
  8738. /// </summary>
  8739. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  8740. /// <param name="sources">Observable sequence of tasks.</param>
  8741. /// <returns>The observable sequence that merges the results of the source tasks.</returns>
  8742. /// <exception cref="ArgumentNullException">
  8743. /// <paramref name="sources" /> is null.</exception>
  8744. /// <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>
  8745. public static IQbservable<TSource> Merge<TSource>(this IQbservable<Task<TSource>> sources)
  8746. {
  8747. if (sources == null)
  8748. throw new ArgumentNullException(nameof(sources));
  8749. return sources.Provider.CreateQuery<TSource>(
  8750. Expression.Call(
  8751. null,
  8752. #if CRIPPLED_REFLECTION
  8753. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<Task<TSource>>))),
  8754. #else
  8755. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8756. #endif
  8757. sources.Expression
  8758. )
  8759. );
  8760. }
  8761. /// <summary>
  8762. /// Merges elements from all of the specified observable sequences into a single observable sequence.
  8763. /// </summary>
  8764. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8765. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8766. /// <param name="sources">Observable sequences.</param>
  8767. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8768. /// <exception cref="ArgumentNullException">
  8769. /// <paramref name="sources" /> is null.</exception>
  8770. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  8771. {
  8772. if (provider == null)
  8773. throw new ArgumentNullException(nameof(provider));
  8774. if (sources == null)
  8775. throw new ArgumentNullException(nameof(sources));
  8776. return provider.CreateQuery<TSource>(
  8777. Expression.Call(
  8778. null,
  8779. #if CRIPPLED_REFLECTION
  8780. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  8781. #else
  8782. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8783. #endif
  8784. Expression.Constant(provider, typeof(IQbservableProvider)),
  8785. GetSourceExpression(sources)
  8786. )
  8787. );
  8788. }
  8789. /// <summary>
  8790. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence.
  8791. /// </summary>
  8792. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8793. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8794. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8795. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8796. /// <exception cref="ArgumentNullException">
  8797. /// <paramref name="sources" /> is null.</exception>
  8798. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  8799. {
  8800. if (provider == null)
  8801. throw new ArgumentNullException(nameof(provider));
  8802. if (sources == null)
  8803. throw new ArgumentNullException(nameof(sources));
  8804. return provider.CreateQuery<TSource>(
  8805. Expression.Call(
  8806. null,
  8807. #if CRIPPLED_REFLECTION
  8808. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  8809. #else
  8810. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8811. #endif
  8812. Expression.Constant(provider, typeof(IQbservableProvider)),
  8813. GetSourceExpression(sources)
  8814. )
  8815. );
  8816. }
  8817. /// <summary>
  8818. /// Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  8819. /// </summary>
  8820. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8821. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8822. /// <param name="maxConcurrent">Maximum number of inner observable sequences being subscribed to concurrently.</param>
  8823. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8824. /// <exception cref="ArgumentNullException">
  8825. /// <paramref name="sources" /> is null.</exception>
  8826. /// <exception cref="ArgumentOutOfRangeException">
  8827. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8828. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources, int maxConcurrent)
  8829. {
  8830. if (sources == null)
  8831. throw new ArgumentNullException(nameof(sources));
  8832. return sources.Provider.CreateQuery<TSource>(
  8833. Expression.Call(
  8834. null,
  8835. #if CRIPPLED_REFLECTION
  8836. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>), default(int))),
  8837. #else
  8838. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8839. #endif
  8840. sources.Expression,
  8841. Expression.Constant(maxConcurrent, typeof(int))
  8842. )
  8843. );
  8844. }
  8845. /// <summary>
  8846. /// 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.
  8847. /// </summary>
  8848. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8849. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8850. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8851. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  8852. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8853. /// <exception cref="ArgumentNullException">
  8854. /// <paramref name="sources" /> is null.</exception>
  8855. /// <exception cref="ArgumentOutOfRangeException">
  8856. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8857. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent)
  8858. {
  8859. if (provider == null)
  8860. throw new ArgumentNullException(nameof(provider));
  8861. if (sources == null)
  8862. throw new ArgumentNullException(nameof(sources));
  8863. return provider.CreateQuery<TSource>(
  8864. Expression.Call(
  8865. null,
  8866. #if CRIPPLED_REFLECTION
  8867. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int))),
  8868. #else
  8869. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8870. #endif
  8871. Expression.Constant(provider, typeof(IQbservableProvider)),
  8872. GetSourceExpression(sources),
  8873. Expression.Constant(maxConcurrent, typeof(int))
  8874. )
  8875. );
  8876. }
  8877. /// <summary>
  8878. /// 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.
  8879. /// </summary>
  8880. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8881. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8882. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8883. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  8884. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8885. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8886. /// <exception cref="ArgumentNullException">
  8887. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  8888. /// <exception cref="ArgumentOutOfRangeException">
  8889. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8890. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent, IScheduler scheduler)
  8891. {
  8892. if (provider == null)
  8893. throw new ArgumentNullException(nameof(provider));
  8894. if (sources == null)
  8895. throw new ArgumentNullException(nameof(sources));
  8896. if (scheduler == null)
  8897. throw new ArgumentNullException(nameof(scheduler));
  8898. return provider.CreateQuery<TSource>(
  8899. Expression.Call(
  8900. null,
  8901. #if CRIPPLED_REFLECTION
  8902. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int), default(IScheduler))),
  8903. #else
  8904. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8905. #endif
  8906. Expression.Constant(provider, typeof(IQbservableProvider)),
  8907. GetSourceExpression(sources),
  8908. Expression.Constant(maxConcurrent, typeof(int)),
  8909. Expression.Constant(scheduler, typeof(IScheduler))
  8910. )
  8911. );
  8912. }
  8913. /// <summary>
  8914. /// 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.
  8915. /// </summary>
  8916. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8917. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8918. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8919. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8920. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8921. /// <exception cref="ArgumentNullException">
  8922. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  8923. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, IScheduler scheduler)
  8924. {
  8925. if (provider == null)
  8926. throw new ArgumentNullException(nameof(provider));
  8927. if (sources == null)
  8928. throw new ArgumentNullException(nameof(sources));
  8929. if (scheduler == null)
  8930. throw new ArgumentNullException(nameof(scheduler));
  8931. return provider.CreateQuery<TSource>(
  8932. Expression.Call(
  8933. null,
  8934. #if CRIPPLED_REFLECTION
  8935. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(IScheduler))),
  8936. #else
  8937. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8938. #endif
  8939. Expression.Constant(provider, typeof(IQbservableProvider)),
  8940. GetSourceExpression(sources),
  8941. Expression.Constant(scheduler, typeof(IScheduler))
  8942. )
  8943. );
  8944. }
  8945. /// <summary>
  8946. /// Returns the minimum value in an observable sequence of <see cref="Decimal" /> values.
  8947. /// </summary>
  8948. /// <param name="source">A sequence of <see cref="Decimal" /> values to determine the minimum value of.</param>
  8949. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8950. /// <exception cref="ArgumentNullException">
  8951. /// <paramref name="source" /> is null.</exception>
  8952. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8953. public static IQbservable<decimal> Min(this IQbservable<decimal> source)
  8954. {
  8955. if (source == null)
  8956. throw new ArgumentNullException(nameof(source));
  8957. return source.Provider.CreateQuery<decimal>(
  8958. Expression.Call(
  8959. null,
  8960. #if CRIPPLED_REFLECTION
  8961. InfoOf(() => Qbservable.Min(default(IQbservable<decimal>))),
  8962. #else
  8963. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8964. #endif
  8965. source.Expression
  8966. )
  8967. );
  8968. }
  8969. /// <summary>
  8970. /// Returns the minimum value in an observable sequence of <see cref="double" /> values.
  8971. /// </summary>
  8972. /// <param name="source">A sequence of <see cref="double" /> values to determine the minimum value of.</param>
  8973. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8974. /// <exception cref="ArgumentNullException">
  8975. /// <paramref name="source" /> is null.</exception>
  8976. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8977. public static IQbservable<double> Min(this IQbservable<double> source)
  8978. {
  8979. if (source == null)
  8980. throw new ArgumentNullException(nameof(source));
  8981. return source.Provider.CreateQuery<double>(
  8982. Expression.Call(
  8983. null,
  8984. #if CRIPPLED_REFLECTION
  8985. InfoOf(() => Qbservable.Min(default(IQbservable<double>))),
  8986. #else
  8987. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8988. #endif
  8989. source.Expression
  8990. )
  8991. );
  8992. }
  8993. /// <summary>
  8994. /// Returns the minimum value in an observable sequence of <see cref="int" /> values.
  8995. /// </summary>
  8996. /// <param name="source">A sequence of <see cref="int" /> values to determine the minimum value of.</param>
  8997. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8998. /// <exception cref="ArgumentNullException">
  8999. /// <paramref name="source" /> is null.</exception>
  9000. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9001. public static IQbservable<int> Min(this IQbservable<int> source)
  9002. {
  9003. if (source == null)
  9004. throw new ArgumentNullException(nameof(source));
  9005. return source.Provider.CreateQuery<int>(
  9006. Expression.Call(
  9007. null,
  9008. #if CRIPPLED_REFLECTION
  9009. InfoOf(() => Qbservable.Min(default(IQbservable<int>))),
  9010. #else
  9011. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9012. #endif
  9013. source.Expression
  9014. )
  9015. );
  9016. }
  9017. /// <summary>
  9018. /// Returns the minimum value in an observable sequence of <see cref="long" /> values.
  9019. /// </summary>
  9020. /// <param name="source">A sequence of <see cref="long" /> values to determine the minimum value of.</param>
  9021. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9022. /// <exception cref="ArgumentNullException">
  9023. /// <paramref name="source" /> is null.</exception>
  9024. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9025. public static IQbservable<long> Min(this IQbservable<long> source)
  9026. {
  9027. if (source == null)
  9028. throw new ArgumentNullException(nameof(source));
  9029. return source.Provider.CreateQuery<long>(
  9030. Expression.Call(
  9031. null,
  9032. #if CRIPPLED_REFLECTION
  9033. InfoOf(() => Qbservable.Min(default(IQbservable<long>))),
  9034. #else
  9035. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9036. #endif
  9037. source.Expression
  9038. )
  9039. );
  9040. }
  9041. /// <summary>
  9042. /// Returns the minimum value in an observable sequence of nullable <see cref="Decimal" /> values.
  9043. /// </summary>
  9044. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to determine the minimum value of.</param>
  9045. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9046. /// <exception cref="ArgumentNullException">
  9047. /// <paramref name="source" /> is null.</exception>
  9048. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9049. public static IQbservable<decimal?> Min(this IQbservable<decimal?> source)
  9050. {
  9051. if (source == null)
  9052. throw new ArgumentNullException(nameof(source));
  9053. return source.Provider.CreateQuery<decimal?>(
  9054. Expression.Call(
  9055. null,
  9056. #if CRIPPLED_REFLECTION
  9057. InfoOf(() => Qbservable.Min(default(IQbservable<decimal?>))),
  9058. #else
  9059. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9060. #endif
  9061. source.Expression
  9062. )
  9063. );
  9064. }
  9065. /// <summary>
  9066. /// Returns the minimum value in an observable sequence of nullable <see cref="double" /> values.
  9067. /// </summary>
  9068. /// <param name="source">A sequence of nullable <see cref="double" /> values to determine the minimum value of.</param>
  9069. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9070. /// <exception cref="ArgumentNullException">
  9071. /// <paramref name="source" /> is null.</exception>
  9072. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9073. public static IQbservable<double?> Min(this IQbservable<double?> source)
  9074. {
  9075. if (source == null)
  9076. throw new ArgumentNullException(nameof(source));
  9077. return source.Provider.CreateQuery<double?>(
  9078. Expression.Call(
  9079. null,
  9080. #if CRIPPLED_REFLECTION
  9081. InfoOf(() => Qbservable.Min(default(IQbservable<double?>))),
  9082. #else
  9083. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9084. #endif
  9085. source.Expression
  9086. )
  9087. );
  9088. }
  9089. /// <summary>
  9090. /// Returns the minimum value in an observable sequence of nullable <see cref="int" /> values.
  9091. /// </summary>
  9092. /// <param name="source">A sequence of nullable <see cref="int" /> values to determine the minimum value of.</param>
  9093. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9094. /// <exception cref="ArgumentNullException">
  9095. /// <paramref name="source" /> is null.</exception>
  9096. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9097. public static IQbservable<int?> Min(this IQbservable<int?> source)
  9098. {
  9099. if (source == null)
  9100. throw new ArgumentNullException(nameof(source));
  9101. return source.Provider.CreateQuery<int?>(
  9102. Expression.Call(
  9103. null,
  9104. #if CRIPPLED_REFLECTION
  9105. InfoOf(() => Qbservable.Min(default(IQbservable<int?>))),
  9106. #else
  9107. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9108. #endif
  9109. source.Expression
  9110. )
  9111. );
  9112. }
  9113. /// <summary>
  9114. /// Returns the minimum value in an observable sequence of nullable <see cref="long" /> values.
  9115. /// </summary>
  9116. /// <param name="source">A sequence of nullable <see cref="long" /> values to determine the minimum value of.</param>
  9117. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9118. /// <exception cref="ArgumentNullException">
  9119. /// <paramref name="source" /> is null.</exception>
  9120. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9121. public static IQbservable<long?> Min(this IQbservable<long?> source)
  9122. {
  9123. if (source == null)
  9124. throw new ArgumentNullException(nameof(source));
  9125. return source.Provider.CreateQuery<long?>(
  9126. Expression.Call(
  9127. null,
  9128. #if CRIPPLED_REFLECTION
  9129. InfoOf(() => Qbservable.Min(default(IQbservable<long?>))),
  9130. #else
  9131. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9132. #endif
  9133. source.Expression
  9134. )
  9135. );
  9136. }
  9137. /// <summary>
  9138. /// Returns the minimum value in an observable sequence of nullable <see cref="Single" /> values.
  9139. /// </summary>
  9140. /// <param name="source">A sequence of nullable <see cref="Single" /> values to determine the minimum value of.</param>
  9141. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9142. /// <exception cref="ArgumentNullException">
  9143. /// <paramref name="source" /> is null.</exception>
  9144. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9145. public static IQbservable<float?> Min(this IQbservable<float?> source)
  9146. {
  9147. if (source == null)
  9148. throw new ArgumentNullException(nameof(source));
  9149. return source.Provider.CreateQuery<float?>(
  9150. Expression.Call(
  9151. null,
  9152. #if CRIPPLED_REFLECTION
  9153. InfoOf(() => Qbservable.Min(default(IQbservable<float?>))),
  9154. #else
  9155. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9156. #endif
  9157. source.Expression
  9158. )
  9159. );
  9160. }
  9161. /// <summary>
  9162. /// Returns the minimum value in an observable sequence of <see cref="Single" /> values.
  9163. /// </summary>
  9164. /// <param name="source">A sequence of <see cref="Single" /> values to determine the minimum value of.</param>
  9165. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9166. /// <exception cref="ArgumentNullException">
  9167. /// <paramref name="source" /> is null.</exception>
  9168. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9169. public static IQbservable<float> Min(this IQbservable<float> source)
  9170. {
  9171. if (source == null)
  9172. throw new ArgumentNullException(nameof(source));
  9173. return source.Provider.CreateQuery<float>(
  9174. Expression.Call(
  9175. null,
  9176. #if CRIPPLED_REFLECTION
  9177. InfoOf(() => Qbservable.Min(default(IQbservable<float>))),
  9178. #else
  9179. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9180. #endif
  9181. source.Expression
  9182. )
  9183. );
  9184. }
  9185. /// <summary>
  9186. /// Returns the minimum element in an observable sequence.
  9187. /// </summary>
  9188. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9189. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9190. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9191. /// <exception cref="ArgumentNullException">
  9192. /// <paramref name="source" /> is null.</exception>
  9193. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9194. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source)
  9195. {
  9196. if (source == null)
  9197. throw new ArgumentNullException(nameof(source));
  9198. return source.Provider.CreateQuery<TSource>(
  9199. Expression.Call(
  9200. null,
  9201. #if CRIPPLED_REFLECTION
  9202. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>))),
  9203. #else
  9204. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9205. #endif
  9206. source.Expression
  9207. )
  9208. );
  9209. }
  9210. /// <summary>
  9211. /// Returns the minimum element in an observable sequence according to the specified comparer.
  9212. /// </summary>
  9213. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9214. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9215. /// <param name="comparer">Comparer used to compare elements.</param>
  9216. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9217. /// <exception cref="ArgumentNullException">
  9218. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  9219. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9220. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  9221. {
  9222. if (source == null)
  9223. throw new ArgumentNullException(nameof(source));
  9224. if (comparer == null)
  9225. throw new ArgumentNullException(nameof(comparer));
  9226. return source.Provider.CreateQuery<TSource>(
  9227. Expression.Call(
  9228. null,
  9229. #if CRIPPLED_REFLECTION
  9230. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  9231. #else
  9232. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9233. #endif
  9234. source.Expression,
  9235. Expression.Constant(comparer, typeof(IComparer<TSource>))
  9236. )
  9237. );
  9238. }
  9239. /// <summary>
  9240. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="double" /> value.
  9241. /// </summary>
  9242. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9243. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9244. /// <param name="selector">A transform function to apply to each element.</param>
  9245. /// <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>
  9246. /// <exception cref="ArgumentNullException">
  9247. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9248. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9249. public static IQbservable<double> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  9250. {
  9251. if (source == null)
  9252. throw new ArgumentNullException(nameof(source));
  9253. if (selector == null)
  9254. throw new ArgumentNullException(nameof(selector));
  9255. return source.Provider.CreateQuery<double>(
  9256. Expression.Call(
  9257. null,
  9258. #if CRIPPLED_REFLECTION
  9259. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  9260. #else
  9261. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9262. #endif
  9263. source.Expression,
  9264. selector
  9265. )
  9266. );
  9267. }
  9268. /// <summary>
  9269. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="Single" /> value.
  9270. /// </summary>
  9271. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9272. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9273. /// <param name="selector">A transform function to apply to each element.</param>
  9274. /// <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>
  9275. /// <exception cref="ArgumentNullException">
  9276. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9277. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9278. public static IQbservable<float> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  9279. {
  9280. if (source == null)
  9281. throw new ArgumentNullException(nameof(source));
  9282. if (selector == null)
  9283. throw new ArgumentNullException(nameof(selector));
  9284. return source.Provider.CreateQuery<float>(
  9285. Expression.Call(
  9286. null,
  9287. #if CRIPPLED_REFLECTION
  9288. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  9289. #else
  9290. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9291. #endif
  9292. source.Expression,
  9293. selector
  9294. )
  9295. );
  9296. }
  9297. /// <summary>
  9298. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="Decimal" /> value.
  9299. /// </summary>
  9300. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9301. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9302. /// <param name="selector">A transform function to apply to each element.</param>
  9303. /// <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>
  9304. /// <exception cref="ArgumentNullException">
  9305. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9306. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9307. public static IQbservable<decimal> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  9308. {
  9309. if (source == null)
  9310. throw new ArgumentNullException(nameof(source));
  9311. if (selector == null)
  9312. throw new ArgumentNullException(nameof(selector));
  9313. return source.Provider.CreateQuery<decimal>(
  9314. Expression.Call(
  9315. null,
  9316. #if CRIPPLED_REFLECTION
  9317. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  9318. #else
  9319. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9320. #endif
  9321. source.Expression,
  9322. selector
  9323. )
  9324. );
  9325. }
  9326. /// <summary>
  9327. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="int" /> value.
  9328. /// </summary>
  9329. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9330. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9331. /// <param name="selector">A transform function to apply to each element.</param>
  9332. /// <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>
  9333. /// <exception cref="ArgumentNullException">
  9334. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9335. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9336. public static IQbservable<int> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  9337. {
  9338. if (source == null)
  9339. throw new ArgumentNullException(nameof(source));
  9340. if (selector == null)
  9341. throw new ArgumentNullException(nameof(selector));
  9342. return source.Provider.CreateQuery<int>(
  9343. Expression.Call(
  9344. null,
  9345. #if CRIPPLED_REFLECTION
  9346. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  9347. #else
  9348. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9349. #endif
  9350. source.Expression,
  9351. selector
  9352. )
  9353. );
  9354. }
  9355. /// <summary>
  9356. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="long" /> value.
  9357. /// </summary>
  9358. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9359. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9360. /// <param name="selector">A transform function to apply to each element.</param>
  9361. /// <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>
  9362. /// <exception cref="ArgumentNullException">
  9363. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9364. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9365. public static IQbservable<long> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  9366. {
  9367. if (source == null)
  9368. throw new ArgumentNullException(nameof(source));
  9369. if (selector == null)
  9370. throw new ArgumentNullException(nameof(selector));
  9371. return source.Provider.CreateQuery<long>(
  9372. Expression.Call(
  9373. null,
  9374. #if CRIPPLED_REFLECTION
  9375. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  9376. #else
  9377. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9378. #endif
  9379. source.Expression,
  9380. selector
  9381. )
  9382. );
  9383. }
  9384. /// <summary>
  9385. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="double" /> value.
  9386. /// </summary>
  9387. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9388. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9389. /// <param name="selector">A transform function to apply to each element.</param>
  9390. /// <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>
  9391. /// <exception cref="ArgumentNullException">
  9392. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9393. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9394. public static IQbservable<double?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  9395. {
  9396. if (source == null)
  9397. throw new ArgumentNullException(nameof(source));
  9398. if (selector == null)
  9399. throw new ArgumentNullException(nameof(selector));
  9400. return source.Provider.CreateQuery<double?>(
  9401. Expression.Call(
  9402. null,
  9403. #if CRIPPLED_REFLECTION
  9404. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  9405. #else
  9406. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9407. #endif
  9408. source.Expression,
  9409. selector
  9410. )
  9411. );
  9412. }
  9413. /// <summary>
  9414. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="Single" /> value.
  9415. /// </summary>
  9416. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9417. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9418. /// <param name="selector">A transform function to apply to each element.</param>
  9419. /// <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>
  9420. /// <exception cref="ArgumentNullException">
  9421. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9422. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9423. public static IQbservable<float?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  9424. {
  9425. if (source == null)
  9426. throw new ArgumentNullException(nameof(source));
  9427. if (selector == null)
  9428. throw new ArgumentNullException(nameof(selector));
  9429. return source.Provider.CreateQuery<float?>(
  9430. Expression.Call(
  9431. null,
  9432. #if CRIPPLED_REFLECTION
  9433. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  9434. #else
  9435. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9436. #endif
  9437. source.Expression,
  9438. selector
  9439. )
  9440. );
  9441. }
  9442. /// <summary>
  9443. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="Decimal" /> value.
  9444. /// </summary>
  9445. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9446. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9447. /// <param name="selector">A transform function to apply to each element.</param>
  9448. /// <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>
  9449. /// <exception cref="ArgumentNullException">
  9450. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9451. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9452. public static IQbservable<decimal?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  9453. {
  9454. if (source == null)
  9455. throw new ArgumentNullException(nameof(source));
  9456. if (selector == null)
  9457. throw new ArgumentNullException(nameof(selector));
  9458. return source.Provider.CreateQuery<decimal?>(
  9459. Expression.Call(
  9460. null,
  9461. #if CRIPPLED_REFLECTION
  9462. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  9463. #else
  9464. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9465. #endif
  9466. source.Expression,
  9467. selector
  9468. )
  9469. );
  9470. }
  9471. /// <summary>
  9472. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="int" /> value.
  9473. /// </summary>
  9474. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9475. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9476. /// <param name="selector">A transform function to apply to each element.</param>
  9477. /// <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>
  9478. /// <exception cref="ArgumentNullException">
  9479. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9480. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9481. public static IQbservable<int?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  9482. {
  9483. if (source == null)
  9484. throw new ArgumentNullException(nameof(source));
  9485. if (selector == null)
  9486. throw new ArgumentNullException(nameof(selector));
  9487. return source.Provider.CreateQuery<int?>(
  9488. Expression.Call(
  9489. null,
  9490. #if CRIPPLED_REFLECTION
  9491. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  9492. #else
  9493. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9494. #endif
  9495. source.Expression,
  9496. selector
  9497. )
  9498. );
  9499. }
  9500. /// <summary>
  9501. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="long" /> value.
  9502. /// </summary>
  9503. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9504. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9505. /// <param name="selector">A transform function to apply to each element.</param>
  9506. /// <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>
  9507. /// <exception cref="ArgumentNullException">
  9508. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9509. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9510. public static IQbservable<long?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  9511. {
  9512. if (source == null)
  9513. throw new ArgumentNullException(nameof(source));
  9514. if (selector == null)
  9515. throw new ArgumentNullException(nameof(selector));
  9516. return source.Provider.CreateQuery<long?>(
  9517. Expression.Call(
  9518. null,
  9519. #if CRIPPLED_REFLECTION
  9520. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  9521. #else
  9522. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9523. #endif
  9524. source.Expression,
  9525. selector
  9526. )
  9527. );
  9528. }
  9529. /// <summary>
  9530. /// Invokes a transform function on each element of a sequence and returns the minimum value.
  9531. /// </summary>
  9532. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9533. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9534. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9535. /// <param name="selector">A transform function to apply to each element.</param>
  9536. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9537. /// <exception cref="ArgumentNullException">
  9538. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9539. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9540. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  9541. {
  9542. if (source == null)
  9543. throw new ArgumentNullException(nameof(source));
  9544. if (selector == null)
  9545. throw new ArgumentNullException(nameof(selector));
  9546. return source.Provider.CreateQuery<TResult>(
  9547. Expression.Call(
  9548. null,
  9549. #if CRIPPLED_REFLECTION
  9550. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  9551. #else
  9552. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9553. #endif
  9554. source.Expression,
  9555. selector
  9556. )
  9557. );
  9558. }
  9559. /// <summary>
  9560. /// Invokes a transform function on each element of a sequence and returns the minimum value according to the specified comparer.
  9561. /// </summary>
  9562. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9563. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9564. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9565. /// <param name="selector">A transform function to apply to each element.</param>
  9566. /// <param name="comparer">Comparer used to compare elements.</param>
  9567. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9568. /// <exception cref="ArgumentNullException">
  9569. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  9570. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9571. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  9572. {
  9573. if (source == null)
  9574. throw new ArgumentNullException(nameof(source));
  9575. if (selector == null)
  9576. throw new ArgumentNullException(nameof(selector));
  9577. if (comparer == null)
  9578. throw new ArgumentNullException(nameof(comparer));
  9579. return source.Provider.CreateQuery<TResult>(
  9580. Expression.Call(
  9581. null,
  9582. #if CRIPPLED_REFLECTION
  9583. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  9584. #else
  9585. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9586. #endif
  9587. source.Expression,
  9588. selector,
  9589. Expression.Constant(comparer, typeof(IComparer<TResult>))
  9590. )
  9591. );
  9592. }
  9593. /// <summary>
  9594. /// Returns the elements in an observable sequence with the minimum key value.
  9595. /// </summary>
  9596. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9597. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9598. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9599. /// <param name="keySelector">Key selector function.</param>
  9600. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9601. /// <exception cref="ArgumentNullException">
  9602. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  9603. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9604. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  9605. {
  9606. if (source == null)
  9607. throw new ArgumentNullException(nameof(source));
  9608. if (keySelector == null)
  9609. throw new ArgumentNullException(nameof(keySelector));
  9610. return source.Provider.CreateQuery<IList<TSource>>(
  9611. Expression.Call(
  9612. null,
  9613. #if CRIPPLED_REFLECTION
  9614. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  9615. #else
  9616. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9617. #endif
  9618. source.Expression,
  9619. keySelector
  9620. )
  9621. );
  9622. }
  9623. /// <summary>
  9624. /// Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
  9625. /// </summary>
  9626. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9627. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9628. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9629. /// <param name="keySelector">Key selector function.</param>
  9630. /// <param name="comparer">Comparer used to compare key values.</param>
  9631. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9632. /// <exception cref="ArgumentNullException">
  9633. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  9634. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9635. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  9636. {
  9637. if (source == null)
  9638. throw new ArgumentNullException(nameof(source));
  9639. if (keySelector == null)
  9640. throw new ArgumentNullException(nameof(keySelector));
  9641. if (comparer == null)
  9642. throw new ArgumentNullException(nameof(comparer));
  9643. return source.Provider.CreateQuery<IList<TSource>>(
  9644. Expression.Call(
  9645. null,
  9646. #if CRIPPLED_REFLECTION
  9647. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  9648. #else
  9649. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9650. #endif
  9651. source.Expression,
  9652. keySelector,
  9653. Expression.Constant(comparer, typeof(IComparer<TKey>))
  9654. )
  9655. );
  9656. }
  9657. /// <summary>
  9658. /// 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.
  9659. /// Enumerators on the resulting sequence never block and can produce the same element repeatedly.
  9660. /// </summary>
  9661. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9662. /// <param name="source">Source observable sequence.</param>
  9663. /// <param name="initialValue">Initial value that will be yielded by the enumerable sequence if no element has been sampled yet.</param>
  9664. /// <returns>The enumerable sequence that returns the last sampled element upon each iteration.</returns>
  9665. /// <exception cref="ArgumentNullException">
  9666. /// <paramref name="source" /> is null.</exception>
  9667. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9668. public static IQueryable<TSource> MostRecent<TSource>(this IQbservable<TSource> source, TSource initialValue)
  9669. {
  9670. if (source == null)
  9671. throw new ArgumentNullException(nameof(source));
  9672. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9673. Expression.Call(
  9674. null,
  9675. #if CRIPPLED_REFLECTION
  9676. InfoOf(() => Qbservable.MostRecent<TSource>(default(IQbservable<TSource>), default(TSource))),
  9677. #else
  9678. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9679. #endif
  9680. source.Expression,
  9681. Expression.Constant(initialValue, typeof(TSource))
  9682. )
  9683. );
  9684. }
  9685. /// <summary>
  9686. /// Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
  9687. /// subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
  9688. /// invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
  9689. /// </summary>
  9690. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9691. /// <typeparam name="TIntermediate">The type of the elements produced by the intermediate subject.</typeparam>
  9692. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9693. /// <param name="source">Source sequence which will be multicasted in the specified selector function.</param>
  9694. /// <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>
  9695. /// <param name="selector">Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject.</param>
  9696. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9697. /// <exception cref="ArgumentNullException">
  9698. /// <paramref name="source" /> or <paramref name="subjectSelector" /> or <paramref name="selector" /> is null.</exception>
  9699. 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)
  9700. {
  9701. if (source == null)
  9702. throw new ArgumentNullException(nameof(source));
  9703. if (subjectSelector == null)
  9704. throw new ArgumentNullException(nameof(subjectSelector));
  9705. if (selector == null)
  9706. throw new ArgumentNullException(nameof(selector));
  9707. return source.Provider.CreateQuery<TResult>(
  9708. Expression.Call(
  9709. null,
  9710. #if CRIPPLED_REFLECTION
  9711. InfoOf(() => Qbservable.Multicast<TSource, TIntermediate, TResult>(default(IQbservable<TSource>), default(Expression<Func<ISubject<TSource, TIntermediate>>>), default(Expression<Func<IObservable<TIntermediate>, IObservable<TResult>>>))),
  9712. #else
  9713. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TIntermediate), typeof(TResult)),
  9714. #endif
  9715. source.Expression,
  9716. subjectSelector,
  9717. selector
  9718. )
  9719. );
  9720. }
  9721. /// <summary>
  9722. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9723. /// </summary>
  9724. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9725. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  9726. /// <returns>An observable sequence whose observers will never get called.</returns>
  9727. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider)
  9728. {
  9729. if (provider == null)
  9730. throw new ArgumentNullException(nameof(provider));
  9731. return provider.CreateQuery<TResult>(
  9732. Expression.Call(
  9733. null,
  9734. #if CRIPPLED_REFLECTION
  9735. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider))),
  9736. #else
  9737. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9738. #endif
  9739. Expression.Constant(provider, typeof(IQbservableProvider))
  9740. )
  9741. );
  9742. }
  9743. /// <summary>
  9744. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9745. /// </summary>
  9746. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9747. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  9748. /// <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>
  9749. /// <returns>An observable sequence whose observers will never get called.</returns>
  9750. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider, TResult witness)
  9751. {
  9752. if (provider == null)
  9753. throw new ArgumentNullException(nameof(provider));
  9754. return provider.CreateQuery<TResult>(
  9755. Expression.Call(
  9756. null,
  9757. #if CRIPPLED_REFLECTION
  9758. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider), default(TResult))),
  9759. #else
  9760. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9761. #endif
  9762. Expression.Constant(provider, typeof(IQbservableProvider)),
  9763. Expression.Constant(witness, typeof(TResult))
  9764. )
  9765. );
  9766. }
  9767. /// <summary>
  9768. /// Returns an enumerable sequence whose enumeration blocks until the next element in the source observable sequence becomes available.
  9769. /// Enumerators on the resulting sequence will block until the next element becomes available.
  9770. /// </summary>
  9771. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9772. /// <param name="source">Source observable sequence.</param>
  9773. /// <returns>The enumerable sequence that blocks upon each iteration until the next element in the observable source sequence becomes available.</returns>
  9774. /// <exception cref="ArgumentNullException">
  9775. /// <paramref name="source" /> is null.</exception>
  9776. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9777. public static IQueryable<TSource> Next<TSource>(this IQbservable<TSource> source)
  9778. {
  9779. if (source == null)
  9780. throw new ArgumentNullException(nameof(source));
  9781. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9782. Expression.Call(
  9783. null,
  9784. #if CRIPPLED_REFLECTION
  9785. InfoOf(() => Qbservable.Next<TSource>(default(IQbservable<TSource>))),
  9786. #else
  9787. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9788. #endif
  9789. source.Expression
  9790. )
  9791. );
  9792. }
  9793. /// <summary>
  9794. /// Wraps the source sequence in order to run its observer callbacks on the specified synchronization context.
  9795. /// </summary>
  9796. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9797. /// <param name="source">Source sequence.</param>
  9798. /// <param name="context">Synchronization context to notify observers on.</param>
  9799. /// <returns>The source sequence whose observations happen on the specified synchronization context.</returns>
  9800. /// <exception cref="ArgumentNullException">
  9801. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  9802. /// <remarks>
  9803. /// This only invokes observer callbacks on a synchronization context. In case the subscription and/or unsubscription actions have side-effects
  9804. /// 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)" />.
  9805. /// </remarks>
  9806. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  9807. {
  9808. if (source == null)
  9809. throw new ArgumentNullException(nameof(source));
  9810. if (context == null)
  9811. throw new ArgumentNullException(nameof(context));
  9812. return source.Provider.CreateQuery<TSource>(
  9813. Expression.Call(
  9814. null,
  9815. #if CRIPPLED_REFLECTION
  9816. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  9817. #else
  9818. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9819. #endif
  9820. source.Expression,
  9821. Expression.Constant(context, typeof(SynchronizationContext))
  9822. )
  9823. );
  9824. }
  9825. /// <summary>
  9826. /// Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
  9827. /// </summary>
  9828. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9829. /// <param name="source">Source sequence.</param>
  9830. /// <param name="scheduler">Scheduler to notify observers on.</param>
  9831. /// <returns>The source sequence whose observations happen on the specified scheduler.</returns>
  9832. /// <exception cref="ArgumentNullException">
  9833. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  9834. /// <remarks>
  9835. /// This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
  9836. /// 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)" />.
  9837. /// </remarks>
  9838. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  9839. {
  9840. if (source == null)
  9841. throw new ArgumentNullException(nameof(source));
  9842. if (scheduler == null)
  9843. throw new ArgumentNullException(nameof(scheduler));
  9844. return source.Provider.CreateQuery<TSource>(
  9845. Expression.Call(
  9846. null,
  9847. #if CRIPPLED_REFLECTION
  9848. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  9849. #else
  9850. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9851. #endif
  9852. source.Expression,
  9853. Expression.Constant(scheduler, typeof(IScheduler))
  9854. )
  9855. );
  9856. }
  9857. /// <summary>
  9858. /// Filters the elements of an observable sequence based on the specified type.
  9859. /// </summary>
  9860. /// <typeparam name="TResult">The type to filter the elements in the source sequence on.</typeparam>
  9861. /// <param name="source">The observable sequence that contains the elements to be filtered.</param>
  9862. /// <returns>An observable sequence that contains elements from the input sequence of type TResult.</returns>
  9863. /// <exception cref="ArgumentNullException">
  9864. /// <paramref name="source" /> is null.</exception>
  9865. public static IQbservable<TResult> OfType<TResult>(this IQbservable<object> source)
  9866. {
  9867. if (source == null)
  9868. throw new ArgumentNullException(nameof(source));
  9869. return source.Provider.CreateQuery<TResult>(
  9870. Expression.Call(
  9871. null,
  9872. #if CRIPPLED_REFLECTION
  9873. InfoOf(() => Qbservable.OfType<TResult>(default(IQbservable<object>))),
  9874. #else
  9875. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9876. #endif
  9877. source.Expression
  9878. )
  9879. );
  9880. }
  9881. /// <summary>
  9882. /// Concatenates the second observable sequence to the first observable sequence upon successful or exceptional termination of the first.
  9883. /// </summary>
  9884. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9885. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  9886. /// <param name="second">Second observable sequence used to produce results after the first sequence terminates.</param>
  9887. /// <returns>An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.</returns>
  9888. /// <exception cref="ArgumentNullException">
  9889. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  9890. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  9891. {
  9892. if (first == null)
  9893. throw new ArgumentNullException(nameof(first));
  9894. if (second == null)
  9895. throw new ArgumentNullException(nameof(second));
  9896. return first.Provider.CreateQuery<TSource>(
  9897. Expression.Call(
  9898. null,
  9899. #if CRIPPLED_REFLECTION
  9900. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  9901. #else
  9902. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9903. #endif
  9904. first.Expression,
  9905. GetSourceExpression(second)
  9906. )
  9907. );
  9908. }
  9909. /// <summary>
  9910. /// Concatenates all of the specified observable sequences, even if the previous observable sequence terminated exceptionally.
  9911. /// </summary>
  9912. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9913. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9914. /// <param name="sources">Observable sequences to concatenate.</param>
  9915. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  9916. /// <exception cref="ArgumentNullException">
  9917. /// <paramref name="sources" /> is null.</exception>
  9918. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  9919. {
  9920. if (provider == null)
  9921. throw new ArgumentNullException(nameof(provider));
  9922. if (sources == null)
  9923. throw new ArgumentNullException(nameof(sources));
  9924. return provider.CreateQuery<TSource>(
  9925. Expression.Call(
  9926. null,
  9927. #if CRIPPLED_REFLECTION
  9928. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  9929. #else
  9930. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9931. #endif
  9932. Expression.Constant(provider, typeof(IQbservableProvider)),
  9933. GetSourceExpression(sources)
  9934. )
  9935. );
  9936. }
  9937. /// <summary>
  9938. /// Concatenates all observable sequences in the given enumerable sequence, even if the previous observable sequence terminated exceptionally.
  9939. /// </summary>
  9940. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9941. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9942. /// <param name="sources">Observable sequences to concatenate.</param>
  9943. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  9944. /// <exception cref="ArgumentNullException">
  9945. /// <paramref name="sources" /> is null.</exception>
  9946. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  9947. {
  9948. if (provider == null)
  9949. throw new ArgumentNullException(nameof(provider));
  9950. if (sources == null)
  9951. throw new ArgumentNullException(nameof(sources));
  9952. return provider.CreateQuery<TSource>(
  9953. Expression.Call(
  9954. null,
  9955. #if CRIPPLED_REFLECTION
  9956. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  9957. #else
  9958. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9959. #endif
  9960. Expression.Constant(provider, typeof(IQbservableProvider)),
  9961. GetSourceExpression(sources)
  9962. )
  9963. );
  9964. }
  9965. /// <summary>
  9966. /// Prepend a value to an observable sequence.
  9967. /// </summary>
  9968. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9969. /// <param name="source">Source sequence to prepend the value to.</param>
  9970. /// <param name="value">Value to prepend to the specified sequence.</param>
  9971. /// <returns>The source sequence prepended with the specified value.</returns>
  9972. /// <exception cref="ArgumentNullException">
  9973. /// <paramref name="source" /> is null.</exception>
  9974. public static IQbservable<TSource> Prepend<TSource>(this IQbservable<TSource> source, TSource value)
  9975. {
  9976. if (source == null)
  9977. throw new ArgumentNullException(nameof(source));
  9978. return source.Provider.CreateQuery<TSource>(
  9979. Expression.Call(
  9980. null,
  9981. #if CRIPPLED_REFLECTION
  9982. InfoOf(() => Qbservable.Prepend<TSource>(default(IQbservable<TSource>), default(TSource))),
  9983. #else
  9984. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9985. #endif
  9986. source.Expression,
  9987. Expression.Constant(value, typeof(TSource))
  9988. )
  9989. );
  9990. }
  9991. /// <summary>
  9992. /// Prepend a value to an observable sequence.
  9993. /// </summary>
  9994. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9995. /// <param name="source">Source sequence to prepend the value to.</param>
  9996. /// <param name="value">Value to prepend to the specified sequence.</param>
  9997. /// <param name="scheduler">Scheduler to emit the prepend values on.</param>
  9998. /// <returns>The source sequence prepended with the specified value.</returns>
  9999. /// <exception cref="ArgumentNullException">
  10000. /// <paramref name="source" /> is null.</exception>
  10001. public static IQbservable<TSource> Prepend<TSource>(this IQbservable<TSource> source, TSource value, IScheduler scheduler)
  10002. {
  10003. if (source == null)
  10004. throw new ArgumentNullException(nameof(source));
  10005. if (scheduler == null)
  10006. throw new ArgumentNullException(nameof(scheduler));
  10007. return source.Provider.CreateQuery<TSource>(
  10008. Expression.Call(
  10009. null,
  10010. #if CRIPPLED_REFLECTION
  10011. InfoOf(() => Qbservable.Prepend<TSource>(default(IQbservable<TSource>), default(TSource), default(IScheduler))),
  10012. #else
  10013. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10014. #endif
  10015. source.Expression,
  10016. Expression.Constant(value, typeof(TSource)),
  10017. Expression.Constant(scheduler, typeof(IScheduler))
  10018. )
  10019. );
  10020. }
  10021. /// <summary>
  10022. /// 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.
  10023. /// This operator is a specialization of Multicast using a regular <see cref="T:System.Reactive.Subjects.Subject`1" />.
  10024. /// </summary>
  10025. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10026. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10027. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10028. /// <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>
  10029. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10030. /// <exception cref="ArgumentNullException">
  10031. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10032. /// <seealso cref="T:System.Reactive.Subjects.Subject`1" />
  10033. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10034. {
  10035. if (source == null)
  10036. throw new ArgumentNullException(nameof(source));
  10037. if (selector == null)
  10038. throw new ArgumentNullException(nameof(selector));
  10039. return source.Provider.CreateQuery<TResult>(
  10040. Expression.Call(
  10041. null,
  10042. #if CRIPPLED_REFLECTION
  10043. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10044. #else
  10045. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10046. #endif
  10047. source.Expression,
  10048. selector
  10049. )
  10050. );
  10051. }
  10052. /// <summary>
  10053. /// 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.
  10054. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.BehaviorSubject`1" />.
  10055. /// </summary>
  10056. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10057. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10058. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10059. /// <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>
  10060. /// <param name="initialValue">Initial value received by observers upon subscription.</param>
  10061. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10062. /// <exception cref="ArgumentNullException">
  10063. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10064. /// <seealso cref="T:System.Reactive.Subjects.BehaviorSubject`1" />
  10065. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TSource initialValue)
  10066. {
  10067. if (source == null)
  10068. throw new ArgumentNullException(nameof(source));
  10069. if (selector == null)
  10070. throw new ArgumentNullException(nameof(selector));
  10071. return source.Provider.CreateQuery<TResult>(
  10072. Expression.Call(
  10073. null,
  10074. #if CRIPPLED_REFLECTION
  10075. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TSource))),
  10076. #else
  10077. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10078. #endif
  10079. source.Expression,
  10080. selector,
  10081. Expression.Constant(initialValue, typeof(TSource))
  10082. )
  10083. );
  10084. }
  10085. /// <summary>
  10086. /// 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.
  10087. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.AsyncSubject`1" />.
  10088. /// </summary>
  10089. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10090. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10091. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10092. /// <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>
  10093. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10094. /// <exception cref="ArgumentNullException">
  10095. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10096. /// <seealso cref="T:System.Reactive.Subjects.AsyncSubject`1" />
  10097. public static IQbservable<TResult> PublishLast<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10098. {
  10099. if (source == null)
  10100. throw new ArgumentNullException(nameof(source));
  10101. if (selector == null)
  10102. throw new ArgumentNullException(nameof(selector));
  10103. return source.Provider.CreateQuery<TResult>(
  10104. Expression.Call(
  10105. null,
  10106. #if CRIPPLED_REFLECTION
  10107. InfoOf(() => Qbservable.PublishLast<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10108. #else
  10109. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10110. #endif
  10111. source.Expression,
  10112. selector
  10113. )
  10114. );
  10115. }
  10116. /// <summary>
  10117. /// Generates an observable sequence of integral numbers within a specified range.
  10118. /// </summary>
  10119. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10120. /// <param name="start">The value of the first integer in the sequence.</param>
  10121. /// <param name="count">The number of sequential integers to generate.</param>
  10122. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10123. /// <exception cref="ArgumentOutOfRangeException">
  10124. /// <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>
  10125. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count)
  10126. {
  10127. if (provider == null)
  10128. throw new ArgumentNullException(nameof(provider));
  10129. return provider.CreateQuery<int>(
  10130. Expression.Call(
  10131. null,
  10132. #if CRIPPLED_REFLECTION
  10133. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int))),
  10134. #else
  10135. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10136. #endif
  10137. Expression.Constant(provider, typeof(IQbservableProvider)),
  10138. Expression.Constant(start, typeof(int)),
  10139. Expression.Constant(count, typeof(int))
  10140. )
  10141. );
  10142. }
  10143. /// <summary>
  10144. /// Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
  10145. /// </summary>
  10146. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10147. /// <param name="start">The value of the first integer in the sequence.</param>
  10148. /// <param name="count">The number of sequential integers to generate.</param>
  10149. /// <param name="scheduler">Scheduler to run the generator loop on.</param>
  10150. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10151. /// <exception cref="ArgumentOutOfRangeException">
  10152. /// <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>
  10153. /// <exception cref="ArgumentNullException">
  10154. /// <paramref name="scheduler" /> is null.</exception>
  10155. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count, IScheduler scheduler)
  10156. {
  10157. if (provider == null)
  10158. throw new ArgumentNullException(nameof(provider));
  10159. if (scheduler == null)
  10160. throw new ArgumentNullException(nameof(scheduler));
  10161. return provider.CreateQuery<int>(
  10162. Expression.Call(
  10163. null,
  10164. #if CRIPPLED_REFLECTION
  10165. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int), default(IScheduler))),
  10166. #else
  10167. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10168. #endif
  10169. Expression.Constant(provider, typeof(IQbservableProvider)),
  10170. Expression.Constant(start, typeof(int)),
  10171. Expression.Constant(count, typeof(int)),
  10172. Expression.Constant(scheduler, typeof(IScheduler))
  10173. )
  10174. );
  10175. }
  10176. /// <summary>
  10177. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10178. /// </summary>
  10179. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10180. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10181. /// <param name="source">Connectable observable sequence.</param>
  10182. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10183. /// <exception cref="ArgumentNullException">
  10184. /// <paramref name="source" /> is null.</exception>
  10185. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source)
  10186. {
  10187. if (provider == null)
  10188. throw new ArgumentNullException(nameof(provider));
  10189. if (source == null)
  10190. throw new ArgumentNullException(nameof(source));
  10191. return provider.CreateQuery<TSource>(
  10192. Expression.Call(
  10193. null,
  10194. #if CRIPPLED_REFLECTION
  10195. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>))),
  10196. #else
  10197. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10198. #endif
  10199. Expression.Constant(provider, typeof(IQbservableProvider)),
  10200. Expression.Constant(source, typeof(IConnectableObservable<TSource>))
  10201. )
  10202. );
  10203. }
  10204. /// <summary>
  10205. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10206. /// </summary>
  10207. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10208. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10209. /// <param name="source">Connectable observable sequence.</param>
  10210. /// <param name="disconnectDelay">The time span that should be waited before possibly unsubscribing from the connectable observable.</param>
  10211. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10212. /// <exception cref="ArgumentNullException">
  10213. /// <paramref name="source" /> is null.</exception>
  10214. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, TimeSpan disconnectDelay)
  10215. {
  10216. if (provider == null)
  10217. throw new ArgumentNullException(nameof(provider));
  10218. if (source == null)
  10219. throw new ArgumentNullException(nameof(source));
  10220. return provider.CreateQuery<TSource>(
  10221. Expression.Call(
  10222. null,
  10223. #if CRIPPLED_REFLECTION
  10224. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(TimeSpan))),
  10225. #else
  10226. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10227. #endif
  10228. Expression.Constant(provider, typeof(IQbservableProvider)),
  10229. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  10230. Expression.Constant(disconnectDelay, typeof(TimeSpan))
  10231. )
  10232. );
  10233. }
  10234. /// <summary>
  10235. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10236. /// </summary>
  10237. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10238. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10239. /// <param name="source">Connectable observable sequence.</param>
  10240. /// <param name="disconnectDelay">The time span that should be waited before possibly unsubscribing from the connectable observable.</param>
  10241. /// <param name="scheduler">The scheduler to use for delayed unsubscription.</param>
  10242. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10243. /// <exception cref="ArgumentNullException">
  10244. /// <paramref name="source" /> is null.</exception>
  10245. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, TimeSpan disconnectDelay, IScheduler scheduler)
  10246. {
  10247. if (provider == null)
  10248. throw new ArgumentNullException(nameof(provider));
  10249. if (source == null)
  10250. throw new ArgumentNullException(nameof(source));
  10251. if (scheduler == null)
  10252. throw new ArgumentNullException(nameof(scheduler));
  10253. return provider.CreateQuery<TSource>(
  10254. Expression.Call(
  10255. null,
  10256. #if CRIPPLED_REFLECTION
  10257. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(TimeSpan), default(IScheduler))),
  10258. #else
  10259. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10260. #endif
  10261. Expression.Constant(provider, typeof(IQbservableProvider)),
  10262. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  10263. Expression.Constant(disconnectDelay, typeof(TimeSpan)),
  10264. Expression.Constant(scheduler, typeof(IScheduler))
  10265. )
  10266. );
  10267. }
  10268. /// <summary>
  10269. /// Generates an observable sequence that repeats the given element infinitely.
  10270. /// </summary>
  10271. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10272. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10273. /// <param name="value">Element to repeat.</param>
  10274. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10275. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value)
  10276. {
  10277. if (provider == null)
  10278. throw new ArgumentNullException(nameof(provider));
  10279. return provider.CreateQuery<TResult>(
  10280. Expression.Call(
  10281. null,
  10282. #if CRIPPLED_REFLECTION
  10283. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult))),
  10284. #else
  10285. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10286. #endif
  10287. Expression.Constant(provider, typeof(IQbservableProvider)),
  10288. Expression.Constant(value, typeof(TResult))
  10289. )
  10290. );
  10291. }
  10292. /// <summary>
  10293. /// Generates an observable sequence that repeats the given element the specified number of times.
  10294. /// </summary>
  10295. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10296. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10297. /// <param name="value">Element to repeat.</param>
  10298. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10299. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10300. /// <exception cref="ArgumentOutOfRangeException">
  10301. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10302. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount)
  10303. {
  10304. if (provider == null)
  10305. throw new ArgumentNullException(nameof(provider));
  10306. return provider.CreateQuery<TResult>(
  10307. Expression.Call(
  10308. null,
  10309. #if CRIPPLED_REFLECTION
  10310. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int))),
  10311. #else
  10312. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10313. #endif
  10314. Expression.Constant(provider, typeof(IQbservableProvider)),
  10315. Expression.Constant(value, typeof(TResult)),
  10316. Expression.Constant(repeatCount, typeof(int))
  10317. )
  10318. );
  10319. }
  10320. /// <summary>
  10321. /// Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
  10322. /// </summary>
  10323. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10324. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10325. /// <param name="value">Element to repeat.</param>
  10326. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10327. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10328. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10329. /// <exception cref="ArgumentOutOfRangeException">
  10330. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10331. /// <exception cref="ArgumentNullException">
  10332. /// <paramref name="scheduler" /> is null.</exception>
  10333. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount, IScheduler scheduler)
  10334. {
  10335. if (provider == null)
  10336. throw new ArgumentNullException(nameof(provider));
  10337. if (scheduler == null)
  10338. throw new ArgumentNullException(nameof(scheduler));
  10339. return provider.CreateQuery<TResult>(
  10340. Expression.Call(
  10341. null,
  10342. #if CRIPPLED_REFLECTION
  10343. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int), default(IScheduler))),
  10344. #else
  10345. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10346. #endif
  10347. Expression.Constant(provider, typeof(IQbservableProvider)),
  10348. Expression.Constant(value, typeof(TResult)),
  10349. Expression.Constant(repeatCount, typeof(int)),
  10350. Expression.Constant(scheduler, typeof(IScheduler))
  10351. )
  10352. );
  10353. }
  10354. /// <summary>
  10355. /// Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.
  10356. /// </summary>
  10357. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10358. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10359. /// <param name="value">Element to repeat.</param>
  10360. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10361. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10362. /// <exception cref="ArgumentNullException">
  10363. /// <paramref name="scheduler" /> is null.</exception>
  10364. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10365. {
  10366. if (provider == null)
  10367. throw new ArgumentNullException(nameof(provider));
  10368. if (scheduler == null)
  10369. throw new ArgumentNullException(nameof(scheduler));
  10370. return provider.CreateQuery<TResult>(
  10371. Expression.Call(
  10372. null,
  10373. #if CRIPPLED_REFLECTION
  10374. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10375. #else
  10376. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10377. #endif
  10378. Expression.Constant(provider, typeof(IQbservableProvider)),
  10379. Expression.Constant(value, typeof(TResult)),
  10380. Expression.Constant(scheduler, typeof(IScheduler))
  10381. )
  10382. );
  10383. }
  10384. /// <summary>
  10385. /// Repeats the observable sequence indefinitely.
  10386. /// </summary>
  10387. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10388. /// <param name="source">Observable sequence to repeat.</param>
  10389. /// <returns>The observable sequence producing the elements of the given sequence repeatedly and sequentially.</returns>
  10390. /// <exception cref="ArgumentNullException">
  10391. /// <paramref name="source" /> is null.</exception>
  10392. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source)
  10393. {
  10394. if (source == null)
  10395. throw new ArgumentNullException(nameof(source));
  10396. return source.Provider.CreateQuery<TSource>(
  10397. Expression.Call(
  10398. null,
  10399. #if CRIPPLED_REFLECTION
  10400. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>))),
  10401. #else
  10402. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10403. #endif
  10404. source.Expression
  10405. )
  10406. );
  10407. }
  10408. /// <summary>
  10409. /// Repeats the observable sequence a specified number of times.
  10410. /// </summary>
  10411. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10412. /// <param name="source">Observable sequence to repeat.</param>
  10413. /// <param name="repeatCount">Number of times to repeat the sequence.</param>
  10414. /// <returns>The observable sequence producing the elements of the given sequence repeatedly.</returns>
  10415. /// <exception cref="ArgumentNullException">
  10416. /// <paramref name="source" /> is null.</exception>
  10417. /// <exception cref="ArgumentOutOfRangeException">
  10418. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10419. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source, int repeatCount)
  10420. {
  10421. if (source == null)
  10422. throw new ArgumentNullException(nameof(source));
  10423. return source.Provider.CreateQuery<TSource>(
  10424. Expression.Call(
  10425. null,
  10426. #if CRIPPLED_REFLECTION
  10427. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>), default(int))),
  10428. #else
  10429. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10430. #endif
  10431. source.Expression,
  10432. Expression.Constant(repeatCount, typeof(int))
  10433. )
  10434. );
  10435. }
  10436. /// <summary>
  10437. /// Repeatedly resubscribes to the source observable after a normal completion and when the observable
  10438. /// returned by a handler produces an arbitrary item.
  10439. /// </summary>
  10440. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10441. /// <typeparam name="TSignal">The arbitrary element type signaled by the handler observable.</typeparam>
  10442. /// <param name="source">Observable sequence to keep repeating when it successfully terminates.</param>
  10443. /// <param name="handler">The function that is called for each observer and takes an observable sequence objects.
  10444. /// It should return an observable of arbitrary items that should signal that arbitrary item in
  10445. /// response to receiving the completion signal from the source observable. If this observable signals
  10446. /// a terminal event, the sequence is terminated with that signal instead.</param>
  10447. /// <returns>An observable sequence producing the elements of the given sequence repeatedly while each repetition terminates successfully.</returns>
  10448. /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
  10449. /// <exception cref="ArgumentNullException"><paramref name="handler"/> is null.</exception>
  10450. public static IQbservable<TSource> RepeatWhen<TSource, TSignal>(this IQbservable<TSource> source, Expression<Func<IObservable<object>, IObservable<TSignal>>> handler)
  10451. {
  10452. if (source == null)
  10453. throw new ArgumentNullException(nameof(source));
  10454. if (handler == null)
  10455. throw new ArgumentNullException(nameof(handler));
  10456. return source.Provider.CreateQuery<TSource>(
  10457. Expression.Call(
  10458. null,
  10459. #if CRIPPLED_REFLECTION
  10460. InfoOf(() => Qbservable.RepeatWhen<TSource, TSignal>(default(IQbservable<TSource>), default(Expression<Func<IObservable<object>, IObservable<TSignal>>>))),
  10461. #else
  10462. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSignal)),
  10463. #endif
  10464. source.Expression,
  10465. handler
  10466. )
  10467. );
  10468. }
  10469. /// <summary>
  10470. /// 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.
  10471. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10472. /// </summary>
  10473. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10474. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10475. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10476. /// <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>
  10477. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10478. /// <exception cref="ArgumentNullException">
  10479. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10480. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10481. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10482. {
  10483. if (source == null)
  10484. throw new ArgumentNullException(nameof(source));
  10485. if (selector == null)
  10486. throw new ArgumentNullException(nameof(selector));
  10487. return source.Provider.CreateQuery<TResult>(
  10488. Expression.Call(
  10489. null,
  10490. #if CRIPPLED_REFLECTION
  10491. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10492. #else
  10493. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10494. #endif
  10495. source.Expression,
  10496. selector
  10497. )
  10498. );
  10499. }
  10500. /// <summary>
  10501. /// 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.
  10502. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10503. /// </summary>
  10504. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10505. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10506. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10507. /// <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>
  10508. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10509. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10510. /// <exception cref="ArgumentNullException">
  10511. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10512. /// <exception cref="ArgumentOutOfRangeException">
  10513. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10514. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10515. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize)
  10516. {
  10517. if (source == null)
  10518. throw new ArgumentNullException(nameof(source));
  10519. if (selector == null)
  10520. throw new ArgumentNullException(nameof(selector));
  10521. return source.Provider.CreateQuery<TResult>(
  10522. Expression.Call(
  10523. null,
  10524. #if CRIPPLED_REFLECTION
  10525. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int))),
  10526. #else
  10527. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10528. #endif
  10529. source.Expression,
  10530. selector,
  10531. Expression.Constant(bufferSize, typeof(int))
  10532. )
  10533. );
  10534. }
  10535. /// <summary>
  10536. /// 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.
  10537. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10538. /// </summary>
  10539. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10540. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10541. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10542. /// <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>
  10543. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10544. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10545. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10546. /// <exception cref="ArgumentNullException">
  10547. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10548. /// <exception cref="ArgumentOutOfRangeException">
  10549. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10550. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10551. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, IScheduler scheduler)
  10552. {
  10553. if (source == null)
  10554. throw new ArgumentNullException(nameof(source));
  10555. if (selector == null)
  10556. throw new ArgumentNullException(nameof(selector));
  10557. if (scheduler == null)
  10558. throw new ArgumentNullException(nameof(scheduler));
  10559. return source.Provider.CreateQuery<TResult>(
  10560. Expression.Call(
  10561. null,
  10562. #if CRIPPLED_REFLECTION
  10563. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(IScheduler))),
  10564. #else
  10565. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10566. #endif
  10567. source.Expression,
  10568. selector,
  10569. Expression.Constant(bufferSize, typeof(int)),
  10570. Expression.Constant(scheduler, typeof(IScheduler))
  10571. )
  10572. );
  10573. }
  10574. /// <summary>
  10575. /// 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.
  10576. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10577. /// </summary>
  10578. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10579. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10580. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10581. /// <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>
  10582. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10583. /// <param name="window">Maximum time length of the replay buffer.</param>
  10584. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10585. /// <exception cref="ArgumentNullException">
  10586. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10587. /// <exception cref="ArgumentOutOfRangeException">
  10588. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10589. /// <exception cref="ArgumentOutOfRangeException">
  10590. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10591. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10592. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window)
  10593. {
  10594. if (source == null)
  10595. throw new ArgumentNullException(nameof(source));
  10596. if (selector == null)
  10597. throw new ArgumentNullException(nameof(selector));
  10598. return source.Provider.CreateQuery<TResult>(
  10599. Expression.Call(
  10600. null,
  10601. #if CRIPPLED_REFLECTION
  10602. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan))),
  10603. #else
  10604. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10605. #endif
  10606. source.Expression,
  10607. selector,
  10608. Expression.Constant(bufferSize, typeof(int)),
  10609. Expression.Constant(window, typeof(TimeSpan))
  10610. )
  10611. );
  10612. }
  10613. /// <summary>
  10614. /// 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.
  10615. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10616. /// </summary>
  10617. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10618. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10619. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10620. /// <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>
  10621. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10622. /// <param name="window">Maximum time length of the replay buffer.</param>
  10623. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10624. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10625. /// <exception cref="ArgumentNullException">
  10626. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10627. /// <exception cref="ArgumentOutOfRangeException">
  10628. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10629. /// <exception cref="ArgumentOutOfRangeException">
  10630. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10631. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10632. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window, IScheduler scheduler)
  10633. {
  10634. if (source == null)
  10635. throw new ArgumentNullException(nameof(source));
  10636. if (selector == null)
  10637. throw new ArgumentNullException(nameof(selector));
  10638. if (scheduler == null)
  10639. throw new ArgumentNullException(nameof(scheduler));
  10640. return source.Provider.CreateQuery<TResult>(
  10641. Expression.Call(
  10642. null,
  10643. #if CRIPPLED_REFLECTION
  10644. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan), default(IScheduler))),
  10645. #else
  10646. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10647. #endif
  10648. source.Expression,
  10649. selector,
  10650. Expression.Constant(bufferSize, typeof(int)),
  10651. Expression.Constant(window, typeof(TimeSpan)),
  10652. Expression.Constant(scheduler, typeof(IScheduler))
  10653. )
  10654. );
  10655. }
  10656. /// <summary>
  10657. /// 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.
  10658. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10659. /// </summary>
  10660. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10661. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10662. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10663. /// <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>
  10664. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10665. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10666. /// <exception cref="ArgumentNullException">
  10667. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10668. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10669. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, IScheduler scheduler)
  10670. {
  10671. if (source == null)
  10672. throw new ArgumentNullException(nameof(source));
  10673. if (selector == null)
  10674. throw new ArgumentNullException(nameof(selector));
  10675. if (scheduler == null)
  10676. throw new ArgumentNullException(nameof(scheduler));
  10677. return source.Provider.CreateQuery<TResult>(
  10678. Expression.Call(
  10679. null,
  10680. #if CRIPPLED_REFLECTION
  10681. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(IScheduler))),
  10682. #else
  10683. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10684. #endif
  10685. source.Expression,
  10686. selector,
  10687. Expression.Constant(scheduler, typeof(IScheduler))
  10688. )
  10689. );
  10690. }
  10691. /// <summary>
  10692. /// 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.
  10693. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10694. /// </summary>
  10695. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10696. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10697. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10698. /// <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>
  10699. /// <param name="window">Maximum time length of the replay buffer.</param>
  10700. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10701. /// <exception cref="ArgumentNullException">
  10702. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10703. /// <exception cref="ArgumentOutOfRangeException">
  10704. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10705. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10706. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window)
  10707. {
  10708. if (source == null)
  10709. throw new ArgumentNullException(nameof(source));
  10710. if (selector == null)
  10711. throw new ArgumentNullException(nameof(selector));
  10712. return source.Provider.CreateQuery<TResult>(
  10713. Expression.Call(
  10714. null,
  10715. #if CRIPPLED_REFLECTION
  10716. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan))),
  10717. #else
  10718. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10719. #endif
  10720. source.Expression,
  10721. selector,
  10722. Expression.Constant(window, typeof(TimeSpan))
  10723. )
  10724. );
  10725. }
  10726. /// <summary>
  10727. /// 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.
  10728. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10729. /// </summary>
  10730. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10731. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10732. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10733. /// <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>
  10734. /// <param name="window">Maximum time length of the replay buffer.</param>
  10735. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10736. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10737. /// <exception cref="ArgumentNullException">
  10738. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10739. /// <exception cref="ArgumentOutOfRangeException">
  10740. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10741. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10742. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window, IScheduler scheduler)
  10743. {
  10744. if (source == null)
  10745. throw new ArgumentNullException(nameof(source));
  10746. if (selector == null)
  10747. throw new ArgumentNullException(nameof(selector));
  10748. if (scheduler == null)
  10749. throw new ArgumentNullException(nameof(scheduler));
  10750. return source.Provider.CreateQuery<TResult>(
  10751. Expression.Call(
  10752. null,
  10753. #if CRIPPLED_REFLECTION
  10754. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan), default(IScheduler))),
  10755. #else
  10756. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10757. #endif
  10758. source.Expression,
  10759. selector,
  10760. Expression.Constant(window, typeof(TimeSpan)),
  10761. Expression.Constant(scheduler, typeof(IScheduler))
  10762. )
  10763. );
  10764. }
  10765. /// <summary>
  10766. /// Repeats the source observable sequence until it successfully terminates.
  10767. /// </summary>
  10768. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10769. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10770. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10771. /// <exception cref="ArgumentNullException">
  10772. /// <paramref name="source" /> is null.</exception>
  10773. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source)
  10774. {
  10775. if (source == null)
  10776. throw new ArgumentNullException(nameof(source));
  10777. return source.Provider.CreateQuery<TSource>(
  10778. Expression.Call(
  10779. null,
  10780. #if CRIPPLED_REFLECTION
  10781. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>))),
  10782. #else
  10783. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10784. #endif
  10785. source.Expression
  10786. )
  10787. );
  10788. }
  10789. /// <summary>
  10790. /// Repeats the source observable sequence the specified number of times or until it successfully terminates.
  10791. /// </summary>
  10792. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10793. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10794. /// <param name="retryCount">Number of times to repeat the sequence.</param>
  10795. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10796. /// <exception cref="ArgumentNullException">
  10797. /// <paramref name="source" /> is null.</exception>
  10798. /// <exception cref="ArgumentOutOfRangeException">
  10799. /// <paramref name="retryCount" /> is less than zero.</exception>
  10800. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source, int retryCount)
  10801. {
  10802. if (source == null)
  10803. throw new ArgumentNullException(nameof(source));
  10804. return source.Provider.CreateQuery<TSource>(
  10805. Expression.Call(
  10806. null,
  10807. #if CRIPPLED_REFLECTION
  10808. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>), default(int))),
  10809. #else
  10810. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10811. #endif
  10812. source.Expression,
  10813. Expression.Constant(retryCount, typeof(int))
  10814. )
  10815. );
  10816. }
  10817. /// <summary>
  10818. /// Retries (resubscribes to) the source observable after a failure and when the observable
  10819. /// returned by a handler produces an arbitrary item.
  10820. /// </summary>
  10821. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10822. /// <typeparam name="TSignal">The arbitrary element type signaled by the handler observable.</typeparam>
  10823. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10824. /// <param name="handler">The function that is called for each observer and takes an observable sequence of
  10825. /// errors. It should return an observable of arbitrary items that should signal that arbitrary item in
  10826. /// response to receiving the failure Exception from the source observable. If this observable signals
  10827. /// a terminal event, the sequence is terminated with that signal instead.</param>
  10828. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10829. /// <exception cref="ArgumentNullException">
  10830. /// <paramref name="source" /> is null.</exception>
  10831. /// <exception cref="ArgumentNullException">
  10832. /// <paramref name="handler" /> is null.</exception>
  10833. public static IQbservable<TSource> RetryWhen<TSource, TSignal>(this IQbservable<TSource> source, Expression<Func<IObservable<Exception>, IObservable<TSignal>>> handler)
  10834. {
  10835. if (source == null)
  10836. throw new ArgumentNullException(nameof(source));
  10837. if (handler == null)
  10838. throw new ArgumentNullException(nameof(handler));
  10839. return source.Provider.CreateQuery<TSource>(
  10840. Expression.Call(
  10841. null,
  10842. #if CRIPPLED_REFLECTION
  10843. InfoOf(() => Qbservable.RetryWhen<TSource, TSignal>(default(IQbservable<TSource>), default(Expression<Func<IObservable<Exception>, IObservable<TSignal>>>))),
  10844. #else
  10845. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSignal)),
  10846. #endif
  10847. source.Expression,
  10848. handler
  10849. )
  10850. );
  10851. }
  10852. /// <summary>
  10853. /// Returns an observable sequence that contains a single element.
  10854. /// </summary>
  10855. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10856. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  10857. /// <param name="value">Single element in the resulting observable sequence.</param>
  10858. /// <returns>An observable sequence containing the single specified element.</returns>
  10859. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value)
  10860. {
  10861. if (provider == null)
  10862. throw new ArgumentNullException(nameof(provider));
  10863. return provider.CreateQuery<TResult>(
  10864. Expression.Call(
  10865. null,
  10866. #if CRIPPLED_REFLECTION
  10867. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult))),
  10868. #else
  10869. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10870. #endif
  10871. Expression.Constant(provider, typeof(IQbservableProvider)),
  10872. Expression.Constant(value, typeof(TResult))
  10873. )
  10874. );
  10875. }
  10876. /// <summary>
  10877. /// Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
  10878. /// </summary>
  10879. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10880. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  10881. /// <param name="value">Single element in the resulting observable sequence.</param>
  10882. /// <param name="scheduler">Scheduler to send the single element on.</param>
  10883. /// <returns>An observable sequence containing the single specified element.</returns>
  10884. /// <exception cref="ArgumentNullException">
  10885. /// <paramref name="scheduler" /> is null.</exception>
  10886. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10887. {
  10888. if (provider == null)
  10889. throw new ArgumentNullException(nameof(provider));
  10890. if (scheduler == null)
  10891. throw new ArgumentNullException(nameof(scheduler));
  10892. return provider.CreateQuery<TResult>(
  10893. Expression.Call(
  10894. null,
  10895. #if CRIPPLED_REFLECTION
  10896. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10897. #else
  10898. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10899. #endif
  10900. Expression.Constant(provider, typeof(IQbservableProvider)),
  10901. Expression.Constant(value, typeof(TResult)),
  10902. Expression.Constant(scheduler, typeof(IScheduler))
  10903. )
  10904. );
  10905. }
  10906. /// <summary>
  10907. /// Samples the observable sequence at each interval.
  10908. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10909. /// </summary>
  10910. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10911. /// <param name="source">Source sequence to sample.</param>
  10912. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  10913. /// <returns>Sampled observable sequence.</returns>
  10914. /// <exception cref="ArgumentNullException">
  10915. /// <paramref name="source" /> is null.</exception>
  10916. /// <exception cref="ArgumentOutOfRangeException">
  10917. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  10918. /// <remarks>
  10919. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  10920. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  10921. /// </remarks>
  10922. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval)
  10923. {
  10924. if (source == null)
  10925. throw new ArgumentNullException(nameof(source));
  10926. return source.Provider.CreateQuery<TSource>(
  10927. Expression.Call(
  10928. null,
  10929. #if CRIPPLED_REFLECTION
  10930. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  10931. #else
  10932. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10933. #endif
  10934. source.Expression,
  10935. Expression.Constant(interval, typeof(TimeSpan))
  10936. )
  10937. );
  10938. }
  10939. /// <summary>
  10940. /// Samples the observable sequence at each interval, using the specified scheduler to run sampling timers.
  10941. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10942. /// </summary>
  10943. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10944. /// <param name="source">Source sequence to sample.</param>
  10945. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  10946. /// <param name="scheduler">Scheduler to run the sampling timer on.</param>
  10947. /// <returns>Sampled observable sequence.</returns>
  10948. /// <exception cref="ArgumentNullException">
  10949. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  10950. /// <exception cref="ArgumentOutOfRangeException">
  10951. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  10952. /// <remarks>
  10953. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  10954. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  10955. /// </remarks>
  10956. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval, IScheduler scheduler)
  10957. {
  10958. if (source == null)
  10959. throw new ArgumentNullException(nameof(source));
  10960. if (scheduler == null)
  10961. throw new ArgumentNullException(nameof(scheduler));
  10962. return source.Provider.CreateQuery<TSource>(
  10963. Expression.Call(
  10964. null,
  10965. #if CRIPPLED_REFLECTION
  10966. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  10967. #else
  10968. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10969. #endif
  10970. source.Expression,
  10971. Expression.Constant(interval, typeof(TimeSpan)),
  10972. Expression.Constant(scheduler, typeof(IScheduler))
  10973. )
  10974. );
  10975. }
  10976. /// <summary>
  10977. /// Samples the source observable sequence using a sampler observable sequence producing sampling ticks.
  10978. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10979. /// </summary>
  10980. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10981. /// <typeparam name="TSample">The type of the elements in the sampling sequence.</typeparam>
  10982. /// <param name="source">Source sequence to sample.</param>
  10983. /// <param name="sampler">Sampling tick sequence.</param>
  10984. /// <returns>Sampled observable sequence.</returns>
  10985. /// <exception cref="ArgumentNullException">
  10986. /// <paramref name="source" /> or <paramref name="sampler" /> is null.</exception>
  10987. public static IQbservable<TSource> Sample<TSource, TSample>(this IQbservable<TSource> source, IObservable<TSample> sampler)
  10988. {
  10989. if (source == null)
  10990. throw new ArgumentNullException(nameof(source));
  10991. if (sampler == null)
  10992. throw new ArgumentNullException(nameof(sampler));
  10993. return source.Provider.CreateQuery<TSource>(
  10994. Expression.Call(
  10995. null,
  10996. #if CRIPPLED_REFLECTION
  10997. InfoOf(() => Qbservable.Sample<TSource, TSample>(default(IQbservable<TSource>), default(IObservable<TSample>))),
  10998. #else
  10999. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSample)),
  11000. #endif
  11001. source.Expression,
  11002. GetSourceExpression(sampler)
  11003. )
  11004. );
  11005. }
  11006. /// <summary>
  11007. /// Applies an accumulator function over an observable sequence and returns each intermediate result.
  11008. /// 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})" />.
  11009. /// </summary>
  11010. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  11011. /// <param name="source">An observable sequence to accumulate over.</param>
  11012. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11013. /// <returns>An observable sequence containing the accumulated values.</returns>
  11014. /// <exception cref="ArgumentNullException">
  11015. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11016. public static IQbservable<TSource> Scan<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  11017. {
  11018. if (source == null)
  11019. throw new ArgumentNullException(nameof(source));
  11020. if (accumulator == null)
  11021. throw new ArgumentNullException(nameof(accumulator));
  11022. return source.Provider.CreateQuery<TSource>(
  11023. Expression.Call(
  11024. null,
  11025. #if CRIPPLED_REFLECTION
  11026. InfoOf(() => Qbservable.Scan<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  11027. #else
  11028. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11029. #endif
  11030. source.Expression,
  11031. accumulator
  11032. )
  11033. );
  11034. }
  11035. /// <summary>
  11036. /// Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
  11037. /// 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})" />.
  11038. /// </summary>
  11039. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11040. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  11041. /// <param name="source">An observable sequence to accumulate over.</param>
  11042. /// <param name="seed">The initial accumulator value.</param>
  11043. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11044. /// <returns>An observable sequence containing the accumulated values.</returns>
  11045. /// <exception cref="ArgumentNullException">
  11046. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11047. public static IQbservable<TAccumulate> Scan<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  11048. {
  11049. if (source == null)
  11050. throw new ArgumentNullException(nameof(source));
  11051. if (accumulator == null)
  11052. throw new ArgumentNullException(nameof(accumulator));
  11053. return source.Provider.CreateQuery<TAccumulate>(
  11054. Expression.Call(
  11055. null,
  11056. #if CRIPPLED_REFLECTION
  11057. InfoOf(() => Qbservable.Scan<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  11058. #else
  11059. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  11060. #endif
  11061. source.Expression,
  11062. Expression.Constant(seed, typeof(TAccumulate)),
  11063. accumulator
  11064. )
  11065. );
  11066. }
  11067. /// <summary>
  11068. /// Projects each element of an observable sequence into a new form.
  11069. /// </summary>
  11070. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11071. /// <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>
  11072. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11073. /// <param name="selector">A transform function to apply to each source element.</param>
  11074. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11075. /// <exception cref="ArgumentNullException">
  11076. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11077. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  11078. {
  11079. if (source == null)
  11080. throw new ArgumentNullException(nameof(source));
  11081. if (selector == null)
  11082. throw new ArgumentNullException(nameof(selector));
  11083. return source.Provider.CreateQuery<TResult>(
  11084. Expression.Call(
  11085. null,
  11086. #if CRIPPLED_REFLECTION
  11087. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  11088. #else
  11089. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11090. #endif
  11091. source.Expression,
  11092. selector
  11093. )
  11094. );
  11095. }
  11096. /// <summary>
  11097. /// Projects each element of an observable sequence into a new form by incorporating the element's index.
  11098. /// </summary>
  11099. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11100. /// <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>
  11101. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11102. /// <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>
  11103. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11104. /// <exception cref="ArgumentNullException">
  11105. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11106. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, TResult>> selector)
  11107. {
  11108. if (source == null)
  11109. throw new ArgumentNullException(nameof(source));
  11110. if (selector == null)
  11111. throw new ArgumentNullException(nameof(selector));
  11112. return source.Provider.CreateQuery<TResult>(
  11113. Expression.Call(
  11114. null,
  11115. #if CRIPPLED_REFLECTION
  11116. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, TResult>>))),
  11117. #else
  11118. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11119. #endif
  11120. source.Expression,
  11121. selector
  11122. )
  11123. );
  11124. }
  11125. /// <summary>
  11126. /// 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.
  11127. /// </summary>
  11128. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11129. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11130. /// <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>
  11131. /// <param name="source">An observable sequence of elements to project.</param>
  11132. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11133. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11134. /// <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>
  11135. /// <exception cref="ArgumentNullException">
  11136. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11137. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11138. {
  11139. if (source == null)
  11140. throw new ArgumentNullException(nameof(source));
  11141. if (collectionSelector == null)
  11142. throw new ArgumentNullException(nameof(collectionSelector));
  11143. if (resultSelector == null)
  11144. throw new ArgumentNullException(nameof(resultSelector));
  11145. return source.Provider.CreateQuery<TResult>(
  11146. Expression.Call(
  11147. null,
  11148. #if CRIPPLED_REFLECTION
  11149. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11150. #else
  11151. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11152. #endif
  11153. source.Expression,
  11154. collectionSelector,
  11155. resultSelector
  11156. )
  11157. );
  11158. }
  11159. /// <summary>
  11160. /// 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.
  11161. /// </summary>
  11162. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11163. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11164. /// <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>
  11165. /// <param name="source">An observable sequence of elements to project.</param>
  11166. /// <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>
  11167. /// <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>
  11168. /// <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>
  11169. /// <exception cref="ArgumentNullException">
  11170. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11171. 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)
  11172. {
  11173. if (source == null)
  11174. throw new ArgumentNullException(nameof(source));
  11175. if (collectionSelector == null)
  11176. throw new ArgumentNullException(nameof(collectionSelector));
  11177. if (resultSelector == null)
  11178. throw new ArgumentNullException(nameof(resultSelector));
  11179. return source.Provider.CreateQuery<TResult>(
  11180. Expression.Call(
  11181. null,
  11182. #if CRIPPLED_REFLECTION
  11183. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11184. #else
  11185. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11186. #endif
  11187. source.Expression,
  11188. collectionSelector,
  11189. resultSelector
  11190. )
  11191. );
  11192. }
  11193. /// <summary>
  11194. /// 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.
  11195. /// </summary>
  11196. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11197. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11198. /// <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>
  11199. /// <param name="source">An observable sequence of elements to project.</param>
  11200. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11201. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11202. /// <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>
  11203. /// <exception cref="ArgumentNullException">
  11204. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11205. /// <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>
  11206. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11207. {
  11208. if (source == null)
  11209. throw new ArgumentNullException(nameof(source));
  11210. if (collectionSelector == null)
  11211. throw new ArgumentNullException(nameof(collectionSelector));
  11212. if (resultSelector == null)
  11213. throw new ArgumentNullException(nameof(resultSelector));
  11214. return source.Provider.CreateQuery<TResult>(
  11215. Expression.Call(
  11216. null,
  11217. #if CRIPPLED_REFLECTION
  11218. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11219. #else
  11220. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11221. #endif
  11222. source.Expression,
  11223. collectionSelector,
  11224. resultSelector
  11225. )
  11226. );
  11227. }
  11228. /// <summary>
  11229. /// 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.
  11230. /// </summary>
  11231. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11232. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11233. /// <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>
  11234. /// <param name="source">An observable sequence of elements to project.</param>
  11235. /// <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>
  11236. /// <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>
  11237. /// <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>
  11238. /// <exception cref="ArgumentNullException">
  11239. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11240. /// <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>
  11241. 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)
  11242. {
  11243. if (source == null)
  11244. throw new ArgumentNullException(nameof(source));
  11245. if (collectionSelector == null)
  11246. throw new ArgumentNullException(nameof(collectionSelector));
  11247. if (resultSelector == null)
  11248. throw new ArgumentNullException(nameof(resultSelector));
  11249. return source.Provider.CreateQuery<TResult>(
  11250. Expression.Call(
  11251. null,
  11252. #if CRIPPLED_REFLECTION
  11253. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11254. #else
  11255. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11256. #endif
  11257. source.Expression,
  11258. collectionSelector,
  11259. resultSelector
  11260. )
  11261. );
  11262. }
  11263. /// <summary>
  11264. /// Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  11265. /// </summary>
  11266. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11267. /// <typeparam name="TOther">The type of the elements in the other sequence and the elements in the result sequence.</typeparam>
  11268. /// <param name="source">An observable sequence of elements to project.</param>
  11269. /// <param name="other">An observable sequence to project each element from the source sequence onto.</param>
  11270. /// <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>
  11271. /// <exception cref="ArgumentNullException">
  11272. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  11273. public static IQbservable<TOther> SelectMany<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  11274. {
  11275. if (source == null)
  11276. throw new ArgumentNullException(nameof(source));
  11277. if (other == null)
  11278. throw new ArgumentNullException(nameof(other));
  11279. return source.Provider.CreateQuery<TOther>(
  11280. Expression.Call(
  11281. null,
  11282. #if CRIPPLED_REFLECTION
  11283. InfoOf(() => Qbservable.SelectMany<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  11284. #else
  11285. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  11286. #endif
  11287. source.Expression,
  11288. GetSourceExpression(other)
  11289. )
  11290. );
  11291. }
  11292. /// <summary>
  11293. /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11294. /// </summary>
  11295. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11296. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11297. /// <param name="source">An observable sequence of notifications to project.</param>
  11298. /// <param name="onNext">A transform function to apply to each element.</param>
  11299. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11300. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11301. /// <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>
  11302. /// <exception cref="ArgumentNullException">
  11303. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11304. 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)
  11305. {
  11306. if (source == null)
  11307. throw new ArgumentNullException(nameof(source));
  11308. if (onNext == null)
  11309. throw new ArgumentNullException(nameof(onNext));
  11310. if (onError == null)
  11311. throw new ArgumentNullException(nameof(onError));
  11312. if (onCompleted == null)
  11313. throw new ArgumentNullException(nameof(onCompleted));
  11314. return source.Provider.CreateQuery<TResult>(
  11315. Expression.Call(
  11316. null,
  11317. #if CRIPPLED_REFLECTION
  11318. 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>>>))),
  11319. #else
  11320. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11321. #endif
  11322. source.Expression,
  11323. onNext,
  11324. onError,
  11325. onCompleted
  11326. )
  11327. );
  11328. }
  11329. /// <summary>
  11330. /// 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.
  11331. /// </summary>
  11332. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11333. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11334. /// <param name="source">An observable sequence of notifications to project.</param>
  11335. /// <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>
  11336. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11337. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11338. /// <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>
  11339. /// <exception cref="ArgumentNullException">
  11340. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11341. 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)
  11342. {
  11343. if (source == null)
  11344. throw new ArgumentNullException(nameof(source));
  11345. if (onNext == null)
  11346. throw new ArgumentNullException(nameof(onNext));
  11347. if (onError == null)
  11348. throw new ArgumentNullException(nameof(onError));
  11349. if (onCompleted == null)
  11350. throw new ArgumentNullException(nameof(onCompleted));
  11351. return source.Provider.CreateQuery<TResult>(
  11352. Expression.Call(
  11353. null,
  11354. #if CRIPPLED_REFLECTION
  11355. 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>>>))),
  11356. #else
  11357. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11358. #endif
  11359. source.Expression,
  11360. onNext,
  11361. onError,
  11362. onCompleted
  11363. )
  11364. );
  11365. }
  11366. /// <summary>
  11367. /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11368. /// </summary>
  11369. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11370. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11371. /// <param name="source">An observable sequence of elements to project.</param>
  11372. /// <param name="selector">A transform function to apply to each element.</param>
  11373. /// <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>
  11374. /// <exception cref="ArgumentNullException">
  11375. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11376. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> selector)
  11377. {
  11378. if (source == null)
  11379. throw new ArgumentNullException(nameof(source));
  11380. if (selector == null)
  11381. throw new ArgumentNullException(nameof(selector));
  11382. return source.Provider.CreateQuery<TResult>(
  11383. Expression.Call(
  11384. null,
  11385. #if CRIPPLED_REFLECTION
  11386. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  11387. #else
  11388. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11389. #endif
  11390. source.Expression,
  11391. selector
  11392. )
  11393. );
  11394. }
  11395. /// <summary>
  11396. /// 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.
  11397. /// </summary>
  11398. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11399. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11400. /// <param name="source">An observable sequence of elements to project.</param>
  11401. /// <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>
  11402. /// <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>
  11403. /// <exception cref="ArgumentNullException">
  11404. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11405. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TResult>>> selector)
  11406. {
  11407. if (source == null)
  11408. throw new ArgumentNullException(nameof(source));
  11409. if (selector == null)
  11410. throw new ArgumentNullException(nameof(selector));
  11411. return source.Provider.CreateQuery<TResult>(
  11412. Expression.Call(
  11413. null,
  11414. #if CRIPPLED_REFLECTION
  11415. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>))),
  11416. #else
  11417. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11418. #endif
  11419. source.Expression,
  11420. selector
  11421. )
  11422. );
  11423. }
  11424. /// <summary>
  11425. /// Projects each element of an observable sequence to a task and merges all of the task results into one observable sequence.
  11426. /// </summary>
  11427. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11428. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11429. /// <param name="source">An observable sequence of elements to project.</param>
  11430. /// <param name="selector">A transform function to apply to each element.</param>
  11431. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11432. /// <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>
  11433. /// <exception cref="ArgumentNullException">
  11434. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11435. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TResult>>> selector)
  11436. {
  11437. if (source == null)
  11438. throw new ArgumentNullException(nameof(source));
  11439. if (selector == null)
  11440. throw new ArgumentNullException(nameof(selector));
  11441. return source.Provider.CreateQuery<TResult>(
  11442. Expression.Call(
  11443. null,
  11444. #if CRIPPLED_REFLECTION
  11445. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TResult>>>))),
  11446. #else
  11447. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11448. #endif
  11449. source.Expression,
  11450. selector
  11451. )
  11452. );
  11453. }
  11454. /// <summary>
  11455. /// 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.
  11456. /// </summary>
  11457. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11458. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11459. /// <param name="source">An observable sequence of elements to project.</param>
  11460. /// <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>
  11461. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11462. /// <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>
  11463. /// <exception cref="ArgumentNullException">
  11464. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11465. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, Task<TResult>>> selector)
  11466. {
  11467. if (source == null)
  11468. throw new ArgumentNullException(nameof(source));
  11469. if (selector == null)
  11470. throw new ArgumentNullException(nameof(selector));
  11471. return source.Provider.CreateQuery<TResult>(
  11472. Expression.Call(
  11473. null,
  11474. #if CRIPPLED_REFLECTION
  11475. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TResult>>>))),
  11476. #else
  11477. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11478. #endif
  11479. source.Expression,
  11480. selector
  11481. )
  11482. );
  11483. }
  11484. /// <summary>
  11485. /// Projects each element of an observable sequence to a task with cancellation support and merges all of the task results into one observable sequence.
  11486. /// </summary>
  11487. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11488. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11489. /// <param name="source">An observable sequence of elements to project.</param>
  11490. /// <param name="selector">A transform function to apply to each element.</param>
  11491. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11492. /// <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>
  11493. /// <exception cref="ArgumentNullException">
  11494. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11495. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, CancellationToken, Task<TResult>>> selector)
  11496. {
  11497. if (source == null)
  11498. throw new ArgumentNullException(nameof(source));
  11499. if (selector == null)
  11500. throw new ArgumentNullException(nameof(selector));
  11501. return source.Provider.CreateQuery<TResult>(
  11502. Expression.Call(
  11503. null,
  11504. #if CRIPPLED_REFLECTION
  11505. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TResult>>>))),
  11506. #else
  11507. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11508. #endif
  11509. source.Expression,
  11510. selector
  11511. )
  11512. );
  11513. }
  11514. /// <summary>
  11515. /// 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.
  11516. /// </summary>
  11517. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11518. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11519. /// <param name="source">An observable sequence of elements to project.</param>
  11520. /// <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>
  11521. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11522. /// <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>
  11523. /// <exception cref="ArgumentNullException">
  11524. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11525. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, CancellationToken, Task<TResult>>> selector)
  11526. {
  11527. if (source == null)
  11528. throw new ArgumentNullException(nameof(source));
  11529. if (selector == null)
  11530. throw new ArgumentNullException(nameof(selector));
  11531. return source.Provider.CreateQuery<TResult>(
  11532. Expression.Call(
  11533. null,
  11534. #if CRIPPLED_REFLECTION
  11535. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TResult>>>))),
  11536. #else
  11537. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11538. #endif
  11539. source.Expression,
  11540. selector
  11541. )
  11542. );
  11543. }
  11544. /// <summary>
  11545. /// Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.
  11546. /// </summary>
  11547. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11548. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11549. /// <param name="source">An observable sequence of elements to project.</param>
  11550. /// <param name="selector">A transform function to apply to each element.</param>
  11551. /// <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>
  11552. /// <exception cref="ArgumentNullException">
  11553. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11554. /// <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>
  11555. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector)
  11556. {
  11557. if (source == null)
  11558. throw new ArgumentNullException(nameof(source));
  11559. if (selector == null)
  11560. throw new ArgumentNullException(nameof(selector));
  11561. return source.Provider.CreateQuery<TResult>(
  11562. Expression.Call(
  11563. null,
  11564. #if CRIPPLED_REFLECTION
  11565. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TResult>>>))),
  11566. #else
  11567. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11568. #endif
  11569. source.Expression,
  11570. selector
  11571. )
  11572. );
  11573. }
  11574. /// <summary>
  11575. /// 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.
  11576. /// </summary>
  11577. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11578. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11579. /// <param name="source">An observable sequence of elements to project.</param>
  11580. /// <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>
  11581. /// <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>
  11582. /// <exception cref="ArgumentNullException">
  11583. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11584. /// <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>
  11585. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IEnumerable<TResult>>> selector)
  11586. {
  11587. if (source == null)
  11588. throw new ArgumentNullException(nameof(source));
  11589. if (selector == null)
  11590. throw new ArgumentNullException(nameof(selector));
  11591. return source.Provider.CreateQuery<TResult>(
  11592. Expression.Call(
  11593. null,
  11594. #if CRIPPLED_REFLECTION
  11595. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TResult>>>))),
  11596. #else
  11597. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11598. #endif
  11599. source.Expression,
  11600. selector
  11601. )
  11602. );
  11603. }
  11604. /// <summary>
  11605. /// 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.
  11606. /// </summary>
  11607. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11608. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11609. /// <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>
  11610. /// <param name="source">An observable sequence of elements to project.</param>
  11611. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11612. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11613. /// <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>
  11614. /// <exception cref="ArgumentNullException">
  11615. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11616. /// <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>
  11617. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, TTaskResult, TResult>> resultSelector)
  11618. {
  11619. if (source == null)
  11620. throw new ArgumentNullException(nameof(source));
  11621. if (taskSelector == null)
  11622. throw new ArgumentNullException(nameof(taskSelector));
  11623. if (resultSelector == null)
  11624. throw new ArgumentNullException(nameof(resultSelector));
  11625. return source.Provider.CreateQuery<TResult>(
  11626. Expression.Call(
  11627. null,
  11628. #if CRIPPLED_REFLECTION
  11629. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11630. #else
  11631. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11632. #endif
  11633. source.Expression,
  11634. taskSelector,
  11635. resultSelector
  11636. )
  11637. );
  11638. }
  11639. /// <summary>
  11640. /// 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.
  11641. /// </summary>
  11642. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11643. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11644. /// <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>
  11645. /// <param name="source">An observable sequence of elements to project.</param>
  11646. /// <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>
  11647. /// <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>
  11648. /// <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>
  11649. /// <exception cref="ArgumentNullException">
  11650. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11651. /// <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>
  11652. 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)
  11653. {
  11654. if (source == null)
  11655. throw new ArgumentNullException(nameof(source));
  11656. if (taskSelector == null)
  11657. throw new ArgumentNullException(nameof(taskSelector));
  11658. if (resultSelector == null)
  11659. throw new ArgumentNullException(nameof(resultSelector));
  11660. return source.Provider.CreateQuery<TResult>(
  11661. Expression.Call(
  11662. null,
  11663. #if CRIPPLED_REFLECTION
  11664. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11665. #else
  11666. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11667. #endif
  11668. source.Expression,
  11669. taskSelector,
  11670. resultSelector
  11671. )
  11672. );
  11673. }
  11674. /// <summary>
  11675. /// 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.
  11676. /// </summary>
  11677. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11678. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11679. /// <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>
  11680. /// <param name="source">An observable sequence of elements to project.</param>
  11681. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11682. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11683. /// <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>
  11684. /// <exception cref="ArgumentNullException">
  11685. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11686. /// <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>
  11687. 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)
  11688. {
  11689. if (source == null)
  11690. throw new ArgumentNullException(nameof(source));
  11691. if (taskSelector == null)
  11692. throw new ArgumentNullException(nameof(taskSelector));
  11693. if (resultSelector == null)
  11694. throw new ArgumentNullException(nameof(resultSelector));
  11695. return source.Provider.CreateQuery<TResult>(
  11696. Expression.Call(
  11697. null,
  11698. #if CRIPPLED_REFLECTION
  11699. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11700. #else
  11701. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11702. #endif
  11703. source.Expression,
  11704. taskSelector,
  11705. resultSelector
  11706. )
  11707. );
  11708. }
  11709. /// <summary>
  11710. /// 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.
  11711. /// </summary>
  11712. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11713. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11714. /// <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>
  11715. /// <param name="source">An observable sequence of elements to project.</param>
  11716. /// <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>
  11717. /// <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>
  11718. /// <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>
  11719. /// <exception cref="ArgumentNullException">
  11720. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11721. /// <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>
  11722. 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)
  11723. {
  11724. if (source == null)
  11725. throw new ArgumentNullException(nameof(source));
  11726. if (taskSelector == null)
  11727. throw new ArgumentNullException(nameof(taskSelector));
  11728. if (resultSelector == null)
  11729. throw new ArgumentNullException(nameof(resultSelector));
  11730. return source.Provider.CreateQuery<TResult>(
  11731. Expression.Call(
  11732. null,
  11733. #if CRIPPLED_REFLECTION
  11734. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11735. #else
  11736. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11737. #endif
  11738. source.Expression,
  11739. taskSelector,
  11740. resultSelector
  11741. )
  11742. );
  11743. }
  11744. /// <summary>
  11745. /// Determines whether two sequences are equal by comparing the elements pairwise.
  11746. /// </summary>
  11747. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11748. /// <param name="first">First observable sequence to compare.</param>
  11749. /// <param name="second">Second observable sequence to compare.</param>
  11750. /// <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>
  11751. /// <exception cref="ArgumentNullException">
  11752. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11753. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11754. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  11755. {
  11756. if (first == null)
  11757. throw new ArgumentNullException(nameof(first));
  11758. if (second == null)
  11759. throw new ArgumentNullException(nameof(second));
  11760. return first.Provider.CreateQuery<bool>(
  11761. Expression.Call(
  11762. null,
  11763. #if CRIPPLED_REFLECTION
  11764. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  11765. #else
  11766. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11767. #endif
  11768. first.Expression,
  11769. GetSourceExpression(second)
  11770. )
  11771. );
  11772. }
  11773. /// <summary>
  11774. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise.
  11775. /// </summary>
  11776. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11777. /// <param name="first">First observable sequence to compare.</param>
  11778. /// <param name="second">Second observable sequence to compare.</param>
  11779. /// <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>
  11780. /// <exception cref="ArgumentNullException">
  11781. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11782. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11783. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second)
  11784. {
  11785. if (first == null)
  11786. throw new ArgumentNullException(nameof(first));
  11787. if (second == null)
  11788. throw new ArgumentNullException(nameof(second));
  11789. return first.Provider.CreateQuery<bool>(
  11790. Expression.Call(
  11791. null,
  11792. #if CRIPPLED_REFLECTION
  11793. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  11794. #else
  11795. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11796. #endif
  11797. first.Expression,
  11798. GetSourceExpression(second)
  11799. )
  11800. );
  11801. }
  11802. /// <summary>
  11803. /// Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
  11804. /// </summary>
  11805. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11806. /// <param name="first">First observable sequence to compare.</param>
  11807. /// <param name="second">Second observable sequence to compare.</param>
  11808. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11809. /// <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>
  11810. /// <exception cref="ArgumentNullException">
  11811. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11812. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11813. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IEqualityComparer<TSource> comparer)
  11814. {
  11815. if (first == null)
  11816. throw new ArgumentNullException(nameof(first));
  11817. if (second == null)
  11818. throw new ArgumentNullException(nameof(second));
  11819. if (comparer == null)
  11820. throw new ArgumentNullException(nameof(comparer));
  11821. return first.Provider.CreateQuery<bool>(
  11822. Expression.Call(
  11823. null,
  11824. #if CRIPPLED_REFLECTION
  11825. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IEqualityComparer<TSource>))),
  11826. #else
  11827. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11828. #endif
  11829. first.Expression,
  11830. GetSourceExpression(second),
  11831. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11832. )
  11833. );
  11834. }
  11835. /// <summary>
  11836. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise using a specified equality comparer.
  11837. /// </summary>
  11838. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11839. /// <param name="first">First observable sequence to compare.</param>
  11840. /// <param name="second">Second observable sequence to compare.</param>
  11841. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11842. /// <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>
  11843. /// <exception cref="ArgumentNullException">
  11844. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11845. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11846. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  11847. {
  11848. if (first == null)
  11849. throw new ArgumentNullException(nameof(first));
  11850. if (second == null)
  11851. throw new ArgumentNullException(nameof(second));
  11852. if (comparer == null)
  11853. throw new ArgumentNullException(nameof(comparer));
  11854. return first.Provider.CreateQuery<bool>(
  11855. Expression.Call(
  11856. null,
  11857. #if CRIPPLED_REFLECTION
  11858. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>), default(IEqualityComparer<TSource>))),
  11859. #else
  11860. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11861. #endif
  11862. first.Expression,
  11863. GetSourceExpression(second),
  11864. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11865. )
  11866. );
  11867. }
  11868. /// <summary>
  11869. /// Returns the only element of an observable sequence, and reports an exception if there is not exactly one element in the observable sequence.
  11870. /// </summary>
  11871. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11872. /// <param name="source">Source observable sequence.</param>
  11873. /// <returns>Sequence containing the single element in the observable sequence.</returns>
  11874. /// <exception cref="ArgumentNullException">
  11875. /// <paramref name="source" /> is null.</exception>
  11876. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence contains more than one element. -or- The source sequence is empty.</exception>
  11877. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source)
  11878. {
  11879. if (source == null)
  11880. throw new ArgumentNullException(nameof(source));
  11881. return source.Provider.CreateQuery<TSource>(
  11882. Expression.Call(
  11883. null,
  11884. #if CRIPPLED_REFLECTION
  11885. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>))),
  11886. #else
  11887. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11888. #endif
  11889. source.Expression
  11890. )
  11891. );
  11892. }
  11893. /// <summary>
  11894. /// 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.
  11895. /// </summary>
  11896. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11897. /// <param name="source">Source observable sequence.</param>
  11898. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  11899. /// <returns>Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.</returns>
  11900. /// <exception cref="ArgumentNullException">
  11901. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  11902. /// <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>
  11903. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  11904. {
  11905. if (source == null)
  11906. throw new ArgumentNullException(nameof(source));
  11907. if (predicate == null)
  11908. throw new ArgumentNullException(nameof(predicate));
  11909. return source.Provider.CreateQuery<TSource>(
  11910. Expression.Call(
  11911. null,
  11912. #if CRIPPLED_REFLECTION
  11913. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  11914. #else
  11915. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11916. #endif
  11917. source.Expression,
  11918. predicate
  11919. )
  11920. );
  11921. }
  11922. /// <summary>
  11923. /// 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.
  11924. /// </summary>
  11925. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11926. /// <param name="source">Source observable sequence.</param>
  11927. /// <returns>Sequence containing the single element in the observable sequence, or a default value if no such element exists.</returns>
  11928. /// <exception cref="ArgumentNullException">
  11929. /// <paramref name="source" /> is null.</exception>
  11930. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence contains more than one element.</exception>
  11931. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  11932. {
  11933. if (source == null)
  11934. throw new ArgumentNullException(nameof(source));
  11935. return source.Provider.CreateQuery<TSource>(
  11936. Expression.Call(
  11937. null,
  11938. #if CRIPPLED_REFLECTION
  11939. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  11940. #else
  11941. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11942. #endif
  11943. source.Expression
  11944. )
  11945. );
  11946. }
  11947. /// <summary>
  11948. /// 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.
  11949. /// </summary>
  11950. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11951. /// <param name="source">Source observable sequence.</param>
  11952. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  11953. /// <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>
  11954. /// <exception cref="ArgumentNullException">
  11955. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  11956. /// <exception cref="InvalidOperationException">(Asynchronous) The sequence contains more than one element that satisfies the condition in the predicate.</exception>
  11957. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  11958. {
  11959. if (source == null)
  11960. throw new ArgumentNullException(nameof(source));
  11961. if (predicate == null)
  11962. throw new ArgumentNullException(nameof(predicate));
  11963. return source.Provider.CreateQuery<TSource>(
  11964. Expression.Call(
  11965. null,
  11966. #if CRIPPLED_REFLECTION
  11967. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  11968. #else
  11969. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11970. #endif
  11971. source.Expression,
  11972. predicate
  11973. )
  11974. );
  11975. }
  11976. /// <summary>
  11977. /// Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
  11978. /// </summary>
  11979. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11980. /// <param name="source">The sequence to take elements from.</param>
  11981. /// <param name="count">The number of elements to skip before returning the remaining elements.</param>
  11982. /// <returns>An observable sequence that contains the elements that occur after the specified index in the input sequence.</returns>
  11983. /// <exception cref="ArgumentNullException">
  11984. /// <paramref name="source" /> is null.</exception>
  11985. /// <exception cref="ArgumentOutOfRangeException">
  11986. /// <paramref name="count" /> is less than zero.</exception>
  11987. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, int count)
  11988. {
  11989. if (source == null)
  11990. throw new ArgumentNullException(nameof(source));
  11991. return source.Provider.CreateQuery<TSource>(
  11992. Expression.Call(
  11993. null,
  11994. #if CRIPPLED_REFLECTION
  11995. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(int))),
  11996. #else
  11997. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11998. #endif
  11999. source.Expression,
  12000. Expression.Constant(count, typeof(int))
  12001. )
  12002. );
  12003. }
  12004. /// <summary>
  12005. /// Skips elements for the specified duration from the start of the observable source sequence.
  12006. /// </summary>
  12007. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12008. /// <param name="source">Source sequence to skip elements for.</param>
  12009. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12010. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12011. /// <exception cref="ArgumentNullException">
  12012. /// <paramref name="source" /> is null.</exception>
  12013. /// <exception cref="ArgumentOutOfRangeException">
  12014. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12015. /// <remarks>
  12016. /// <para>
  12017. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12018. /// 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
  12019. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12020. /// </para>
  12021. /// <para>
  12022. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12023. /// </para>
  12024. /// </remarks>
  12025. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12026. {
  12027. if (source == null)
  12028. throw new ArgumentNullException(nameof(source));
  12029. return source.Provider.CreateQuery<TSource>(
  12030. Expression.Call(
  12031. null,
  12032. #if CRIPPLED_REFLECTION
  12033. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12034. #else
  12035. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12036. #endif
  12037. source.Expression,
  12038. Expression.Constant(duration, typeof(TimeSpan))
  12039. )
  12040. );
  12041. }
  12042. /// <summary>
  12043. /// Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  12044. /// </summary>
  12045. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12046. /// <param name="source">Source sequence to skip elements for.</param>
  12047. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12048. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12049. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12050. /// <exception cref="ArgumentNullException">
  12051. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12052. /// <exception cref="ArgumentOutOfRangeException">
  12053. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12054. /// <remarks>
  12055. /// <para>
  12056. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12057. /// 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
  12058. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12059. /// </para>
  12060. /// <para>
  12061. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12062. /// </para>
  12063. /// </remarks>
  12064. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  12065. {
  12066. if (source == null)
  12067. throw new ArgumentNullException(nameof(source));
  12068. if (scheduler == null)
  12069. throw new ArgumentNullException(nameof(scheduler));
  12070. return source.Provider.CreateQuery<TSource>(
  12071. Expression.Call(
  12072. null,
  12073. #if CRIPPLED_REFLECTION
  12074. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12075. #else
  12076. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12077. #endif
  12078. source.Expression,
  12079. Expression.Constant(duration, typeof(TimeSpan)),
  12080. Expression.Constant(scheduler, typeof(IScheduler))
  12081. )
  12082. );
  12083. }
  12084. /// <summary>
  12085. /// Bypasses a specified number of elements at the end of an observable sequence.
  12086. /// </summary>
  12087. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12088. /// <param name="source">Source sequence.</param>
  12089. /// <param name="count">Number of elements to bypass at the end of the source sequence.</param>
  12090. /// <returns>An observable sequence containing the source sequence elements except for the bypassed ones at the end.</returns>
  12091. /// <exception cref="ArgumentNullException">
  12092. /// <paramref name="source" /> is null.</exception>
  12093. /// <exception cref="ArgumentOutOfRangeException">
  12094. /// <paramref name="count" /> is less than zero.</exception>
  12095. /// <remarks>
  12096. /// This operator accumulates a queue with a length enough to store the first <paramref name="count" /> elements. As more elements are
  12097. /// received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
  12098. /// </remarks>
  12099. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, int count)
  12100. {
  12101. if (source == null)
  12102. throw new ArgumentNullException(nameof(source));
  12103. return source.Provider.CreateQuery<TSource>(
  12104. Expression.Call(
  12105. null,
  12106. #if CRIPPLED_REFLECTION
  12107. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(int))),
  12108. #else
  12109. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12110. #endif
  12111. source.Expression,
  12112. Expression.Constant(count, typeof(int))
  12113. )
  12114. );
  12115. }
  12116. /// <summary>
  12117. /// Skips elements for the specified duration from the end of the observable source sequence.
  12118. /// </summary>
  12119. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12120. /// <param name="source">Source sequence to skip elements for.</param>
  12121. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12122. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12123. /// <exception cref="ArgumentNullException">
  12124. /// <paramref name="source" /> is null.</exception>
  12125. /// <exception cref="ArgumentOutOfRangeException">
  12126. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12127. /// <remarks>
  12128. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12129. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12130. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12131. /// </remarks>
  12132. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12133. {
  12134. if (source == null)
  12135. throw new ArgumentNullException(nameof(source));
  12136. return source.Provider.CreateQuery<TSource>(
  12137. Expression.Call(
  12138. null,
  12139. #if CRIPPLED_REFLECTION
  12140. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12141. #else
  12142. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12143. #endif
  12144. source.Expression,
  12145. Expression.Constant(duration, typeof(TimeSpan))
  12146. )
  12147. );
  12148. }
  12149. /// <summary>
  12150. /// Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  12151. /// </summary>
  12152. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12153. /// <param name="source">Source sequence to skip elements for.</param>
  12154. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12155. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12156. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12157. /// <exception cref="ArgumentNullException">
  12158. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12159. /// <exception cref="ArgumentOutOfRangeException">
  12160. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12161. /// <remarks>
  12162. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12163. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12164. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12165. /// </remarks>
  12166. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  12167. {
  12168. if (source == null)
  12169. throw new ArgumentNullException(nameof(source));
  12170. if (scheduler == null)
  12171. throw new ArgumentNullException(nameof(scheduler));
  12172. return source.Provider.CreateQuery<TSource>(
  12173. Expression.Call(
  12174. null,
  12175. #if CRIPPLED_REFLECTION
  12176. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12177. #else
  12178. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12179. #endif
  12180. source.Expression,
  12181. Expression.Constant(duration, typeof(TimeSpan)),
  12182. Expression.Constant(scheduler, typeof(IScheduler))
  12183. )
  12184. );
  12185. }
  12186. /// <summary>
  12187. /// Skips elements from the observable source sequence until the specified start time.
  12188. /// </summary>
  12189. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12190. /// <param name="source">Source sequence to skip elements for.</param>
  12191. /// <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>
  12192. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12193. /// <exception cref="ArgumentNullException">
  12194. /// <paramref name="source" /> is null.</exception>
  12195. /// <remarks>
  12196. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12197. /// </remarks>
  12198. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime)
  12199. {
  12200. if (source == null)
  12201. throw new ArgumentNullException(nameof(source));
  12202. return source.Provider.CreateQuery<TSource>(
  12203. Expression.Call(
  12204. null,
  12205. #if CRIPPLED_REFLECTION
  12206. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  12207. #else
  12208. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12209. #endif
  12210. source.Expression,
  12211. Expression.Constant(startTime, typeof(DateTimeOffset))
  12212. )
  12213. );
  12214. }
  12215. /// <summary>
  12216. /// Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  12217. /// </summary>
  12218. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12219. /// <param name="source">Source sequence to skip elements for.</param>
  12220. /// <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>
  12221. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12222. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12223. /// <exception cref="ArgumentNullException">
  12224. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12225. /// <remarks>
  12226. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12227. /// </remarks>
  12228. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime, IScheduler scheduler)
  12229. {
  12230. if (source == null)
  12231. throw new ArgumentNullException(nameof(source));
  12232. if (scheduler == null)
  12233. throw new ArgumentNullException(nameof(scheduler));
  12234. return source.Provider.CreateQuery<TSource>(
  12235. Expression.Call(
  12236. null,
  12237. #if CRIPPLED_REFLECTION
  12238. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  12239. #else
  12240. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12241. #endif
  12242. source.Expression,
  12243. Expression.Constant(startTime, typeof(DateTimeOffset)),
  12244. Expression.Constant(scheduler, typeof(IScheduler))
  12245. )
  12246. );
  12247. }
  12248. /// <summary>
  12249. /// Returns the elements from the source observable sequence only after the other observable sequence produces an element.
  12250. /// Starting from Rx.NET 4.0, this will subscribe to <paramref name="other" /> before subscribing to <paramref name="source" />
  12251. /// so in case <paramref name="other" /> emits an element right away, elements from <paramref name="source" /> are not missed.
  12252. /// </summary>
  12253. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12254. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of skip behavior.</typeparam>
  12255. /// <param name="source">Source sequence to propagate elements for.</param>
  12256. /// <param name="other">Observable sequence that triggers propagation of elements of the source sequence.</param>
  12257. /// <returns>An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.</returns>
  12258. /// <exception cref="ArgumentNullException">
  12259. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  12260. public static IQbservable<TSource> SkipUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  12261. {
  12262. if (source == null)
  12263. throw new ArgumentNullException(nameof(source));
  12264. if (other == null)
  12265. throw new ArgumentNullException(nameof(other));
  12266. return source.Provider.CreateQuery<TSource>(
  12267. Expression.Call(
  12268. null,
  12269. #if CRIPPLED_REFLECTION
  12270. InfoOf(() => Qbservable.SkipUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  12271. #else
  12272. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  12273. #endif
  12274. source.Expression,
  12275. GetSourceExpression(other)
  12276. )
  12277. );
  12278. }
  12279. /// <summary>
  12280. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12281. /// </summary>
  12282. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12283. /// <param name="source">An observable sequence to return elements from.</param>
  12284. /// <param name="predicate">A function to test each element for a condition.</param>
  12285. /// <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>
  12286. /// <exception cref="ArgumentNullException">
  12287. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12288. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12289. {
  12290. if (source == null)
  12291. throw new ArgumentNullException(nameof(source));
  12292. if (predicate == null)
  12293. throw new ArgumentNullException(nameof(predicate));
  12294. return source.Provider.CreateQuery<TSource>(
  12295. Expression.Call(
  12296. null,
  12297. #if CRIPPLED_REFLECTION
  12298. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12299. #else
  12300. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12301. #endif
  12302. source.Expression,
  12303. predicate
  12304. )
  12305. );
  12306. }
  12307. /// <summary>
  12308. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12309. /// The element's index is used in the logic of the predicate function.
  12310. /// </summary>
  12311. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12312. /// <param name="source">An observable sequence to return elements from.</param>
  12313. /// <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>
  12314. /// <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>
  12315. /// <exception cref="ArgumentNullException">
  12316. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12317. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  12318. {
  12319. if (source == null)
  12320. throw new ArgumentNullException(nameof(source));
  12321. if (predicate == null)
  12322. throw new ArgumentNullException(nameof(predicate));
  12323. return source.Provider.CreateQuery<TSource>(
  12324. Expression.Call(
  12325. null,
  12326. #if CRIPPLED_REFLECTION
  12327. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  12328. #else
  12329. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12330. #endif
  12331. source.Expression,
  12332. predicate
  12333. )
  12334. );
  12335. }
  12336. /// <summary>
  12337. /// Invokes the action asynchronously, surfacing the result through an observable sequence.
  12338. /// </summary>
  12339. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12340. /// <param name="action">Action to run asynchronously.</param>
  12341. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12342. /// <exception cref="ArgumentNullException">
  12343. /// <paramref name="action" /> is null.</exception>
  12344. /// <remarks>
  12345. /// <list type="bullet">
  12346. /// <item>
  12347. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12348. /// </item>
  12349. /// <item>
  12350. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12351. /// </item>
  12352. /// </list>
  12353. /// </remarks>
  12354. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action)
  12355. {
  12356. if (provider == null)
  12357. throw new ArgumentNullException(nameof(provider));
  12358. if (action == null)
  12359. throw new ArgumentNullException(nameof(action));
  12360. return provider.CreateQuery<Unit>(
  12361. Expression.Call(
  12362. null,
  12363. #if CRIPPLED_REFLECTION
  12364. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>))),
  12365. #else
  12366. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12367. #endif
  12368. Expression.Constant(provider, typeof(IQbservableProvider)),
  12369. action
  12370. )
  12371. );
  12372. }
  12373. /// <summary>
  12374. /// Invokes the action asynchronously on the specified scheduler, surfacing the result through an observable sequence.
  12375. /// </summary>
  12376. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12377. /// <param name="action">Action to run asynchronously.</param>
  12378. /// <param name="scheduler">Scheduler to run the action on.</param>
  12379. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12380. /// <exception cref="ArgumentNullException">
  12381. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  12382. /// <remarks>
  12383. /// <list type="bullet">
  12384. /// <item>
  12385. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12386. /// </item>
  12387. /// <item>
  12388. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12389. /// </item>
  12390. /// </list>
  12391. /// </remarks>
  12392. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  12393. {
  12394. if (provider == null)
  12395. throw new ArgumentNullException(nameof(provider));
  12396. if (action == null)
  12397. throw new ArgumentNullException(nameof(action));
  12398. if (scheduler == null)
  12399. throw new ArgumentNullException(nameof(scheduler));
  12400. return provider.CreateQuery<Unit>(
  12401. Expression.Call(
  12402. null,
  12403. #if CRIPPLED_REFLECTION
  12404. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>), default(IScheduler))),
  12405. #else
  12406. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12407. #endif
  12408. Expression.Constant(provider, typeof(IQbservableProvider)),
  12409. action,
  12410. Expression.Constant(scheduler, typeof(IScheduler))
  12411. )
  12412. );
  12413. }
  12414. /// <summary>
  12415. /// Invokes the specified function asynchronously, surfacing the result through an observable sequence.
  12416. /// </summary>
  12417. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12418. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12419. /// <param name="function">Function to run asynchronously.</param>
  12420. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12421. /// <exception cref="ArgumentNullException">
  12422. /// <paramref name="function" /> is null.</exception>
  12423. /// <remarks>
  12424. /// <list type="bullet">
  12425. /// <item>
  12426. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12427. /// </item>
  12428. /// <item>
  12429. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12430. /// </item>
  12431. /// </list>
  12432. /// </remarks>
  12433. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  12434. {
  12435. if (provider == null)
  12436. throw new ArgumentNullException(nameof(provider));
  12437. if (function == null)
  12438. throw new ArgumentNullException(nameof(function));
  12439. return provider.CreateQuery<TResult>(
  12440. Expression.Call(
  12441. null,
  12442. #if CRIPPLED_REFLECTION
  12443. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>))),
  12444. #else
  12445. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12446. #endif
  12447. Expression.Constant(provider, typeof(IQbservableProvider)),
  12448. function
  12449. )
  12450. );
  12451. }
  12452. /// <summary>
  12453. /// Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence
  12454. /// </summary>
  12455. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12456. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12457. /// <param name="function">Function to run asynchronously.</param>
  12458. /// <param name="scheduler">Scheduler to run the function on.</param>
  12459. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12460. /// <exception cref="ArgumentNullException">
  12461. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  12462. /// <remarks>
  12463. /// <list type="bullet">
  12464. /// <item>
  12465. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12466. /// </item>
  12467. /// <item>
  12468. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12469. /// </item>
  12470. /// </list>
  12471. /// </remarks>
  12472. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  12473. {
  12474. if (provider == null)
  12475. throw new ArgumentNullException(nameof(provider));
  12476. if (function == null)
  12477. throw new ArgumentNullException(nameof(function));
  12478. if (scheduler == null)
  12479. throw new ArgumentNullException(nameof(scheduler));
  12480. return provider.CreateQuery<TResult>(
  12481. Expression.Call(
  12482. null,
  12483. #if CRIPPLED_REFLECTION
  12484. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler))),
  12485. #else
  12486. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12487. #endif
  12488. Expression.Constant(provider, typeof(IQbservableProvider)),
  12489. function,
  12490. Expression.Constant(scheduler, typeof(IScheduler))
  12491. )
  12492. );
  12493. }
  12494. /// <summary>
  12495. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12496. /// </summary>
  12497. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12498. /// <param name="actionAsync">Asynchronous action to run.</param>
  12499. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12500. /// <exception cref="ArgumentNullException">
  12501. /// <paramref name="actionAsync" /> is null.</exception>
  12502. /// <remarks>
  12503. /// <list type="bullet">
  12504. /// <item>
  12505. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12506. /// </item>
  12507. /// <item>
  12508. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12509. /// </item>
  12510. /// </list>
  12511. /// </remarks>
  12512. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  12513. {
  12514. if (provider == null)
  12515. throw new ArgumentNullException(nameof(provider));
  12516. if (actionAsync == null)
  12517. throw new ArgumentNullException(nameof(actionAsync));
  12518. return provider.CreateQuery<Unit>(
  12519. Expression.Call(
  12520. null,
  12521. #if CRIPPLED_REFLECTION
  12522. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  12523. #else
  12524. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12525. #endif
  12526. Expression.Constant(provider, typeof(IQbservableProvider)),
  12527. actionAsync
  12528. )
  12529. );
  12530. }
  12531. /// <summary>
  12532. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12533. /// </summary>
  12534. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12535. /// <param name="actionAsync">Asynchronous action to run.</param>
  12536. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12537. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12538. /// <exception cref="ArgumentNullException">
  12539. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12540. /// <remarks>
  12541. /// <list type="bullet">
  12542. /// <item>
  12543. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12544. /// </item>
  12545. /// <item>
  12546. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12547. /// </item>
  12548. /// </list>
  12549. /// </remarks>
  12550. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync, IScheduler scheduler)
  12551. {
  12552. if (provider == null)
  12553. throw new ArgumentNullException(nameof(provider));
  12554. if (actionAsync == null)
  12555. throw new ArgumentNullException(nameof(actionAsync));
  12556. if (scheduler == null)
  12557. throw new ArgumentNullException(nameof(scheduler));
  12558. return provider.CreateQuery<Unit>(
  12559. Expression.Call(
  12560. null,
  12561. #if CRIPPLED_REFLECTION
  12562. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>), default(IScheduler))),
  12563. #else
  12564. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12565. #endif
  12566. Expression.Constant(provider, typeof(IQbservableProvider)),
  12567. actionAsync,
  12568. Expression.Constant(scheduler, typeof(IScheduler))
  12569. )
  12570. );
  12571. }
  12572. /// <summary>
  12573. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12574. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12575. /// </summary>
  12576. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12577. /// <param name="actionAsync">Asynchronous action to run.</param>
  12578. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12579. /// <exception cref="ArgumentNullException">
  12580. /// <paramref name="actionAsync" /> is null.</exception>
  12581. /// <remarks>
  12582. /// <list type="bullet">
  12583. /// <item>
  12584. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12585. /// </item>
  12586. /// <item>
  12587. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12588. /// </item>
  12589. /// <item>
  12590. /// <description>
  12591. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12592. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12593. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12594. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12595. /// multicast operators.
  12596. /// </description>
  12597. /// </item>
  12598. /// </list>
  12599. /// </remarks>
  12600. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  12601. {
  12602. if (provider == null)
  12603. throw new ArgumentNullException(nameof(provider));
  12604. if (actionAsync == null)
  12605. throw new ArgumentNullException(nameof(actionAsync));
  12606. return provider.CreateQuery<Unit>(
  12607. Expression.Call(
  12608. null,
  12609. #if CRIPPLED_REFLECTION
  12610. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  12611. #else
  12612. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12613. #endif
  12614. Expression.Constant(provider, typeof(IQbservableProvider)),
  12615. actionAsync
  12616. )
  12617. );
  12618. }
  12619. /// <summary>
  12620. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12621. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12622. /// </summary>
  12623. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12624. /// <param name="actionAsync">Asynchronous action to run.</param>
  12625. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12626. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12627. /// <exception cref="ArgumentNullException">
  12628. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12629. /// <remarks>
  12630. /// <list type="bullet">
  12631. /// <item>
  12632. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12633. /// </item>
  12634. /// <item>
  12635. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12636. /// </item>
  12637. /// <item>
  12638. /// <description>
  12639. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12640. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12641. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12642. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12643. /// multicast operators.
  12644. /// </description>
  12645. /// </item>
  12646. /// </list>
  12647. /// </remarks>
  12648. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync, IScheduler scheduler)
  12649. {
  12650. if (provider == null)
  12651. throw new ArgumentNullException(nameof(provider));
  12652. if (actionAsync == null)
  12653. throw new ArgumentNullException(nameof(actionAsync));
  12654. if (scheduler == null)
  12655. throw new ArgumentNullException(nameof(scheduler));
  12656. return provider.CreateQuery<Unit>(
  12657. Expression.Call(
  12658. null,
  12659. #if CRIPPLED_REFLECTION
  12660. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>), default(IScheduler))),
  12661. #else
  12662. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12663. #endif
  12664. Expression.Constant(provider, typeof(IQbservableProvider)),
  12665. actionAsync,
  12666. Expression.Constant(scheduler, typeof(IScheduler))
  12667. )
  12668. );
  12669. }
  12670. /// <summary>
  12671. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12672. /// </summary>
  12673. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12674. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12675. /// <param name="functionAsync">Asynchronous function to run.</param>
  12676. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12677. /// <exception cref="ArgumentNullException">
  12678. /// <paramref name="functionAsync" /> is null.</exception>
  12679. /// <remarks>
  12680. /// <list type="bullet">
  12681. /// <item>
  12682. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12683. /// </item>
  12684. /// <item>
  12685. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12686. /// </item>
  12687. /// </list>
  12688. /// </remarks>
  12689. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  12690. {
  12691. if (provider == null)
  12692. throw new ArgumentNullException(nameof(provider));
  12693. if (functionAsync == null)
  12694. throw new ArgumentNullException(nameof(functionAsync));
  12695. return provider.CreateQuery<TResult>(
  12696. Expression.Call(
  12697. null,
  12698. #if CRIPPLED_REFLECTION
  12699. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  12700. #else
  12701. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12702. #endif
  12703. Expression.Constant(provider, typeof(IQbservableProvider)),
  12704. functionAsync
  12705. )
  12706. );
  12707. }
  12708. /// <summary>
  12709. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12710. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12711. /// </summary>
  12712. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12713. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12714. /// <param name="functionAsync">Asynchronous function to run.</param>
  12715. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12716. /// <exception cref="ArgumentNullException">
  12717. /// <paramref name="functionAsync" /> is null.</exception>
  12718. /// <remarks>
  12719. /// <list type="bullet">
  12720. /// <item>
  12721. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12722. /// </item>
  12723. /// <item>
  12724. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12725. /// </item>
  12726. /// <item>
  12727. /// <description>
  12728. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12729. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12730. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12731. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12732. /// multicast operators.
  12733. /// </description>
  12734. /// </item>
  12735. /// </list>
  12736. /// </remarks>
  12737. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  12738. {
  12739. if (provider == null)
  12740. throw new ArgumentNullException(nameof(provider));
  12741. if (functionAsync == null)
  12742. throw new ArgumentNullException(nameof(functionAsync));
  12743. return provider.CreateQuery<TResult>(
  12744. Expression.Call(
  12745. null,
  12746. #if CRIPPLED_REFLECTION
  12747. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  12748. #else
  12749. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12750. #endif
  12751. Expression.Constant(provider, typeof(IQbservableProvider)),
  12752. functionAsync
  12753. )
  12754. );
  12755. }
  12756. /// <summary>
  12757. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12758. /// </summary>
  12759. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12760. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12761. /// <param name="functionAsync">Asynchronous function to run.</param>
  12762. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12763. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12764. /// <exception cref="ArgumentNullException">
  12765. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12766. /// <remarks>
  12767. /// <list type="bullet">
  12768. /// <item>
  12769. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12770. /// </item>
  12771. /// <item>
  12772. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12773. /// </item>
  12774. /// </list>
  12775. /// </remarks>
  12776. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync, IScheduler scheduler)
  12777. {
  12778. if (provider == null)
  12779. throw new ArgumentNullException(nameof(provider));
  12780. if (functionAsync == null)
  12781. throw new ArgumentNullException(nameof(functionAsync));
  12782. if (scheduler == null)
  12783. throw new ArgumentNullException(nameof(scheduler));
  12784. return provider.CreateQuery<TResult>(
  12785. Expression.Call(
  12786. null,
  12787. #if CRIPPLED_REFLECTION
  12788. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>), default(IScheduler))),
  12789. #else
  12790. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12791. #endif
  12792. Expression.Constant(provider, typeof(IQbservableProvider)),
  12793. functionAsync,
  12794. Expression.Constant(scheduler, typeof(IScheduler))
  12795. )
  12796. );
  12797. }
  12798. /// <summary>
  12799. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12800. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12801. /// </summary>
  12802. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12803. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12804. /// <param name="functionAsync">Asynchronous function to run.</param>
  12805. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12806. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12807. /// <exception cref="ArgumentNullException">
  12808. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12809. /// <remarks>
  12810. /// <list type="bullet">
  12811. /// <item>
  12812. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12813. /// </item>
  12814. /// <item>
  12815. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12816. /// </item>
  12817. /// <item>
  12818. /// <description>
  12819. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12820. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12821. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12822. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12823. /// multicast operators.
  12824. /// </description>
  12825. /// </item>
  12826. /// </list>
  12827. /// </remarks>
  12828. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync, IScheduler scheduler)
  12829. {
  12830. if (provider == null)
  12831. throw new ArgumentNullException(nameof(provider));
  12832. if (functionAsync == null)
  12833. throw new ArgumentNullException(nameof(functionAsync));
  12834. if (scheduler == null)
  12835. throw new ArgumentNullException(nameof(scheduler));
  12836. return provider.CreateQuery<TResult>(
  12837. Expression.Call(
  12838. null,
  12839. #if CRIPPLED_REFLECTION
  12840. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>), default(IScheduler))),
  12841. #else
  12842. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12843. #endif
  12844. Expression.Constant(provider, typeof(IQbservableProvider)),
  12845. functionAsync,
  12846. Expression.Constant(scheduler, typeof(IScheduler))
  12847. )
  12848. );
  12849. }
  12850. /// <summary>
  12851. /// Prepends a sequence of values to an observable sequence.
  12852. /// </summary>
  12853. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12854. /// <param name="source">Source sequence to prepend values to.</param>
  12855. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  12856. /// <param name="values">Values to prepend to the specified sequence.</param>
  12857. /// <returns>The source sequence prepended with the specified values.</returns>
  12858. /// <exception cref="ArgumentNullException">
  12859. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  12860. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, params TSource[] values)
  12861. {
  12862. if (source == null)
  12863. throw new ArgumentNullException(nameof(source));
  12864. if (scheduler == null)
  12865. throw new ArgumentNullException(nameof(scheduler));
  12866. if (values == null)
  12867. throw new ArgumentNullException(nameof(values));
  12868. return source.Provider.CreateQuery<TSource>(
  12869. Expression.Call(
  12870. null,
  12871. #if CRIPPLED_REFLECTION
  12872. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(TSource[]))),
  12873. #else
  12874. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12875. #endif
  12876. source.Expression,
  12877. Expression.Constant(scheduler, typeof(IScheduler)),
  12878. Expression.Constant(values, typeof(TSource[]))
  12879. )
  12880. );
  12881. }
  12882. /// <summary>
  12883. /// Prepends a sequence of values to an observable sequence.
  12884. /// </summary>
  12885. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12886. /// <param name="source">Source sequence to prepend values to.</param>
  12887. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  12888. /// <param name="values">Values to prepend to the specified sequence.</param>
  12889. /// <returns>The source sequence prepended with the specified values.</returns>
  12890. /// <exception cref="ArgumentNullException">
  12891. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  12892. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, IEnumerable<TSource> values)
  12893. {
  12894. if (source == null)
  12895. throw new ArgumentNullException(nameof(source));
  12896. if (scheduler == null)
  12897. throw new ArgumentNullException(nameof(scheduler));
  12898. if (values == null)
  12899. throw new ArgumentNullException(nameof(values));
  12900. return source.Provider.CreateQuery<TSource>(
  12901. Expression.Call(
  12902. null,
  12903. #if CRIPPLED_REFLECTION
  12904. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(IEnumerable<TSource>))),
  12905. #else
  12906. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12907. #endif
  12908. source.Expression,
  12909. Expression.Constant(scheduler, typeof(IScheduler)),
  12910. GetSourceExpression(values)
  12911. )
  12912. );
  12913. }
  12914. /// <summary>
  12915. /// Prepends a sequence of values to an observable sequence.
  12916. /// </summary>
  12917. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12918. /// <param name="source">Source sequence to prepend values to.</param>
  12919. /// <param name="values">Values to prepend to the specified sequence.</param>
  12920. /// <returns>The source sequence prepended with the specified values.</returns>
  12921. /// <exception cref="ArgumentNullException">
  12922. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  12923. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, params TSource[] values)
  12924. {
  12925. if (source == null)
  12926. throw new ArgumentNullException(nameof(source));
  12927. if (values == null)
  12928. throw new ArgumentNullException(nameof(values));
  12929. return source.Provider.CreateQuery<TSource>(
  12930. Expression.Call(
  12931. null,
  12932. #if CRIPPLED_REFLECTION
  12933. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(TSource[]))),
  12934. #else
  12935. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12936. #endif
  12937. source.Expression,
  12938. Expression.Constant(values, typeof(TSource[]))
  12939. )
  12940. );
  12941. }
  12942. /// <summary>
  12943. /// Prepends a sequence of values to an observable sequence.
  12944. /// </summary>
  12945. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12946. /// <param name="source">Source sequence to prepend values to.</param>
  12947. /// <param name="values">Values to prepend to the specified sequence.</param>
  12948. /// <returns>The source sequence prepended with the specified values.</returns>
  12949. /// <exception cref="ArgumentNullException">
  12950. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  12951. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IEnumerable<TSource> values)
  12952. {
  12953. if (source == null)
  12954. throw new ArgumentNullException(nameof(source));
  12955. if (values == null)
  12956. throw new ArgumentNullException(nameof(values));
  12957. return source.Provider.CreateQuery<TSource>(
  12958. Expression.Call(
  12959. null,
  12960. #if CRIPPLED_REFLECTION
  12961. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  12962. #else
  12963. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12964. #endif
  12965. source.Expression,
  12966. GetSourceExpression(values)
  12967. )
  12968. );
  12969. }
  12970. /// <summary>
  12971. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context. This operation is not commonly used;
  12972. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  12973. /// </summary>
  12974. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12975. /// <param name="source">Source sequence.</param>
  12976. /// <param name="context">Synchronization context to perform subscription and unsubscription actions on.</param>
  12977. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified synchronization context.</returns>
  12978. /// <exception cref="ArgumentNullException">
  12979. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  12980. /// <remarks>
  12981. /// This only performs the side-effects of subscription and unsubscription on the specified synchronization context. In order to invoke observer
  12982. /// callbacks on a synchronization context, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Threading.SynchronizationContext)" />.
  12983. /// </remarks>
  12984. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  12985. {
  12986. if (source == null)
  12987. throw new ArgumentNullException(nameof(source));
  12988. if (context == null)
  12989. throw new ArgumentNullException(nameof(context));
  12990. return source.Provider.CreateQuery<TSource>(
  12991. Expression.Call(
  12992. null,
  12993. #if CRIPPLED_REFLECTION
  12994. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  12995. #else
  12996. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12997. #endif
  12998. source.Expression,
  12999. Expression.Constant(context, typeof(SynchronizationContext))
  13000. )
  13001. );
  13002. }
  13003. /// <summary>
  13004. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
  13005. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  13006. /// </summary>
  13007. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13008. /// <param name="source">Source sequence.</param>
  13009. /// <param name="scheduler">Scheduler to perform subscription and unsubscription actions on.</param>
  13010. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.</returns>
  13011. /// <exception cref="ArgumentNullException">
  13012. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13013. /// <remarks>
  13014. /// This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
  13015. /// callbacks on a scheduler, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Reactive.Concurrency.IScheduler)" />.
  13016. /// </remarks>
  13017. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  13018. {
  13019. if (source == null)
  13020. throw new ArgumentNullException(nameof(source));
  13021. if (scheduler == null)
  13022. throw new ArgumentNullException(nameof(scheduler));
  13023. return source.Provider.CreateQuery<TSource>(
  13024. Expression.Call(
  13025. null,
  13026. #if CRIPPLED_REFLECTION
  13027. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  13028. #else
  13029. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13030. #endif
  13031. source.Expression,
  13032. Expression.Constant(scheduler, typeof(IScheduler))
  13033. )
  13034. );
  13035. }
  13036. /// <summary>
  13037. /// Computes the sum of a sequence of <see cref="Decimal" /> values.
  13038. /// </summary>
  13039. /// <param name="source">A sequence of <see cref="Decimal" /> values to calculate the sum of.</param>
  13040. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13041. /// <exception cref="ArgumentNullException">
  13042. /// <paramref name="source" /> is null.</exception>
  13043. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  13044. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13045. public static IQbservable<decimal> Sum(this IQbservable<decimal> source)
  13046. {
  13047. if (source == null)
  13048. throw new ArgumentNullException(nameof(source));
  13049. return source.Provider.CreateQuery<decimal>(
  13050. Expression.Call(
  13051. null,
  13052. #if CRIPPLED_REFLECTION
  13053. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal>))),
  13054. #else
  13055. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13056. #endif
  13057. source.Expression
  13058. )
  13059. );
  13060. }
  13061. /// <summary>
  13062. /// Computes the sum of a sequence of <see cref="double" /> values.
  13063. /// </summary>
  13064. /// <param name="source">A sequence of <see cref="double" /> values to calculate the sum of.</param>
  13065. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13066. /// <exception cref="ArgumentNullException">
  13067. /// <paramref name="source" /> is null.</exception>
  13068. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13069. public static IQbservable<double> Sum(this IQbservable<double> source)
  13070. {
  13071. if (source == null)
  13072. throw new ArgumentNullException(nameof(source));
  13073. return source.Provider.CreateQuery<double>(
  13074. Expression.Call(
  13075. null,
  13076. #if CRIPPLED_REFLECTION
  13077. InfoOf(() => Qbservable.Sum(default(IQbservable<double>))),
  13078. #else
  13079. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13080. #endif
  13081. source.Expression
  13082. )
  13083. );
  13084. }
  13085. /// <summary>
  13086. /// Computes the sum of a sequence of <see cref="int" /> values.
  13087. /// </summary>
  13088. /// <param name="source">A sequence of <see cref="int" /> values to calculate the sum of.</param>
  13089. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13090. /// <exception cref="ArgumentNullException">
  13091. /// <paramref name="source" /> is null.</exception>
  13092. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
  13093. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13094. public static IQbservable<int> Sum(this IQbservable<int> source)
  13095. {
  13096. if (source == null)
  13097. throw new ArgumentNullException(nameof(source));
  13098. return source.Provider.CreateQuery<int>(
  13099. Expression.Call(
  13100. null,
  13101. #if CRIPPLED_REFLECTION
  13102. InfoOf(() => Qbservable.Sum(default(IQbservable<int>))),
  13103. #else
  13104. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13105. #endif
  13106. source.Expression
  13107. )
  13108. );
  13109. }
  13110. /// <summary>
  13111. /// Computes the sum of a sequence of <see cref="long" /> values.
  13112. /// </summary>
  13113. /// <param name="source">A sequence of <see cref="long" /> values to calculate the sum of.</param>
  13114. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13115. /// <exception cref="ArgumentNullException">
  13116. /// <paramref name="source" /> is null.</exception>
  13117. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  13118. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13119. public static IQbservable<long> Sum(this IQbservable<long> source)
  13120. {
  13121. if (source == null)
  13122. throw new ArgumentNullException(nameof(source));
  13123. return source.Provider.CreateQuery<long>(
  13124. Expression.Call(
  13125. null,
  13126. #if CRIPPLED_REFLECTION
  13127. InfoOf(() => Qbservable.Sum(default(IQbservable<long>))),
  13128. #else
  13129. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13130. #endif
  13131. source.Expression
  13132. )
  13133. );
  13134. }
  13135. /// <summary>
  13136. /// Computes the sum of a sequence of nullable <see cref="Decimal" /> values.
  13137. /// </summary>
  13138. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to calculate the sum of.</param>
  13139. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13140. /// <exception cref="ArgumentNullException">
  13141. /// <paramref name="source" /> is null.</exception>
  13142. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  13143. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13144. public static IQbservable<decimal?> Sum(this IQbservable<decimal?> source)
  13145. {
  13146. if (source == null)
  13147. throw new ArgumentNullException(nameof(source));
  13148. return source.Provider.CreateQuery<decimal?>(
  13149. Expression.Call(
  13150. null,
  13151. #if CRIPPLED_REFLECTION
  13152. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal?>))),
  13153. #else
  13154. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13155. #endif
  13156. source.Expression
  13157. )
  13158. );
  13159. }
  13160. /// <summary>
  13161. /// Computes the sum of a sequence of nullable <see cref="double" /> values.
  13162. /// </summary>
  13163. /// <param name="source">A sequence of nullable <see cref="double" /> values to calculate the sum of.</param>
  13164. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13165. /// <exception cref="ArgumentNullException">
  13166. /// <paramref name="source" /> is null.</exception>
  13167. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13168. public static IQbservable<double?> Sum(this IQbservable<double?> source)
  13169. {
  13170. if (source == null)
  13171. throw new ArgumentNullException(nameof(source));
  13172. return source.Provider.CreateQuery<double?>(
  13173. Expression.Call(
  13174. null,
  13175. #if CRIPPLED_REFLECTION
  13176. InfoOf(() => Qbservable.Sum(default(IQbservable<double?>))),
  13177. #else
  13178. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13179. #endif
  13180. source.Expression
  13181. )
  13182. );
  13183. }
  13184. /// <summary>
  13185. /// Computes the sum of a sequence of nullable <see cref="int" /> values.
  13186. /// </summary>
  13187. /// <param name="source">A sequence of nullable <see cref="int" /> values to calculate the sum of.</param>
  13188. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13189. /// <exception cref="ArgumentNullException">
  13190. /// <paramref name="source" /> is null.</exception>
  13191. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
  13192. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13193. public static IQbservable<int?> Sum(this IQbservable<int?> source)
  13194. {
  13195. if (source == null)
  13196. throw new ArgumentNullException(nameof(source));
  13197. return source.Provider.CreateQuery<int?>(
  13198. Expression.Call(
  13199. null,
  13200. #if CRIPPLED_REFLECTION
  13201. InfoOf(() => Qbservable.Sum(default(IQbservable<int?>))),
  13202. #else
  13203. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13204. #endif
  13205. source.Expression
  13206. )
  13207. );
  13208. }
  13209. /// <summary>
  13210. /// Computes the sum of a sequence of nullable <see cref="long" /> values.
  13211. /// </summary>
  13212. /// <param name="source">A sequence of nullable <see cref="long" /> values to calculate the sum of.</param>
  13213. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13214. /// <exception cref="ArgumentNullException">
  13215. /// <paramref name="source" /> is null.</exception>
  13216. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  13217. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13218. public static IQbservable<long?> Sum(this IQbservable<long?> source)
  13219. {
  13220. if (source == null)
  13221. throw new ArgumentNullException(nameof(source));
  13222. return source.Provider.CreateQuery<long?>(
  13223. Expression.Call(
  13224. null,
  13225. #if CRIPPLED_REFLECTION
  13226. InfoOf(() => Qbservable.Sum(default(IQbservable<long?>))),
  13227. #else
  13228. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13229. #endif
  13230. source.Expression
  13231. )
  13232. );
  13233. }
  13234. /// <summary>
  13235. /// Computes the sum of a sequence of nullable <see cref="Single" /> values.
  13236. /// </summary>
  13237. /// <param name="source">A sequence of nullable <see cref="Single" /> values to calculate the sum of.</param>
  13238. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13239. /// <exception cref="ArgumentNullException">
  13240. /// <paramref name="source" /> is null.</exception>
  13241. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13242. public static IQbservable<float?> Sum(this IQbservable<float?> source)
  13243. {
  13244. if (source == null)
  13245. throw new ArgumentNullException(nameof(source));
  13246. return source.Provider.CreateQuery<float?>(
  13247. Expression.Call(
  13248. null,
  13249. #if CRIPPLED_REFLECTION
  13250. InfoOf(() => Qbservable.Sum(default(IQbservable<float?>))),
  13251. #else
  13252. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13253. #endif
  13254. source.Expression
  13255. )
  13256. );
  13257. }
  13258. /// <summary>
  13259. /// Computes the sum of a sequence of <see cref="Single" /> values.
  13260. /// </summary>
  13261. /// <param name="source">A sequence of <see cref="Single" /> values to calculate the sum of.</param>
  13262. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13263. /// <exception cref="ArgumentNullException">
  13264. /// <paramref name="source" /> is null.</exception>
  13265. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13266. public static IQbservable<float> Sum(this IQbservable<float> source)
  13267. {
  13268. if (source == null)
  13269. throw new ArgumentNullException(nameof(source));
  13270. return source.Provider.CreateQuery<float>(
  13271. Expression.Call(
  13272. null,
  13273. #if CRIPPLED_REFLECTION
  13274. InfoOf(() => Qbservable.Sum(default(IQbservable<float>))),
  13275. #else
  13276. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13277. #endif
  13278. source.Expression
  13279. )
  13280. );
  13281. }
  13282. /// <summary>
  13283. /// 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.
  13284. /// </summary>
  13285. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13286. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13287. /// <param name="selector">A transform function to apply to each element.</param>
  13288. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13289. /// <exception cref="ArgumentNullException">
  13290. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13291. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13292. public static IQbservable<double> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  13293. {
  13294. if (source == null)
  13295. throw new ArgumentNullException(nameof(source));
  13296. if (selector == null)
  13297. throw new ArgumentNullException(nameof(selector));
  13298. return source.Provider.CreateQuery<double>(
  13299. Expression.Call(
  13300. null,
  13301. #if CRIPPLED_REFLECTION
  13302. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  13303. #else
  13304. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13305. #endif
  13306. source.Expression,
  13307. selector
  13308. )
  13309. );
  13310. }
  13311. /// <summary>
  13312. /// 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.
  13313. /// </summary>
  13314. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13315. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13316. /// <param name="selector">A transform function to apply to each element.</param>
  13317. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13318. /// <exception cref="ArgumentNullException">
  13319. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13320. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13321. public static IQbservable<float> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  13322. {
  13323. if (source == null)
  13324. throw new ArgumentNullException(nameof(source));
  13325. if (selector == null)
  13326. throw new ArgumentNullException(nameof(selector));
  13327. return source.Provider.CreateQuery<float>(
  13328. Expression.Call(
  13329. null,
  13330. #if CRIPPLED_REFLECTION
  13331. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  13332. #else
  13333. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13334. #endif
  13335. source.Expression,
  13336. selector
  13337. )
  13338. );
  13339. }
  13340. /// <summary>
  13341. /// 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.
  13342. /// </summary>
  13343. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13344. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13345. /// <param name="selector">A transform function to apply to each element.</param>
  13346. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13347. /// <exception cref="ArgumentNullException">
  13348. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13349. /// <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>
  13350. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13351. public static IQbservable<decimal> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  13352. {
  13353. if (source == null)
  13354. throw new ArgumentNullException(nameof(source));
  13355. if (selector == null)
  13356. throw new ArgumentNullException(nameof(selector));
  13357. return source.Provider.CreateQuery<decimal>(
  13358. Expression.Call(
  13359. null,
  13360. #if CRIPPLED_REFLECTION
  13361. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  13362. #else
  13363. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13364. #endif
  13365. source.Expression,
  13366. selector
  13367. )
  13368. );
  13369. }
  13370. /// <summary>
  13371. /// 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.
  13372. /// </summary>
  13373. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13374. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13375. /// <param name="selector">A transform function to apply to each element.</param>
  13376. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13377. /// <exception cref="ArgumentNullException">
  13378. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13379. /// <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>
  13380. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13381. public static IQbservable<int> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  13382. {
  13383. if (source == null)
  13384. throw new ArgumentNullException(nameof(source));
  13385. if (selector == null)
  13386. throw new ArgumentNullException(nameof(selector));
  13387. return source.Provider.CreateQuery<int>(
  13388. Expression.Call(
  13389. null,
  13390. #if CRIPPLED_REFLECTION
  13391. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  13392. #else
  13393. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13394. #endif
  13395. source.Expression,
  13396. selector
  13397. )
  13398. );
  13399. }
  13400. /// <summary>
  13401. /// 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.
  13402. /// </summary>
  13403. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13404. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13405. /// <param name="selector">A transform function to apply to each element.</param>
  13406. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13407. /// <exception cref="ArgumentNullException">
  13408. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13409. /// <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>
  13410. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13411. public static IQbservable<long> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  13412. {
  13413. if (source == null)
  13414. throw new ArgumentNullException(nameof(source));
  13415. if (selector == null)
  13416. throw new ArgumentNullException(nameof(selector));
  13417. return source.Provider.CreateQuery<long>(
  13418. Expression.Call(
  13419. null,
  13420. #if CRIPPLED_REFLECTION
  13421. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  13422. #else
  13423. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13424. #endif
  13425. source.Expression,
  13426. selector
  13427. )
  13428. );
  13429. }
  13430. /// <summary>
  13431. /// 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.
  13432. /// </summary>
  13433. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13434. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13435. /// <param name="selector">A transform function to apply to each element.</param>
  13436. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13437. /// <exception cref="ArgumentNullException">
  13438. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13439. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13440. public static IQbservable<double?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  13441. {
  13442. if (source == null)
  13443. throw new ArgumentNullException(nameof(source));
  13444. if (selector == null)
  13445. throw new ArgumentNullException(nameof(selector));
  13446. return source.Provider.CreateQuery<double?>(
  13447. Expression.Call(
  13448. null,
  13449. #if CRIPPLED_REFLECTION
  13450. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  13451. #else
  13452. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13453. #endif
  13454. source.Expression,
  13455. selector
  13456. )
  13457. );
  13458. }
  13459. /// <summary>
  13460. /// 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.
  13461. /// </summary>
  13462. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13463. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13464. /// <param name="selector">A transform function to apply to each element.</param>
  13465. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13466. /// <exception cref="ArgumentNullException">
  13467. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13468. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13469. public static IQbservable<float?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  13470. {
  13471. if (source == null)
  13472. throw new ArgumentNullException(nameof(source));
  13473. if (selector == null)
  13474. throw new ArgumentNullException(nameof(selector));
  13475. return source.Provider.CreateQuery<float?>(
  13476. Expression.Call(
  13477. null,
  13478. #if CRIPPLED_REFLECTION
  13479. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  13480. #else
  13481. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13482. #endif
  13483. source.Expression,
  13484. selector
  13485. )
  13486. );
  13487. }
  13488. /// <summary>
  13489. /// 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.
  13490. /// </summary>
  13491. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13492. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13493. /// <param name="selector">A transform function to apply to each element.</param>
  13494. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13495. /// <exception cref="ArgumentNullException">
  13496. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13497. /// <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>
  13498. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13499. public static IQbservable<decimal?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  13500. {
  13501. if (source == null)
  13502. throw new ArgumentNullException(nameof(source));
  13503. if (selector == null)
  13504. throw new ArgumentNullException(nameof(selector));
  13505. return source.Provider.CreateQuery<decimal?>(
  13506. Expression.Call(
  13507. null,
  13508. #if CRIPPLED_REFLECTION
  13509. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  13510. #else
  13511. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13512. #endif
  13513. source.Expression,
  13514. selector
  13515. )
  13516. );
  13517. }
  13518. /// <summary>
  13519. /// 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.
  13520. /// </summary>
  13521. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13522. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13523. /// <param name="selector">A transform function to apply to each element.</param>
  13524. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13525. /// <exception cref="ArgumentNullException">
  13526. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13527. /// <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>
  13528. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13529. public static IQbservable<int?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  13530. {
  13531. if (source == null)
  13532. throw new ArgumentNullException(nameof(source));
  13533. if (selector == null)
  13534. throw new ArgumentNullException(nameof(selector));
  13535. return source.Provider.CreateQuery<int?>(
  13536. Expression.Call(
  13537. null,
  13538. #if CRIPPLED_REFLECTION
  13539. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  13540. #else
  13541. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13542. #endif
  13543. source.Expression,
  13544. selector
  13545. )
  13546. );
  13547. }
  13548. /// <summary>
  13549. /// 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.
  13550. /// </summary>
  13551. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13552. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13553. /// <param name="selector">A transform function to apply to each element.</param>
  13554. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13555. /// <exception cref="ArgumentNullException">
  13556. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13557. /// <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>
  13558. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13559. public static IQbservable<long?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  13560. {
  13561. if (source == null)
  13562. throw new ArgumentNullException(nameof(source));
  13563. if (selector == null)
  13564. throw new ArgumentNullException(nameof(selector));
  13565. return source.Provider.CreateQuery<long?>(
  13566. Expression.Call(
  13567. null,
  13568. #if CRIPPLED_REFLECTION
  13569. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  13570. #else
  13571. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13572. #endif
  13573. source.Expression,
  13574. selector
  13575. )
  13576. );
  13577. }
  13578. /// <summary>
  13579. /// Transforms an observable sequence of observable sequences into an observable sequence
  13580. /// producing values only from the most recent observable sequence.
  13581. /// Each time a new inner observable sequence is received, unsubscribe from the
  13582. /// previous inner observable sequence.
  13583. /// </summary>
  13584. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  13585. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  13586. /// <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>
  13587. /// <exception cref="ArgumentNullException">
  13588. /// <paramref name="sources" /> is null.</exception>
  13589. public static IQbservable<TSource> Switch<TSource>(this IQbservable<IObservable<TSource>> sources)
  13590. {
  13591. if (sources == null)
  13592. throw new ArgumentNullException(nameof(sources));
  13593. return sources.Provider.CreateQuery<TSource>(
  13594. Expression.Call(
  13595. null,
  13596. #if CRIPPLED_REFLECTION
  13597. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<IObservable<TSource>>))),
  13598. #else
  13599. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13600. #endif
  13601. sources.Expression
  13602. )
  13603. );
  13604. }
  13605. /// <summary>
  13606. /// Transforms an observable sequence of tasks into an observable sequence
  13607. /// producing values only from the most recent observable sequence.
  13608. /// Each time a new task is received, the previous task's result is ignored.
  13609. /// </summary>
  13610. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  13611. /// <param name="sources">Observable sequence of tasks.</param>
  13612. /// <returns>The observable sequence that at any point in time produces the result of the most recent task that has been received.</returns>
  13613. /// <exception cref="ArgumentNullException">
  13614. /// <paramref name="sources" /> is null.</exception>
  13615. /// <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>
  13616. public static IQbservable<TSource> Switch<TSource>(this IQbservable<Task<TSource>> sources)
  13617. {
  13618. if (sources == null)
  13619. throw new ArgumentNullException(nameof(sources));
  13620. return sources.Provider.CreateQuery<TSource>(
  13621. Expression.Call(
  13622. null,
  13623. #if CRIPPLED_REFLECTION
  13624. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<Task<TSource>>))),
  13625. #else
  13626. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13627. #endif
  13628. sources.Expression
  13629. )
  13630. );
  13631. }
  13632. /// <summary>
  13633. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently.
  13634. /// This overload is useful to "fix" an observable sequence that exhibits concurrent callbacks on individual observers, which is invalid behavior for the query processor.
  13635. /// </summary>
  13636. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13637. /// <param name="source">Source sequence.</param>
  13638. /// <returns>The source sequence whose outgoing calls to observers are synchronized.</returns>
  13639. /// <exception cref="ArgumentNullException">
  13640. /// <paramref name="source" /> is null.</exception>
  13641. /// <remarks>
  13642. /// It's invalid behavior - according to the observer grammar - for a sequence to exhibit concurrent callbacks on a given observer.
  13643. /// This operator can be used to "fix" a source that doesn't conform to this rule.
  13644. /// </remarks>
  13645. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source)
  13646. {
  13647. if (source == null)
  13648. throw new ArgumentNullException(nameof(source));
  13649. return source.Provider.CreateQuery<TSource>(
  13650. Expression.Call(
  13651. null,
  13652. #if CRIPPLED_REFLECTION
  13653. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>))),
  13654. #else
  13655. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13656. #endif
  13657. source.Expression
  13658. )
  13659. );
  13660. }
  13661. /// <summary>
  13662. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently, using the specified gate object.
  13663. /// 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.
  13664. /// </summary>
  13665. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13666. /// <param name="source">Source sequence.</param>
  13667. /// <param name="gate">Gate object to synchronize each observer call on.</param>
  13668. /// <returns>The source sequence whose outgoing calls to observers are synchronized on the given gate object.</returns>
  13669. /// <exception cref="ArgumentNullException">
  13670. /// <paramref name="source" /> or <paramref name="gate" /> is null.</exception>
  13671. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source, object gate)
  13672. {
  13673. if (source == null)
  13674. throw new ArgumentNullException(nameof(source));
  13675. if (gate == null)
  13676. throw new ArgumentNullException(nameof(gate));
  13677. return source.Provider.CreateQuery<TSource>(
  13678. Expression.Call(
  13679. null,
  13680. #if CRIPPLED_REFLECTION
  13681. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>), default(object))),
  13682. #else
  13683. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13684. #endif
  13685. source.Expression,
  13686. Expression.Constant(gate, typeof(object))
  13687. )
  13688. );
  13689. }
  13690. /// <summary>
  13691. /// Returns a specified number of contiguous elements from the start of an observable sequence.
  13692. /// </summary>
  13693. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13694. /// <param name="source">The sequence to take elements from.</param>
  13695. /// <param name="count">The number of elements to return.</param>
  13696. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13697. /// <exception cref="ArgumentNullException">
  13698. /// <paramref name="source" /> is null.</exception>
  13699. /// <exception cref="ArgumentOutOfRangeException">
  13700. /// <paramref name="count" /> is less than zero.</exception>
  13701. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count)
  13702. {
  13703. if (source == null)
  13704. throw new ArgumentNullException(nameof(source));
  13705. return source.Provider.CreateQuery<TSource>(
  13706. Expression.Call(
  13707. null,
  13708. #if CRIPPLED_REFLECTION
  13709. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int))),
  13710. #else
  13711. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13712. #endif
  13713. source.Expression,
  13714. Expression.Constant(count, typeof(int))
  13715. )
  13716. );
  13717. }
  13718. /// <summary>
  13719. /// 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).
  13720. /// </summary>
  13721. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13722. /// <param name="source">The sequence to take elements from.</param>
  13723. /// <param name="count">The number of elements to return.</param>
  13724. /// <param name="scheduler">Scheduler used to produce an OnCompleted message in case <paramref name="count">count</paramref> is set to 0.</param>
  13725. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13726. /// <exception cref="ArgumentNullException">
  13727. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13728. /// <exception cref="ArgumentOutOfRangeException">
  13729. /// <paramref name="count" /> is less than zero.</exception>
  13730. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13731. {
  13732. if (source == null)
  13733. throw new ArgumentNullException(nameof(source));
  13734. if (scheduler == null)
  13735. throw new ArgumentNullException(nameof(scheduler));
  13736. return source.Provider.CreateQuery<TSource>(
  13737. Expression.Call(
  13738. null,
  13739. #if CRIPPLED_REFLECTION
  13740. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13741. #else
  13742. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13743. #endif
  13744. source.Expression,
  13745. Expression.Constant(count, typeof(int)),
  13746. Expression.Constant(scheduler, typeof(IScheduler))
  13747. )
  13748. );
  13749. }
  13750. /// <summary>
  13751. /// Takes elements for the specified duration from the start of the observable source sequence.
  13752. /// </summary>
  13753. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13754. /// <param name="source">Source sequence to take elements from.</param>
  13755. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13756. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13757. /// <exception cref="ArgumentNullException">
  13758. /// <paramref name="source" /> is null.</exception>
  13759. /// <exception cref="ArgumentOutOfRangeException">
  13760. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13761. /// <remarks>
  13762. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13763. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13764. /// immediately, despite the TimeSpan.Zero due time.
  13765. /// </remarks>
  13766. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13767. {
  13768. if (source == null)
  13769. throw new ArgumentNullException(nameof(source));
  13770. return source.Provider.CreateQuery<TSource>(
  13771. Expression.Call(
  13772. null,
  13773. #if CRIPPLED_REFLECTION
  13774. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13775. #else
  13776. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13777. #endif
  13778. source.Expression,
  13779. Expression.Constant(duration, typeof(TimeSpan))
  13780. )
  13781. );
  13782. }
  13783. /// <summary>
  13784. /// Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  13785. /// </summary>
  13786. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13787. /// <param name="source">Source sequence to take elements from.</param>
  13788. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13789. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13790. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13791. /// <exception cref="ArgumentNullException">
  13792. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13793. /// <exception cref="ArgumentOutOfRangeException">
  13794. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13795. /// <remarks>
  13796. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13797. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13798. /// immediately, despite the TimeSpan.Zero due time.
  13799. /// </remarks>
  13800. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13801. {
  13802. if (source == null)
  13803. throw new ArgumentNullException(nameof(source));
  13804. if (scheduler == null)
  13805. throw new ArgumentNullException(nameof(scheduler));
  13806. return source.Provider.CreateQuery<TSource>(
  13807. Expression.Call(
  13808. null,
  13809. #if CRIPPLED_REFLECTION
  13810. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13811. #else
  13812. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13813. #endif
  13814. source.Expression,
  13815. Expression.Constant(duration, typeof(TimeSpan)),
  13816. Expression.Constant(scheduler, typeof(IScheduler))
  13817. )
  13818. );
  13819. }
  13820. /// <summary>
  13821. /// Returns a specified number of contiguous elements from the end of an observable sequence.
  13822. /// </summary>
  13823. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13824. /// <param name="source">Source sequence.</param>
  13825. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13826. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13827. /// <exception cref="ArgumentNullException">
  13828. /// <paramref name="source" /> is null.</exception>
  13829. /// <exception cref="ArgumentOutOfRangeException">
  13830. /// <paramref name="count" /> is less than zero.</exception>
  13831. /// <remarks>
  13832. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13833. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13834. /// </remarks>
  13835. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count)
  13836. {
  13837. if (source == null)
  13838. throw new ArgumentNullException(nameof(source));
  13839. return source.Provider.CreateQuery<TSource>(
  13840. Expression.Call(
  13841. null,
  13842. #if CRIPPLED_REFLECTION
  13843. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int))),
  13844. #else
  13845. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13846. #endif
  13847. source.Expression,
  13848. Expression.Constant(count, typeof(int))
  13849. )
  13850. );
  13851. }
  13852. /// <summary>
  13853. /// Returns a specified number of contiguous elements from the end of an observable sequence, using the specified scheduler to drain the queue.
  13854. /// </summary>
  13855. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13856. /// <param name="source">Source sequence.</param>
  13857. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13858. /// <param name="scheduler">Scheduler used to drain the queue upon completion of the source sequence.</param>
  13859. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13860. /// <exception cref="ArgumentNullException">
  13861. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13862. /// <exception cref="ArgumentOutOfRangeException">
  13863. /// <paramref name="count" /> is less than zero.</exception>
  13864. /// <remarks>
  13865. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13866. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13867. /// </remarks>
  13868. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13869. {
  13870. if (source == null)
  13871. throw new ArgumentNullException(nameof(source));
  13872. if (scheduler == null)
  13873. throw new ArgumentNullException(nameof(scheduler));
  13874. return source.Provider.CreateQuery<TSource>(
  13875. Expression.Call(
  13876. null,
  13877. #if CRIPPLED_REFLECTION
  13878. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13879. #else
  13880. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13881. #endif
  13882. source.Expression,
  13883. Expression.Constant(count, typeof(int)),
  13884. Expression.Constant(scheduler, typeof(IScheduler))
  13885. )
  13886. );
  13887. }
  13888. /// <summary>
  13889. /// Returns elements within the specified duration from the end of the observable source sequence.
  13890. /// </summary>
  13891. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13892. /// <param name="source">Source sequence to take elements from.</param>
  13893. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13894. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13895. /// <exception cref="ArgumentNullException">
  13896. /// <paramref name="source" /> is null.</exception>
  13897. /// <exception cref="ArgumentOutOfRangeException">
  13898. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13899. /// <remarks>
  13900. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13901. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13902. /// to be delayed with <paramref name="duration" />.
  13903. /// </remarks>
  13904. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13905. {
  13906. if (source == null)
  13907. throw new ArgumentNullException(nameof(source));
  13908. return source.Provider.CreateQuery<TSource>(
  13909. Expression.Call(
  13910. null,
  13911. #if CRIPPLED_REFLECTION
  13912. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13913. #else
  13914. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13915. #endif
  13916. source.Expression,
  13917. Expression.Constant(duration, typeof(TimeSpan))
  13918. )
  13919. );
  13920. }
  13921. /// <summary>
  13922. /// Returns elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  13923. /// </summary>
  13924. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13925. /// <param name="source">Source sequence to take elements from.</param>
  13926. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13927. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13928. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13929. /// <exception cref="ArgumentNullException">
  13930. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13931. /// <exception cref="ArgumentOutOfRangeException">
  13932. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13933. /// <remarks>
  13934. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13935. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13936. /// to be delayed with <paramref name="duration" />.
  13937. /// </remarks>
  13938. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13939. {
  13940. if (source == null)
  13941. throw new ArgumentNullException(nameof(source));
  13942. if (scheduler == null)
  13943. throw new ArgumentNullException(nameof(scheduler));
  13944. return source.Provider.CreateQuery<TSource>(
  13945. Expression.Call(
  13946. null,
  13947. #if CRIPPLED_REFLECTION
  13948. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13949. #else
  13950. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13951. #endif
  13952. source.Expression,
  13953. Expression.Constant(duration, typeof(TimeSpan)),
  13954. Expression.Constant(scheduler, typeof(IScheduler))
  13955. )
  13956. );
  13957. }
  13958. /// <summary>
  13959. /// 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.
  13960. /// </summary>
  13961. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13962. /// <param name="source">Source sequence to take elements from.</param>
  13963. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13964. /// <param name="timerScheduler">Scheduler to run the timer on.</param>
  13965. /// <param name="loopScheduler">Scheduler to drain the collected elements.</param>
  13966. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13967. /// <exception cref="ArgumentNullException">
  13968. /// <paramref name="source" /> or <paramref name="timerScheduler" /> or <paramref name="loopScheduler" /> is null.</exception>
  13969. /// <exception cref="ArgumentOutOfRangeException">
  13970. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13971. /// <remarks>
  13972. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13973. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13974. /// to be delayed with <paramref name="duration" />.
  13975. /// </remarks>
  13976. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler timerScheduler, IScheduler loopScheduler)
  13977. {
  13978. if (source == null)
  13979. throw new ArgumentNullException(nameof(source));
  13980. if (timerScheduler == null)
  13981. throw new ArgumentNullException(nameof(timerScheduler));
  13982. if (loopScheduler == null)
  13983. throw new ArgumentNullException(nameof(loopScheduler));
  13984. return source.Provider.CreateQuery<TSource>(
  13985. Expression.Call(
  13986. null,
  13987. #if CRIPPLED_REFLECTION
  13988. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler), default(IScheduler))),
  13989. #else
  13990. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13991. #endif
  13992. source.Expression,
  13993. Expression.Constant(duration, typeof(TimeSpan)),
  13994. Expression.Constant(timerScheduler, typeof(IScheduler)),
  13995. Expression.Constant(loopScheduler, typeof(IScheduler))
  13996. )
  13997. );
  13998. }
  13999. /// <summary>
  14000. /// Returns a list with the specified number of contiguous elements from the end of an observable sequence.
  14001. /// </summary>
  14002. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14003. /// <param name="source">Source sequence.</param>
  14004. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  14005. /// <returns>An observable sequence containing a single list with the specified number of elements from the end of the source sequence.</returns>
  14006. /// <exception cref="ArgumentNullException">
  14007. /// <paramref name="source" /> is null.</exception>
  14008. /// <exception cref="ArgumentOutOfRangeException">
  14009. /// <paramref name="count" /> is less than zero.</exception>
  14010. /// <remarks>
  14011. /// This operator accumulates a buffer with a length enough to store <paramref name="count" /> elements. Upon completion of the
  14012. /// source sequence, this buffer is produced on the result sequence.
  14013. /// </remarks>
  14014. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, int count)
  14015. {
  14016. if (source == null)
  14017. throw new ArgumentNullException(nameof(source));
  14018. return source.Provider.CreateQuery<IList<TSource>>(
  14019. Expression.Call(
  14020. null,
  14021. #if CRIPPLED_REFLECTION
  14022. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(int))),
  14023. #else
  14024. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14025. #endif
  14026. source.Expression,
  14027. Expression.Constant(count, typeof(int))
  14028. )
  14029. );
  14030. }
  14031. /// <summary>
  14032. /// Returns a list with the elements within the specified duration from the end of the observable source sequence.
  14033. /// </summary>
  14034. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14035. /// <param name="source">Source sequence to take elements from.</param>
  14036. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14037. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  14038. /// <exception cref="ArgumentNullException">
  14039. /// <paramref name="source" /> is null.</exception>
  14040. /// <exception cref="ArgumentOutOfRangeException">
  14041. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14042. /// <remarks>
  14043. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14044. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  14045. /// </remarks>
  14046. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  14047. {
  14048. if (source == null)
  14049. throw new ArgumentNullException(nameof(source));
  14050. return source.Provider.CreateQuery<IList<TSource>>(
  14051. Expression.Call(
  14052. null,
  14053. #if CRIPPLED_REFLECTION
  14054. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14055. #else
  14056. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14057. #endif
  14058. source.Expression,
  14059. Expression.Constant(duration, typeof(TimeSpan))
  14060. )
  14061. );
  14062. }
  14063. /// <summary>
  14064. /// 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.
  14065. /// </summary>
  14066. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14067. /// <param name="source">Source sequence to take elements from.</param>
  14068. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14069. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14070. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  14071. /// <exception cref="ArgumentNullException">
  14072. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14073. /// <exception cref="ArgumentOutOfRangeException">
  14074. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14075. /// <remarks>
  14076. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14077. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  14078. /// </remarks>
  14079. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  14080. {
  14081. if (source == null)
  14082. throw new ArgumentNullException(nameof(source));
  14083. if (scheduler == null)
  14084. throw new ArgumentNullException(nameof(scheduler));
  14085. return source.Provider.CreateQuery<IList<TSource>>(
  14086. Expression.Call(
  14087. null,
  14088. #if CRIPPLED_REFLECTION
  14089. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14090. #else
  14091. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14092. #endif
  14093. source.Expression,
  14094. Expression.Constant(duration, typeof(TimeSpan)),
  14095. Expression.Constant(scheduler, typeof(IScheduler))
  14096. )
  14097. );
  14098. }
  14099. /// <summary>
  14100. /// Takes elements for the specified duration until the specified end time.
  14101. /// </summary>
  14102. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14103. /// <param name="source">Source sequence to take elements from.</param>
  14104. /// <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>
  14105. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  14106. /// <exception cref="ArgumentNullException">
  14107. /// <paramref name="source" /> is null.</exception>
  14108. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime)
  14109. {
  14110. if (source == null)
  14111. throw new ArgumentNullException(nameof(source));
  14112. return source.Provider.CreateQuery<TSource>(
  14113. Expression.Call(
  14114. null,
  14115. #if CRIPPLED_REFLECTION
  14116. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14117. #else
  14118. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14119. #endif
  14120. source.Expression,
  14121. Expression.Constant(endTime, typeof(DateTimeOffset))
  14122. )
  14123. );
  14124. }
  14125. /// <summary>
  14126. /// Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  14127. /// </summary>
  14128. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14129. /// <param name="source">Source sequence to take elements from.</param>
  14130. /// <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>
  14131. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14132. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  14133. /// <exception cref="ArgumentNullException">
  14134. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14135. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime, IScheduler scheduler)
  14136. {
  14137. if (source == null)
  14138. throw new ArgumentNullException(nameof(source));
  14139. if (scheduler == null)
  14140. throw new ArgumentNullException(nameof(scheduler));
  14141. return source.Provider.CreateQuery<TSource>(
  14142. Expression.Call(
  14143. null,
  14144. #if CRIPPLED_REFLECTION
  14145. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14146. #else
  14147. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14148. #endif
  14149. source.Expression,
  14150. Expression.Constant(endTime, typeof(DateTimeOffset)),
  14151. Expression.Constant(scheduler, typeof(IScheduler))
  14152. )
  14153. );
  14154. }
  14155. /// <summary>
  14156. /// Returns the elements from the source observable sequence until the other observable sequence produces an element.
  14157. /// </summary>
  14158. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14159. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of take behavior.</typeparam>
  14160. /// <param name="source">Source sequence to propagate elements for.</param>
  14161. /// <param name="other">Observable sequence that terminates propagation of elements of the source sequence.</param>
  14162. /// <returns>An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.</returns>
  14163. /// <exception cref="ArgumentNullException">
  14164. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14165. public static IQbservable<TSource> TakeUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  14166. {
  14167. if (source == null)
  14168. throw new ArgumentNullException(nameof(source));
  14169. if (other == null)
  14170. throw new ArgumentNullException(nameof(other));
  14171. return source.Provider.CreateQuery<TSource>(
  14172. Expression.Call(
  14173. null,
  14174. #if CRIPPLED_REFLECTION
  14175. InfoOf(() => Qbservable.TakeUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  14176. #else
  14177. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  14178. #endif
  14179. source.Expression,
  14180. GetSourceExpression(other)
  14181. )
  14182. );
  14183. }
  14184. /// <summary>
  14185. /// Relays elements from the source observable sequence and calls the predicate after an
  14186. /// emission to check if the sequence should stop after that specific item.
  14187. /// </summary>
  14188. /// <typeparam name="TSource">The type of the elements in the source and result sequences.</typeparam>
  14189. /// <param name="source">The source sequence to relay elements of.</param>
  14190. /// <param name="stopPredicate">Called after each upstream item has been emitted with
  14191. /// that upstream item and should return <code>true</code> to indicate the sequence should
  14192. /// complete.</param>
  14193. /// <returns>The observable sequence with the source elements until the stop predicate returns true.</returns>
  14194. /// <example>
  14195. /// The following sequence will stop after the value 5 has been encountered:
  14196. /// <code>
  14197. /// Observable.Range(1, 10)
  14198. /// .TakeUntil(item =&gt; item == 5)
  14199. /// .Subscribe(Console.WriteLine);
  14200. /// </code>
  14201. /// </example>
  14202. /// <exception cref="ArgumentException">If <typeparamref name="TSource"/> or <paramref name="stopPredicate"/> is <code>null</code>.</exception>
  14203. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> stopPredicate)
  14204. {
  14205. if (source == null)
  14206. throw new ArgumentNullException(nameof(source));
  14207. if (stopPredicate == null)
  14208. throw new ArgumentNullException(nameof(stopPredicate));
  14209. return source.Provider.CreateQuery<TSource>(
  14210. Expression.Call(
  14211. null,
  14212. #if CRIPPLED_REFLECTION
  14213. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  14214. #else
  14215. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14216. #endif
  14217. source.Expression,
  14218. stopPredicate
  14219. )
  14220. );
  14221. }
  14222. /// <summary>
  14223. /// Returns elements from an observable sequence as long as a specified condition is true.
  14224. /// </summary>
  14225. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14226. /// <param name="source">A sequence to return elements from.</param>
  14227. /// <param name="predicate">A function to test each element for a condition.</param>
  14228. /// <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>
  14229. /// <exception cref="ArgumentNullException">
  14230. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14231. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  14232. {
  14233. if (source == null)
  14234. throw new ArgumentNullException(nameof(source));
  14235. if (predicate == null)
  14236. throw new ArgumentNullException(nameof(predicate));
  14237. return source.Provider.CreateQuery<TSource>(
  14238. Expression.Call(
  14239. null,
  14240. #if CRIPPLED_REFLECTION
  14241. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  14242. #else
  14243. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14244. #endif
  14245. source.Expression,
  14246. predicate
  14247. )
  14248. );
  14249. }
  14250. /// <summary>
  14251. /// Returns elements from an observable sequence as long as a specified condition is true.
  14252. /// The element's index is used in the logic of the predicate function.
  14253. /// </summary>
  14254. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14255. /// <param name="source">A sequence to return elements from.</param>
  14256. /// <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>
  14257. /// <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>
  14258. /// <exception cref="ArgumentNullException">
  14259. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14260. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  14261. {
  14262. if (source == null)
  14263. throw new ArgumentNullException(nameof(source));
  14264. if (predicate == null)
  14265. throw new ArgumentNullException(nameof(predicate));
  14266. return source.Provider.CreateQuery<TSource>(
  14267. Expression.Call(
  14268. null,
  14269. #if CRIPPLED_REFLECTION
  14270. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  14271. #else
  14272. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14273. #endif
  14274. source.Expression,
  14275. predicate
  14276. )
  14277. );
  14278. }
  14279. /// <summary>
  14280. /// Ignores elements from an observable sequence which are followed by another element within a specified relative time duration.
  14281. /// </summary>
  14282. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14283. /// <param name="source">Source sequence to throttle.</param>
  14284. /// <param name="dueTime">Throttling duration for each element.</param>
  14285. /// <returns>The throttled sequence.</returns>
  14286. /// <exception cref="ArgumentNullException">
  14287. /// <paramref name="source" /> is null.</exception>
  14288. /// <exception cref="ArgumentOutOfRangeException">
  14289. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14290. /// <remarks>
  14291. /// <para>
  14292. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14293. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14294. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14295. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14296. /// Observable.Sample set of operators.
  14297. /// </para>
  14298. /// <para>
  14299. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14300. /// 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
  14301. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14302. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14303. /// </para>
  14304. /// </remarks>
  14305. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14306. {
  14307. if (source == null)
  14308. throw new ArgumentNullException(nameof(source));
  14309. return source.Provider.CreateQuery<TSource>(
  14310. Expression.Call(
  14311. null,
  14312. #if CRIPPLED_REFLECTION
  14313. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14314. #else
  14315. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14316. #endif
  14317. source.Expression,
  14318. Expression.Constant(dueTime, typeof(TimeSpan))
  14319. )
  14320. );
  14321. }
  14322. /// <summary>
  14323. /// 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.
  14324. /// </summary>
  14325. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14326. /// <param name="source">Source sequence to throttle.</param>
  14327. /// <param name="dueTime">Throttling duration for each element.</param>
  14328. /// <param name="scheduler">Scheduler to run the throttle timers on.</param>
  14329. /// <returns>The throttled sequence.</returns>
  14330. /// <exception cref="ArgumentNullException">
  14331. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14332. /// <exception cref="ArgumentOutOfRangeException">
  14333. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14334. /// <remarks>
  14335. /// <para>
  14336. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14337. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14338. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14339. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14340. /// Observable.Sample set of operators.
  14341. /// </para>
  14342. /// <para>
  14343. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14344. /// 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
  14345. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14346. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14347. /// </para>
  14348. /// </remarks>
  14349. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14350. {
  14351. if (source == null)
  14352. throw new ArgumentNullException(nameof(source));
  14353. if (scheduler == null)
  14354. throw new ArgumentNullException(nameof(scheduler));
  14355. return source.Provider.CreateQuery<TSource>(
  14356. Expression.Call(
  14357. null,
  14358. #if CRIPPLED_REFLECTION
  14359. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14360. #else
  14361. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14362. #endif
  14363. source.Expression,
  14364. Expression.Constant(dueTime, typeof(TimeSpan)),
  14365. Expression.Constant(scheduler, typeof(IScheduler))
  14366. )
  14367. );
  14368. }
  14369. /// <summary>
  14370. /// Ignores elements from an observable sequence which are followed by another value within a computed throttle duration.
  14371. /// </summary>
  14372. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14373. /// <typeparam name="TThrottle">The type of the elements in the throttle sequences selected for each element in the source sequence.</typeparam>
  14374. /// <param name="source">Source sequence to throttle.</param>
  14375. /// <param name="throttleDurationSelector">Selector function to retrieve a sequence indicating the throttle duration for each given element.</param>
  14376. /// <returns>The throttled sequence.</returns>
  14377. /// <exception cref="ArgumentNullException">
  14378. /// <paramref name="source" /> or <paramref name="throttleDurationSelector" /> is null.</exception>
  14379. /// <remarks>
  14380. /// This operator throttles the source sequence by holding on to each element for the duration denoted by <paramref name="throttleDurationSelector" />.
  14381. /// 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
  14382. /// whole process. For streams where the duration computed by applying the <paramref name="throttleDurationSelector" /> to each element overlaps with
  14383. /// the occurrence of the successor element, the resulting stream won't produce any elements. In order to reduce the volume of a stream whilst
  14384. /// guaranteeing the periodic production of elements, consider using the Observable.Sample set of operators.
  14385. /// </remarks>
  14386. public static IQbservable<TSource> Throttle<TSource, TThrottle>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TThrottle>>> throttleDurationSelector)
  14387. {
  14388. if (source == null)
  14389. throw new ArgumentNullException(nameof(source));
  14390. if (throttleDurationSelector == null)
  14391. throw new ArgumentNullException(nameof(throttleDurationSelector));
  14392. return source.Provider.CreateQuery<TSource>(
  14393. Expression.Call(
  14394. null,
  14395. #if CRIPPLED_REFLECTION
  14396. InfoOf(() => Qbservable.Throttle<TSource, TThrottle>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TThrottle>>>))),
  14397. #else
  14398. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TThrottle)),
  14399. #endif
  14400. source.Expression,
  14401. throttleDurationSelector
  14402. )
  14403. );
  14404. }
  14405. /// <summary>
  14406. /// Returns an observable sequence that terminates with an exception.
  14407. /// </summary>
  14408. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14409. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14410. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14411. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14412. /// <exception cref="ArgumentNullException">
  14413. /// <paramref name="exception" /> is null.</exception>
  14414. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception)
  14415. {
  14416. if (provider == null)
  14417. throw new ArgumentNullException(nameof(provider));
  14418. if (exception == null)
  14419. throw new ArgumentNullException(nameof(exception));
  14420. return provider.CreateQuery<TResult>(
  14421. Expression.Call(
  14422. null,
  14423. #if CRIPPLED_REFLECTION
  14424. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception))),
  14425. #else
  14426. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14427. #endif
  14428. Expression.Constant(provider, typeof(IQbservableProvider)),
  14429. Expression.Constant(exception, typeof(Exception))
  14430. )
  14431. );
  14432. }
  14433. /// <summary>
  14434. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14435. /// </summary>
  14436. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14437. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14438. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14439. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14440. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14441. /// <exception cref="ArgumentNullException">
  14442. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14443. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler)
  14444. {
  14445. if (provider == null)
  14446. throw new ArgumentNullException(nameof(provider));
  14447. if (exception == null)
  14448. throw new ArgumentNullException(nameof(exception));
  14449. if (scheduler == null)
  14450. throw new ArgumentNullException(nameof(scheduler));
  14451. return provider.CreateQuery<TResult>(
  14452. Expression.Call(
  14453. null,
  14454. #if CRIPPLED_REFLECTION
  14455. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler))),
  14456. #else
  14457. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14458. #endif
  14459. Expression.Constant(provider, typeof(IQbservableProvider)),
  14460. Expression.Constant(exception, typeof(Exception)),
  14461. Expression.Constant(scheduler, typeof(IScheduler))
  14462. )
  14463. );
  14464. }
  14465. /// <summary>
  14466. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14467. /// </summary>
  14468. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14469. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14470. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14471. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14472. /// <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>
  14473. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14474. /// <exception cref="ArgumentNullException">
  14475. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14476. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler, TResult witness)
  14477. {
  14478. if (provider == null)
  14479. throw new ArgumentNullException(nameof(provider));
  14480. if (exception == null)
  14481. throw new ArgumentNullException(nameof(exception));
  14482. if (scheduler == null)
  14483. throw new ArgumentNullException(nameof(scheduler));
  14484. return provider.CreateQuery<TResult>(
  14485. Expression.Call(
  14486. null,
  14487. #if CRIPPLED_REFLECTION
  14488. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler), default(TResult))),
  14489. #else
  14490. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14491. #endif
  14492. Expression.Constant(provider, typeof(IQbservableProvider)),
  14493. Expression.Constant(exception, typeof(Exception)),
  14494. Expression.Constant(scheduler, typeof(IScheduler)),
  14495. Expression.Constant(witness, typeof(TResult))
  14496. )
  14497. );
  14498. }
  14499. /// <summary>
  14500. /// Returns an observable sequence that terminates with an exception.
  14501. /// </summary>
  14502. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14503. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14504. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14505. /// <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>
  14506. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14507. /// <exception cref="ArgumentNullException">
  14508. /// <paramref name="exception" /> is null.</exception>
  14509. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, TResult witness)
  14510. {
  14511. if (provider == null)
  14512. throw new ArgumentNullException(nameof(provider));
  14513. if (exception == null)
  14514. throw new ArgumentNullException(nameof(exception));
  14515. return provider.CreateQuery<TResult>(
  14516. Expression.Call(
  14517. null,
  14518. #if CRIPPLED_REFLECTION
  14519. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(TResult))),
  14520. #else
  14521. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14522. #endif
  14523. Expression.Constant(provider, typeof(IQbservableProvider)),
  14524. Expression.Constant(exception, typeof(Exception)),
  14525. Expression.Constant(witness, typeof(TResult))
  14526. )
  14527. );
  14528. }
  14529. /// <summary>
  14530. /// Records the time interval between consecutive elements in an observable sequence.
  14531. /// </summary>
  14532. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14533. /// <param name="source">Source sequence to record time intervals for.</param>
  14534. /// <returns>An observable sequence with time interval information on elements.</returns>
  14535. /// <exception cref="ArgumentNullException">
  14536. /// <paramref name="source" /> is null.</exception>
  14537. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source)
  14538. {
  14539. if (source == null)
  14540. throw new ArgumentNullException(nameof(source));
  14541. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14542. Expression.Call(
  14543. null,
  14544. #if CRIPPLED_REFLECTION
  14545. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>))),
  14546. #else
  14547. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14548. #endif
  14549. source.Expression
  14550. )
  14551. );
  14552. }
  14553. /// <summary>
  14554. /// Records the time interval between consecutive elements in an observable sequence, using the specified scheduler to compute time intervals.
  14555. /// </summary>
  14556. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14557. /// <param name="source">Source sequence to record time intervals for.</param>
  14558. /// <param name="scheduler">Scheduler used to compute time intervals.</param>
  14559. /// <returns>An observable sequence with time interval information on elements.</returns>
  14560. /// <exception cref="ArgumentNullException">
  14561. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14562. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  14563. {
  14564. if (source == null)
  14565. throw new ArgumentNullException(nameof(source));
  14566. if (scheduler == null)
  14567. throw new ArgumentNullException(nameof(scheduler));
  14568. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14569. Expression.Call(
  14570. null,
  14571. #if CRIPPLED_REFLECTION
  14572. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  14573. #else
  14574. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14575. #endif
  14576. source.Expression,
  14577. Expression.Constant(scheduler, typeof(IScheduler))
  14578. )
  14579. );
  14580. }
  14581. /// <summary>
  14582. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14583. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14584. /// </summary>
  14585. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14586. /// <param name="source">Source sequence to perform a timeout for.</param>
  14587. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14588. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14589. /// <exception cref="ArgumentNullException">
  14590. /// <paramref name="source" /> is null.</exception>
  14591. /// <exception cref="TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14592. /// <remarks>
  14593. /// 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})" />
  14594. /// 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
  14595. /// 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.
  14596. /// </remarks>
  14597. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  14598. {
  14599. if (source == null)
  14600. throw new ArgumentNullException(nameof(source));
  14601. return source.Provider.CreateQuery<TSource>(
  14602. Expression.Call(
  14603. null,
  14604. #if CRIPPLED_REFLECTION
  14605. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14606. #else
  14607. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14608. #endif
  14609. source.Expression,
  14610. Expression.Constant(dueTime, typeof(DateTimeOffset))
  14611. )
  14612. );
  14613. }
  14614. /// <summary>
  14615. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14616. /// 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.
  14617. /// </summary>
  14618. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14619. /// <param name="source">Source sequence to perform a timeout for.</param>
  14620. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14621. /// <param name="other">Sequence to return in case of a timeout.</param>
  14622. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14623. /// <exception cref="ArgumentNullException">
  14624. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14625. /// <remarks>
  14626. /// 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})" />
  14627. /// 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
  14628. /// 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.
  14629. /// </remarks>
  14630. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other)
  14631. {
  14632. if (source == null)
  14633. throw new ArgumentNullException(nameof(source));
  14634. if (other == null)
  14635. throw new ArgumentNullException(nameof(other));
  14636. return source.Provider.CreateQuery<TSource>(
  14637. Expression.Call(
  14638. null,
  14639. #if CRIPPLED_REFLECTION
  14640. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>))),
  14641. #else
  14642. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14643. #endif
  14644. source.Expression,
  14645. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14646. GetSourceExpression(other)
  14647. )
  14648. );
  14649. }
  14650. /// <summary>
  14651. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14652. /// 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.
  14653. /// </summary>
  14654. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14655. /// <param name="source">Source sequence to perform a timeout for.</param>
  14656. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14657. /// <param name="other">Sequence to return in case of a timeout.</param>
  14658. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14659. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14660. /// <exception cref="ArgumentNullException">
  14661. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14662. /// <remarks>
  14663. /// 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})" />
  14664. /// 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
  14665. /// 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.
  14666. /// </remarks>
  14667. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other, IScheduler scheduler)
  14668. {
  14669. if (source == null)
  14670. throw new ArgumentNullException(nameof(source));
  14671. if (other == null)
  14672. throw new ArgumentNullException(nameof(other));
  14673. if (scheduler == null)
  14674. throw new ArgumentNullException(nameof(scheduler));
  14675. return source.Provider.CreateQuery<TSource>(
  14676. Expression.Call(
  14677. null,
  14678. #if CRIPPLED_REFLECTION
  14679. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>), default(IScheduler))),
  14680. #else
  14681. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14682. #endif
  14683. source.Expression,
  14684. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14685. GetSourceExpression(other),
  14686. Expression.Constant(scheduler, typeof(IScheduler))
  14687. )
  14688. );
  14689. }
  14690. /// <summary>
  14691. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14692. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14693. /// </summary>
  14694. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14695. /// <param name="source">Source sequence to perform a timeout for.</param>
  14696. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14697. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14698. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14699. /// <exception cref="ArgumentNullException">
  14700. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14701. /// <exception cref="TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14702. /// <remarks>
  14703. /// 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})" />
  14704. /// 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
  14705. /// 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.
  14706. /// </remarks>
  14707. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  14708. {
  14709. if (source == null)
  14710. throw new ArgumentNullException(nameof(source));
  14711. if (scheduler == null)
  14712. throw new ArgumentNullException(nameof(scheduler));
  14713. return source.Provider.CreateQuery<TSource>(
  14714. Expression.Call(
  14715. null,
  14716. #if CRIPPLED_REFLECTION
  14717. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14718. #else
  14719. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14720. #endif
  14721. source.Expression,
  14722. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14723. Expression.Constant(scheduler, typeof(IScheduler))
  14724. )
  14725. );
  14726. }
  14727. /// <summary>
  14728. /// Applies a timeout policy for each element in the observable sequence.
  14729. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14730. /// </summary>
  14731. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14732. /// <param name="source">Source sequence to perform a timeout for.</param>
  14733. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14734. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14735. /// <exception cref="ArgumentNullException">
  14736. /// <paramref name="source" /> is null.</exception>
  14737. /// <exception cref="ArgumentOutOfRangeException">
  14738. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14739. /// <exception cref="TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14740. /// <remarks>
  14741. /// <para>
  14742. /// 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})" />
  14743. /// 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
  14744. /// 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.
  14745. /// </para>
  14746. /// <para>
  14747. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14748. /// 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
  14749. /// 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
  14750. /// arrive before the scheduler gets a chance to run the timeout action.
  14751. /// </para>
  14752. /// </remarks>
  14753. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14754. {
  14755. if (source == null)
  14756. throw new ArgumentNullException(nameof(source));
  14757. return source.Provider.CreateQuery<TSource>(
  14758. Expression.Call(
  14759. null,
  14760. #if CRIPPLED_REFLECTION
  14761. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14762. #else
  14763. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14764. #endif
  14765. source.Expression,
  14766. Expression.Constant(dueTime, typeof(TimeSpan))
  14767. )
  14768. );
  14769. }
  14770. /// <summary>
  14771. /// Applies a timeout policy for each element in the observable sequence.
  14772. /// 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.
  14773. /// </summary>
  14774. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14775. /// <param name="source">Source sequence to perform a timeout for.</param>
  14776. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14777. /// <param name="other">Sequence to return in case of a timeout.</param>
  14778. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14779. /// <exception cref="ArgumentNullException">
  14780. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14781. /// <exception cref="ArgumentOutOfRangeException">
  14782. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14783. /// <remarks>
  14784. /// <para>
  14785. /// 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})" />
  14786. /// 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
  14787. /// 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.
  14788. /// </para>
  14789. /// <para>
  14790. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14791. /// 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
  14792. /// 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
  14793. /// arrive before the scheduler gets a chance to run the timeout action.
  14794. /// </para>
  14795. /// </remarks>
  14796. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other)
  14797. {
  14798. if (source == null)
  14799. throw new ArgumentNullException(nameof(source));
  14800. if (other == null)
  14801. throw new ArgumentNullException(nameof(other));
  14802. return source.Provider.CreateQuery<TSource>(
  14803. Expression.Call(
  14804. null,
  14805. #if CRIPPLED_REFLECTION
  14806. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>))),
  14807. #else
  14808. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14809. #endif
  14810. source.Expression,
  14811. Expression.Constant(dueTime, typeof(TimeSpan)),
  14812. GetSourceExpression(other)
  14813. )
  14814. );
  14815. }
  14816. /// <summary>
  14817. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14818. /// 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.
  14819. /// </summary>
  14820. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14821. /// <param name="source">Source sequence to perform a timeout for.</param>
  14822. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14823. /// <param name="other">Sequence to return in case of a timeout.</param>
  14824. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14825. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14826. /// <exception cref="ArgumentNullException">
  14827. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14828. /// <exception cref="ArgumentOutOfRangeException">
  14829. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14830. /// <remarks>
  14831. /// <para>
  14832. /// 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})" />
  14833. /// 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
  14834. /// 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.
  14835. /// </para>
  14836. /// <para>
  14837. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14838. /// 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
  14839. /// 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
  14840. /// arrive before the scheduler gets a chance to run the timeout action.
  14841. /// </para>
  14842. /// </remarks>
  14843. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other, IScheduler scheduler)
  14844. {
  14845. if (source == null)
  14846. throw new ArgumentNullException(nameof(source));
  14847. if (other == null)
  14848. throw new ArgumentNullException(nameof(other));
  14849. if (scheduler == null)
  14850. throw new ArgumentNullException(nameof(scheduler));
  14851. return source.Provider.CreateQuery<TSource>(
  14852. Expression.Call(
  14853. null,
  14854. #if CRIPPLED_REFLECTION
  14855. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>), default(IScheduler))),
  14856. #else
  14857. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14858. #endif
  14859. source.Expression,
  14860. Expression.Constant(dueTime, typeof(TimeSpan)),
  14861. GetSourceExpression(other),
  14862. Expression.Constant(scheduler, typeof(IScheduler))
  14863. )
  14864. );
  14865. }
  14866. /// <summary>
  14867. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14868. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14869. /// </summary>
  14870. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14871. /// <param name="source">Source sequence to perform a timeout for.</param>
  14872. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14873. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14874. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14875. /// <exception cref="ArgumentNullException">
  14876. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14877. /// <exception cref="ArgumentOutOfRangeException">
  14878. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14879. /// <exception cref="TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14880. /// <remarks>
  14881. /// <para>
  14882. /// 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})" />
  14883. /// 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
  14884. /// 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.
  14885. /// </para>
  14886. /// <para>
  14887. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14888. /// 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
  14889. /// 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
  14890. /// arrive before the scheduler gets a chance to run the timeout action.
  14891. /// </para>
  14892. /// </remarks>
  14893. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14894. {
  14895. if (source == null)
  14896. throw new ArgumentNullException(nameof(source));
  14897. if (scheduler == null)
  14898. throw new ArgumentNullException(nameof(scheduler));
  14899. return source.Provider.CreateQuery<TSource>(
  14900. Expression.Call(
  14901. null,
  14902. #if CRIPPLED_REFLECTION
  14903. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14904. #else
  14905. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14906. #endif
  14907. source.Expression,
  14908. Expression.Constant(dueTime, typeof(TimeSpan)),
  14909. Expression.Constant(scheduler, typeof(IScheduler))
  14910. )
  14911. );
  14912. }
  14913. /// <summary>
  14914. /// 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.
  14915. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14916. /// </summary>
  14917. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14918. /// <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>
  14919. /// <param name="source">Source sequence to perform a timeout for.</param>
  14920. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  14921. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14922. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14923. /// <exception cref="ArgumentNullException">
  14924. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  14925. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  14926. {
  14927. if (source == null)
  14928. throw new ArgumentNullException(nameof(source));
  14929. if (firstTimeout == null)
  14930. throw new ArgumentNullException(nameof(firstTimeout));
  14931. if (timeoutDurationSelector == null)
  14932. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  14933. return source.Provider.CreateQuery<TSource>(
  14934. Expression.Call(
  14935. null,
  14936. #if CRIPPLED_REFLECTION
  14937. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  14938. #else
  14939. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14940. #endif
  14941. source.Expression,
  14942. GetSourceExpression(firstTimeout),
  14943. timeoutDurationSelector
  14944. )
  14945. );
  14946. }
  14947. /// <summary>
  14948. /// 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.
  14949. /// 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.
  14950. /// </summary>
  14951. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14952. /// <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>
  14953. /// <param name="source">Source sequence to perform a timeout for.</param>
  14954. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  14955. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14956. /// <param name="other">Sequence to return in case of a timeout.</param>
  14957. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14958. /// <exception cref="ArgumentNullException">
  14959. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  14960. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  14961. {
  14962. if (source == null)
  14963. throw new ArgumentNullException(nameof(source));
  14964. if (firstTimeout == null)
  14965. throw new ArgumentNullException(nameof(firstTimeout));
  14966. if (timeoutDurationSelector == null)
  14967. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  14968. if (other == null)
  14969. throw new ArgumentNullException(nameof(other));
  14970. return source.Provider.CreateQuery<TSource>(
  14971. Expression.Call(
  14972. null,
  14973. #if CRIPPLED_REFLECTION
  14974. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  14975. #else
  14976. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14977. #endif
  14978. source.Expression,
  14979. GetSourceExpression(firstTimeout),
  14980. timeoutDurationSelector,
  14981. GetSourceExpression(other)
  14982. )
  14983. );
  14984. }
  14985. /// <summary>
  14986. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  14987. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14988. /// </summary>
  14989. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14990. /// <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>
  14991. /// <param name="source">Source sequence to perform a timeout for.</param>
  14992. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14993. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14994. /// <exception cref="ArgumentNullException">
  14995. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  14996. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  14997. {
  14998. if (source == null)
  14999. throw new ArgumentNullException(nameof(source));
  15000. if (timeoutDurationSelector == null)
  15001. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  15002. return source.Provider.CreateQuery<TSource>(
  15003. Expression.Call(
  15004. null,
  15005. #if CRIPPLED_REFLECTION
  15006. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  15007. #else
  15008. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15009. #endif
  15010. source.Expression,
  15011. timeoutDurationSelector
  15012. )
  15013. );
  15014. }
  15015. /// <summary>
  15016. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  15017. /// 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.
  15018. /// </summary>
  15019. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  15020. /// <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>
  15021. /// <param name="source">Source sequence to perform a timeout for.</param>
  15022. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15023. /// <param name="other">Sequence to return in case of a timeout.</param>
  15024. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15025. /// <exception cref="ArgumentNullException">
  15026. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  15027. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  15028. {
  15029. if (source == null)
  15030. throw new ArgumentNullException(nameof(source));
  15031. if (timeoutDurationSelector == null)
  15032. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  15033. if (other == null)
  15034. throw new ArgumentNullException(nameof(other));
  15035. return source.Provider.CreateQuery<TSource>(
  15036. Expression.Call(
  15037. null,
  15038. #if CRIPPLED_REFLECTION
  15039. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  15040. #else
  15041. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15042. #endif
  15043. source.Expression,
  15044. timeoutDurationSelector,
  15045. GetSourceExpression(other)
  15046. )
  15047. );
  15048. }
  15049. /// <summary>
  15050. /// Returns an observable sequence that produces a single value at the specified absolute due time.
  15051. /// </summary>
  15052. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15053. /// <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>
  15054. /// <returns>An observable sequence that produces a value at due time.</returns>
  15055. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime)
  15056. {
  15057. if (provider == null)
  15058. throw new ArgumentNullException(nameof(provider));
  15059. return provider.CreateQuery<long>(
  15060. Expression.Call(
  15061. null,
  15062. #if CRIPPLED_REFLECTION
  15063. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset))),
  15064. #else
  15065. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15066. #endif
  15067. Expression.Constant(provider, typeof(IQbservableProvider)),
  15068. Expression.Constant(dueTime, typeof(DateTimeOffset))
  15069. )
  15070. );
  15071. }
  15072. /// <summary>
  15073. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time.
  15074. /// </summary>
  15075. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15076. /// <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>
  15077. /// <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>
  15078. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  15079. /// <exception cref="ArgumentOutOfRangeException">
  15080. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15081. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period)
  15082. {
  15083. if (provider == null)
  15084. throw new ArgumentNullException(nameof(provider));
  15085. return provider.CreateQuery<long>(
  15086. Expression.Call(
  15087. null,
  15088. #if CRIPPLED_REFLECTION
  15089. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan))),
  15090. #else
  15091. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15092. #endif
  15093. Expression.Constant(provider, typeof(IQbservableProvider)),
  15094. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15095. Expression.Constant(period, typeof(TimeSpan))
  15096. )
  15097. );
  15098. }
  15099. /// <summary>
  15100. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time, using the specified scheduler to run timers.
  15101. /// </summary>
  15102. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15103. /// <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>
  15104. /// <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>
  15105. /// <param name="scheduler">Scheduler to run timers on.</param>
  15106. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  15107. /// <exception cref="ArgumentOutOfRangeException">
  15108. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15109. /// <exception cref="ArgumentNullException">
  15110. /// <paramref name="scheduler" /> is null.</exception>
  15111. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period, IScheduler scheduler)
  15112. {
  15113. if (provider == null)
  15114. throw new ArgumentNullException(nameof(provider));
  15115. if (scheduler == null)
  15116. throw new ArgumentNullException(nameof(scheduler));
  15117. return provider.CreateQuery<long>(
  15118. Expression.Call(
  15119. null,
  15120. #if CRIPPLED_REFLECTION
  15121. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan), default(IScheduler))),
  15122. #else
  15123. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15124. #endif
  15125. Expression.Constant(provider, typeof(IQbservableProvider)),
  15126. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15127. Expression.Constant(period, typeof(TimeSpan)),
  15128. Expression.Constant(scheduler, typeof(IScheduler))
  15129. )
  15130. );
  15131. }
  15132. /// <summary>
  15133. /// Returns an observable sequence that produces a single value at the specified absolute due time, using the specified scheduler to run the timer.
  15134. /// </summary>
  15135. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15136. /// <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>
  15137. /// <param name="scheduler">Scheduler to run the timer on.</param>
  15138. /// <returns>An observable sequence that produces a value at due time.</returns>
  15139. /// <exception cref="ArgumentNullException">
  15140. /// <paramref name="scheduler" /> is null.</exception>
  15141. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, IScheduler scheduler)
  15142. {
  15143. if (provider == null)
  15144. throw new ArgumentNullException(nameof(provider));
  15145. if (scheduler == null)
  15146. throw new ArgumentNullException(nameof(scheduler));
  15147. return provider.CreateQuery<long>(
  15148. Expression.Call(
  15149. null,
  15150. #if CRIPPLED_REFLECTION
  15151. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(IScheduler))),
  15152. #else
  15153. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15154. #endif
  15155. Expression.Constant(provider, typeof(IQbservableProvider)),
  15156. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15157. Expression.Constant(scheduler, typeof(IScheduler))
  15158. )
  15159. );
  15160. }
  15161. /// <summary>
  15162. /// Returns an observable sequence that produces a single value after the specified relative due time has elapsed.
  15163. /// </summary>
  15164. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15165. /// <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>
  15166. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15167. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime)
  15168. {
  15169. if (provider == null)
  15170. throw new ArgumentNullException(nameof(provider));
  15171. return provider.CreateQuery<long>(
  15172. Expression.Call(
  15173. null,
  15174. #if CRIPPLED_REFLECTION
  15175. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan))),
  15176. #else
  15177. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15178. #endif
  15179. Expression.Constant(provider, typeof(IQbservableProvider)),
  15180. Expression.Constant(dueTime, typeof(TimeSpan))
  15181. )
  15182. );
  15183. }
  15184. /// <summary>
  15185. /// Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed.
  15186. /// </summary>
  15187. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15188. /// <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>
  15189. /// <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>
  15190. /// <returns>An observable sequence that produces a value after due time has elapsed and then after each period.</returns>
  15191. /// <exception cref="ArgumentOutOfRangeException">
  15192. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15193. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period)
  15194. {
  15195. if (provider == null)
  15196. throw new ArgumentNullException(nameof(provider));
  15197. return provider.CreateQuery<long>(
  15198. Expression.Call(
  15199. null,
  15200. #if CRIPPLED_REFLECTION
  15201. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan))),
  15202. #else
  15203. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15204. #endif
  15205. Expression.Constant(provider, typeof(IQbservableProvider)),
  15206. Expression.Constant(dueTime, typeof(TimeSpan)),
  15207. Expression.Constant(period, typeof(TimeSpan))
  15208. )
  15209. );
  15210. }
  15211. /// <summary>
  15212. /// 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.
  15213. /// </summary>
  15214. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15215. /// <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>
  15216. /// <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>
  15217. /// <param name="scheduler">Scheduler to run timers on.</param>
  15218. /// <returns>An observable sequence that produces a value after due time has elapsed and then each period.</returns>
  15219. /// <exception cref="ArgumentOutOfRangeException">
  15220. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15221. /// <exception cref="ArgumentNullException">
  15222. /// <paramref name="scheduler" /> is null.</exception>
  15223. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period, IScheduler scheduler)
  15224. {
  15225. if (provider == null)
  15226. throw new ArgumentNullException(nameof(provider));
  15227. if (scheduler == null)
  15228. throw new ArgumentNullException(nameof(scheduler));
  15229. return provider.CreateQuery<long>(
  15230. Expression.Call(
  15231. null,
  15232. #if CRIPPLED_REFLECTION
  15233. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  15234. #else
  15235. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15236. #endif
  15237. Expression.Constant(provider, typeof(IQbservableProvider)),
  15238. Expression.Constant(dueTime, typeof(TimeSpan)),
  15239. Expression.Constant(period, typeof(TimeSpan)),
  15240. Expression.Constant(scheduler, typeof(IScheduler))
  15241. )
  15242. );
  15243. }
  15244. /// <summary>
  15245. /// 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.
  15246. /// </summary>
  15247. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15248. /// <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>
  15249. /// <param name="scheduler">Scheduler to run the timer on.</param>
  15250. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15251. /// <exception cref="ArgumentNullException">
  15252. /// <paramref name="scheduler" /> is null.</exception>
  15253. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, IScheduler scheduler)
  15254. {
  15255. if (provider == null)
  15256. throw new ArgumentNullException(nameof(provider));
  15257. if (scheduler == null)
  15258. throw new ArgumentNullException(nameof(scheduler));
  15259. return provider.CreateQuery<long>(
  15260. Expression.Call(
  15261. null,
  15262. #if CRIPPLED_REFLECTION
  15263. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  15264. #else
  15265. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15266. #endif
  15267. Expression.Constant(provider, typeof(IQbservableProvider)),
  15268. Expression.Constant(dueTime, typeof(TimeSpan)),
  15269. Expression.Constant(scheduler, typeof(IScheduler))
  15270. )
  15271. );
  15272. }
  15273. /// <summary>
  15274. /// Timestamps each element in an observable sequence using the local system clock.
  15275. /// </summary>
  15276. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15277. /// <param name="source">Source sequence to timestamp elements for.</param>
  15278. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15279. /// <exception cref="ArgumentNullException">
  15280. /// <paramref name="source" /> is null.</exception>
  15281. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source)
  15282. {
  15283. if (source == null)
  15284. throw new ArgumentNullException(nameof(source));
  15285. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15286. Expression.Call(
  15287. null,
  15288. #if CRIPPLED_REFLECTION
  15289. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>))),
  15290. #else
  15291. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15292. #endif
  15293. source.Expression
  15294. )
  15295. );
  15296. }
  15297. /// <summary>
  15298. /// Timestamp each element in an observable sequence using the clock of the specified scheduler.
  15299. /// </summary>
  15300. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15301. /// <param name="source">Source sequence to timestamp elements for.</param>
  15302. /// <param name="scheduler">Scheduler used to compute timestamps.</param>
  15303. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15304. /// <exception cref="ArgumentNullException">
  15305. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15306. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  15307. {
  15308. if (source == null)
  15309. throw new ArgumentNullException(nameof(source));
  15310. if (scheduler == null)
  15311. throw new ArgumentNullException(nameof(scheduler));
  15312. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15313. Expression.Call(
  15314. null,
  15315. #if CRIPPLED_REFLECTION
  15316. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  15317. #else
  15318. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15319. #endif
  15320. source.Expression,
  15321. Expression.Constant(scheduler, typeof(IScheduler))
  15322. )
  15323. );
  15324. }
  15325. /// <summary>
  15326. /// Creates an array from an observable sequence.
  15327. /// </summary>
  15328. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15329. /// <param name="source">The source observable sequence to get an array of elements for.</param>
  15330. /// <returns>An observable sequence containing a single element with an array containing all the elements of the source sequence.</returns>
  15331. /// <exception cref="ArgumentNullException">
  15332. /// <paramref name="source" /> is null.</exception>
  15333. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15334. public static IQbservable<TSource[]> ToArray<TSource>(this IQbservable<TSource> source)
  15335. {
  15336. if (source == null)
  15337. throw new ArgumentNullException(nameof(source));
  15338. return source.Provider.CreateQuery<TSource[]>(
  15339. Expression.Call(
  15340. null,
  15341. #if CRIPPLED_REFLECTION
  15342. InfoOf(() => Qbservable.ToArray<TSource>(default(IQbservable<TSource>))),
  15343. #else
  15344. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15345. #endif
  15346. source.Expression
  15347. )
  15348. );
  15349. }
  15350. /// <summary>
  15351. /// Creates a dictionary from an observable sequence according to a specified key selector function.
  15352. /// </summary>
  15353. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15354. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15355. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15356. /// <param name="keySelector">A function to extract a key from each element.</param>
  15357. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15358. /// <exception cref="ArgumentNullException">
  15359. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15360. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15361. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15362. {
  15363. if (source == null)
  15364. throw new ArgumentNullException(nameof(source));
  15365. if (keySelector == null)
  15366. throw new ArgumentNullException(nameof(keySelector));
  15367. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15368. Expression.Call(
  15369. null,
  15370. #if CRIPPLED_REFLECTION
  15371. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15372. #else
  15373. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15374. #endif
  15375. source.Expression,
  15376. keySelector
  15377. )
  15378. );
  15379. }
  15380. /// <summary>
  15381. /// Creates a dictionary from an observable sequence according to a specified key selector function, and a comparer.
  15382. /// </summary>
  15383. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15384. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15385. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15386. /// <param name="keySelector">A function to extract a key from each element.</param>
  15387. /// <param name="comparer">An equality comparer to compare keys.</param>
  15388. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15389. /// <exception cref="ArgumentNullException">
  15390. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15391. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15392. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15393. {
  15394. if (source == null)
  15395. throw new ArgumentNullException(nameof(source));
  15396. if (keySelector == null)
  15397. throw new ArgumentNullException(nameof(keySelector));
  15398. if (comparer == null)
  15399. throw new ArgumentNullException(nameof(comparer));
  15400. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15401. Expression.Call(
  15402. null,
  15403. #if CRIPPLED_REFLECTION
  15404. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15405. #else
  15406. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15407. #endif
  15408. source.Expression,
  15409. keySelector,
  15410. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15411. )
  15412. );
  15413. }
  15414. /// <summary>
  15415. /// Creates a dictionary from an observable sequence according to a specified key selector function, and an element selector function.
  15416. /// </summary>
  15417. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15418. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15419. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15420. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15421. /// <param name="keySelector">A function to extract a key from each element.</param>
  15422. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15423. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15424. /// <exception cref="ArgumentNullException">
  15425. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15426. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15427. public static IQbservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15428. {
  15429. if (source == null)
  15430. throw new ArgumentNullException(nameof(source));
  15431. if (keySelector == null)
  15432. throw new ArgumentNullException(nameof(keySelector));
  15433. if (elementSelector == null)
  15434. throw new ArgumentNullException(nameof(elementSelector));
  15435. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15436. Expression.Call(
  15437. null,
  15438. #if CRIPPLED_REFLECTION
  15439. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15440. #else
  15441. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15442. #endif
  15443. source.Expression,
  15444. keySelector,
  15445. elementSelector
  15446. )
  15447. );
  15448. }
  15449. /// <summary>
  15450. /// Creates a dictionary from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15451. /// </summary>
  15452. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15453. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15454. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15455. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15456. /// <param name="keySelector">A function to extract a key from each element.</param>
  15457. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15458. /// <param name="comparer">An equality comparer to compare keys.</param>
  15459. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15460. /// <exception cref="ArgumentNullException">
  15461. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15462. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15463. 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)
  15464. {
  15465. if (source == null)
  15466. throw new ArgumentNullException(nameof(source));
  15467. if (keySelector == null)
  15468. throw new ArgumentNullException(nameof(keySelector));
  15469. if (elementSelector == null)
  15470. throw new ArgumentNullException(nameof(elementSelector));
  15471. if (comparer == null)
  15472. throw new ArgumentNullException(nameof(comparer));
  15473. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15474. Expression.Call(
  15475. null,
  15476. #if CRIPPLED_REFLECTION
  15477. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15478. #else
  15479. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15480. #endif
  15481. source.Expression,
  15482. keySelector,
  15483. elementSelector,
  15484. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15485. )
  15486. );
  15487. }
  15488. /// <summary>
  15489. /// Converts an observable sequence to an enumerable sequence.
  15490. /// </summary>
  15491. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15492. /// <param name="source">An observable sequence to convert to an enumerable sequence.</param>
  15493. /// <returns>The enumerable sequence containing the elements in the observable sequence.</returns>
  15494. /// <exception cref="ArgumentNullException">
  15495. /// <paramref name="source" /> is null.</exception>
  15496. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  15497. public static IQueryable<TSource> ToQueryable<TSource>(this IQbservable<TSource> source)
  15498. {
  15499. if (source == null)
  15500. throw new ArgumentNullException(nameof(source));
  15501. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  15502. Expression.Call(
  15503. null,
  15504. #if CRIPPLED_REFLECTION
  15505. InfoOf(() => Qbservable.ToQueryable<TSource>(default(IQbservable<TSource>))),
  15506. #else
  15507. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15508. #endif
  15509. source.Expression
  15510. )
  15511. );
  15512. }
  15513. /// <summary>
  15514. /// Creates a list from an observable sequence.
  15515. /// </summary>
  15516. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15517. /// <param name="source">The source observable sequence to get a list of elements for.</param>
  15518. /// <returns>An observable sequence containing a single element with a list containing all the elements of the source sequence.</returns>
  15519. /// <exception cref="ArgumentNullException">
  15520. /// <paramref name="source" /> is null.</exception>
  15521. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15522. public static IQbservable<IList<TSource>> ToList<TSource>(this IQbservable<TSource> source)
  15523. {
  15524. if (source == null)
  15525. throw new ArgumentNullException(nameof(source));
  15526. return source.Provider.CreateQuery<IList<TSource>>(
  15527. Expression.Call(
  15528. null,
  15529. #if CRIPPLED_REFLECTION
  15530. InfoOf(() => Qbservable.ToList<TSource>(default(IQbservable<TSource>))),
  15531. #else
  15532. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15533. #endif
  15534. source.Expression
  15535. )
  15536. );
  15537. }
  15538. /// <summary>
  15539. /// Creates a lookup from an observable sequence according to a specified key selector function.
  15540. /// </summary>
  15541. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15542. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15543. /// <param name="source">An observable sequence to create a lookup for.</param>
  15544. /// <param name="keySelector">A function to extract a key from each element.</param>
  15545. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15546. /// <exception cref="ArgumentNullException">
  15547. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15548. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15549. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15550. {
  15551. if (source == null)
  15552. throw new ArgumentNullException(nameof(source));
  15553. if (keySelector == null)
  15554. throw new ArgumentNullException(nameof(keySelector));
  15555. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15556. Expression.Call(
  15557. null,
  15558. #if CRIPPLED_REFLECTION
  15559. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15560. #else
  15561. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15562. #endif
  15563. source.Expression,
  15564. keySelector
  15565. )
  15566. );
  15567. }
  15568. /// <summary>
  15569. /// Creates a lookup from an observable sequence according to a specified key selector function, and a comparer.
  15570. /// </summary>
  15571. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15572. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15573. /// <param name="source">An observable sequence to create a lookup for.</param>
  15574. /// <param name="keySelector">A function to extract a key from each element.</param>
  15575. /// <param name="comparer">An equality comparer to compare keys.</param>
  15576. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15577. /// <exception cref="ArgumentNullException">
  15578. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15579. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15580. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15581. {
  15582. if (source == null)
  15583. throw new ArgumentNullException(nameof(source));
  15584. if (keySelector == null)
  15585. throw new ArgumentNullException(nameof(keySelector));
  15586. if (comparer == null)
  15587. throw new ArgumentNullException(nameof(comparer));
  15588. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15589. Expression.Call(
  15590. null,
  15591. #if CRIPPLED_REFLECTION
  15592. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15593. #else
  15594. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15595. #endif
  15596. source.Expression,
  15597. keySelector,
  15598. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15599. )
  15600. );
  15601. }
  15602. /// <summary>
  15603. /// Creates a lookup from an observable sequence according to a specified key selector function, and an element selector function.
  15604. /// </summary>
  15605. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15606. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15607. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15608. /// <param name="source">An observable sequence to create a lookup for.</param>
  15609. /// <param name="keySelector">A function to extract a key from each element.</param>
  15610. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15611. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15612. /// <exception cref="ArgumentNullException">
  15613. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15614. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15615. public static IQbservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15616. {
  15617. if (source == null)
  15618. throw new ArgumentNullException(nameof(source));
  15619. if (keySelector == null)
  15620. throw new ArgumentNullException(nameof(keySelector));
  15621. if (elementSelector == null)
  15622. throw new ArgumentNullException(nameof(elementSelector));
  15623. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15624. Expression.Call(
  15625. null,
  15626. #if CRIPPLED_REFLECTION
  15627. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15628. #else
  15629. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15630. #endif
  15631. source.Expression,
  15632. keySelector,
  15633. elementSelector
  15634. )
  15635. );
  15636. }
  15637. /// <summary>
  15638. /// Creates a lookup from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15639. /// </summary>
  15640. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15641. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15642. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15643. /// <param name="source">An observable sequence to create a lookup for.</param>
  15644. /// <param name="keySelector">A function to extract a key from each element.</param>
  15645. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15646. /// <param name="comparer">An equality comparer to compare keys.</param>
  15647. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15648. /// <exception cref="ArgumentNullException">
  15649. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15650. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15651. 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)
  15652. {
  15653. if (source == null)
  15654. throw new ArgumentNullException(nameof(source));
  15655. if (keySelector == null)
  15656. throw new ArgumentNullException(nameof(keySelector));
  15657. if (elementSelector == null)
  15658. throw new ArgumentNullException(nameof(elementSelector));
  15659. if (comparer == null)
  15660. throw new ArgumentNullException(nameof(comparer));
  15661. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15662. Expression.Call(
  15663. null,
  15664. #if CRIPPLED_REFLECTION
  15665. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15666. #else
  15667. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15668. #endif
  15669. source.Expression,
  15670. keySelector,
  15671. elementSelector,
  15672. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15673. )
  15674. );
  15675. }
  15676. /// <summary>
  15677. /// Converts an enumerable sequence to an observable sequence.
  15678. /// </summary>
  15679. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15680. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15681. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15682. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15683. /// <exception cref="ArgumentNullException">
  15684. /// <paramref name="source" /> is null.</exception>
  15685. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source)
  15686. {
  15687. if (provider == null)
  15688. throw new ArgumentNullException(nameof(provider));
  15689. if (source == null)
  15690. throw new ArgumentNullException(nameof(source));
  15691. return provider.CreateQuery<TSource>(
  15692. Expression.Call(
  15693. null,
  15694. #if CRIPPLED_REFLECTION
  15695. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>))),
  15696. #else
  15697. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15698. #endif
  15699. Expression.Constant(provider, typeof(IQbservableProvider)),
  15700. GetSourceExpression(source)
  15701. )
  15702. );
  15703. }
  15704. /// <summary>
  15705. /// Converts an enumerable sequence to an observable sequence, using the specified scheduler to run the enumeration loop.
  15706. /// </summary>
  15707. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15708. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15709. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15710. /// <param name="scheduler">Scheduler to run the enumeration of the input sequence on.</param>
  15711. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15712. /// <exception cref="ArgumentNullException">
  15713. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15714. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source, IScheduler scheduler)
  15715. {
  15716. if (provider == null)
  15717. throw new ArgumentNullException(nameof(provider));
  15718. if (source == null)
  15719. throw new ArgumentNullException(nameof(source));
  15720. if (scheduler == null)
  15721. throw new ArgumentNullException(nameof(scheduler));
  15722. return provider.CreateQuery<TSource>(
  15723. Expression.Call(
  15724. null,
  15725. #if CRIPPLED_REFLECTION
  15726. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>), default(IScheduler))),
  15727. #else
  15728. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15729. #endif
  15730. Expression.Constant(provider, typeof(IQbservableProvider)),
  15731. GetSourceExpression(source),
  15732. Expression.Constant(scheduler, typeof(IScheduler))
  15733. )
  15734. );
  15735. }
  15736. /// <summary>
  15737. /// Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
  15738. /// </summary>
  15739. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15740. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15741. /// <typeparam name="TResource">The type of the resource used during the generation of the resulting sequence. Needs to implement <see cref="IDisposable" />.</typeparam>
  15742. /// <param name="resourceFactory">Factory function to obtain a resource object.</param>
  15743. /// <param name="observableFactory">Factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15744. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15745. /// <exception cref="ArgumentNullException">
  15746. /// <paramref name="resourceFactory" /> or <paramref name="observableFactory" /> is null.</exception>
  15747. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<TResource>> resourceFactory, Expression<Func<TResource, IObservable<TResult>>> observableFactory)
  15748. where TResource : IDisposable
  15749. {
  15750. if (provider == null)
  15751. throw new ArgumentNullException(nameof(provider));
  15752. if (resourceFactory == null)
  15753. throw new ArgumentNullException(nameof(resourceFactory));
  15754. if (observableFactory == null)
  15755. throw new ArgumentNullException(nameof(observableFactory));
  15756. return provider.CreateQuery<TResult>(
  15757. Expression.Call(
  15758. null,
  15759. #if CRIPPLED_REFLECTION
  15760. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<TResource>>), default(Expression<Func<TResource, IObservable<TResult>>>))),
  15761. #else
  15762. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15763. #endif
  15764. Expression.Constant(provider, typeof(IQbservableProvider)),
  15765. resourceFactory,
  15766. observableFactory
  15767. )
  15768. );
  15769. }
  15770. /// <summary>
  15771. /// 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.
  15772. /// 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.
  15773. /// </summary>
  15774. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15775. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15776. /// <typeparam name="TResource">The type of the resource used during the generation of the resulting sequence. Needs to implement <see cref="IDisposable" />.</typeparam>
  15777. /// <param name="resourceFactoryAsync">Asynchronous factory function to obtain a resource object.</param>
  15778. /// <param name="observableFactoryAsync">Asynchronous factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15779. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15780. /// <exception cref="ArgumentNullException">
  15781. /// <paramref name="resourceFactoryAsync" /> or <paramref name="observableFactoryAsync" /> is null.</exception>
  15782. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  15783. /// <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>
  15784. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResource>>> resourceFactoryAsync, Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  15785. where TResource : IDisposable
  15786. {
  15787. if (provider == null)
  15788. throw new ArgumentNullException(nameof(provider));
  15789. if (resourceFactoryAsync == null)
  15790. throw new ArgumentNullException(nameof(resourceFactoryAsync));
  15791. if (observableFactoryAsync == null)
  15792. throw new ArgumentNullException(nameof(observableFactoryAsync));
  15793. return provider.CreateQuery<TResult>(
  15794. Expression.Call(
  15795. null,
  15796. #if CRIPPLED_REFLECTION
  15797. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResource>>>), default(Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>>))),
  15798. #else
  15799. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15800. #endif
  15801. Expression.Constant(provider, typeof(IQbservableProvider)),
  15802. resourceFactoryAsync,
  15803. observableFactoryAsync
  15804. )
  15805. );
  15806. }
  15807. /// <summary>
  15808. /// Filters the elements of an observable sequence based on a predicate.
  15809. /// </summary>
  15810. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15811. /// <param name="source">An observable sequence whose elements to filter.</param>
  15812. /// <param name="predicate">A function to test each source element for a condition.</param>
  15813. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15814. /// <exception cref="ArgumentNullException">
  15815. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15816. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  15817. {
  15818. if (source == null)
  15819. throw new ArgumentNullException(nameof(source));
  15820. if (predicate == null)
  15821. throw new ArgumentNullException(nameof(predicate));
  15822. return source.Provider.CreateQuery<TSource>(
  15823. Expression.Call(
  15824. null,
  15825. #if CRIPPLED_REFLECTION
  15826. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  15827. #else
  15828. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15829. #endif
  15830. source.Expression,
  15831. predicate
  15832. )
  15833. );
  15834. }
  15835. /// <summary>
  15836. /// Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
  15837. /// </summary>
  15838. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15839. /// <param name="source">An observable sequence whose elements to filter.</param>
  15840. /// <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>
  15841. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15842. /// <exception cref="ArgumentNullException">
  15843. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15844. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  15845. {
  15846. if (source == null)
  15847. throw new ArgumentNullException(nameof(source));
  15848. if (predicate == null)
  15849. throw new ArgumentNullException(nameof(predicate));
  15850. return source.Provider.CreateQuery<TSource>(
  15851. Expression.Call(
  15852. null,
  15853. #if CRIPPLED_REFLECTION
  15854. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  15855. #else
  15856. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15857. #endif
  15858. source.Expression,
  15859. predicate
  15860. )
  15861. );
  15862. }
  15863. /// <summary>
  15864. /// 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.
  15865. /// </summary>
  15866. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15867. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15868. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  15869. /// <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>
  15870. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  15871. /// <exception cref="ArgumentNullException">
  15872. /// <paramref name="condition" /> or <paramref name="source" /> is null.</exception>
  15873. public static IQbservable<TSource> While<TSource>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TSource> source)
  15874. {
  15875. if (provider == null)
  15876. throw new ArgumentNullException(nameof(provider));
  15877. if (condition == null)
  15878. throw new ArgumentNullException(nameof(condition));
  15879. if (source == null)
  15880. throw new ArgumentNullException(nameof(source));
  15881. return provider.CreateQuery<TSource>(
  15882. Expression.Call(
  15883. null,
  15884. #if CRIPPLED_REFLECTION
  15885. InfoOf(() => Qbservable.While<TSource>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TSource>))),
  15886. #else
  15887. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15888. #endif
  15889. Expression.Constant(provider, typeof(IQbservableProvider)),
  15890. condition,
  15891. GetSourceExpression(source)
  15892. )
  15893. );
  15894. }
  15895. /// <summary>
  15896. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on element count information.
  15897. /// </summary>
  15898. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15899. /// <param name="source">Source sequence to produce windows over.</param>
  15900. /// <param name="count">Length of each window.</param>
  15901. /// <returns>An observable sequence of windows.</returns>
  15902. /// <exception cref="ArgumentNullException">
  15903. /// <paramref name="source" /> is null.</exception>
  15904. /// <exception cref="ArgumentOutOfRangeException">
  15905. /// <paramref name="count" /> is less than or equal to zero.</exception>
  15906. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count)
  15907. {
  15908. if (source == null)
  15909. throw new ArgumentNullException(nameof(source));
  15910. return source.Provider.CreateQuery<IObservable<TSource>>(
  15911. Expression.Call(
  15912. null,
  15913. #if CRIPPLED_REFLECTION
  15914. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int))),
  15915. #else
  15916. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15917. #endif
  15918. source.Expression,
  15919. Expression.Constant(count, typeof(int))
  15920. )
  15921. );
  15922. }
  15923. /// <summary>
  15924. /// Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
  15925. /// </summary>
  15926. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15927. /// <param name="source">Source sequence to produce windows over.</param>
  15928. /// <param name="count">Length of each window.</param>
  15929. /// <param name="skip">Number of elements to skip between creation of consecutive windows.</param>
  15930. /// <returns>An observable sequence of windows.</returns>
  15931. /// <exception cref="ArgumentNullException">
  15932. /// <paramref name="source" /> is null.</exception>
  15933. /// <exception cref="ArgumentOutOfRangeException">
  15934. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  15935. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count, int skip)
  15936. {
  15937. if (source == null)
  15938. throw new ArgumentNullException(nameof(source));
  15939. return source.Provider.CreateQuery<IObservable<TSource>>(
  15940. Expression.Call(
  15941. null,
  15942. #if CRIPPLED_REFLECTION
  15943. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  15944. #else
  15945. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15946. #endif
  15947. source.Expression,
  15948. Expression.Constant(count, typeof(int)),
  15949. Expression.Constant(skip, typeof(int))
  15950. )
  15951. );
  15952. }
  15953. /// <summary>
  15954. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information.
  15955. /// </summary>
  15956. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15957. /// <param name="source">Source sequence to produce windows over.</param>
  15958. /// <param name="timeSpan">Length of each window.</param>
  15959. /// <returns>The sequence of windows.</returns>
  15960. /// <exception cref="ArgumentNullException">
  15961. /// <paramref name="source" /> is null.</exception>
  15962. /// <exception cref="ArgumentOutOfRangeException">
  15963. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15964. /// <remarks>
  15965. /// 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.
  15966. /// 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
  15967. /// 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.
  15968. /// </remarks>
  15969. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  15970. {
  15971. if (source == null)
  15972. throw new ArgumentNullException(nameof(source));
  15973. return source.Provider.CreateQuery<IObservable<TSource>>(
  15974. Expression.Call(
  15975. null,
  15976. #if CRIPPLED_REFLECTION
  15977. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  15978. #else
  15979. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15980. #endif
  15981. source.Expression,
  15982. Expression.Constant(timeSpan, typeof(TimeSpan))
  15983. )
  15984. );
  15985. }
  15986. /// <summary>
  15987. /// 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.
  15988. /// 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.
  15989. /// </summary>
  15990. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15991. /// <param name="source">Source sequence to produce windows over.</param>
  15992. /// <param name="timeSpan">Maximum time length of a window.</param>
  15993. /// <param name="count">Maximum element count of a window.</param>
  15994. /// <returns>An observable sequence of windows.</returns>
  15995. /// <exception cref="ArgumentNullException">
  15996. /// <paramref name="source" /> is null.</exception>
  15997. /// <exception cref="ArgumentOutOfRangeException">
  15998. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  15999. /// <remarks>
  16000. /// 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.
  16001. /// 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
  16002. /// 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.
  16003. /// </remarks>
  16004. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  16005. {
  16006. if (source == null)
  16007. throw new ArgumentNullException(nameof(source));
  16008. return source.Provider.CreateQuery<IObservable<TSource>>(
  16009. Expression.Call(
  16010. null,
  16011. #if CRIPPLED_REFLECTION
  16012. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  16013. #else
  16014. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16015. #endif
  16016. source.Expression,
  16017. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16018. Expression.Constant(count, typeof(int))
  16019. )
  16020. );
  16021. }
  16022. /// <summary>
  16023. /// 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.
  16024. /// 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.
  16025. /// </summary>
  16026. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16027. /// <param name="source">Source sequence to produce windows over.</param>
  16028. /// <param name="timeSpan">Maximum time length of a window.</param>
  16029. /// <param name="count">Maximum element count of a window.</param>
  16030. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16031. /// <returns>An observable sequence of windows.</returns>
  16032. /// <exception cref="ArgumentNullException">
  16033. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16034. /// <exception cref="ArgumentOutOfRangeException">
  16035. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  16036. /// <remarks>
  16037. /// 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.
  16038. /// 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
  16039. /// 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.
  16040. /// </remarks>
  16041. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  16042. {
  16043. if (source == null)
  16044. throw new ArgumentNullException(nameof(source));
  16045. if (scheduler == null)
  16046. throw new ArgumentNullException(nameof(scheduler));
  16047. return source.Provider.CreateQuery<IObservable<TSource>>(
  16048. Expression.Call(
  16049. null,
  16050. #if CRIPPLED_REFLECTION
  16051. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  16052. #else
  16053. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16054. #endif
  16055. source.Expression,
  16056. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16057. Expression.Constant(count, typeof(int)),
  16058. Expression.Constant(scheduler, typeof(IScheduler))
  16059. )
  16060. );
  16061. }
  16062. /// <summary>
  16063. /// 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.
  16064. /// </summary>
  16065. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16066. /// <param name="source">Source sequence to produce windows over.</param>
  16067. /// <param name="timeSpan">Length of each window.</param>
  16068. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16069. /// <returns>An observable sequence of windows.</returns>
  16070. /// <exception cref="ArgumentNullException">
  16071. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16072. /// <exception cref="ArgumentOutOfRangeException">
  16073. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16074. /// <remarks>
  16075. /// 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.
  16076. /// 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
  16077. /// 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.
  16078. /// </remarks>
  16079. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  16080. {
  16081. if (source == null)
  16082. throw new ArgumentNullException(nameof(source));
  16083. if (scheduler == null)
  16084. throw new ArgumentNullException(nameof(scheduler));
  16085. return source.Provider.CreateQuery<IObservable<TSource>>(
  16086. Expression.Call(
  16087. null,
  16088. #if CRIPPLED_REFLECTION
  16089. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  16090. #else
  16091. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16092. #endif
  16093. source.Expression,
  16094. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16095. Expression.Constant(scheduler, typeof(IScheduler))
  16096. )
  16097. );
  16098. }
  16099. /// <summary>
  16100. /// Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  16101. /// </summary>
  16102. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16103. /// <param name="source">Source sequence to produce windows over.</param>
  16104. /// <param name="timeSpan">Length of each window.</param>
  16105. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  16106. /// <returns>An observable sequence of windows.</returns>
  16107. /// <exception cref="ArgumentNullException">
  16108. /// <paramref name="source" /> is null.</exception>
  16109. /// <exception cref="ArgumentOutOfRangeException">
  16110. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16111. /// <remarks>
  16112. /// <para>
  16113. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  16114. /// 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
  16115. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  16116. /// </para>
  16117. /// <para>
  16118. /// 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.
  16119. /// 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,
  16120. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16121. /// </para>
  16122. /// </remarks>
  16123. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  16124. {
  16125. if (source == null)
  16126. throw new ArgumentNullException(nameof(source));
  16127. return source.Provider.CreateQuery<IObservable<TSource>>(
  16128. Expression.Call(
  16129. null,
  16130. #if CRIPPLED_REFLECTION
  16131. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  16132. #else
  16133. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16134. #endif
  16135. source.Expression,
  16136. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16137. Expression.Constant(timeShift, typeof(TimeSpan))
  16138. )
  16139. );
  16140. }
  16141. /// <summary>
  16142. /// 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.
  16143. /// </summary>
  16144. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16145. /// <param name="source">Source sequence to produce windows over.</param>
  16146. /// <param name="timeSpan">Length of each window.</param>
  16147. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  16148. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16149. /// <returns>An observable sequence of windows.</returns>
  16150. /// <exception cref="ArgumentNullException">
  16151. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16152. /// <exception cref="ArgumentOutOfRangeException">
  16153. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16154. /// <remarks>
  16155. /// <para>
  16156. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  16157. /// 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
  16158. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  16159. /// </para>
  16160. /// <para>
  16161. /// 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.
  16162. /// 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,
  16163. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16164. /// </para>
  16165. /// </remarks>
  16166. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  16167. {
  16168. if (source == null)
  16169. throw new ArgumentNullException(nameof(source));
  16170. if (scheduler == null)
  16171. throw new ArgumentNullException(nameof(scheduler));
  16172. return source.Provider.CreateQuery<IObservable<TSource>>(
  16173. Expression.Call(
  16174. null,
  16175. #if CRIPPLED_REFLECTION
  16176. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  16177. #else
  16178. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16179. #endif
  16180. source.Expression,
  16181. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16182. Expression.Constant(timeShift, typeof(TimeSpan)),
  16183. Expression.Constant(scheduler, typeof(IScheduler))
  16184. )
  16185. );
  16186. }
  16187. /// <summary>
  16188. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16189. /// </summary>
  16190. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16191. /// <typeparam name="TWindowBoundary">The type of the elements in the sequences indicating window boundary events.</typeparam>
  16192. /// <param name="source">Source sequence to produce windows over.</param>
  16193. /// <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>
  16194. /// <returns>An observable sequence of windows.</returns>
  16195. /// <exception cref="ArgumentNullException">
  16196. /// <paramref name="source" /> or <paramref name="windowBoundaries" /> is null.</exception>
  16197. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowBoundary>(this IQbservable<TSource> source, IObservable<TWindowBoundary> windowBoundaries)
  16198. {
  16199. if (source == null)
  16200. throw new ArgumentNullException(nameof(source));
  16201. if (windowBoundaries == null)
  16202. throw new ArgumentNullException(nameof(windowBoundaries));
  16203. return source.Provider.CreateQuery<IObservable<TSource>>(
  16204. Expression.Call(
  16205. null,
  16206. #if CRIPPLED_REFLECTION
  16207. InfoOf(() => Qbservable.Window<TSource, TWindowBoundary>(default(IQbservable<TSource>), default(IObservable<TWindowBoundary>))),
  16208. #else
  16209. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowBoundary)),
  16210. #endif
  16211. source.Expression,
  16212. GetSourceExpression(windowBoundaries)
  16213. )
  16214. );
  16215. }
  16216. /// <summary>
  16217. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16218. /// </summary>
  16219. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16220. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16221. /// <param name="source">Source sequence to produce windows over.</param>
  16222. /// <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>
  16223. /// <returns>An observable sequence of windows.</returns>
  16224. /// <exception cref="ArgumentNullException">
  16225. /// <paramref name="source" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16226. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TWindowClosing>>> windowClosingSelector)
  16227. {
  16228. if (source == null)
  16229. throw new ArgumentNullException(nameof(source));
  16230. if (windowClosingSelector == null)
  16231. throw new ArgumentNullException(nameof(windowClosingSelector));
  16232. return source.Provider.CreateQuery<IObservable<TSource>>(
  16233. Expression.Call(
  16234. null,
  16235. #if CRIPPLED_REFLECTION
  16236. InfoOf(() => Qbservable.Window<TSource, TWindowClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TWindowClosing>>>))),
  16237. #else
  16238. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowClosing)),
  16239. #endif
  16240. source.Expression,
  16241. windowClosingSelector
  16242. )
  16243. );
  16244. }
  16245. /// <summary>
  16246. /// Projects each element of an observable sequence into zero or more windows.
  16247. /// </summary>
  16248. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16249. /// <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>
  16250. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16251. /// <param name="source">Source sequence to produce windows over.</param>
  16252. /// <param name="windowOpenings">Observable sequence whose elements denote the creation of new windows.</param>
  16253. /// <param name="windowClosingSelector">A function invoked to define the closing of each produced window.</param>
  16254. /// <returns>An observable sequence of windows.</returns>
  16255. /// <exception cref="ArgumentNullException">
  16256. /// <paramref name="source" /> or <paramref name="windowOpenings" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16257. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowOpening, TWindowClosing>(this IQbservable<TSource> source, IObservable<TWindowOpening> windowOpenings, Expression<Func<TWindowOpening, IObservable<TWindowClosing>>> windowClosingSelector)
  16258. {
  16259. if (source == null)
  16260. throw new ArgumentNullException(nameof(source));
  16261. if (windowOpenings == null)
  16262. throw new ArgumentNullException(nameof(windowOpenings));
  16263. if (windowClosingSelector == null)
  16264. throw new ArgumentNullException(nameof(windowClosingSelector));
  16265. return source.Provider.CreateQuery<IObservable<TSource>>(
  16266. Expression.Call(
  16267. null,
  16268. #if CRIPPLED_REFLECTION
  16269. InfoOf(() => Qbservable.Window<TSource, TWindowOpening, TWindowClosing>(default(IQbservable<TSource>), default(IObservable<TWindowOpening>), default(Expression<Func<TWindowOpening, IObservable<TWindowClosing>>>))),
  16270. #else
  16271. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowOpening), typeof(TWindowClosing)),
  16272. #endif
  16273. source.Expression,
  16274. GetSourceExpression(windowOpenings),
  16275. windowClosingSelector
  16276. )
  16277. );
  16278. }
  16279. /// <summary>
  16280. /// 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.
  16281. /// 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
  16282. /// in case <paramref name="first" /> emits an element right away.
  16283. /// </summary>
  16284. /// <typeparam name="TFirst">The type of the elements in the first source sequence.</typeparam>
  16285. /// <typeparam name="TSecond">The type of the elements in the second source sequence.</typeparam>
  16286. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16287. /// <param name="first">First observable source.</param>
  16288. /// <param name="second">Second observable source.</param>
  16289. /// <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>
  16290. /// <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>
  16291. /// <exception cref="ArgumentNullException">
  16292. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16293. public static IQbservable<TResult> WithLatestFrom<TFirst, TSecond, TResult>(this IQbservable<TFirst> first, IObservable<TSecond> second, Expression<Func<TFirst, TSecond, TResult>> resultSelector)
  16294. {
  16295. if (first == null)
  16296. throw new ArgumentNullException(nameof(first));
  16297. if (second == null)
  16298. throw new ArgumentNullException(nameof(second));
  16299. if (resultSelector == null)
  16300. throw new ArgumentNullException(nameof(resultSelector));
  16301. return first.Provider.CreateQuery<TResult>(
  16302. Expression.Call(
  16303. null,
  16304. #if CRIPPLED_REFLECTION
  16305. InfoOf(() => Qbservable.WithLatestFrom<TFirst, TSecond, TResult>(default(IQbservable<TFirst>), default(IObservable<TSecond>), default(Expression<Func<TFirst, TSecond, TResult>>))),
  16306. #else
  16307. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)),
  16308. #endif
  16309. first.Expression,
  16310. GetSourceExpression(second),
  16311. resultSelector
  16312. )
  16313. );
  16314. }
  16315. /// <summary>
  16316. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16317. /// </summary>
  16318. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16319. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16320. /// <param name="sources">Observable sources.</param>
  16321. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16322. /// <exception cref="ArgumentNullException">
  16323. /// <paramref name="sources" /> is null.</exception>
  16324. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  16325. {
  16326. if (provider == null)
  16327. throw new ArgumentNullException(nameof(provider));
  16328. if (sources == null)
  16329. throw new ArgumentNullException(nameof(sources));
  16330. return provider.CreateQuery<IList<TSource>>(
  16331. Expression.Call(
  16332. null,
  16333. #if CRIPPLED_REFLECTION
  16334. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  16335. #else
  16336. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16337. #endif
  16338. Expression.Constant(provider, typeof(IQbservableProvider)),
  16339. GetSourceExpression(sources)
  16340. )
  16341. );
  16342. }
  16343. /// <summary>
  16344. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16345. /// </summary>
  16346. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16347. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16348. /// <param name="sources">Observable sources.</param>
  16349. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16350. /// <exception cref="ArgumentNullException">
  16351. /// <paramref name="sources" /> is null.</exception>
  16352. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  16353. {
  16354. if (provider == null)
  16355. throw new ArgumentNullException(nameof(provider));
  16356. if (sources == null)
  16357. throw new ArgumentNullException(nameof(sources));
  16358. return provider.CreateQuery<IList<TSource>>(
  16359. Expression.Call(
  16360. null,
  16361. #if CRIPPLED_REFLECTION
  16362. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  16363. #else
  16364. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16365. #endif
  16366. Expression.Constant(provider, typeof(IQbservableProvider)),
  16367. GetSourceExpression(sources)
  16368. )
  16369. );
  16370. }
  16371. /// <summary>
  16372. /// 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.
  16373. /// </summary>
  16374. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16375. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  16376. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16377. /// <param name="sources">Observable sources.</param>
  16378. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16379. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16380. /// <exception cref="ArgumentNullException">
  16381. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  16382. public static IQbservable<TResult> Zip<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  16383. {
  16384. if (provider == null)
  16385. throw new ArgumentNullException(nameof(provider));
  16386. if (sources == null)
  16387. throw new ArgumentNullException(nameof(sources));
  16388. if (resultSelector == null)
  16389. throw new ArgumentNullException(nameof(resultSelector));
  16390. return provider.CreateQuery<TResult>(
  16391. Expression.Call(
  16392. null,
  16393. #if CRIPPLED_REFLECTION
  16394. InfoOf(() => Qbservable.Zip<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  16395. #else
  16396. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  16397. #endif
  16398. Expression.Constant(provider, typeof(IQbservableProvider)),
  16399. GetSourceExpression(sources),
  16400. resultSelector
  16401. )
  16402. );
  16403. }
  16404. /// <summary>
  16405. /// Merges two observable sequences into one observable sequence by combining their elements in a pairwise fashion.
  16406. /// </summary>
  16407. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16408. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16409. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16410. /// <param name="first">First observable source.</param>
  16411. /// <param name="second">Second observable source.</param>
  16412. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16413. /// <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>
  16414. /// <exception cref="ArgumentNullException">
  16415. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16416. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16417. {
  16418. if (first == null)
  16419. throw new ArgumentNullException(nameof(first));
  16420. if (second == null)
  16421. throw new ArgumentNullException(nameof(second));
  16422. if (resultSelector == null)
  16423. throw new ArgumentNullException(nameof(resultSelector));
  16424. return first.Provider.CreateQuery<TResult>(
  16425. Expression.Call(
  16426. null,
  16427. #if CRIPPLED_REFLECTION
  16428. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16429. #else
  16430. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16431. #endif
  16432. first.Expression,
  16433. GetSourceExpression(second),
  16434. resultSelector
  16435. )
  16436. );
  16437. }
  16438. /// <summary>
  16439. /// Merges an observable sequence and an enumerable sequence into one observable sequence by using the selector function.
  16440. /// </summary>
  16441. /// <typeparam name="TSource1">The type of the elements in the first observable source sequence.</typeparam>
  16442. /// <typeparam name="TSource2">The type of the elements in the second enumerable source sequence.</typeparam>
  16443. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16444. /// <param name="first">First observable source.</param>
  16445. /// <param name="second">Second enumerable source.</param>
  16446. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16447. /// <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>
  16448. /// <exception cref="ArgumentNullException">
  16449. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16450. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IEnumerable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16451. {
  16452. if (first == null)
  16453. throw new ArgumentNullException(nameof(first));
  16454. if (second == null)
  16455. throw new ArgumentNullException(nameof(second));
  16456. if (resultSelector == null)
  16457. throw new ArgumentNullException(nameof(resultSelector));
  16458. return first.Provider.CreateQuery<TResult>(
  16459. Expression.Call(
  16460. null,
  16461. #if CRIPPLED_REFLECTION
  16462. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IEnumerable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16463. #else
  16464. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16465. #endif
  16466. first.Expression,
  16467. GetSourceExpression(second),
  16468. resultSelector
  16469. )
  16470. );
  16471. }
  16472. /// <summary>
  16473. /// 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.
  16474. /// </summary>
  16475. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16476. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16477. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16478. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16479. /// <param name="source1">First observable source.</param>
  16480. /// <param name="source2">Second observable source.</param>
  16481. /// <param name="source3">Third observable source.</param>
  16482. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16483. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16484. /// <exception cref="ArgumentNullException">
  16485. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  16486. 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)
  16487. {
  16488. if (source1 == null)
  16489. throw new ArgumentNullException(nameof(source1));
  16490. if (source2 == null)
  16491. throw new ArgumentNullException(nameof(source2));
  16492. if (source3 == null)
  16493. throw new ArgumentNullException(nameof(source3));
  16494. if (resultSelector == null)
  16495. throw new ArgumentNullException(nameof(resultSelector));
  16496. return source1.Provider.CreateQuery<TResult>(
  16497. Expression.Call(
  16498. null,
  16499. #if CRIPPLED_REFLECTION
  16500. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  16501. #else
  16502. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  16503. #endif
  16504. source1.Expression,
  16505. GetSourceExpression(source2),
  16506. GetSourceExpression(source3),
  16507. resultSelector
  16508. )
  16509. );
  16510. }
  16511. /// <summary>
  16512. /// 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.
  16513. /// </summary>
  16514. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16515. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16516. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16517. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16518. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16519. /// <param name="source1">First observable source.</param>
  16520. /// <param name="source2">Second observable source.</param>
  16521. /// <param name="source3">Third observable source.</param>
  16522. /// <param name="source4">Fourth observable source.</param>
  16523. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16524. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16525. /// <exception cref="ArgumentNullException">
  16526. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  16527. 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)
  16528. {
  16529. if (source1 == null)
  16530. throw new ArgumentNullException(nameof(source1));
  16531. if (source2 == null)
  16532. throw new ArgumentNullException(nameof(source2));
  16533. if (source3 == null)
  16534. throw new ArgumentNullException(nameof(source3));
  16535. if (source4 == null)
  16536. throw new ArgumentNullException(nameof(source4));
  16537. if (resultSelector == null)
  16538. throw new ArgumentNullException(nameof(resultSelector));
  16539. return source1.Provider.CreateQuery<TResult>(
  16540. Expression.Call(
  16541. null,
  16542. #if CRIPPLED_REFLECTION
  16543. 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>>))),
  16544. #else
  16545. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  16546. #endif
  16547. source1.Expression,
  16548. GetSourceExpression(source2),
  16549. GetSourceExpression(source3),
  16550. GetSourceExpression(source4),
  16551. resultSelector
  16552. )
  16553. );
  16554. }
  16555. /// <summary>
  16556. /// 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.
  16557. /// </summary>
  16558. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16559. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16560. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16561. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16562. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16563. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16564. /// <param name="source1">First observable source.</param>
  16565. /// <param name="source2">Second observable source.</param>
  16566. /// <param name="source3">Third observable source.</param>
  16567. /// <param name="source4">Fourth observable source.</param>
  16568. /// <param name="source5">Fifth observable source.</param>
  16569. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16570. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16571. /// <exception cref="ArgumentNullException">
  16572. /// <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>
  16573. 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)
  16574. {
  16575. if (source1 == null)
  16576. throw new ArgumentNullException(nameof(source1));
  16577. if (source2 == null)
  16578. throw new ArgumentNullException(nameof(source2));
  16579. if (source3 == null)
  16580. throw new ArgumentNullException(nameof(source3));
  16581. if (source4 == null)
  16582. throw new ArgumentNullException(nameof(source4));
  16583. if (source5 == null)
  16584. throw new ArgumentNullException(nameof(source5));
  16585. if (resultSelector == null)
  16586. throw new ArgumentNullException(nameof(resultSelector));
  16587. return source1.Provider.CreateQuery<TResult>(
  16588. Expression.Call(
  16589. null,
  16590. #if CRIPPLED_REFLECTION
  16591. 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>>))),
  16592. #else
  16593. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  16594. #endif
  16595. source1.Expression,
  16596. GetSourceExpression(source2),
  16597. GetSourceExpression(source3),
  16598. GetSourceExpression(source4),
  16599. GetSourceExpression(source5),
  16600. resultSelector
  16601. )
  16602. );
  16603. }
  16604. /// <summary>
  16605. /// 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.
  16606. /// </summary>
  16607. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16608. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16609. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16610. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16611. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16612. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16613. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16614. /// <param name="source1">First observable source.</param>
  16615. /// <param name="source2">Second observable source.</param>
  16616. /// <param name="source3">Third observable source.</param>
  16617. /// <param name="source4">Fourth observable source.</param>
  16618. /// <param name="source5">Fifth observable source.</param>
  16619. /// <param name="source6">Sixth observable source.</param>
  16620. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16621. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16622. /// <exception cref="ArgumentNullException">
  16623. /// <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>
  16624. 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)
  16625. {
  16626. if (source1 == null)
  16627. throw new ArgumentNullException(nameof(source1));
  16628. if (source2 == null)
  16629. throw new ArgumentNullException(nameof(source2));
  16630. if (source3 == null)
  16631. throw new ArgumentNullException(nameof(source3));
  16632. if (source4 == null)
  16633. throw new ArgumentNullException(nameof(source4));
  16634. if (source5 == null)
  16635. throw new ArgumentNullException(nameof(source5));
  16636. if (source6 == null)
  16637. throw new ArgumentNullException(nameof(source6));
  16638. if (resultSelector == null)
  16639. throw new ArgumentNullException(nameof(resultSelector));
  16640. return source1.Provider.CreateQuery<TResult>(
  16641. Expression.Call(
  16642. null,
  16643. #if CRIPPLED_REFLECTION
  16644. 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>>))),
  16645. #else
  16646. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  16647. #endif
  16648. source1.Expression,
  16649. GetSourceExpression(source2),
  16650. GetSourceExpression(source3),
  16651. GetSourceExpression(source4),
  16652. GetSourceExpression(source5),
  16653. GetSourceExpression(source6),
  16654. resultSelector
  16655. )
  16656. );
  16657. }
  16658. /// <summary>
  16659. /// 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.
  16660. /// </summary>
  16661. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16662. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16663. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16664. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16665. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16666. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16667. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16668. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16669. /// <param name="source1">First observable source.</param>
  16670. /// <param name="source2">Second observable source.</param>
  16671. /// <param name="source3">Third observable source.</param>
  16672. /// <param name="source4">Fourth observable source.</param>
  16673. /// <param name="source5">Fifth observable source.</param>
  16674. /// <param name="source6">Sixth observable source.</param>
  16675. /// <param name="source7">Seventh observable source.</param>
  16676. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16677. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16678. /// <exception cref="ArgumentNullException">
  16679. /// <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>
  16680. 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)
  16681. {
  16682. if (source1 == null)
  16683. throw new ArgumentNullException(nameof(source1));
  16684. if (source2 == null)
  16685. throw new ArgumentNullException(nameof(source2));
  16686. if (source3 == null)
  16687. throw new ArgumentNullException(nameof(source3));
  16688. if (source4 == null)
  16689. throw new ArgumentNullException(nameof(source4));
  16690. if (source5 == null)
  16691. throw new ArgumentNullException(nameof(source5));
  16692. if (source6 == null)
  16693. throw new ArgumentNullException(nameof(source6));
  16694. if (source7 == null)
  16695. throw new ArgumentNullException(nameof(source7));
  16696. if (resultSelector == null)
  16697. throw new ArgumentNullException(nameof(resultSelector));
  16698. return source1.Provider.CreateQuery<TResult>(
  16699. Expression.Call(
  16700. null,
  16701. #if CRIPPLED_REFLECTION
  16702. 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>>))),
  16703. #else
  16704. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  16705. #endif
  16706. source1.Expression,
  16707. GetSourceExpression(source2),
  16708. GetSourceExpression(source3),
  16709. GetSourceExpression(source4),
  16710. GetSourceExpression(source5),
  16711. GetSourceExpression(source6),
  16712. GetSourceExpression(source7),
  16713. resultSelector
  16714. )
  16715. );
  16716. }
  16717. /// <summary>
  16718. /// 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.
  16719. /// </summary>
  16720. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16721. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16722. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16723. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16724. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16725. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16726. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16727. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16728. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16729. /// <param name="source1">First observable source.</param>
  16730. /// <param name="source2">Second observable source.</param>
  16731. /// <param name="source3">Third observable source.</param>
  16732. /// <param name="source4">Fourth observable source.</param>
  16733. /// <param name="source5">Fifth observable source.</param>
  16734. /// <param name="source6">Sixth observable source.</param>
  16735. /// <param name="source7">Seventh observable source.</param>
  16736. /// <param name="source8">Eighth observable source.</param>
  16737. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16738. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16739. /// <exception cref="ArgumentNullException">
  16740. /// <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>
  16741. 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)
  16742. {
  16743. if (source1 == null)
  16744. throw new ArgumentNullException(nameof(source1));
  16745. if (source2 == null)
  16746. throw new ArgumentNullException(nameof(source2));
  16747. if (source3 == null)
  16748. throw new ArgumentNullException(nameof(source3));
  16749. if (source4 == null)
  16750. throw new ArgumentNullException(nameof(source4));
  16751. if (source5 == null)
  16752. throw new ArgumentNullException(nameof(source5));
  16753. if (source6 == null)
  16754. throw new ArgumentNullException(nameof(source6));
  16755. if (source7 == null)
  16756. throw new ArgumentNullException(nameof(source7));
  16757. if (source8 == null)
  16758. throw new ArgumentNullException(nameof(source8));
  16759. if (resultSelector == null)
  16760. throw new ArgumentNullException(nameof(resultSelector));
  16761. return source1.Provider.CreateQuery<TResult>(
  16762. Expression.Call(
  16763. null,
  16764. #if CRIPPLED_REFLECTION
  16765. 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>>))),
  16766. #else
  16767. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  16768. #endif
  16769. source1.Expression,
  16770. GetSourceExpression(source2),
  16771. GetSourceExpression(source3),
  16772. GetSourceExpression(source4),
  16773. GetSourceExpression(source5),
  16774. GetSourceExpression(source6),
  16775. GetSourceExpression(source7),
  16776. GetSourceExpression(source8),
  16777. resultSelector
  16778. )
  16779. );
  16780. }
  16781. /// <summary>
  16782. /// 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.
  16783. /// </summary>
  16784. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16785. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16786. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16787. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16788. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16789. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16790. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16791. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16792. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16793. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16794. /// <param name="source1">First observable source.</param>
  16795. /// <param name="source2">Second observable source.</param>
  16796. /// <param name="source3">Third observable source.</param>
  16797. /// <param name="source4">Fourth observable source.</param>
  16798. /// <param name="source5">Fifth observable source.</param>
  16799. /// <param name="source6">Sixth observable source.</param>
  16800. /// <param name="source7">Seventh observable source.</param>
  16801. /// <param name="source8">Eighth observable source.</param>
  16802. /// <param name="source9">Ninth observable source.</param>
  16803. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16804. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16805. /// <exception cref="ArgumentNullException">
  16806. /// <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>
  16807. 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)
  16808. {
  16809. if (source1 == null)
  16810. throw new ArgumentNullException(nameof(source1));
  16811. if (source2 == null)
  16812. throw new ArgumentNullException(nameof(source2));
  16813. if (source3 == null)
  16814. throw new ArgumentNullException(nameof(source3));
  16815. if (source4 == null)
  16816. throw new ArgumentNullException(nameof(source4));
  16817. if (source5 == null)
  16818. throw new ArgumentNullException(nameof(source5));
  16819. if (source6 == null)
  16820. throw new ArgumentNullException(nameof(source6));
  16821. if (source7 == null)
  16822. throw new ArgumentNullException(nameof(source7));
  16823. if (source8 == null)
  16824. throw new ArgumentNullException(nameof(source8));
  16825. if (source9 == null)
  16826. throw new ArgumentNullException(nameof(source9));
  16827. if (resultSelector == null)
  16828. throw new ArgumentNullException(nameof(resultSelector));
  16829. return source1.Provider.CreateQuery<TResult>(
  16830. Expression.Call(
  16831. null,
  16832. #if CRIPPLED_REFLECTION
  16833. 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>>))),
  16834. #else
  16835. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  16836. #endif
  16837. source1.Expression,
  16838. GetSourceExpression(source2),
  16839. GetSourceExpression(source3),
  16840. GetSourceExpression(source4),
  16841. GetSourceExpression(source5),
  16842. GetSourceExpression(source6),
  16843. GetSourceExpression(source7),
  16844. GetSourceExpression(source8),
  16845. GetSourceExpression(source9),
  16846. resultSelector
  16847. )
  16848. );
  16849. }
  16850. /// <summary>
  16851. /// 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.
  16852. /// </summary>
  16853. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16854. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16855. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16856. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16857. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16858. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16859. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16860. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16861. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16862. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16863. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16864. /// <param name="source1">First observable source.</param>
  16865. /// <param name="source2">Second observable source.</param>
  16866. /// <param name="source3">Third observable source.</param>
  16867. /// <param name="source4">Fourth observable source.</param>
  16868. /// <param name="source5">Fifth observable source.</param>
  16869. /// <param name="source6">Sixth observable source.</param>
  16870. /// <param name="source7">Seventh observable source.</param>
  16871. /// <param name="source8">Eighth observable source.</param>
  16872. /// <param name="source9">Ninth observable source.</param>
  16873. /// <param name="source10">Tenth observable source.</param>
  16874. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16875. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16876. /// <exception cref="ArgumentNullException">
  16877. /// <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>
  16878. 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)
  16879. {
  16880. if (source1 == null)
  16881. throw new ArgumentNullException(nameof(source1));
  16882. if (source2 == null)
  16883. throw new ArgumentNullException(nameof(source2));
  16884. if (source3 == null)
  16885. throw new ArgumentNullException(nameof(source3));
  16886. if (source4 == null)
  16887. throw new ArgumentNullException(nameof(source4));
  16888. if (source5 == null)
  16889. throw new ArgumentNullException(nameof(source5));
  16890. if (source6 == null)
  16891. throw new ArgumentNullException(nameof(source6));
  16892. if (source7 == null)
  16893. throw new ArgumentNullException(nameof(source7));
  16894. if (source8 == null)
  16895. throw new ArgumentNullException(nameof(source8));
  16896. if (source9 == null)
  16897. throw new ArgumentNullException(nameof(source9));
  16898. if (source10 == null)
  16899. throw new ArgumentNullException(nameof(source10));
  16900. if (resultSelector == null)
  16901. throw new ArgumentNullException(nameof(resultSelector));
  16902. return source1.Provider.CreateQuery<TResult>(
  16903. Expression.Call(
  16904. null,
  16905. #if CRIPPLED_REFLECTION
  16906. 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>>))),
  16907. #else
  16908. ((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)),
  16909. #endif
  16910. source1.Expression,
  16911. GetSourceExpression(source2),
  16912. GetSourceExpression(source3),
  16913. GetSourceExpression(source4),
  16914. GetSourceExpression(source5),
  16915. GetSourceExpression(source6),
  16916. GetSourceExpression(source7),
  16917. GetSourceExpression(source8),
  16918. GetSourceExpression(source9),
  16919. GetSourceExpression(source10),
  16920. resultSelector
  16921. )
  16922. );
  16923. }
  16924. /// <summary>
  16925. /// 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.
  16926. /// </summary>
  16927. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16928. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16929. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16930. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16931. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16932. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16933. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16934. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16935. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16936. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16937. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16938. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16939. /// <param name="source1">First observable source.</param>
  16940. /// <param name="source2">Second observable source.</param>
  16941. /// <param name="source3">Third observable source.</param>
  16942. /// <param name="source4">Fourth observable source.</param>
  16943. /// <param name="source5">Fifth observable source.</param>
  16944. /// <param name="source6">Sixth observable source.</param>
  16945. /// <param name="source7">Seventh observable source.</param>
  16946. /// <param name="source8">Eighth observable source.</param>
  16947. /// <param name="source9">Ninth observable source.</param>
  16948. /// <param name="source10">Tenth observable source.</param>
  16949. /// <param name="source11">Eleventh observable source.</param>
  16950. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16951. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16952. /// <exception cref="ArgumentNullException">
  16953. /// <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>
  16954. 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)
  16955. {
  16956. if (source1 == null)
  16957. throw new ArgumentNullException(nameof(source1));
  16958. if (source2 == null)
  16959. throw new ArgumentNullException(nameof(source2));
  16960. if (source3 == null)
  16961. throw new ArgumentNullException(nameof(source3));
  16962. if (source4 == null)
  16963. throw new ArgumentNullException(nameof(source4));
  16964. if (source5 == null)
  16965. throw new ArgumentNullException(nameof(source5));
  16966. if (source6 == null)
  16967. throw new ArgumentNullException(nameof(source6));
  16968. if (source7 == null)
  16969. throw new ArgumentNullException(nameof(source7));
  16970. if (source8 == null)
  16971. throw new ArgumentNullException(nameof(source8));
  16972. if (source9 == null)
  16973. throw new ArgumentNullException(nameof(source9));
  16974. if (source10 == null)
  16975. throw new ArgumentNullException(nameof(source10));
  16976. if (source11 == null)
  16977. throw new ArgumentNullException(nameof(source11));
  16978. if (resultSelector == null)
  16979. throw new ArgumentNullException(nameof(resultSelector));
  16980. return source1.Provider.CreateQuery<TResult>(
  16981. Expression.Call(
  16982. null,
  16983. #if CRIPPLED_REFLECTION
  16984. 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>>))),
  16985. #else
  16986. ((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)),
  16987. #endif
  16988. source1.Expression,
  16989. GetSourceExpression(source2),
  16990. GetSourceExpression(source3),
  16991. GetSourceExpression(source4),
  16992. GetSourceExpression(source5),
  16993. GetSourceExpression(source6),
  16994. GetSourceExpression(source7),
  16995. GetSourceExpression(source8),
  16996. GetSourceExpression(source9),
  16997. GetSourceExpression(source10),
  16998. GetSourceExpression(source11),
  16999. resultSelector
  17000. )
  17001. );
  17002. }
  17003. /// <summary>
  17004. /// 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.
  17005. /// </summary>
  17006. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17007. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17008. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17009. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17010. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17011. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17012. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17013. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17014. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17015. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17016. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17017. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17018. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17019. /// <param name="source1">First observable source.</param>
  17020. /// <param name="source2">Second observable source.</param>
  17021. /// <param name="source3">Third observable source.</param>
  17022. /// <param name="source4">Fourth observable source.</param>
  17023. /// <param name="source5">Fifth observable source.</param>
  17024. /// <param name="source6">Sixth observable source.</param>
  17025. /// <param name="source7">Seventh observable source.</param>
  17026. /// <param name="source8">Eighth observable source.</param>
  17027. /// <param name="source9">Ninth observable source.</param>
  17028. /// <param name="source10">Tenth observable source.</param>
  17029. /// <param name="source11">Eleventh observable source.</param>
  17030. /// <param name="source12">Twelfth observable source.</param>
  17031. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17032. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17033. /// <exception cref="ArgumentNullException">
  17034. /// <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>
  17035. 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)
  17036. {
  17037. if (source1 == null)
  17038. throw new ArgumentNullException(nameof(source1));
  17039. if (source2 == null)
  17040. throw new ArgumentNullException(nameof(source2));
  17041. if (source3 == null)
  17042. throw new ArgumentNullException(nameof(source3));
  17043. if (source4 == null)
  17044. throw new ArgumentNullException(nameof(source4));
  17045. if (source5 == null)
  17046. throw new ArgumentNullException(nameof(source5));
  17047. if (source6 == null)
  17048. throw new ArgumentNullException(nameof(source6));
  17049. if (source7 == null)
  17050. throw new ArgumentNullException(nameof(source7));
  17051. if (source8 == null)
  17052. throw new ArgumentNullException(nameof(source8));
  17053. if (source9 == null)
  17054. throw new ArgumentNullException(nameof(source9));
  17055. if (source10 == null)
  17056. throw new ArgumentNullException(nameof(source10));
  17057. if (source11 == null)
  17058. throw new ArgumentNullException(nameof(source11));
  17059. if (source12 == null)
  17060. throw new ArgumentNullException(nameof(source12));
  17061. if (resultSelector == null)
  17062. throw new ArgumentNullException(nameof(resultSelector));
  17063. return source1.Provider.CreateQuery<TResult>(
  17064. Expression.Call(
  17065. null,
  17066. #if CRIPPLED_REFLECTION
  17067. 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>>))),
  17068. #else
  17069. ((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)),
  17070. #endif
  17071. source1.Expression,
  17072. GetSourceExpression(source2),
  17073. GetSourceExpression(source3),
  17074. GetSourceExpression(source4),
  17075. GetSourceExpression(source5),
  17076. GetSourceExpression(source6),
  17077. GetSourceExpression(source7),
  17078. GetSourceExpression(source8),
  17079. GetSourceExpression(source9),
  17080. GetSourceExpression(source10),
  17081. GetSourceExpression(source11),
  17082. GetSourceExpression(source12),
  17083. resultSelector
  17084. )
  17085. );
  17086. }
  17087. /// <summary>
  17088. /// 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.
  17089. /// </summary>
  17090. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17091. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17092. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17093. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17094. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17095. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17096. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17097. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17098. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17099. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17100. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17101. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17102. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17103. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17104. /// <param name="source1">First observable source.</param>
  17105. /// <param name="source2">Second observable source.</param>
  17106. /// <param name="source3">Third observable source.</param>
  17107. /// <param name="source4">Fourth observable source.</param>
  17108. /// <param name="source5">Fifth observable source.</param>
  17109. /// <param name="source6">Sixth observable source.</param>
  17110. /// <param name="source7">Seventh observable source.</param>
  17111. /// <param name="source8">Eighth observable source.</param>
  17112. /// <param name="source9">Ninth observable source.</param>
  17113. /// <param name="source10">Tenth observable source.</param>
  17114. /// <param name="source11">Eleventh observable source.</param>
  17115. /// <param name="source12">Twelfth observable source.</param>
  17116. /// <param name="source13">Thirteenth observable source.</param>
  17117. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17118. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17119. /// <exception cref="ArgumentNullException">
  17120. /// <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>
  17121. 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)
  17122. {
  17123. if (source1 == null)
  17124. throw new ArgumentNullException(nameof(source1));
  17125. if (source2 == null)
  17126. throw new ArgumentNullException(nameof(source2));
  17127. if (source3 == null)
  17128. throw new ArgumentNullException(nameof(source3));
  17129. if (source4 == null)
  17130. throw new ArgumentNullException(nameof(source4));
  17131. if (source5 == null)
  17132. throw new ArgumentNullException(nameof(source5));
  17133. if (source6 == null)
  17134. throw new ArgumentNullException(nameof(source6));
  17135. if (source7 == null)
  17136. throw new ArgumentNullException(nameof(source7));
  17137. if (source8 == null)
  17138. throw new ArgumentNullException(nameof(source8));
  17139. if (source9 == null)
  17140. throw new ArgumentNullException(nameof(source9));
  17141. if (source10 == null)
  17142. throw new ArgumentNullException(nameof(source10));
  17143. if (source11 == null)
  17144. throw new ArgumentNullException(nameof(source11));
  17145. if (source12 == null)
  17146. throw new ArgumentNullException(nameof(source12));
  17147. if (source13 == null)
  17148. throw new ArgumentNullException(nameof(source13));
  17149. if (resultSelector == null)
  17150. throw new ArgumentNullException(nameof(resultSelector));
  17151. return source1.Provider.CreateQuery<TResult>(
  17152. Expression.Call(
  17153. null,
  17154. #if CRIPPLED_REFLECTION
  17155. 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>>))),
  17156. #else
  17157. ((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)),
  17158. #endif
  17159. source1.Expression,
  17160. GetSourceExpression(source2),
  17161. GetSourceExpression(source3),
  17162. GetSourceExpression(source4),
  17163. GetSourceExpression(source5),
  17164. GetSourceExpression(source6),
  17165. GetSourceExpression(source7),
  17166. GetSourceExpression(source8),
  17167. GetSourceExpression(source9),
  17168. GetSourceExpression(source10),
  17169. GetSourceExpression(source11),
  17170. GetSourceExpression(source12),
  17171. GetSourceExpression(source13),
  17172. resultSelector
  17173. )
  17174. );
  17175. }
  17176. /// <summary>
  17177. /// 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.
  17178. /// </summary>
  17179. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17180. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17181. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17182. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17183. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17184. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17185. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17186. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17187. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17188. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17189. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17190. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17191. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17192. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17193. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17194. /// <param name="source1">First observable source.</param>
  17195. /// <param name="source2">Second observable source.</param>
  17196. /// <param name="source3">Third observable source.</param>
  17197. /// <param name="source4">Fourth observable source.</param>
  17198. /// <param name="source5">Fifth observable source.</param>
  17199. /// <param name="source6">Sixth observable source.</param>
  17200. /// <param name="source7">Seventh observable source.</param>
  17201. /// <param name="source8">Eighth observable source.</param>
  17202. /// <param name="source9">Ninth observable source.</param>
  17203. /// <param name="source10">Tenth observable source.</param>
  17204. /// <param name="source11">Eleventh observable source.</param>
  17205. /// <param name="source12">Twelfth observable source.</param>
  17206. /// <param name="source13">Thirteenth observable source.</param>
  17207. /// <param name="source14">Fourteenth observable source.</param>
  17208. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17209. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17210. /// <exception cref="ArgumentNullException">
  17211. /// <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>
  17212. 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)
  17213. {
  17214. if (source1 == null)
  17215. throw new ArgumentNullException(nameof(source1));
  17216. if (source2 == null)
  17217. throw new ArgumentNullException(nameof(source2));
  17218. if (source3 == null)
  17219. throw new ArgumentNullException(nameof(source3));
  17220. if (source4 == null)
  17221. throw new ArgumentNullException(nameof(source4));
  17222. if (source5 == null)
  17223. throw new ArgumentNullException(nameof(source5));
  17224. if (source6 == null)
  17225. throw new ArgumentNullException(nameof(source6));
  17226. if (source7 == null)
  17227. throw new ArgumentNullException(nameof(source7));
  17228. if (source8 == null)
  17229. throw new ArgumentNullException(nameof(source8));
  17230. if (source9 == null)
  17231. throw new ArgumentNullException(nameof(source9));
  17232. if (source10 == null)
  17233. throw new ArgumentNullException(nameof(source10));
  17234. if (source11 == null)
  17235. throw new ArgumentNullException(nameof(source11));
  17236. if (source12 == null)
  17237. throw new ArgumentNullException(nameof(source12));
  17238. if (source13 == null)
  17239. throw new ArgumentNullException(nameof(source13));
  17240. if (source14 == null)
  17241. throw new ArgumentNullException(nameof(source14));
  17242. if (resultSelector == null)
  17243. throw new ArgumentNullException(nameof(resultSelector));
  17244. return source1.Provider.CreateQuery<TResult>(
  17245. Expression.Call(
  17246. null,
  17247. #if CRIPPLED_REFLECTION
  17248. 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>>))),
  17249. #else
  17250. ((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)),
  17251. #endif
  17252. source1.Expression,
  17253. GetSourceExpression(source2),
  17254. GetSourceExpression(source3),
  17255. GetSourceExpression(source4),
  17256. GetSourceExpression(source5),
  17257. GetSourceExpression(source6),
  17258. GetSourceExpression(source7),
  17259. GetSourceExpression(source8),
  17260. GetSourceExpression(source9),
  17261. GetSourceExpression(source10),
  17262. GetSourceExpression(source11),
  17263. GetSourceExpression(source12),
  17264. GetSourceExpression(source13),
  17265. GetSourceExpression(source14),
  17266. resultSelector
  17267. )
  17268. );
  17269. }
  17270. /// <summary>
  17271. /// 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.
  17272. /// </summary>
  17273. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17274. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17275. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17276. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17277. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17278. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17279. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17280. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17281. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17282. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17283. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17284. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17285. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17286. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17287. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17288. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17289. /// <param name="source1">First observable source.</param>
  17290. /// <param name="source2">Second observable source.</param>
  17291. /// <param name="source3">Third observable source.</param>
  17292. /// <param name="source4">Fourth observable source.</param>
  17293. /// <param name="source5">Fifth observable source.</param>
  17294. /// <param name="source6">Sixth observable source.</param>
  17295. /// <param name="source7">Seventh observable source.</param>
  17296. /// <param name="source8">Eighth observable source.</param>
  17297. /// <param name="source9">Ninth observable source.</param>
  17298. /// <param name="source10">Tenth observable source.</param>
  17299. /// <param name="source11">Eleventh observable source.</param>
  17300. /// <param name="source12">Twelfth observable source.</param>
  17301. /// <param name="source13">Thirteenth observable source.</param>
  17302. /// <param name="source14">Fourteenth observable source.</param>
  17303. /// <param name="source15">Fifteenth observable source.</param>
  17304. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17305. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17306. /// <exception cref="ArgumentNullException">
  17307. /// <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>
  17308. 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)
  17309. {
  17310. if (source1 == null)
  17311. throw new ArgumentNullException(nameof(source1));
  17312. if (source2 == null)
  17313. throw new ArgumentNullException(nameof(source2));
  17314. if (source3 == null)
  17315. throw new ArgumentNullException(nameof(source3));
  17316. if (source4 == null)
  17317. throw new ArgumentNullException(nameof(source4));
  17318. if (source5 == null)
  17319. throw new ArgumentNullException(nameof(source5));
  17320. if (source6 == null)
  17321. throw new ArgumentNullException(nameof(source6));
  17322. if (source7 == null)
  17323. throw new ArgumentNullException(nameof(source7));
  17324. if (source8 == null)
  17325. throw new ArgumentNullException(nameof(source8));
  17326. if (source9 == null)
  17327. throw new ArgumentNullException(nameof(source9));
  17328. if (source10 == null)
  17329. throw new ArgumentNullException(nameof(source10));
  17330. if (source11 == null)
  17331. throw new ArgumentNullException(nameof(source11));
  17332. if (source12 == null)
  17333. throw new ArgumentNullException(nameof(source12));
  17334. if (source13 == null)
  17335. throw new ArgumentNullException(nameof(source13));
  17336. if (source14 == null)
  17337. throw new ArgumentNullException(nameof(source14));
  17338. if (source15 == null)
  17339. throw new ArgumentNullException(nameof(source15));
  17340. if (resultSelector == null)
  17341. throw new ArgumentNullException(nameof(resultSelector));
  17342. return source1.Provider.CreateQuery<TResult>(
  17343. Expression.Call(
  17344. null,
  17345. #if CRIPPLED_REFLECTION
  17346. 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>>))),
  17347. #else
  17348. ((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)),
  17349. #endif
  17350. source1.Expression,
  17351. GetSourceExpression(source2),
  17352. GetSourceExpression(source3),
  17353. GetSourceExpression(source4),
  17354. GetSourceExpression(source5),
  17355. GetSourceExpression(source6),
  17356. GetSourceExpression(source7),
  17357. GetSourceExpression(source8),
  17358. GetSourceExpression(source9),
  17359. GetSourceExpression(source10),
  17360. GetSourceExpression(source11),
  17361. GetSourceExpression(source12),
  17362. GetSourceExpression(source13),
  17363. GetSourceExpression(source14),
  17364. GetSourceExpression(source15),
  17365. resultSelector
  17366. )
  17367. );
  17368. }
  17369. /// <summary>
  17370. /// 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.
  17371. /// </summary>
  17372. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17373. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17374. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17375. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17376. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17377. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17378. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17379. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17380. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17381. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17382. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17383. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17384. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17385. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17386. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17387. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  17388. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17389. /// <param name="source1">First observable source.</param>
  17390. /// <param name="source2">Second observable source.</param>
  17391. /// <param name="source3">Third observable source.</param>
  17392. /// <param name="source4">Fourth observable source.</param>
  17393. /// <param name="source5">Fifth observable source.</param>
  17394. /// <param name="source6">Sixth observable source.</param>
  17395. /// <param name="source7">Seventh observable source.</param>
  17396. /// <param name="source8">Eighth observable source.</param>
  17397. /// <param name="source9">Ninth observable source.</param>
  17398. /// <param name="source10">Tenth observable source.</param>
  17399. /// <param name="source11">Eleventh observable source.</param>
  17400. /// <param name="source12">Twelfth observable source.</param>
  17401. /// <param name="source13">Thirteenth observable source.</param>
  17402. /// <param name="source14">Fourteenth observable source.</param>
  17403. /// <param name="source15">Fifteenth observable source.</param>
  17404. /// <param name="source16">Sixteenth observable source.</param>
  17405. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17406. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17407. /// <exception cref="ArgumentNullException">
  17408. /// <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>
  17409. 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)
  17410. {
  17411. if (source1 == null)
  17412. throw new ArgumentNullException(nameof(source1));
  17413. if (source2 == null)
  17414. throw new ArgumentNullException(nameof(source2));
  17415. if (source3 == null)
  17416. throw new ArgumentNullException(nameof(source3));
  17417. if (source4 == null)
  17418. throw new ArgumentNullException(nameof(source4));
  17419. if (source5 == null)
  17420. throw new ArgumentNullException(nameof(source5));
  17421. if (source6 == null)
  17422. throw new ArgumentNullException(nameof(source6));
  17423. if (source7 == null)
  17424. throw new ArgumentNullException(nameof(source7));
  17425. if (source8 == null)
  17426. throw new ArgumentNullException(nameof(source8));
  17427. if (source9 == null)
  17428. throw new ArgumentNullException(nameof(source9));
  17429. if (source10 == null)
  17430. throw new ArgumentNullException(nameof(source10));
  17431. if (source11 == null)
  17432. throw new ArgumentNullException(nameof(source11));
  17433. if (source12 == null)
  17434. throw new ArgumentNullException(nameof(source12));
  17435. if (source13 == null)
  17436. throw new ArgumentNullException(nameof(source13));
  17437. if (source14 == null)
  17438. throw new ArgumentNullException(nameof(source14));
  17439. if (source15 == null)
  17440. throw new ArgumentNullException(nameof(source15));
  17441. if (source16 == null)
  17442. throw new ArgumentNullException(nameof(source16));
  17443. if (resultSelector == null)
  17444. throw new ArgumentNullException(nameof(resultSelector));
  17445. return source1.Provider.CreateQuery<TResult>(
  17446. Expression.Call(
  17447. null,
  17448. #if CRIPPLED_REFLECTION
  17449. 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>>))),
  17450. #else
  17451. ((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)),
  17452. #endif
  17453. source1.Expression,
  17454. GetSourceExpression(source2),
  17455. GetSourceExpression(source3),
  17456. GetSourceExpression(source4),
  17457. GetSourceExpression(source5),
  17458. GetSourceExpression(source6),
  17459. GetSourceExpression(source7),
  17460. GetSourceExpression(source8),
  17461. GetSourceExpression(source9),
  17462. GetSourceExpression(source10),
  17463. GetSourceExpression(source11),
  17464. GetSourceExpression(source12),
  17465. GetSourceExpression(source13),
  17466. GetSourceExpression(source14),
  17467. GetSourceExpression(source15),
  17468. GetSourceExpression(source16),
  17469. resultSelector
  17470. )
  17471. );
  17472. }
  17473. /// <summary>
  17474. /// 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.
  17475. /// </summary>
  17476. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17477. /// <param name="action">Action to convert to an asynchronous action.</param>
  17478. /// <returns>Asynchronous action.</returns>
  17479. /// <exception cref="ArgumentNullException">
  17480. /// <paramref name="action" /> is null.</exception>
  17481. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action)
  17482. {
  17483. if (provider == null)
  17484. throw new ArgumentNullException(nameof(provider));
  17485. if (action == null)
  17486. throw new ArgumentNullException(nameof(action));
  17487. #if CRIPPLED_REFLECTION
  17488. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>)));
  17489. #else
  17490. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17491. #endif
  17492. return () => provider.CreateQuery<Unit>(
  17493. Expression.Invoke(
  17494. Expression.Call(
  17495. null,
  17496. m,
  17497. Expression.Constant(provider, typeof(IQbservableProvider)),
  17498. action
  17499. )
  17500. )
  17501. );
  17502. }
  17503. /// <summary>
  17504. /// 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.
  17505. /// </summary>
  17506. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17507. /// <param name="action">Action to convert to an asynchronous action.</param>
  17508. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17509. /// <returns>Asynchronous action.</returns>
  17510. /// <exception cref="ArgumentNullException">
  17511. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17512. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  17513. {
  17514. if (provider == null)
  17515. throw new ArgumentNullException(nameof(provider));
  17516. if (action == null)
  17517. throw new ArgumentNullException(nameof(action));
  17518. if (scheduler == null)
  17519. throw new ArgumentNullException(nameof(scheduler));
  17520. #if CRIPPLED_REFLECTION
  17521. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>), default(IScheduler)));
  17522. #else
  17523. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17524. #endif
  17525. return () => provider.CreateQuery<Unit>(
  17526. Expression.Invoke(
  17527. Expression.Call(
  17528. null,
  17529. m,
  17530. Expression.Constant(provider, typeof(IQbservableProvider)),
  17531. action,
  17532. Expression.Constant(scheduler, typeof(IScheduler))
  17533. )
  17534. )
  17535. );
  17536. }
  17537. /// <summary>
  17538. /// 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.
  17539. /// </summary>
  17540. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17541. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17542. /// <param name="action">Action to convert to an asynchronous action.</param>
  17543. /// <returns>Asynchronous action.</returns>
  17544. /// <exception cref="ArgumentNullException">
  17545. /// <paramref name="action" /> is null.</exception>
  17546. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action)
  17547. {
  17548. if (provider == null)
  17549. throw new ArgumentNullException(nameof(provider));
  17550. if (action == null)
  17551. throw new ArgumentNullException(nameof(action));
  17552. #if CRIPPLED_REFLECTION
  17553. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>)));
  17554. #else
  17555. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17556. #endif
  17557. return (t1) => provider.CreateQuery<Unit>(
  17558. Expression.Invoke(
  17559. Expression.Call(
  17560. null,
  17561. m,
  17562. Expression.Constant(provider, typeof(IQbservableProvider)),
  17563. action
  17564. ),
  17565. Expression.Constant(t1, typeof(TArg1))
  17566. )
  17567. );
  17568. }
  17569. /// <summary>
  17570. /// 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.
  17571. /// </summary>
  17572. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17573. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17574. /// <param name="action">Action to convert to an asynchronous action.</param>
  17575. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17576. /// <returns>Asynchronous action.</returns>
  17577. /// <exception cref="ArgumentNullException">
  17578. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17579. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action, IScheduler scheduler)
  17580. {
  17581. if (provider == null)
  17582. throw new ArgumentNullException(nameof(provider));
  17583. if (action == null)
  17584. throw new ArgumentNullException(nameof(action));
  17585. if (scheduler == null)
  17586. throw new ArgumentNullException(nameof(scheduler));
  17587. #if CRIPPLED_REFLECTION
  17588. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>), default(IScheduler)));
  17589. #else
  17590. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17591. #endif
  17592. return (t1) => provider.CreateQuery<Unit>(
  17593. Expression.Invoke(
  17594. Expression.Call(
  17595. null,
  17596. m,
  17597. Expression.Constant(provider, typeof(IQbservableProvider)),
  17598. action,
  17599. Expression.Constant(scheduler, typeof(IScheduler))
  17600. ),
  17601. Expression.Constant(t1, typeof(TArg1))
  17602. )
  17603. );
  17604. }
  17605. /// <summary>
  17606. /// 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.
  17607. /// </summary>
  17608. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17609. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17610. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17611. /// <param name="action">Action to convert to an asynchronous action.</param>
  17612. /// <returns>Asynchronous action.</returns>
  17613. /// <exception cref="ArgumentNullException">
  17614. /// <paramref name="action" /> is null.</exception>
  17615. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action)
  17616. {
  17617. if (provider == null)
  17618. throw new ArgumentNullException(nameof(provider));
  17619. if (action == null)
  17620. throw new ArgumentNullException(nameof(action));
  17621. #if CRIPPLED_REFLECTION
  17622. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>)));
  17623. #else
  17624. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17625. #endif
  17626. return (t1, t2) => provider.CreateQuery<Unit>(
  17627. Expression.Invoke(
  17628. Expression.Call(
  17629. null,
  17630. m,
  17631. Expression.Constant(provider, typeof(IQbservableProvider)),
  17632. action
  17633. ),
  17634. Expression.Constant(t1, typeof(TArg1)),
  17635. Expression.Constant(t2, typeof(TArg2))
  17636. )
  17637. );
  17638. }
  17639. /// <summary>
  17640. /// 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.
  17641. /// </summary>
  17642. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17643. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17644. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17645. /// <param name="action">Action to convert to an asynchronous action.</param>
  17646. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17647. /// <returns>Asynchronous action.</returns>
  17648. /// <exception cref="ArgumentNullException">
  17649. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17650. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action, IScheduler scheduler)
  17651. {
  17652. if (provider == null)
  17653. throw new ArgumentNullException(nameof(provider));
  17654. if (action == null)
  17655. throw new ArgumentNullException(nameof(action));
  17656. if (scheduler == null)
  17657. throw new ArgumentNullException(nameof(scheduler));
  17658. #if CRIPPLED_REFLECTION
  17659. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>), default(IScheduler)));
  17660. #else
  17661. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17662. #endif
  17663. return (t1, t2) => provider.CreateQuery<Unit>(
  17664. Expression.Invoke(
  17665. Expression.Call(
  17666. null,
  17667. m,
  17668. Expression.Constant(provider, typeof(IQbservableProvider)),
  17669. action,
  17670. Expression.Constant(scheduler, typeof(IScheduler))
  17671. ),
  17672. Expression.Constant(t1, typeof(TArg1)),
  17673. Expression.Constant(t2, typeof(TArg2))
  17674. )
  17675. );
  17676. }
  17677. /// <summary>
  17678. /// 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.
  17679. /// </summary>
  17680. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17681. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17682. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17683. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17684. /// <param name="action">Action to convert to an asynchronous action.</param>
  17685. /// <returns>Asynchronous action.</returns>
  17686. /// <exception cref="ArgumentNullException">
  17687. /// <paramref name="action" /> is null.</exception>
  17688. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action)
  17689. {
  17690. if (provider == null)
  17691. throw new ArgumentNullException(nameof(provider));
  17692. if (action == null)
  17693. throw new ArgumentNullException(nameof(action));
  17694. #if CRIPPLED_REFLECTION
  17695. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>)));
  17696. #else
  17697. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17698. #endif
  17699. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17700. Expression.Invoke(
  17701. Expression.Call(
  17702. null,
  17703. m,
  17704. Expression.Constant(provider, typeof(IQbservableProvider)),
  17705. action
  17706. ),
  17707. Expression.Constant(t1, typeof(TArg1)),
  17708. Expression.Constant(t2, typeof(TArg2)),
  17709. Expression.Constant(t3, typeof(TArg3))
  17710. )
  17711. );
  17712. }
  17713. /// <summary>
  17714. /// 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.
  17715. /// </summary>
  17716. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17717. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17718. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17719. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17720. /// <param name="action">Action to convert to an asynchronous action.</param>
  17721. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17722. /// <returns>Asynchronous action.</returns>
  17723. /// <exception cref="ArgumentNullException">
  17724. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17725. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action, IScheduler scheduler)
  17726. {
  17727. if (provider == null)
  17728. throw new ArgumentNullException(nameof(provider));
  17729. if (action == null)
  17730. throw new ArgumentNullException(nameof(action));
  17731. if (scheduler == null)
  17732. throw new ArgumentNullException(nameof(scheduler));
  17733. #if CRIPPLED_REFLECTION
  17734. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>), default(IScheduler)));
  17735. #else
  17736. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17737. #endif
  17738. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17739. Expression.Invoke(
  17740. Expression.Call(
  17741. null,
  17742. m,
  17743. Expression.Constant(provider, typeof(IQbservableProvider)),
  17744. action,
  17745. Expression.Constant(scheduler, typeof(IScheduler))
  17746. ),
  17747. Expression.Constant(t1, typeof(TArg1)),
  17748. Expression.Constant(t2, typeof(TArg2)),
  17749. Expression.Constant(t3, typeof(TArg3))
  17750. )
  17751. );
  17752. }
  17753. /// <summary>
  17754. /// 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.
  17755. /// </summary>
  17756. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17757. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17758. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17759. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17760. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17761. /// <param name="action">Action to convert to an asynchronous action.</param>
  17762. /// <returns>Asynchronous action.</returns>
  17763. /// <exception cref="ArgumentNullException">
  17764. /// <paramref name="action" /> is null.</exception>
  17765. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4>> action)
  17766. {
  17767. if (provider == null)
  17768. throw new ArgumentNullException(nameof(provider));
  17769. if (action == null)
  17770. throw new ArgumentNullException(nameof(action));
  17771. #if CRIPPLED_REFLECTION
  17772. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>)));
  17773. #else
  17774. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17775. #endif
  17776. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17777. Expression.Invoke(
  17778. Expression.Call(
  17779. null,
  17780. m,
  17781. Expression.Constant(provider, typeof(IQbservableProvider)),
  17782. action
  17783. ),
  17784. Expression.Constant(t1, typeof(TArg1)),
  17785. Expression.Constant(t2, typeof(TArg2)),
  17786. Expression.Constant(t3, typeof(TArg3)),
  17787. Expression.Constant(t4, typeof(TArg4))
  17788. )
  17789. );
  17790. }
  17791. /// <summary>
  17792. /// 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.
  17793. /// </summary>
  17794. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17795. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17796. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17797. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17798. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17799. /// <param name="action">Action to convert to an asynchronous action.</param>
  17800. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17801. /// <returns>Asynchronous action.</returns>
  17802. /// <exception cref="ArgumentNullException">
  17803. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17804. 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)
  17805. {
  17806. if (provider == null)
  17807. throw new ArgumentNullException(nameof(provider));
  17808. if (action == null)
  17809. throw new ArgumentNullException(nameof(action));
  17810. if (scheduler == null)
  17811. throw new ArgumentNullException(nameof(scheduler));
  17812. #if CRIPPLED_REFLECTION
  17813. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>), default(IScheduler)));
  17814. #else
  17815. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17816. #endif
  17817. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17818. Expression.Invoke(
  17819. Expression.Call(
  17820. null,
  17821. m,
  17822. Expression.Constant(provider, typeof(IQbservableProvider)),
  17823. action,
  17824. Expression.Constant(scheduler, typeof(IScheduler))
  17825. ),
  17826. Expression.Constant(t1, typeof(TArg1)),
  17827. Expression.Constant(t2, typeof(TArg2)),
  17828. Expression.Constant(t3, typeof(TArg3)),
  17829. Expression.Constant(t4, typeof(TArg4))
  17830. )
  17831. );
  17832. }
  17833. /// <summary>
  17834. /// 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.
  17835. /// </summary>
  17836. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17837. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17838. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17839. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17840. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17841. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17842. /// <param name="action">Action to convert to an asynchronous action.</param>
  17843. /// <returns>Asynchronous action.</returns>
  17844. /// <exception cref="ArgumentNullException">
  17845. /// <paramref name="action" /> is null.</exception>
  17846. 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)
  17847. {
  17848. if (provider == null)
  17849. throw new ArgumentNullException(nameof(provider));
  17850. if (action == null)
  17851. throw new ArgumentNullException(nameof(action));
  17852. #if CRIPPLED_REFLECTION
  17853. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>)));
  17854. #else
  17855. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  17856. #endif
  17857. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  17858. Expression.Invoke(
  17859. Expression.Call(
  17860. null,
  17861. m,
  17862. Expression.Constant(provider, typeof(IQbservableProvider)),
  17863. action
  17864. ),
  17865. Expression.Constant(t1, typeof(TArg1)),
  17866. Expression.Constant(t2, typeof(TArg2)),
  17867. Expression.Constant(t3, typeof(TArg3)),
  17868. Expression.Constant(t4, typeof(TArg4)),
  17869. Expression.Constant(t5, typeof(TArg5))
  17870. )
  17871. );
  17872. }
  17873. /// <summary>
  17874. /// 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.
  17875. /// </summary>
  17876. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17877. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17878. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17879. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17880. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17881. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17882. /// <param name="action">Action to convert to an asynchronous action.</param>
  17883. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17884. /// <returns>Asynchronous action.</returns>
  17885. /// <exception cref="ArgumentNullException">
  17886. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17887. 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)
  17888. {
  17889. if (provider == null)
  17890. throw new ArgumentNullException(nameof(provider));
  17891. if (action == null)
  17892. throw new ArgumentNullException(nameof(action));
  17893. if (scheduler == null)
  17894. throw new ArgumentNullException(nameof(scheduler));
  17895. #if CRIPPLED_REFLECTION
  17896. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>), default(IScheduler)));
  17897. #else
  17898. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  17899. #endif
  17900. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  17901. Expression.Invoke(
  17902. Expression.Call(
  17903. null,
  17904. m,
  17905. Expression.Constant(provider, typeof(IQbservableProvider)),
  17906. action,
  17907. Expression.Constant(scheduler, typeof(IScheduler))
  17908. ),
  17909. Expression.Constant(t1, typeof(TArg1)),
  17910. Expression.Constant(t2, typeof(TArg2)),
  17911. Expression.Constant(t3, typeof(TArg3)),
  17912. Expression.Constant(t4, typeof(TArg4)),
  17913. Expression.Constant(t5, typeof(TArg5))
  17914. )
  17915. );
  17916. }
  17917. /// <summary>
  17918. /// 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.
  17919. /// </summary>
  17920. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17921. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17922. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17923. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17924. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17925. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17926. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17927. /// <param name="action">Action to convert to an asynchronous action.</param>
  17928. /// <returns>Asynchronous action.</returns>
  17929. /// <exception cref="ArgumentNullException">
  17930. /// <paramref name="action" /> is null.</exception>
  17931. 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)
  17932. {
  17933. if (provider == null)
  17934. throw new ArgumentNullException(nameof(provider));
  17935. if (action == null)
  17936. throw new ArgumentNullException(nameof(action));
  17937. #if CRIPPLED_REFLECTION
  17938. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>)));
  17939. #else
  17940. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  17941. #endif
  17942. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  17943. Expression.Invoke(
  17944. Expression.Call(
  17945. null,
  17946. m,
  17947. Expression.Constant(provider, typeof(IQbservableProvider)),
  17948. action
  17949. ),
  17950. Expression.Constant(t1, typeof(TArg1)),
  17951. Expression.Constant(t2, typeof(TArg2)),
  17952. Expression.Constant(t3, typeof(TArg3)),
  17953. Expression.Constant(t4, typeof(TArg4)),
  17954. Expression.Constant(t5, typeof(TArg5)),
  17955. Expression.Constant(t6, typeof(TArg6))
  17956. )
  17957. );
  17958. }
  17959. /// <summary>
  17960. /// 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.
  17961. /// </summary>
  17962. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17963. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17964. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17965. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17966. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17967. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17968. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17969. /// <param name="action">Action to convert to an asynchronous action.</param>
  17970. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17971. /// <returns>Asynchronous action.</returns>
  17972. /// <exception cref="ArgumentNullException">
  17973. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17974. 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)
  17975. {
  17976. if (provider == null)
  17977. throw new ArgumentNullException(nameof(provider));
  17978. if (action == null)
  17979. throw new ArgumentNullException(nameof(action));
  17980. if (scheduler == null)
  17981. throw new ArgumentNullException(nameof(scheduler));
  17982. #if CRIPPLED_REFLECTION
  17983. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>), default(IScheduler)));
  17984. #else
  17985. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  17986. #endif
  17987. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  17988. Expression.Invoke(
  17989. Expression.Call(
  17990. null,
  17991. m,
  17992. Expression.Constant(provider, typeof(IQbservableProvider)),
  17993. action,
  17994. Expression.Constant(scheduler, typeof(IScheduler))
  17995. ),
  17996. Expression.Constant(t1, typeof(TArg1)),
  17997. Expression.Constant(t2, typeof(TArg2)),
  17998. Expression.Constant(t3, typeof(TArg3)),
  17999. Expression.Constant(t4, typeof(TArg4)),
  18000. Expression.Constant(t5, typeof(TArg5)),
  18001. Expression.Constant(t6, typeof(TArg6))
  18002. )
  18003. );
  18004. }
  18005. /// <summary>
  18006. /// 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.
  18007. /// </summary>
  18008. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18009. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18010. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18011. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18012. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18013. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18014. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18015. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18016. /// <param name="action">Action to convert to an asynchronous action.</param>
  18017. /// <returns>Asynchronous action.</returns>
  18018. /// <exception cref="ArgumentNullException">
  18019. /// <paramref name="action" /> is null.</exception>
  18020. 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)
  18021. {
  18022. if (provider == null)
  18023. throw new ArgumentNullException(nameof(provider));
  18024. if (action == null)
  18025. throw new ArgumentNullException(nameof(action));
  18026. #if CRIPPLED_REFLECTION
  18027. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>>)));
  18028. #else
  18029. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  18030. #endif
  18031. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  18032. Expression.Invoke(
  18033. Expression.Call(
  18034. null,
  18035. m,
  18036. Expression.Constant(provider, typeof(IQbservableProvider)),
  18037. action
  18038. ),
  18039. Expression.Constant(t1, typeof(TArg1)),
  18040. Expression.Constant(t2, typeof(TArg2)),
  18041. Expression.Constant(t3, typeof(TArg3)),
  18042. Expression.Constant(t4, typeof(TArg4)),
  18043. Expression.Constant(t5, typeof(TArg5)),
  18044. Expression.Constant(t6, typeof(TArg6)),
  18045. Expression.Constant(t7, typeof(TArg7))
  18046. )
  18047. );
  18048. }
  18049. /// <summary>
  18050. /// 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.
  18051. /// </summary>
  18052. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18053. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18054. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18055. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18056. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18057. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18058. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18059. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18060. /// <param name="action">Action to convert to an asynchronous action.</param>
  18061. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18062. /// <returns>Asynchronous action.</returns>
  18063. /// <exception cref="ArgumentNullException">
  18064. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18065. 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)
  18066. {
  18067. if (provider == null)
  18068. throw new ArgumentNullException(nameof(provider));
  18069. if (action == null)
  18070. throw new ArgumentNullException(nameof(action));
  18071. if (scheduler == null)
  18072. throw new ArgumentNullException(nameof(scheduler));
  18073. #if CRIPPLED_REFLECTION
  18074. 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)));
  18075. #else
  18076. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  18077. #endif
  18078. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  18079. Expression.Invoke(
  18080. Expression.Call(
  18081. null,
  18082. m,
  18083. Expression.Constant(provider, typeof(IQbservableProvider)),
  18084. action,
  18085. Expression.Constant(scheduler, typeof(IScheduler))
  18086. ),
  18087. Expression.Constant(t1, typeof(TArg1)),
  18088. Expression.Constant(t2, typeof(TArg2)),
  18089. Expression.Constant(t3, typeof(TArg3)),
  18090. Expression.Constant(t4, typeof(TArg4)),
  18091. Expression.Constant(t5, typeof(TArg5)),
  18092. Expression.Constant(t6, typeof(TArg6)),
  18093. Expression.Constant(t7, typeof(TArg7))
  18094. )
  18095. );
  18096. }
  18097. /// <summary>
  18098. /// 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.
  18099. /// </summary>
  18100. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18101. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18102. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18103. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18104. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18105. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18106. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18107. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18108. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18109. /// <param name="action">Action to convert to an asynchronous action.</param>
  18110. /// <returns>Asynchronous action.</returns>
  18111. /// <exception cref="ArgumentNullException">
  18112. /// <paramref name="action" /> is null.</exception>
  18113. 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)
  18114. {
  18115. if (provider == null)
  18116. throw new ArgumentNullException(nameof(provider));
  18117. if (action == null)
  18118. throw new ArgumentNullException(nameof(action));
  18119. #if CRIPPLED_REFLECTION
  18120. 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>>)));
  18121. #else
  18122. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  18123. #endif
  18124. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  18125. Expression.Invoke(
  18126. Expression.Call(
  18127. null,
  18128. m,
  18129. Expression.Constant(provider, typeof(IQbservableProvider)),
  18130. action
  18131. ),
  18132. Expression.Constant(t1, typeof(TArg1)),
  18133. Expression.Constant(t2, typeof(TArg2)),
  18134. Expression.Constant(t3, typeof(TArg3)),
  18135. Expression.Constant(t4, typeof(TArg4)),
  18136. Expression.Constant(t5, typeof(TArg5)),
  18137. Expression.Constant(t6, typeof(TArg6)),
  18138. Expression.Constant(t7, typeof(TArg7)),
  18139. Expression.Constant(t8, typeof(TArg8))
  18140. )
  18141. );
  18142. }
  18143. /// <summary>
  18144. /// 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.
  18145. /// </summary>
  18146. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18147. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18148. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18149. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18150. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18151. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18152. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18153. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18154. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18155. /// <param name="action">Action to convert to an asynchronous action.</param>
  18156. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18157. /// <returns>Asynchronous action.</returns>
  18158. /// <exception cref="ArgumentNullException">
  18159. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18160. 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)
  18161. {
  18162. if (provider == null)
  18163. throw new ArgumentNullException(nameof(provider));
  18164. if (action == null)
  18165. throw new ArgumentNullException(nameof(action));
  18166. if (scheduler == null)
  18167. throw new ArgumentNullException(nameof(scheduler));
  18168. #if CRIPPLED_REFLECTION
  18169. 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)));
  18170. #else
  18171. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  18172. #endif
  18173. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  18174. Expression.Invoke(
  18175. Expression.Call(
  18176. null,
  18177. m,
  18178. Expression.Constant(provider, typeof(IQbservableProvider)),
  18179. action,
  18180. Expression.Constant(scheduler, typeof(IScheduler))
  18181. ),
  18182. Expression.Constant(t1, typeof(TArg1)),
  18183. Expression.Constant(t2, typeof(TArg2)),
  18184. Expression.Constant(t3, typeof(TArg3)),
  18185. Expression.Constant(t4, typeof(TArg4)),
  18186. Expression.Constant(t5, typeof(TArg5)),
  18187. Expression.Constant(t6, typeof(TArg6)),
  18188. Expression.Constant(t7, typeof(TArg7)),
  18189. Expression.Constant(t8, typeof(TArg8))
  18190. )
  18191. );
  18192. }
  18193. /// <summary>
  18194. /// 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.
  18195. /// </summary>
  18196. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18197. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18198. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18199. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18200. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18201. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18202. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18203. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18204. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18205. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18206. /// <param name="action">Action to convert to an asynchronous action.</param>
  18207. /// <returns>Asynchronous action.</returns>
  18208. /// <exception cref="ArgumentNullException">
  18209. /// <paramref name="action" /> is null.</exception>
  18210. 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)
  18211. {
  18212. if (provider == null)
  18213. throw new ArgumentNullException(nameof(provider));
  18214. if (action == null)
  18215. throw new ArgumentNullException(nameof(action));
  18216. #if CRIPPLED_REFLECTION
  18217. 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>>)));
  18218. #else
  18219. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18220. #endif
  18221. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18222. Expression.Invoke(
  18223. Expression.Call(
  18224. null,
  18225. m,
  18226. Expression.Constant(provider, typeof(IQbservableProvider)),
  18227. action
  18228. ),
  18229. Expression.Constant(t1, typeof(TArg1)),
  18230. Expression.Constant(t2, typeof(TArg2)),
  18231. Expression.Constant(t3, typeof(TArg3)),
  18232. Expression.Constant(t4, typeof(TArg4)),
  18233. Expression.Constant(t5, typeof(TArg5)),
  18234. Expression.Constant(t6, typeof(TArg6)),
  18235. Expression.Constant(t7, typeof(TArg7)),
  18236. Expression.Constant(t8, typeof(TArg8)),
  18237. Expression.Constant(t9, typeof(TArg9))
  18238. )
  18239. );
  18240. }
  18241. /// <summary>
  18242. /// 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.
  18243. /// </summary>
  18244. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18245. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18246. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18247. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18248. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18249. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18250. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18251. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18252. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18253. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18254. /// <param name="action">Action to convert to an asynchronous action.</param>
  18255. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18256. /// <returns>Asynchronous action.</returns>
  18257. /// <exception cref="ArgumentNullException">
  18258. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18259. 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)
  18260. {
  18261. if (provider == null)
  18262. throw new ArgumentNullException(nameof(provider));
  18263. if (action == null)
  18264. throw new ArgumentNullException(nameof(action));
  18265. if (scheduler == null)
  18266. throw new ArgumentNullException(nameof(scheduler));
  18267. #if CRIPPLED_REFLECTION
  18268. 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)));
  18269. #else
  18270. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18271. #endif
  18272. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18273. Expression.Invoke(
  18274. Expression.Call(
  18275. null,
  18276. m,
  18277. Expression.Constant(provider, typeof(IQbservableProvider)),
  18278. action,
  18279. Expression.Constant(scheduler, typeof(IScheduler))
  18280. ),
  18281. Expression.Constant(t1, typeof(TArg1)),
  18282. Expression.Constant(t2, typeof(TArg2)),
  18283. Expression.Constant(t3, typeof(TArg3)),
  18284. Expression.Constant(t4, typeof(TArg4)),
  18285. Expression.Constant(t5, typeof(TArg5)),
  18286. Expression.Constant(t6, typeof(TArg6)),
  18287. Expression.Constant(t7, typeof(TArg7)),
  18288. Expression.Constant(t8, typeof(TArg8)),
  18289. Expression.Constant(t9, typeof(TArg9))
  18290. )
  18291. );
  18292. }
  18293. /// <summary>
  18294. /// 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.
  18295. /// </summary>
  18296. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18297. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18298. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18299. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18300. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18301. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18302. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18303. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18304. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18305. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18306. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18307. /// <param name="action">Action to convert to an asynchronous action.</param>
  18308. /// <returns>Asynchronous action.</returns>
  18309. /// <exception cref="ArgumentNullException">
  18310. /// <paramref name="action" /> is null.</exception>
  18311. 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)
  18312. {
  18313. if (provider == null)
  18314. throw new ArgumentNullException(nameof(provider));
  18315. if (action == null)
  18316. throw new ArgumentNullException(nameof(action));
  18317. #if CRIPPLED_REFLECTION
  18318. 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>>)));
  18319. #else
  18320. 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));
  18321. #endif
  18322. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18323. Expression.Invoke(
  18324. Expression.Call(
  18325. null,
  18326. m,
  18327. Expression.Constant(provider, typeof(IQbservableProvider)),
  18328. action
  18329. ),
  18330. Expression.Constant(t1, typeof(TArg1)),
  18331. Expression.Constant(t2, typeof(TArg2)),
  18332. Expression.Constant(t3, typeof(TArg3)),
  18333. Expression.Constant(t4, typeof(TArg4)),
  18334. Expression.Constant(t5, typeof(TArg5)),
  18335. Expression.Constant(t6, typeof(TArg6)),
  18336. Expression.Constant(t7, typeof(TArg7)),
  18337. Expression.Constant(t8, typeof(TArg8)),
  18338. Expression.Constant(t9, typeof(TArg9)),
  18339. Expression.Constant(t10, typeof(TArg10))
  18340. )
  18341. );
  18342. }
  18343. /// <summary>
  18344. /// 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.
  18345. /// </summary>
  18346. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18347. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18348. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18349. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18350. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18351. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18352. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18353. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18354. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18355. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18356. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18357. /// <param name="action">Action to convert to an asynchronous action.</param>
  18358. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18359. /// <returns>Asynchronous action.</returns>
  18360. /// <exception cref="ArgumentNullException">
  18361. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18362. 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)
  18363. {
  18364. if (provider == null)
  18365. throw new ArgumentNullException(nameof(provider));
  18366. if (action == null)
  18367. throw new ArgumentNullException(nameof(action));
  18368. if (scheduler == null)
  18369. throw new ArgumentNullException(nameof(scheduler));
  18370. #if CRIPPLED_REFLECTION
  18371. 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)));
  18372. #else
  18373. 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));
  18374. #endif
  18375. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18376. Expression.Invoke(
  18377. Expression.Call(
  18378. null,
  18379. m,
  18380. Expression.Constant(provider, typeof(IQbservableProvider)),
  18381. action,
  18382. Expression.Constant(scheduler, typeof(IScheduler))
  18383. ),
  18384. Expression.Constant(t1, typeof(TArg1)),
  18385. Expression.Constant(t2, typeof(TArg2)),
  18386. Expression.Constant(t3, typeof(TArg3)),
  18387. Expression.Constant(t4, typeof(TArg4)),
  18388. Expression.Constant(t5, typeof(TArg5)),
  18389. Expression.Constant(t6, typeof(TArg6)),
  18390. Expression.Constant(t7, typeof(TArg7)),
  18391. Expression.Constant(t8, typeof(TArg8)),
  18392. Expression.Constant(t9, typeof(TArg9)),
  18393. Expression.Constant(t10, typeof(TArg10))
  18394. )
  18395. );
  18396. }
  18397. /// <summary>
  18398. /// 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.
  18399. /// </summary>
  18400. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18401. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18402. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18403. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18404. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18405. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18406. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18407. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18408. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18409. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18410. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18411. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18412. /// <param name="action">Action to convert to an asynchronous action.</param>
  18413. /// <returns>Asynchronous action.</returns>
  18414. /// <exception cref="ArgumentNullException">
  18415. /// <paramref name="action" /> is null.</exception>
  18416. 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)
  18417. {
  18418. if (provider == null)
  18419. throw new ArgumentNullException(nameof(provider));
  18420. if (action == null)
  18421. throw new ArgumentNullException(nameof(action));
  18422. #if CRIPPLED_REFLECTION
  18423. 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>>)));
  18424. #else
  18425. 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));
  18426. #endif
  18427. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18428. Expression.Invoke(
  18429. Expression.Call(
  18430. null,
  18431. m,
  18432. Expression.Constant(provider, typeof(IQbservableProvider)),
  18433. action
  18434. ),
  18435. Expression.Constant(t1, typeof(TArg1)),
  18436. Expression.Constant(t2, typeof(TArg2)),
  18437. Expression.Constant(t3, typeof(TArg3)),
  18438. Expression.Constant(t4, typeof(TArg4)),
  18439. Expression.Constant(t5, typeof(TArg5)),
  18440. Expression.Constant(t6, typeof(TArg6)),
  18441. Expression.Constant(t7, typeof(TArg7)),
  18442. Expression.Constant(t8, typeof(TArg8)),
  18443. Expression.Constant(t9, typeof(TArg9)),
  18444. Expression.Constant(t10, typeof(TArg10)),
  18445. Expression.Constant(t11, typeof(TArg11))
  18446. )
  18447. );
  18448. }
  18449. /// <summary>
  18450. /// 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.
  18451. /// </summary>
  18452. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18453. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18454. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18455. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18456. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18457. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18458. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18459. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18460. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18461. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18462. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18463. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18464. /// <param name="action">Action to convert to an asynchronous action.</param>
  18465. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18466. /// <returns>Asynchronous action.</returns>
  18467. /// <exception cref="ArgumentNullException">
  18468. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18469. 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)
  18470. {
  18471. if (provider == null)
  18472. throw new ArgumentNullException(nameof(provider));
  18473. if (action == null)
  18474. throw new ArgumentNullException(nameof(action));
  18475. if (scheduler == null)
  18476. throw new ArgumentNullException(nameof(scheduler));
  18477. #if CRIPPLED_REFLECTION
  18478. 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)));
  18479. #else
  18480. 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));
  18481. #endif
  18482. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18483. Expression.Invoke(
  18484. Expression.Call(
  18485. null,
  18486. m,
  18487. Expression.Constant(provider, typeof(IQbservableProvider)),
  18488. action,
  18489. Expression.Constant(scheduler, typeof(IScheduler))
  18490. ),
  18491. Expression.Constant(t1, typeof(TArg1)),
  18492. Expression.Constant(t2, typeof(TArg2)),
  18493. Expression.Constant(t3, typeof(TArg3)),
  18494. Expression.Constant(t4, typeof(TArg4)),
  18495. Expression.Constant(t5, typeof(TArg5)),
  18496. Expression.Constant(t6, typeof(TArg6)),
  18497. Expression.Constant(t7, typeof(TArg7)),
  18498. Expression.Constant(t8, typeof(TArg8)),
  18499. Expression.Constant(t9, typeof(TArg9)),
  18500. Expression.Constant(t10, typeof(TArg10)),
  18501. Expression.Constant(t11, typeof(TArg11))
  18502. )
  18503. );
  18504. }
  18505. /// <summary>
  18506. /// 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.
  18507. /// </summary>
  18508. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18509. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18510. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18511. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18512. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18513. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18514. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18515. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18516. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18517. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18518. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18519. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18520. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18521. /// <param name="action">Action to convert to an asynchronous action.</param>
  18522. /// <returns>Asynchronous action.</returns>
  18523. /// <exception cref="ArgumentNullException">
  18524. /// <paramref name="action" /> is null.</exception>
  18525. 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)
  18526. {
  18527. if (provider == null)
  18528. throw new ArgumentNullException(nameof(provider));
  18529. if (action == null)
  18530. throw new ArgumentNullException(nameof(action));
  18531. #if CRIPPLED_REFLECTION
  18532. 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>>)));
  18533. #else
  18534. 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));
  18535. #endif
  18536. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18537. Expression.Invoke(
  18538. Expression.Call(
  18539. null,
  18540. m,
  18541. Expression.Constant(provider, typeof(IQbservableProvider)),
  18542. action
  18543. ),
  18544. Expression.Constant(t1, typeof(TArg1)),
  18545. Expression.Constant(t2, typeof(TArg2)),
  18546. Expression.Constant(t3, typeof(TArg3)),
  18547. Expression.Constant(t4, typeof(TArg4)),
  18548. Expression.Constant(t5, typeof(TArg5)),
  18549. Expression.Constant(t6, typeof(TArg6)),
  18550. Expression.Constant(t7, typeof(TArg7)),
  18551. Expression.Constant(t8, typeof(TArg8)),
  18552. Expression.Constant(t9, typeof(TArg9)),
  18553. Expression.Constant(t10, typeof(TArg10)),
  18554. Expression.Constant(t11, typeof(TArg11)),
  18555. Expression.Constant(t12, typeof(TArg12))
  18556. )
  18557. );
  18558. }
  18559. /// <summary>
  18560. /// 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.
  18561. /// </summary>
  18562. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18563. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18564. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18565. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18566. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18567. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18568. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18569. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18570. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18571. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18572. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18573. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18574. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18575. /// <param name="action">Action to convert to an asynchronous action.</param>
  18576. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18577. /// <returns>Asynchronous action.</returns>
  18578. /// <exception cref="ArgumentNullException">
  18579. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18580. 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)
  18581. {
  18582. if (provider == null)
  18583. throw new ArgumentNullException(nameof(provider));
  18584. if (action == null)
  18585. throw new ArgumentNullException(nameof(action));
  18586. if (scheduler == null)
  18587. throw new ArgumentNullException(nameof(scheduler));
  18588. #if CRIPPLED_REFLECTION
  18589. 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)));
  18590. #else
  18591. 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));
  18592. #endif
  18593. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18594. Expression.Invoke(
  18595. Expression.Call(
  18596. null,
  18597. m,
  18598. Expression.Constant(provider, typeof(IQbservableProvider)),
  18599. action,
  18600. Expression.Constant(scheduler, typeof(IScheduler))
  18601. ),
  18602. Expression.Constant(t1, typeof(TArg1)),
  18603. Expression.Constant(t2, typeof(TArg2)),
  18604. Expression.Constant(t3, typeof(TArg3)),
  18605. Expression.Constant(t4, typeof(TArg4)),
  18606. Expression.Constant(t5, typeof(TArg5)),
  18607. Expression.Constant(t6, typeof(TArg6)),
  18608. Expression.Constant(t7, typeof(TArg7)),
  18609. Expression.Constant(t8, typeof(TArg8)),
  18610. Expression.Constant(t9, typeof(TArg9)),
  18611. Expression.Constant(t10, typeof(TArg10)),
  18612. Expression.Constant(t11, typeof(TArg11)),
  18613. Expression.Constant(t12, typeof(TArg12))
  18614. )
  18615. );
  18616. }
  18617. /// <summary>
  18618. /// 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.
  18619. /// </summary>
  18620. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18621. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18622. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18623. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18624. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18625. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18626. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18627. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18628. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18629. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18630. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18631. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18632. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18633. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18634. /// <param name="action">Action to convert to an asynchronous action.</param>
  18635. /// <returns>Asynchronous action.</returns>
  18636. /// <exception cref="ArgumentNullException">
  18637. /// <paramref name="action" /> is null.</exception>
  18638. 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)
  18639. {
  18640. if (provider == null)
  18641. throw new ArgumentNullException(nameof(provider));
  18642. if (action == null)
  18643. throw new ArgumentNullException(nameof(action));
  18644. #if CRIPPLED_REFLECTION
  18645. 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>>)));
  18646. #else
  18647. 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));
  18648. #endif
  18649. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18650. Expression.Invoke(
  18651. Expression.Call(
  18652. null,
  18653. m,
  18654. Expression.Constant(provider, typeof(IQbservableProvider)),
  18655. action
  18656. ),
  18657. Expression.Constant(t1, typeof(TArg1)),
  18658. Expression.Constant(t2, typeof(TArg2)),
  18659. Expression.Constant(t3, typeof(TArg3)),
  18660. Expression.Constant(t4, typeof(TArg4)),
  18661. Expression.Constant(t5, typeof(TArg5)),
  18662. Expression.Constant(t6, typeof(TArg6)),
  18663. Expression.Constant(t7, typeof(TArg7)),
  18664. Expression.Constant(t8, typeof(TArg8)),
  18665. Expression.Constant(t9, typeof(TArg9)),
  18666. Expression.Constant(t10, typeof(TArg10)),
  18667. Expression.Constant(t11, typeof(TArg11)),
  18668. Expression.Constant(t12, typeof(TArg12)),
  18669. Expression.Constant(t13, typeof(TArg13))
  18670. )
  18671. );
  18672. }
  18673. /// <summary>
  18674. /// 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.
  18675. /// </summary>
  18676. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18677. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18678. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18679. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18680. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18681. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18682. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18683. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18684. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18685. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18686. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18687. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18688. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18689. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18690. /// <param name="action">Action to convert to an asynchronous action.</param>
  18691. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18692. /// <returns>Asynchronous action.</returns>
  18693. /// <exception cref="ArgumentNullException">
  18694. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18695. 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)
  18696. {
  18697. if (provider == null)
  18698. throw new ArgumentNullException(nameof(provider));
  18699. if (action == null)
  18700. throw new ArgumentNullException(nameof(action));
  18701. if (scheduler == null)
  18702. throw new ArgumentNullException(nameof(scheduler));
  18703. #if CRIPPLED_REFLECTION
  18704. 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)));
  18705. #else
  18706. 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));
  18707. #endif
  18708. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18709. Expression.Invoke(
  18710. Expression.Call(
  18711. null,
  18712. m,
  18713. Expression.Constant(provider, typeof(IQbservableProvider)),
  18714. action,
  18715. Expression.Constant(scheduler, typeof(IScheduler))
  18716. ),
  18717. Expression.Constant(t1, typeof(TArg1)),
  18718. Expression.Constant(t2, typeof(TArg2)),
  18719. Expression.Constant(t3, typeof(TArg3)),
  18720. Expression.Constant(t4, typeof(TArg4)),
  18721. Expression.Constant(t5, typeof(TArg5)),
  18722. Expression.Constant(t6, typeof(TArg6)),
  18723. Expression.Constant(t7, typeof(TArg7)),
  18724. Expression.Constant(t8, typeof(TArg8)),
  18725. Expression.Constant(t9, typeof(TArg9)),
  18726. Expression.Constant(t10, typeof(TArg10)),
  18727. Expression.Constant(t11, typeof(TArg11)),
  18728. Expression.Constant(t12, typeof(TArg12)),
  18729. Expression.Constant(t13, typeof(TArg13))
  18730. )
  18731. );
  18732. }
  18733. /// <summary>
  18734. /// 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.
  18735. /// </summary>
  18736. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18737. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18738. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18739. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18740. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18741. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18742. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18743. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18744. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18745. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18746. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18747. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18748. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18749. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18750. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18751. /// <param name="action">Action to convert to an asynchronous action.</param>
  18752. /// <returns>Asynchronous action.</returns>
  18753. /// <exception cref="ArgumentNullException">
  18754. /// <paramref name="action" /> is null.</exception>
  18755. 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)
  18756. {
  18757. if (provider == null)
  18758. throw new ArgumentNullException(nameof(provider));
  18759. if (action == null)
  18760. throw new ArgumentNullException(nameof(action));
  18761. #if CRIPPLED_REFLECTION
  18762. 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>>)));
  18763. #else
  18764. 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));
  18765. #endif
  18766. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18767. Expression.Invoke(
  18768. Expression.Call(
  18769. null,
  18770. m,
  18771. Expression.Constant(provider, typeof(IQbservableProvider)),
  18772. action
  18773. ),
  18774. Expression.Constant(t1, typeof(TArg1)),
  18775. Expression.Constant(t2, typeof(TArg2)),
  18776. Expression.Constant(t3, typeof(TArg3)),
  18777. Expression.Constant(t4, typeof(TArg4)),
  18778. Expression.Constant(t5, typeof(TArg5)),
  18779. Expression.Constant(t6, typeof(TArg6)),
  18780. Expression.Constant(t7, typeof(TArg7)),
  18781. Expression.Constant(t8, typeof(TArg8)),
  18782. Expression.Constant(t9, typeof(TArg9)),
  18783. Expression.Constant(t10, typeof(TArg10)),
  18784. Expression.Constant(t11, typeof(TArg11)),
  18785. Expression.Constant(t12, typeof(TArg12)),
  18786. Expression.Constant(t13, typeof(TArg13)),
  18787. Expression.Constant(t14, typeof(TArg14))
  18788. )
  18789. );
  18790. }
  18791. /// <summary>
  18792. /// 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.
  18793. /// </summary>
  18794. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18795. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18796. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18797. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18798. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18799. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18800. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18801. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18802. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18803. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18804. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18805. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18806. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18807. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18808. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18809. /// <param name="action">Action to convert to an asynchronous action.</param>
  18810. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18811. /// <returns>Asynchronous action.</returns>
  18812. /// <exception cref="ArgumentNullException">
  18813. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18814. 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)
  18815. {
  18816. if (provider == null)
  18817. throw new ArgumentNullException(nameof(provider));
  18818. if (action == null)
  18819. throw new ArgumentNullException(nameof(action));
  18820. if (scheduler == null)
  18821. throw new ArgumentNullException(nameof(scheduler));
  18822. #if CRIPPLED_REFLECTION
  18823. 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)));
  18824. #else
  18825. 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));
  18826. #endif
  18827. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18828. Expression.Invoke(
  18829. Expression.Call(
  18830. null,
  18831. m,
  18832. Expression.Constant(provider, typeof(IQbservableProvider)),
  18833. action,
  18834. Expression.Constant(scheduler, typeof(IScheduler))
  18835. ),
  18836. Expression.Constant(t1, typeof(TArg1)),
  18837. Expression.Constant(t2, typeof(TArg2)),
  18838. Expression.Constant(t3, typeof(TArg3)),
  18839. Expression.Constant(t4, typeof(TArg4)),
  18840. Expression.Constant(t5, typeof(TArg5)),
  18841. Expression.Constant(t6, typeof(TArg6)),
  18842. Expression.Constant(t7, typeof(TArg7)),
  18843. Expression.Constant(t8, typeof(TArg8)),
  18844. Expression.Constant(t9, typeof(TArg9)),
  18845. Expression.Constant(t10, typeof(TArg10)),
  18846. Expression.Constant(t11, typeof(TArg11)),
  18847. Expression.Constant(t12, typeof(TArg12)),
  18848. Expression.Constant(t13, typeof(TArg13)),
  18849. Expression.Constant(t14, typeof(TArg14))
  18850. )
  18851. );
  18852. }
  18853. /// <summary>
  18854. /// 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.
  18855. /// </summary>
  18856. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18857. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18858. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18859. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18860. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18861. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18862. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18863. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18864. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18865. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18866. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18867. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18868. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18869. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18870. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18871. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18872. /// <param name="action">Action to convert to an asynchronous action.</param>
  18873. /// <returns>Asynchronous action.</returns>
  18874. /// <exception cref="ArgumentNullException">
  18875. /// <paramref name="action" /> is null.</exception>
  18876. 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)
  18877. {
  18878. if (provider == null)
  18879. throw new ArgumentNullException(nameof(provider));
  18880. if (action == null)
  18881. throw new ArgumentNullException(nameof(action));
  18882. #if CRIPPLED_REFLECTION
  18883. 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>>)));
  18884. #else
  18885. 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));
  18886. #endif
  18887. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  18888. Expression.Invoke(
  18889. Expression.Call(
  18890. null,
  18891. m,
  18892. Expression.Constant(provider, typeof(IQbservableProvider)),
  18893. action
  18894. ),
  18895. Expression.Constant(t1, typeof(TArg1)),
  18896. Expression.Constant(t2, typeof(TArg2)),
  18897. Expression.Constant(t3, typeof(TArg3)),
  18898. Expression.Constant(t4, typeof(TArg4)),
  18899. Expression.Constant(t5, typeof(TArg5)),
  18900. Expression.Constant(t6, typeof(TArg6)),
  18901. Expression.Constant(t7, typeof(TArg7)),
  18902. Expression.Constant(t8, typeof(TArg8)),
  18903. Expression.Constant(t9, typeof(TArg9)),
  18904. Expression.Constant(t10, typeof(TArg10)),
  18905. Expression.Constant(t11, typeof(TArg11)),
  18906. Expression.Constant(t12, typeof(TArg12)),
  18907. Expression.Constant(t13, typeof(TArg13)),
  18908. Expression.Constant(t14, typeof(TArg14)),
  18909. Expression.Constant(t15, typeof(TArg15))
  18910. )
  18911. );
  18912. }
  18913. /// <summary>
  18914. /// 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.
  18915. /// </summary>
  18916. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18917. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18918. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18919. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18920. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18921. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18922. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18923. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18924. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18925. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18926. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18927. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18928. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18929. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18930. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18931. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18932. /// <param name="action">Action to convert to an asynchronous action.</param>
  18933. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18934. /// <returns>Asynchronous action.</returns>
  18935. /// <exception cref="ArgumentNullException">
  18936. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18937. 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)
  18938. {
  18939. if (provider == null)
  18940. throw new ArgumentNullException(nameof(provider));
  18941. if (action == null)
  18942. throw new ArgumentNullException(nameof(action));
  18943. if (scheduler == null)
  18944. throw new ArgumentNullException(nameof(scheduler));
  18945. #if CRIPPLED_REFLECTION
  18946. 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)));
  18947. #else
  18948. 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));
  18949. #endif
  18950. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  18951. Expression.Invoke(
  18952. Expression.Call(
  18953. null,
  18954. m,
  18955. Expression.Constant(provider, typeof(IQbservableProvider)),
  18956. action,
  18957. Expression.Constant(scheduler, typeof(IScheduler))
  18958. ),
  18959. Expression.Constant(t1, typeof(TArg1)),
  18960. Expression.Constant(t2, typeof(TArg2)),
  18961. Expression.Constant(t3, typeof(TArg3)),
  18962. Expression.Constant(t4, typeof(TArg4)),
  18963. Expression.Constant(t5, typeof(TArg5)),
  18964. Expression.Constant(t6, typeof(TArg6)),
  18965. Expression.Constant(t7, typeof(TArg7)),
  18966. Expression.Constant(t8, typeof(TArg8)),
  18967. Expression.Constant(t9, typeof(TArg9)),
  18968. Expression.Constant(t10, typeof(TArg10)),
  18969. Expression.Constant(t11, typeof(TArg11)),
  18970. Expression.Constant(t12, typeof(TArg12)),
  18971. Expression.Constant(t13, typeof(TArg13)),
  18972. Expression.Constant(t14, typeof(TArg14)),
  18973. Expression.Constant(t15, typeof(TArg15))
  18974. )
  18975. );
  18976. }
  18977. /// <summary>
  18978. /// 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.
  18979. /// </summary>
  18980. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18981. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18982. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18983. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18984. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18985. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18986. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18987. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18988. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18989. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18990. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18991. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18992. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18993. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18994. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18995. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18996. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  18997. /// <param name="action">Action to convert to an asynchronous action.</param>
  18998. /// <returns>Asynchronous action.</returns>
  18999. /// <exception cref="ArgumentNullException">
  19000. /// <paramref name="action" /> is null.</exception>
  19001. 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)
  19002. {
  19003. if (provider == null)
  19004. throw new ArgumentNullException(nameof(provider));
  19005. if (action == null)
  19006. throw new ArgumentNullException(nameof(action));
  19007. #if CRIPPLED_REFLECTION
  19008. 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>>)));
  19009. #else
  19010. 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));
  19011. #endif
  19012. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  19013. Expression.Invoke(
  19014. Expression.Call(
  19015. null,
  19016. m,
  19017. Expression.Constant(provider, typeof(IQbservableProvider)),
  19018. action
  19019. ),
  19020. Expression.Constant(t1, typeof(TArg1)),
  19021. Expression.Constant(t2, typeof(TArg2)),
  19022. Expression.Constant(t3, typeof(TArg3)),
  19023. Expression.Constant(t4, typeof(TArg4)),
  19024. Expression.Constant(t5, typeof(TArg5)),
  19025. Expression.Constant(t6, typeof(TArg6)),
  19026. Expression.Constant(t7, typeof(TArg7)),
  19027. Expression.Constant(t8, typeof(TArg8)),
  19028. Expression.Constant(t9, typeof(TArg9)),
  19029. Expression.Constant(t10, typeof(TArg10)),
  19030. Expression.Constant(t11, typeof(TArg11)),
  19031. Expression.Constant(t12, typeof(TArg12)),
  19032. Expression.Constant(t13, typeof(TArg13)),
  19033. Expression.Constant(t14, typeof(TArg14)),
  19034. Expression.Constant(t15, typeof(TArg15)),
  19035. Expression.Constant(t16, typeof(TArg16))
  19036. )
  19037. );
  19038. }
  19039. /// <summary>
  19040. /// 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.
  19041. /// </summary>
  19042. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19043. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19044. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19045. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19046. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19047. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19048. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19049. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19050. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19051. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19052. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19053. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19054. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19055. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19056. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19057. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19058. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  19059. /// <param name="action">Action to convert to an asynchronous action.</param>
  19060. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  19061. /// <returns>Asynchronous action.</returns>
  19062. /// <exception cref="ArgumentNullException">
  19063. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  19064. 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)
  19065. {
  19066. if (provider == null)
  19067. throw new ArgumentNullException(nameof(provider));
  19068. if (action == null)
  19069. throw new ArgumentNullException(nameof(action));
  19070. if (scheduler == null)
  19071. throw new ArgumentNullException(nameof(scheduler));
  19072. #if CRIPPLED_REFLECTION
  19073. 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)));
  19074. #else
  19075. 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));
  19076. #endif
  19077. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  19078. Expression.Invoke(
  19079. Expression.Call(
  19080. null,
  19081. m,
  19082. Expression.Constant(provider, typeof(IQbservableProvider)),
  19083. action,
  19084. Expression.Constant(scheduler, typeof(IScheduler))
  19085. ),
  19086. Expression.Constant(t1, typeof(TArg1)),
  19087. Expression.Constant(t2, typeof(TArg2)),
  19088. Expression.Constant(t3, typeof(TArg3)),
  19089. Expression.Constant(t4, typeof(TArg4)),
  19090. Expression.Constant(t5, typeof(TArg5)),
  19091. Expression.Constant(t6, typeof(TArg6)),
  19092. Expression.Constant(t7, typeof(TArg7)),
  19093. Expression.Constant(t8, typeof(TArg8)),
  19094. Expression.Constant(t9, typeof(TArg9)),
  19095. Expression.Constant(t10, typeof(TArg10)),
  19096. Expression.Constant(t11, typeof(TArg11)),
  19097. Expression.Constant(t12, typeof(TArg12)),
  19098. Expression.Constant(t13, typeof(TArg13)),
  19099. Expression.Constant(t14, typeof(TArg14)),
  19100. Expression.Constant(t15, typeof(TArg15)),
  19101. Expression.Constant(t16, typeof(TArg16))
  19102. )
  19103. );
  19104. }
  19105. /// <summary>
  19106. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19107. /// </summary>
  19108. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19109. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19110. /// <param name="function">Function to convert to an asynchronous function.</param>
  19111. /// <returns>Asynchronous function.</returns>
  19112. /// <exception cref="ArgumentNullException">
  19113. /// <paramref name="function" /> is null.</exception>
  19114. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  19115. {
  19116. if (provider == null)
  19117. throw new ArgumentNullException(nameof(provider));
  19118. if (function == null)
  19119. throw new ArgumentNullException(nameof(function));
  19120. #if CRIPPLED_REFLECTION
  19121. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>)));
  19122. #else
  19123. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  19124. #endif
  19125. return () => provider.CreateQuery<TResult>(
  19126. Expression.Invoke(
  19127. Expression.Call(
  19128. null,
  19129. m,
  19130. Expression.Constant(provider, typeof(IQbservableProvider)),
  19131. function
  19132. )
  19133. )
  19134. );
  19135. }
  19136. /// <summary>
  19137. /// 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.
  19138. /// </summary>
  19139. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19140. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19141. /// <param name="function">Function to convert to an asynchronous function.</param>
  19142. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19143. /// <returns>Asynchronous function.</returns>
  19144. /// <exception cref="ArgumentNullException">
  19145. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19146. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  19147. {
  19148. if (provider == null)
  19149. throw new ArgumentNullException(nameof(provider));
  19150. if (function == null)
  19151. throw new ArgumentNullException(nameof(function));
  19152. if (scheduler == null)
  19153. throw new ArgumentNullException(nameof(scheduler));
  19154. #if CRIPPLED_REFLECTION
  19155. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler)));
  19156. #else
  19157. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  19158. #endif
  19159. return () => provider.CreateQuery<TResult>(
  19160. Expression.Invoke(
  19161. Expression.Call(
  19162. null,
  19163. m,
  19164. Expression.Constant(provider, typeof(IQbservableProvider)),
  19165. function,
  19166. Expression.Constant(scheduler, typeof(IScheduler))
  19167. )
  19168. )
  19169. );
  19170. }
  19171. /// <summary>
  19172. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19173. /// </summary>
  19174. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19175. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19176. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19177. /// <param name="function">Function to convert to an asynchronous function.</param>
  19178. /// <returns>Asynchronous function.</returns>
  19179. /// <exception cref="ArgumentNullException">
  19180. /// <paramref name="function" /> is null.</exception>
  19181. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function)
  19182. {
  19183. if (provider == null)
  19184. throw new ArgumentNullException(nameof(provider));
  19185. if (function == null)
  19186. throw new ArgumentNullException(nameof(function));
  19187. #if CRIPPLED_REFLECTION
  19188. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>)));
  19189. #else
  19190. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19191. #endif
  19192. return (t1) => provider.CreateQuery<TResult>(
  19193. Expression.Invoke(
  19194. Expression.Call(
  19195. null,
  19196. m,
  19197. Expression.Constant(provider, typeof(IQbservableProvider)),
  19198. function
  19199. ),
  19200. Expression.Constant(t1, typeof(TArg1))
  19201. )
  19202. );
  19203. }
  19204. /// <summary>
  19205. /// 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.
  19206. /// </summary>
  19207. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19208. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19209. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19210. /// <param name="function">Function to convert to an asynchronous function.</param>
  19211. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19212. /// <returns>Asynchronous function.</returns>
  19213. /// <exception cref="ArgumentNullException">
  19214. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19215. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function, IScheduler scheduler)
  19216. {
  19217. if (provider == null)
  19218. throw new ArgumentNullException(nameof(provider));
  19219. if (function == null)
  19220. throw new ArgumentNullException(nameof(function));
  19221. if (scheduler == null)
  19222. throw new ArgumentNullException(nameof(scheduler));
  19223. #if CRIPPLED_REFLECTION
  19224. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>), default(IScheduler)));
  19225. #else
  19226. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19227. #endif
  19228. return (t1) => provider.CreateQuery<TResult>(
  19229. Expression.Invoke(
  19230. Expression.Call(
  19231. null,
  19232. m,
  19233. Expression.Constant(provider, typeof(IQbservableProvider)),
  19234. function,
  19235. Expression.Constant(scheduler, typeof(IScheduler))
  19236. ),
  19237. Expression.Constant(t1, typeof(TArg1))
  19238. )
  19239. );
  19240. }
  19241. /// <summary>
  19242. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19243. /// </summary>
  19244. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19245. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19246. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19247. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19248. /// <param name="function">Function to convert to an asynchronous function.</param>
  19249. /// <returns>Asynchronous function.</returns>
  19250. /// <exception cref="ArgumentNullException">
  19251. /// <paramref name="function" /> is null.</exception>
  19252. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function)
  19253. {
  19254. if (provider == null)
  19255. throw new ArgumentNullException(nameof(provider));
  19256. if (function == null)
  19257. throw new ArgumentNullException(nameof(function));
  19258. #if CRIPPLED_REFLECTION
  19259. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>)));
  19260. #else
  19261. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19262. #endif
  19263. return (t1, t2) => provider.CreateQuery<TResult>(
  19264. Expression.Invoke(
  19265. Expression.Call(
  19266. null,
  19267. m,
  19268. Expression.Constant(provider, typeof(IQbservableProvider)),
  19269. function
  19270. ),
  19271. Expression.Constant(t1, typeof(TArg1)),
  19272. Expression.Constant(t2, typeof(TArg2))
  19273. )
  19274. );
  19275. }
  19276. /// <summary>
  19277. /// 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.
  19278. /// </summary>
  19279. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19280. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19281. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19282. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19283. /// <param name="function">Function to convert to an asynchronous function.</param>
  19284. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19285. /// <returns>Asynchronous function.</returns>
  19286. /// <exception cref="ArgumentNullException">
  19287. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19288. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function, IScheduler scheduler)
  19289. {
  19290. if (provider == null)
  19291. throw new ArgumentNullException(nameof(provider));
  19292. if (function == null)
  19293. throw new ArgumentNullException(nameof(function));
  19294. if (scheduler == null)
  19295. throw new ArgumentNullException(nameof(scheduler));
  19296. #if CRIPPLED_REFLECTION
  19297. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>), default(IScheduler)));
  19298. #else
  19299. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19300. #endif
  19301. return (t1, t2) => provider.CreateQuery<TResult>(
  19302. Expression.Invoke(
  19303. Expression.Call(
  19304. null,
  19305. m,
  19306. Expression.Constant(provider, typeof(IQbservableProvider)),
  19307. function,
  19308. Expression.Constant(scheduler, typeof(IScheduler))
  19309. ),
  19310. Expression.Constant(t1, typeof(TArg1)),
  19311. Expression.Constant(t2, typeof(TArg2))
  19312. )
  19313. );
  19314. }
  19315. /// <summary>
  19316. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19317. /// </summary>
  19318. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19319. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19320. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19321. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19322. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19323. /// <param name="function">Function to convert to an asynchronous function.</param>
  19324. /// <returns>Asynchronous function.</returns>
  19325. /// <exception cref="ArgumentNullException">
  19326. /// <paramref name="function" /> is null.</exception>
  19327. public static Func<TArg1, TArg2, TArg3, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TResult>> function)
  19328. {
  19329. if (provider == null)
  19330. throw new ArgumentNullException(nameof(provider));
  19331. if (function == null)
  19332. throw new ArgumentNullException(nameof(function));
  19333. #if CRIPPLED_REFLECTION
  19334. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>)));
  19335. #else
  19336. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19337. #endif
  19338. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19339. Expression.Invoke(
  19340. Expression.Call(
  19341. null,
  19342. m,
  19343. Expression.Constant(provider, typeof(IQbservableProvider)),
  19344. function
  19345. ),
  19346. Expression.Constant(t1, typeof(TArg1)),
  19347. Expression.Constant(t2, typeof(TArg2)),
  19348. Expression.Constant(t3, typeof(TArg3))
  19349. )
  19350. );
  19351. }
  19352. /// <summary>
  19353. /// 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.
  19354. /// </summary>
  19355. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19356. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19357. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19358. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19359. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19360. /// <param name="function">Function to convert to an asynchronous function.</param>
  19361. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19362. /// <returns>Asynchronous function.</returns>
  19363. /// <exception cref="ArgumentNullException">
  19364. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19365. 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)
  19366. {
  19367. if (provider == null)
  19368. throw new ArgumentNullException(nameof(provider));
  19369. if (function == null)
  19370. throw new ArgumentNullException(nameof(function));
  19371. if (scheduler == null)
  19372. throw new ArgumentNullException(nameof(scheduler));
  19373. #if CRIPPLED_REFLECTION
  19374. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>), default(IScheduler)));
  19375. #else
  19376. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19377. #endif
  19378. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19379. Expression.Invoke(
  19380. Expression.Call(
  19381. null,
  19382. m,
  19383. Expression.Constant(provider, typeof(IQbservableProvider)),
  19384. function,
  19385. Expression.Constant(scheduler, typeof(IScheduler))
  19386. ),
  19387. Expression.Constant(t1, typeof(TArg1)),
  19388. Expression.Constant(t2, typeof(TArg2)),
  19389. Expression.Constant(t3, typeof(TArg3))
  19390. )
  19391. );
  19392. }
  19393. /// <summary>
  19394. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19395. /// </summary>
  19396. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19397. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19398. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19399. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19400. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19401. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19402. /// <param name="function">Function to convert to an asynchronous function.</param>
  19403. /// <returns>Asynchronous function.</returns>
  19404. /// <exception cref="ArgumentNullException">
  19405. /// <paramref name="function" /> is null.</exception>
  19406. 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)
  19407. {
  19408. if (provider == null)
  19409. throw new ArgumentNullException(nameof(provider));
  19410. if (function == null)
  19411. throw new ArgumentNullException(nameof(function));
  19412. #if CRIPPLED_REFLECTION
  19413. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>)));
  19414. #else
  19415. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19416. #endif
  19417. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19418. Expression.Invoke(
  19419. Expression.Call(
  19420. null,
  19421. m,
  19422. Expression.Constant(provider, typeof(IQbservableProvider)),
  19423. function
  19424. ),
  19425. Expression.Constant(t1, typeof(TArg1)),
  19426. Expression.Constant(t2, typeof(TArg2)),
  19427. Expression.Constant(t3, typeof(TArg3)),
  19428. Expression.Constant(t4, typeof(TArg4))
  19429. )
  19430. );
  19431. }
  19432. /// <summary>
  19433. /// 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.
  19434. /// </summary>
  19435. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19436. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19437. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19438. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19439. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19440. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19441. /// <param name="function">Function to convert to an asynchronous function.</param>
  19442. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19443. /// <returns>Asynchronous function.</returns>
  19444. /// <exception cref="ArgumentNullException">
  19445. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19446. 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)
  19447. {
  19448. if (provider == null)
  19449. throw new ArgumentNullException(nameof(provider));
  19450. if (function == null)
  19451. throw new ArgumentNullException(nameof(function));
  19452. if (scheduler == null)
  19453. throw new ArgumentNullException(nameof(scheduler));
  19454. #if CRIPPLED_REFLECTION
  19455. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>), default(IScheduler)));
  19456. #else
  19457. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19458. #endif
  19459. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19460. Expression.Invoke(
  19461. Expression.Call(
  19462. null,
  19463. m,
  19464. Expression.Constant(provider, typeof(IQbservableProvider)),
  19465. function,
  19466. Expression.Constant(scheduler, typeof(IScheduler))
  19467. ),
  19468. Expression.Constant(t1, typeof(TArg1)),
  19469. Expression.Constant(t2, typeof(TArg2)),
  19470. Expression.Constant(t3, typeof(TArg3)),
  19471. Expression.Constant(t4, typeof(TArg4))
  19472. )
  19473. );
  19474. }
  19475. /// <summary>
  19476. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19477. /// </summary>
  19478. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19479. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19480. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19481. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19482. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19483. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19484. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19485. /// <param name="function">Function to convert to an asynchronous function.</param>
  19486. /// <returns>Asynchronous function.</returns>
  19487. /// <exception cref="ArgumentNullException">
  19488. /// <paramref name="function" /> is null.</exception>
  19489. 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)
  19490. {
  19491. if (provider == null)
  19492. throw new ArgumentNullException(nameof(provider));
  19493. if (function == null)
  19494. throw new ArgumentNullException(nameof(function));
  19495. #if CRIPPLED_REFLECTION
  19496. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>)));
  19497. #else
  19498. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19499. #endif
  19500. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19501. Expression.Invoke(
  19502. Expression.Call(
  19503. null,
  19504. m,
  19505. Expression.Constant(provider, typeof(IQbservableProvider)),
  19506. function
  19507. ),
  19508. Expression.Constant(t1, typeof(TArg1)),
  19509. Expression.Constant(t2, typeof(TArg2)),
  19510. Expression.Constant(t3, typeof(TArg3)),
  19511. Expression.Constant(t4, typeof(TArg4)),
  19512. Expression.Constant(t5, typeof(TArg5))
  19513. )
  19514. );
  19515. }
  19516. /// <summary>
  19517. /// 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.
  19518. /// </summary>
  19519. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19520. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19521. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19522. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19523. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19524. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19525. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19526. /// <param name="function">Function to convert to an asynchronous function.</param>
  19527. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19528. /// <returns>Asynchronous function.</returns>
  19529. /// <exception cref="ArgumentNullException">
  19530. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19531. 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)
  19532. {
  19533. if (provider == null)
  19534. throw new ArgumentNullException(nameof(provider));
  19535. if (function == null)
  19536. throw new ArgumentNullException(nameof(function));
  19537. if (scheduler == null)
  19538. throw new ArgumentNullException(nameof(scheduler));
  19539. #if CRIPPLED_REFLECTION
  19540. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>), default(IScheduler)));
  19541. #else
  19542. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19543. #endif
  19544. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19545. Expression.Invoke(
  19546. Expression.Call(
  19547. null,
  19548. m,
  19549. Expression.Constant(provider, typeof(IQbservableProvider)),
  19550. function,
  19551. Expression.Constant(scheduler, typeof(IScheduler))
  19552. ),
  19553. Expression.Constant(t1, typeof(TArg1)),
  19554. Expression.Constant(t2, typeof(TArg2)),
  19555. Expression.Constant(t3, typeof(TArg3)),
  19556. Expression.Constant(t4, typeof(TArg4)),
  19557. Expression.Constant(t5, typeof(TArg5))
  19558. )
  19559. );
  19560. }
  19561. /// <summary>
  19562. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19563. /// </summary>
  19564. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19565. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19566. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19567. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19568. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19569. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19570. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19571. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19572. /// <param name="function">Function to convert to an asynchronous function.</param>
  19573. /// <returns>Asynchronous function.</returns>
  19574. /// <exception cref="ArgumentNullException">
  19575. /// <paramref name="function" /> is null.</exception>
  19576. 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)
  19577. {
  19578. if (provider == null)
  19579. throw new ArgumentNullException(nameof(provider));
  19580. if (function == null)
  19581. throw new ArgumentNullException(nameof(function));
  19582. #if CRIPPLED_REFLECTION
  19583. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>>)));
  19584. #else
  19585. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19586. #endif
  19587. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19588. Expression.Invoke(
  19589. Expression.Call(
  19590. null,
  19591. m,
  19592. Expression.Constant(provider, typeof(IQbservableProvider)),
  19593. function
  19594. ),
  19595. Expression.Constant(t1, typeof(TArg1)),
  19596. Expression.Constant(t2, typeof(TArg2)),
  19597. Expression.Constant(t3, typeof(TArg3)),
  19598. Expression.Constant(t4, typeof(TArg4)),
  19599. Expression.Constant(t5, typeof(TArg5)),
  19600. Expression.Constant(t6, typeof(TArg6))
  19601. )
  19602. );
  19603. }
  19604. /// <summary>
  19605. /// 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.
  19606. /// </summary>
  19607. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19608. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19609. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19610. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19611. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19612. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19613. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19614. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19615. /// <param name="function">Function to convert to an asynchronous function.</param>
  19616. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19617. /// <returns>Asynchronous function.</returns>
  19618. /// <exception cref="ArgumentNullException">
  19619. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19620. 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)
  19621. {
  19622. if (provider == null)
  19623. throw new ArgumentNullException(nameof(provider));
  19624. if (function == null)
  19625. throw new ArgumentNullException(nameof(function));
  19626. if (scheduler == null)
  19627. throw new ArgumentNullException(nameof(scheduler));
  19628. #if CRIPPLED_REFLECTION
  19629. 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)));
  19630. #else
  19631. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19632. #endif
  19633. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19634. Expression.Invoke(
  19635. Expression.Call(
  19636. null,
  19637. m,
  19638. Expression.Constant(provider, typeof(IQbservableProvider)),
  19639. function,
  19640. Expression.Constant(scheduler, typeof(IScheduler))
  19641. ),
  19642. Expression.Constant(t1, typeof(TArg1)),
  19643. Expression.Constant(t2, typeof(TArg2)),
  19644. Expression.Constant(t3, typeof(TArg3)),
  19645. Expression.Constant(t4, typeof(TArg4)),
  19646. Expression.Constant(t5, typeof(TArg5)),
  19647. Expression.Constant(t6, typeof(TArg6))
  19648. )
  19649. );
  19650. }
  19651. /// <summary>
  19652. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19653. /// </summary>
  19654. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19655. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19656. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19657. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19658. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19659. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19660. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19661. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19662. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19663. /// <param name="function">Function to convert to an asynchronous function.</param>
  19664. /// <returns>Asynchronous function.</returns>
  19665. /// <exception cref="ArgumentNullException">
  19666. /// <paramref name="function" /> is null.</exception>
  19667. 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)
  19668. {
  19669. if (provider == null)
  19670. throw new ArgumentNullException(nameof(provider));
  19671. if (function == null)
  19672. throw new ArgumentNullException(nameof(function));
  19673. #if CRIPPLED_REFLECTION
  19674. 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>>)));
  19675. #else
  19676. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19677. #endif
  19678. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19679. Expression.Invoke(
  19680. Expression.Call(
  19681. null,
  19682. m,
  19683. Expression.Constant(provider, typeof(IQbservableProvider)),
  19684. function
  19685. ),
  19686. Expression.Constant(t1, typeof(TArg1)),
  19687. Expression.Constant(t2, typeof(TArg2)),
  19688. Expression.Constant(t3, typeof(TArg3)),
  19689. Expression.Constant(t4, typeof(TArg4)),
  19690. Expression.Constant(t5, typeof(TArg5)),
  19691. Expression.Constant(t6, typeof(TArg6)),
  19692. Expression.Constant(t7, typeof(TArg7))
  19693. )
  19694. );
  19695. }
  19696. /// <summary>
  19697. /// 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.
  19698. /// </summary>
  19699. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19700. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19701. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19702. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19703. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19704. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19705. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19706. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19707. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19708. /// <param name="function">Function to convert to an asynchronous function.</param>
  19709. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19710. /// <returns>Asynchronous function.</returns>
  19711. /// <exception cref="ArgumentNullException">
  19712. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19713. 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)
  19714. {
  19715. if (provider == null)
  19716. throw new ArgumentNullException(nameof(provider));
  19717. if (function == null)
  19718. throw new ArgumentNullException(nameof(function));
  19719. if (scheduler == null)
  19720. throw new ArgumentNullException(nameof(scheduler));
  19721. #if CRIPPLED_REFLECTION
  19722. 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)));
  19723. #else
  19724. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19725. #endif
  19726. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19727. Expression.Invoke(
  19728. Expression.Call(
  19729. null,
  19730. m,
  19731. Expression.Constant(provider, typeof(IQbservableProvider)),
  19732. function,
  19733. Expression.Constant(scheduler, typeof(IScheduler))
  19734. ),
  19735. Expression.Constant(t1, typeof(TArg1)),
  19736. Expression.Constant(t2, typeof(TArg2)),
  19737. Expression.Constant(t3, typeof(TArg3)),
  19738. Expression.Constant(t4, typeof(TArg4)),
  19739. Expression.Constant(t5, typeof(TArg5)),
  19740. Expression.Constant(t6, typeof(TArg6)),
  19741. Expression.Constant(t7, typeof(TArg7))
  19742. )
  19743. );
  19744. }
  19745. /// <summary>
  19746. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19747. /// </summary>
  19748. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19749. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19750. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19751. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19752. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19753. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19754. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19755. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19756. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19757. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19758. /// <param name="function">Function to convert to an asynchronous function.</param>
  19759. /// <returns>Asynchronous function.</returns>
  19760. /// <exception cref="ArgumentNullException">
  19761. /// <paramref name="function" /> is null.</exception>
  19762. 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)
  19763. {
  19764. if (provider == null)
  19765. throw new ArgumentNullException(nameof(provider));
  19766. if (function == null)
  19767. throw new ArgumentNullException(nameof(function));
  19768. #if CRIPPLED_REFLECTION
  19769. 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>>)));
  19770. #else
  19771. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19772. #endif
  19773. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19774. Expression.Invoke(
  19775. Expression.Call(
  19776. null,
  19777. m,
  19778. Expression.Constant(provider, typeof(IQbservableProvider)),
  19779. function
  19780. ),
  19781. Expression.Constant(t1, typeof(TArg1)),
  19782. Expression.Constant(t2, typeof(TArg2)),
  19783. Expression.Constant(t3, typeof(TArg3)),
  19784. Expression.Constant(t4, typeof(TArg4)),
  19785. Expression.Constant(t5, typeof(TArg5)),
  19786. Expression.Constant(t6, typeof(TArg6)),
  19787. Expression.Constant(t7, typeof(TArg7)),
  19788. Expression.Constant(t8, typeof(TArg8))
  19789. )
  19790. );
  19791. }
  19792. /// <summary>
  19793. /// 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.
  19794. /// </summary>
  19795. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19796. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19797. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19798. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19799. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19800. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19801. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19802. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19803. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19804. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19805. /// <param name="function">Function to convert to an asynchronous function.</param>
  19806. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19807. /// <returns>Asynchronous function.</returns>
  19808. /// <exception cref="ArgumentNullException">
  19809. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19810. 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)
  19811. {
  19812. if (provider == null)
  19813. throw new ArgumentNullException(nameof(provider));
  19814. if (function == null)
  19815. throw new ArgumentNullException(nameof(function));
  19816. if (scheduler == null)
  19817. throw new ArgumentNullException(nameof(scheduler));
  19818. #if CRIPPLED_REFLECTION
  19819. 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)));
  19820. #else
  19821. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19822. #endif
  19823. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19824. Expression.Invoke(
  19825. Expression.Call(
  19826. null,
  19827. m,
  19828. Expression.Constant(provider, typeof(IQbservableProvider)),
  19829. function,
  19830. Expression.Constant(scheduler, typeof(IScheduler))
  19831. ),
  19832. Expression.Constant(t1, typeof(TArg1)),
  19833. Expression.Constant(t2, typeof(TArg2)),
  19834. Expression.Constant(t3, typeof(TArg3)),
  19835. Expression.Constant(t4, typeof(TArg4)),
  19836. Expression.Constant(t5, typeof(TArg5)),
  19837. Expression.Constant(t6, typeof(TArg6)),
  19838. Expression.Constant(t7, typeof(TArg7)),
  19839. Expression.Constant(t8, typeof(TArg8))
  19840. )
  19841. );
  19842. }
  19843. /// <summary>
  19844. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19845. /// </summary>
  19846. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19847. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19848. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19849. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19850. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19851. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19852. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19853. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19854. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19855. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19856. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19857. /// <param name="function">Function to convert to an asynchronous function.</param>
  19858. /// <returns>Asynchronous function.</returns>
  19859. /// <exception cref="ArgumentNullException">
  19860. /// <paramref name="function" /> is null.</exception>
  19861. 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)
  19862. {
  19863. if (provider == null)
  19864. throw new ArgumentNullException(nameof(provider));
  19865. if (function == null)
  19866. throw new ArgumentNullException(nameof(function));
  19867. #if CRIPPLED_REFLECTION
  19868. 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>>)));
  19869. #else
  19870. 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));
  19871. #endif
  19872. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  19873. Expression.Invoke(
  19874. Expression.Call(
  19875. null,
  19876. m,
  19877. Expression.Constant(provider, typeof(IQbservableProvider)),
  19878. function
  19879. ),
  19880. Expression.Constant(t1, typeof(TArg1)),
  19881. Expression.Constant(t2, typeof(TArg2)),
  19882. Expression.Constant(t3, typeof(TArg3)),
  19883. Expression.Constant(t4, typeof(TArg4)),
  19884. Expression.Constant(t5, typeof(TArg5)),
  19885. Expression.Constant(t6, typeof(TArg6)),
  19886. Expression.Constant(t7, typeof(TArg7)),
  19887. Expression.Constant(t8, typeof(TArg8)),
  19888. Expression.Constant(t9, typeof(TArg9))
  19889. )
  19890. );
  19891. }
  19892. /// <summary>
  19893. /// 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.
  19894. /// </summary>
  19895. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19896. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19897. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19898. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19899. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19900. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19901. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19902. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19903. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19904. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19905. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19906. /// <param name="function">Function to convert to an asynchronous function.</param>
  19907. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19908. /// <returns>Asynchronous function.</returns>
  19909. /// <exception cref="ArgumentNullException">
  19910. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19911. 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)
  19912. {
  19913. if (provider == null)
  19914. throw new ArgumentNullException(nameof(provider));
  19915. if (function == null)
  19916. throw new ArgumentNullException(nameof(function));
  19917. if (scheduler == null)
  19918. throw new ArgumentNullException(nameof(scheduler));
  19919. #if CRIPPLED_REFLECTION
  19920. 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)));
  19921. #else
  19922. 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));
  19923. #endif
  19924. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  19925. Expression.Invoke(
  19926. Expression.Call(
  19927. null,
  19928. m,
  19929. Expression.Constant(provider, typeof(IQbservableProvider)),
  19930. function,
  19931. Expression.Constant(scheduler, typeof(IScheduler))
  19932. ),
  19933. Expression.Constant(t1, typeof(TArg1)),
  19934. Expression.Constant(t2, typeof(TArg2)),
  19935. Expression.Constant(t3, typeof(TArg3)),
  19936. Expression.Constant(t4, typeof(TArg4)),
  19937. Expression.Constant(t5, typeof(TArg5)),
  19938. Expression.Constant(t6, typeof(TArg6)),
  19939. Expression.Constant(t7, typeof(TArg7)),
  19940. Expression.Constant(t8, typeof(TArg8)),
  19941. Expression.Constant(t9, typeof(TArg9))
  19942. )
  19943. );
  19944. }
  19945. /// <summary>
  19946. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19947. /// </summary>
  19948. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19949. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19950. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19951. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19952. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19953. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19954. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19955. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19956. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19957. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19958. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19959. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19960. /// <param name="function">Function to convert to an asynchronous function.</param>
  19961. /// <returns>Asynchronous function.</returns>
  19962. /// <exception cref="ArgumentNullException">
  19963. /// <paramref name="function" /> is null.</exception>
  19964. 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)
  19965. {
  19966. if (provider == null)
  19967. throw new ArgumentNullException(nameof(provider));
  19968. if (function == null)
  19969. throw new ArgumentNullException(nameof(function));
  19970. #if CRIPPLED_REFLECTION
  19971. 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>>)));
  19972. #else
  19973. 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));
  19974. #endif
  19975. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  19976. Expression.Invoke(
  19977. Expression.Call(
  19978. null,
  19979. m,
  19980. Expression.Constant(provider, typeof(IQbservableProvider)),
  19981. function
  19982. ),
  19983. Expression.Constant(t1, typeof(TArg1)),
  19984. Expression.Constant(t2, typeof(TArg2)),
  19985. Expression.Constant(t3, typeof(TArg3)),
  19986. Expression.Constant(t4, typeof(TArg4)),
  19987. Expression.Constant(t5, typeof(TArg5)),
  19988. Expression.Constant(t6, typeof(TArg6)),
  19989. Expression.Constant(t7, typeof(TArg7)),
  19990. Expression.Constant(t8, typeof(TArg8)),
  19991. Expression.Constant(t9, typeof(TArg9)),
  19992. Expression.Constant(t10, typeof(TArg10))
  19993. )
  19994. );
  19995. }
  19996. /// <summary>
  19997. /// 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.
  19998. /// </summary>
  19999. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20000. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20001. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20002. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20003. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20004. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20005. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20006. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20007. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20008. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20009. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20010. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20011. /// <param name="function">Function to convert to an asynchronous function.</param>
  20012. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20013. /// <returns>Asynchronous function.</returns>
  20014. /// <exception cref="ArgumentNullException">
  20015. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20016. 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)
  20017. {
  20018. if (provider == null)
  20019. throw new ArgumentNullException(nameof(provider));
  20020. if (function == null)
  20021. throw new ArgumentNullException(nameof(function));
  20022. if (scheduler == null)
  20023. throw new ArgumentNullException(nameof(scheduler));
  20024. #if CRIPPLED_REFLECTION
  20025. 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)));
  20026. #else
  20027. 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));
  20028. #endif
  20029. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  20030. Expression.Invoke(
  20031. Expression.Call(
  20032. null,
  20033. m,
  20034. Expression.Constant(provider, typeof(IQbservableProvider)),
  20035. function,
  20036. Expression.Constant(scheduler, typeof(IScheduler))
  20037. ),
  20038. Expression.Constant(t1, typeof(TArg1)),
  20039. Expression.Constant(t2, typeof(TArg2)),
  20040. Expression.Constant(t3, typeof(TArg3)),
  20041. Expression.Constant(t4, typeof(TArg4)),
  20042. Expression.Constant(t5, typeof(TArg5)),
  20043. Expression.Constant(t6, typeof(TArg6)),
  20044. Expression.Constant(t7, typeof(TArg7)),
  20045. Expression.Constant(t8, typeof(TArg8)),
  20046. Expression.Constant(t9, typeof(TArg9)),
  20047. Expression.Constant(t10, typeof(TArg10))
  20048. )
  20049. );
  20050. }
  20051. /// <summary>
  20052. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20053. /// </summary>
  20054. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20055. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20056. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20057. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20058. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20059. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20060. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20061. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20062. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20063. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20064. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20065. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20066. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20067. /// <param name="function">Function to convert to an asynchronous function.</param>
  20068. /// <returns>Asynchronous function.</returns>
  20069. /// <exception cref="ArgumentNullException">
  20070. /// <paramref name="function" /> is null.</exception>
  20071. 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)
  20072. {
  20073. if (provider == null)
  20074. throw new ArgumentNullException(nameof(provider));
  20075. if (function == null)
  20076. throw new ArgumentNullException(nameof(function));
  20077. #if CRIPPLED_REFLECTION
  20078. 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>>)));
  20079. #else
  20080. 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));
  20081. #endif
  20082. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  20083. Expression.Invoke(
  20084. Expression.Call(
  20085. null,
  20086. m,
  20087. Expression.Constant(provider, typeof(IQbservableProvider)),
  20088. function
  20089. ),
  20090. Expression.Constant(t1, typeof(TArg1)),
  20091. Expression.Constant(t2, typeof(TArg2)),
  20092. Expression.Constant(t3, typeof(TArg3)),
  20093. Expression.Constant(t4, typeof(TArg4)),
  20094. Expression.Constant(t5, typeof(TArg5)),
  20095. Expression.Constant(t6, typeof(TArg6)),
  20096. Expression.Constant(t7, typeof(TArg7)),
  20097. Expression.Constant(t8, typeof(TArg8)),
  20098. Expression.Constant(t9, typeof(TArg9)),
  20099. Expression.Constant(t10, typeof(TArg10)),
  20100. Expression.Constant(t11, typeof(TArg11))
  20101. )
  20102. );
  20103. }
  20104. /// <summary>
  20105. /// 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.
  20106. /// </summary>
  20107. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20108. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20109. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20110. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20111. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20112. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20113. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20114. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20115. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20116. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20117. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20118. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20119. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20120. /// <param name="function">Function to convert to an asynchronous function.</param>
  20121. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20122. /// <returns>Asynchronous function.</returns>
  20123. /// <exception cref="ArgumentNullException">
  20124. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20125. 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)
  20126. {
  20127. if (provider == null)
  20128. throw new ArgumentNullException(nameof(provider));
  20129. if (function == null)
  20130. throw new ArgumentNullException(nameof(function));
  20131. if (scheduler == null)
  20132. throw new ArgumentNullException(nameof(scheduler));
  20133. #if CRIPPLED_REFLECTION
  20134. 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)));
  20135. #else
  20136. 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));
  20137. #endif
  20138. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  20139. Expression.Invoke(
  20140. Expression.Call(
  20141. null,
  20142. m,
  20143. Expression.Constant(provider, typeof(IQbservableProvider)),
  20144. function,
  20145. Expression.Constant(scheduler, typeof(IScheduler))
  20146. ),
  20147. Expression.Constant(t1, typeof(TArg1)),
  20148. Expression.Constant(t2, typeof(TArg2)),
  20149. Expression.Constant(t3, typeof(TArg3)),
  20150. Expression.Constant(t4, typeof(TArg4)),
  20151. Expression.Constant(t5, typeof(TArg5)),
  20152. Expression.Constant(t6, typeof(TArg6)),
  20153. Expression.Constant(t7, typeof(TArg7)),
  20154. Expression.Constant(t8, typeof(TArg8)),
  20155. Expression.Constant(t9, typeof(TArg9)),
  20156. Expression.Constant(t10, typeof(TArg10)),
  20157. Expression.Constant(t11, typeof(TArg11))
  20158. )
  20159. );
  20160. }
  20161. /// <summary>
  20162. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20163. /// </summary>
  20164. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20165. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20166. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20167. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20168. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20169. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20170. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20171. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20172. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20173. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20174. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20175. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20176. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20177. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20178. /// <param name="function">Function to convert to an asynchronous function.</param>
  20179. /// <returns>Asynchronous function.</returns>
  20180. /// <exception cref="ArgumentNullException">
  20181. /// <paramref name="function" /> is null.</exception>
  20182. 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)
  20183. {
  20184. if (provider == null)
  20185. throw new ArgumentNullException(nameof(provider));
  20186. if (function == null)
  20187. throw new ArgumentNullException(nameof(function));
  20188. #if CRIPPLED_REFLECTION
  20189. 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>>)));
  20190. #else
  20191. 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));
  20192. #endif
  20193. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20194. Expression.Invoke(
  20195. Expression.Call(
  20196. null,
  20197. m,
  20198. Expression.Constant(provider, typeof(IQbservableProvider)),
  20199. function
  20200. ),
  20201. Expression.Constant(t1, typeof(TArg1)),
  20202. Expression.Constant(t2, typeof(TArg2)),
  20203. Expression.Constant(t3, typeof(TArg3)),
  20204. Expression.Constant(t4, typeof(TArg4)),
  20205. Expression.Constant(t5, typeof(TArg5)),
  20206. Expression.Constant(t6, typeof(TArg6)),
  20207. Expression.Constant(t7, typeof(TArg7)),
  20208. Expression.Constant(t8, typeof(TArg8)),
  20209. Expression.Constant(t9, typeof(TArg9)),
  20210. Expression.Constant(t10, typeof(TArg10)),
  20211. Expression.Constant(t11, typeof(TArg11)),
  20212. Expression.Constant(t12, typeof(TArg12))
  20213. )
  20214. );
  20215. }
  20216. /// <summary>
  20217. /// 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.
  20218. /// </summary>
  20219. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20220. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20221. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20222. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20223. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20224. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20225. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20226. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20227. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20228. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20229. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20230. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20231. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20232. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20233. /// <param name="function">Function to convert to an asynchronous function.</param>
  20234. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20235. /// <returns>Asynchronous function.</returns>
  20236. /// <exception cref="ArgumentNullException">
  20237. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20238. 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)
  20239. {
  20240. if (provider == null)
  20241. throw new ArgumentNullException(nameof(provider));
  20242. if (function == null)
  20243. throw new ArgumentNullException(nameof(function));
  20244. if (scheduler == null)
  20245. throw new ArgumentNullException(nameof(scheduler));
  20246. #if CRIPPLED_REFLECTION
  20247. 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)));
  20248. #else
  20249. 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));
  20250. #endif
  20251. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20252. Expression.Invoke(
  20253. Expression.Call(
  20254. null,
  20255. m,
  20256. Expression.Constant(provider, typeof(IQbservableProvider)),
  20257. function,
  20258. Expression.Constant(scheduler, typeof(IScheduler))
  20259. ),
  20260. Expression.Constant(t1, typeof(TArg1)),
  20261. Expression.Constant(t2, typeof(TArg2)),
  20262. Expression.Constant(t3, typeof(TArg3)),
  20263. Expression.Constant(t4, typeof(TArg4)),
  20264. Expression.Constant(t5, typeof(TArg5)),
  20265. Expression.Constant(t6, typeof(TArg6)),
  20266. Expression.Constant(t7, typeof(TArg7)),
  20267. Expression.Constant(t8, typeof(TArg8)),
  20268. Expression.Constant(t9, typeof(TArg9)),
  20269. Expression.Constant(t10, typeof(TArg10)),
  20270. Expression.Constant(t11, typeof(TArg11)),
  20271. Expression.Constant(t12, typeof(TArg12))
  20272. )
  20273. );
  20274. }
  20275. /// <summary>
  20276. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20277. /// </summary>
  20278. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20279. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20280. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20281. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20282. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20283. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20284. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20285. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20286. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20287. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20288. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20289. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20290. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20291. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20292. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20293. /// <param name="function">Function to convert to an asynchronous function.</param>
  20294. /// <returns>Asynchronous function.</returns>
  20295. /// <exception cref="ArgumentNullException">
  20296. /// <paramref name="function" /> is null.</exception>
  20297. 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)
  20298. {
  20299. if (provider == null)
  20300. throw new ArgumentNullException(nameof(provider));
  20301. if (function == null)
  20302. throw new ArgumentNullException(nameof(function));
  20303. #if CRIPPLED_REFLECTION
  20304. 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>>)));
  20305. #else
  20306. 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));
  20307. #endif
  20308. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20309. Expression.Invoke(
  20310. Expression.Call(
  20311. null,
  20312. m,
  20313. Expression.Constant(provider, typeof(IQbservableProvider)),
  20314. function
  20315. ),
  20316. Expression.Constant(t1, typeof(TArg1)),
  20317. Expression.Constant(t2, typeof(TArg2)),
  20318. Expression.Constant(t3, typeof(TArg3)),
  20319. Expression.Constant(t4, typeof(TArg4)),
  20320. Expression.Constant(t5, typeof(TArg5)),
  20321. Expression.Constant(t6, typeof(TArg6)),
  20322. Expression.Constant(t7, typeof(TArg7)),
  20323. Expression.Constant(t8, typeof(TArg8)),
  20324. Expression.Constant(t9, typeof(TArg9)),
  20325. Expression.Constant(t10, typeof(TArg10)),
  20326. Expression.Constant(t11, typeof(TArg11)),
  20327. Expression.Constant(t12, typeof(TArg12)),
  20328. Expression.Constant(t13, typeof(TArg13))
  20329. )
  20330. );
  20331. }
  20332. /// <summary>
  20333. /// 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.
  20334. /// </summary>
  20335. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20336. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20337. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20338. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20339. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20340. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20341. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20342. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20343. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20344. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20345. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20346. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20347. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20348. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20349. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20350. /// <param name="function">Function to convert to an asynchronous function.</param>
  20351. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20352. /// <returns>Asynchronous function.</returns>
  20353. /// <exception cref="ArgumentNullException">
  20354. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20355. 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)
  20356. {
  20357. if (provider == null)
  20358. throw new ArgumentNullException(nameof(provider));
  20359. if (function == null)
  20360. throw new ArgumentNullException(nameof(function));
  20361. if (scheduler == null)
  20362. throw new ArgumentNullException(nameof(scheduler));
  20363. #if CRIPPLED_REFLECTION
  20364. 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)));
  20365. #else
  20366. 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));
  20367. #endif
  20368. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20369. Expression.Invoke(
  20370. Expression.Call(
  20371. null,
  20372. m,
  20373. Expression.Constant(provider, typeof(IQbservableProvider)),
  20374. function,
  20375. Expression.Constant(scheduler, typeof(IScheduler))
  20376. ),
  20377. Expression.Constant(t1, typeof(TArg1)),
  20378. Expression.Constant(t2, typeof(TArg2)),
  20379. Expression.Constant(t3, typeof(TArg3)),
  20380. Expression.Constant(t4, typeof(TArg4)),
  20381. Expression.Constant(t5, typeof(TArg5)),
  20382. Expression.Constant(t6, typeof(TArg6)),
  20383. Expression.Constant(t7, typeof(TArg7)),
  20384. Expression.Constant(t8, typeof(TArg8)),
  20385. Expression.Constant(t9, typeof(TArg9)),
  20386. Expression.Constant(t10, typeof(TArg10)),
  20387. Expression.Constant(t11, typeof(TArg11)),
  20388. Expression.Constant(t12, typeof(TArg12)),
  20389. Expression.Constant(t13, typeof(TArg13))
  20390. )
  20391. );
  20392. }
  20393. /// <summary>
  20394. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20395. /// </summary>
  20396. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20397. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20398. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20399. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20400. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20401. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20402. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20403. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20404. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20405. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20406. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20407. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20408. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20409. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20410. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20411. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20412. /// <param name="function">Function to convert to an asynchronous function.</param>
  20413. /// <returns>Asynchronous function.</returns>
  20414. /// <exception cref="ArgumentNullException">
  20415. /// <paramref name="function" /> is null.</exception>
  20416. 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)
  20417. {
  20418. if (provider == null)
  20419. throw new ArgumentNullException(nameof(provider));
  20420. if (function == null)
  20421. throw new ArgumentNullException(nameof(function));
  20422. #if CRIPPLED_REFLECTION
  20423. 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>>)));
  20424. #else
  20425. 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));
  20426. #endif
  20427. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20428. Expression.Invoke(
  20429. Expression.Call(
  20430. null,
  20431. m,
  20432. Expression.Constant(provider, typeof(IQbservableProvider)),
  20433. function
  20434. ),
  20435. Expression.Constant(t1, typeof(TArg1)),
  20436. Expression.Constant(t2, typeof(TArg2)),
  20437. Expression.Constant(t3, typeof(TArg3)),
  20438. Expression.Constant(t4, typeof(TArg4)),
  20439. Expression.Constant(t5, typeof(TArg5)),
  20440. Expression.Constant(t6, typeof(TArg6)),
  20441. Expression.Constant(t7, typeof(TArg7)),
  20442. Expression.Constant(t8, typeof(TArg8)),
  20443. Expression.Constant(t9, typeof(TArg9)),
  20444. Expression.Constant(t10, typeof(TArg10)),
  20445. Expression.Constant(t11, typeof(TArg11)),
  20446. Expression.Constant(t12, typeof(TArg12)),
  20447. Expression.Constant(t13, typeof(TArg13)),
  20448. Expression.Constant(t14, typeof(TArg14))
  20449. )
  20450. );
  20451. }
  20452. /// <summary>
  20453. /// 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.
  20454. /// </summary>
  20455. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20456. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20457. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20458. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20459. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20460. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20461. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20462. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20463. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20464. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20465. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20466. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20467. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20468. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20469. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20470. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20471. /// <param name="function">Function to convert to an asynchronous function.</param>
  20472. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20473. /// <returns>Asynchronous function.</returns>
  20474. /// <exception cref="ArgumentNullException">
  20475. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20476. 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)
  20477. {
  20478. if (provider == null)
  20479. throw new ArgumentNullException(nameof(provider));
  20480. if (function == null)
  20481. throw new ArgumentNullException(nameof(function));
  20482. if (scheduler == null)
  20483. throw new ArgumentNullException(nameof(scheduler));
  20484. #if CRIPPLED_REFLECTION
  20485. 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)));
  20486. #else
  20487. 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));
  20488. #endif
  20489. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20490. Expression.Invoke(
  20491. Expression.Call(
  20492. null,
  20493. m,
  20494. Expression.Constant(provider, typeof(IQbservableProvider)),
  20495. function,
  20496. Expression.Constant(scheduler, typeof(IScheduler))
  20497. ),
  20498. Expression.Constant(t1, typeof(TArg1)),
  20499. Expression.Constant(t2, typeof(TArg2)),
  20500. Expression.Constant(t3, typeof(TArg3)),
  20501. Expression.Constant(t4, typeof(TArg4)),
  20502. Expression.Constant(t5, typeof(TArg5)),
  20503. Expression.Constant(t6, typeof(TArg6)),
  20504. Expression.Constant(t7, typeof(TArg7)),
  20505. Expression.Constant(t8, typeof(TArg8)),
  20506. Expression.Constant(t9, typeof(TArg9)),
  20507. Expression.Constant(t10, typeof(TArg10)),
  20508. Expression.Constant(t11, typeof(TArg11)),
  20509. Expression.Constant(t12, typeof(TArg12)),
  20510. Expression.Constant(t13, typeof(TArg13)),
  20511. Expression.Constant(t14, typeof(TArg14))
  20512. )
  20513. );
  20514. }
  20515. /// <summary>
  20516. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20517. /// </summary>
  20518. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20519. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20520. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20521. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20522. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20523. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20524. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20525. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20526. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20527. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20528. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20529. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20530. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20531. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20532. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20533. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20534. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20535. /// <param name="function">Function to convert to an asynchronous function.</param>
  20536. /// <returns>Asynchronous function.</returns>
  20537. /// <exception cref="ArgumentNullException">
  20538. /// <paramref name="function" /> is null.</exception>
  20539. 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)
  20540. {
  20541. if (provider == null)
  20542. throw new ArgumentNullException(nameof(provider));
  20543. if (function == null)
  20544. throw new ArgumentNullException(nameof(function));
  20545. #if CRIPPLED_REFLECTION
  20546. 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>>)));
  20547. #else
  20548. 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));
  20549. #endif
  20550. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20551. Expression.Invoke(
  20552. Expression.Call(
  20553. null,
  20554. m,
  20555. Expression.Constant(provider, typeof(IQbservableProvider)),
  20556. function
  20557. ),
  20558. Expression.Constant(t1, typeof(TArg1)),
  20559. Expression.Constant(t2, typeof(TArg2)),
  20560. Expression.Constant(t3, typeof(TArg3)),
  20561. Expression.Constant(t4, typeof(TArg4)),
  20562. Expression.Constant(t5, typeof(TArg5)),
  20563. Expression.Constant(t6, typeof(TArg6)),
  20564. Expression.Constant(t7, typeof(TArg7)),
  20565. Expression.Constant(t8, typeof(TArg8)),
  20566. Expression.Constant(t9, typeof(TArg9)),
  20567. Expression.Constant(t10, typeof(TArg10)),
  20568. Expression.Constant(t11, typeof(TArg11)),
  20569. Expression.Constant(t12, typeof(TArg12)),
  20570. Expression.Constant(t13, typeof(TArg13)),
  20571. Expression.Constant(t14, typeof(TArg14)),
  20572. Expression.Constant(t15, typeof(TArg15))
  20573. )
  20574. );
  20575. }
  20576. /// <summary>
  20577. /// 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.
  20578. /// </summary>
  20579. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20580. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20581. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20582. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20583. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20584. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20585. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20586. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20587. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20588. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20589. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20590. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20591. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20592. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20593. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20594. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20595. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20596. /// <param name="function">Function to convert to an asynchronous function.</param>
  20597. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20598. /// <returns>Asynchronous function.</returns>
  20599. /// <exception cref="ArgumentNullException">
  20600. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20601. 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)
  20602. {
  20603. if (provider == null)
  20604. throw new ArgumentNullException(nameof(provider));
  20605. if (function == null)
  20606. throw new ArgumentNullException(nameof(function));
  20607. if (scheduler == null)
  20608. throw new ArgumentNullException(nameof(scheduler));
  20609. #if CRIPPLED_REFLECTION
  20610. 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)));
  20611. #else
  20612. 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));
  20613. #endif
  20614. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20615. Expression.Invoke(
  20616. Expression.Call(
  20617. null,
  20618. m,
  20619. Expression.Constant(provider, typeof(IQbservableProvider)),
  20620. function,
  20621. Expression.Constant(scheduler, typeof(IScheduler))
  20622. ),
  20623. Expression.Constant(t1, typeof(TArg1)),
  20624. Expression.Constant(t2, typeof(TArg2)),
  20625. Expression.Constant(t3, typeof(TArg3)),
  20626. Expression.Constant(t4, typeof(TArg4)),
  20627. Expression.Constant(t5, typeof(TArg5)),
  20628. Expression.Constant(t6, typeof(TArg6)),
  20629. Expression.Constant(t7, typeof(TArg7)),
  20630. Expression.Constant(t8, typeof(TArg8)),
  20631. Expression.Constant(t9, typeof(TArg9)),
  20632. Expression.Constant(t10, typeof(TArg10)),
  20633. Expression.Constant(t11, typeof(TArg11)),
  20634. Expression.Constant(t12, typeof(TArg12)),
  20635. Expression.Constant(t13, typeof(TArg13)),
  20636. Expression.Constant(t14, typeof(TArg14)),
  20637. Expression.Constant(t15, typeof(TArg15))
  20638. )
  20639. );
  20640. }
  20641. /// <summary>
  20642. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20643. /// </summary>
  20644. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20645. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20646. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20647. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20648. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20649. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20650. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20651. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20652. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20653. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20654. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20655. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20656. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20657. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20658. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20659. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20660. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20661. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20662. /// <param name="function">Function to convert to an asynchronous function.</param>
  20663. /// <returns>Asynchronous function.</returns>
  20664. /// <exception cref="ArgumentNullException">
  20665. /// <paramref name="function" /> is null.</exception>
  20666. 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)
  20667. {
  20668. if (provider == null)
  20669. throw new ArgumentNullException(nameof(provider));
  20670. if (function == null)
  20671. throw new ArgumentNullException(nameof(function));
  20672. #if CRIPPLED_REFLECTION
  20673. 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>>)));
  20674. #else
  20675. 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));
  20676. #endif
  20677. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20678. Expression.Invoke(
  20679. Expression.Call(
  20680. null,
  20681. m,
  20682. Expression.Constant(provider, typeof(IQbservableProvider)),
  20683. function
  20684. ),
  20685. Expression.Constant(t1, typeof(TArg1)),
  20686. Expression.Constant(t2, typeof(TArg2)),
  20687. Expression.Constant(t3, typeof(TArg3)),
  20688. Expression.Constant(t4, typeof(TArg4)),
  20689. Expression.Constant(t5, typeof(TArg5)),
  20690. Expression.Constant(t6, typeof(TArg6)),
  20691. Expression.Constant(t7, typeof(TArg7)),
  20692. Expression.Constant(t8, typeof(TArg8)),
  20693. Expression.Constant(t9, typeof(TArg9)),
  20694. Expression.Constant(t10, typeof(TArg10)),
  20695. Expression.Constant(t11, typeof(TArg11)),
  20696. Expression.Constant(t12, typeof(TArg12)),
  20697. Expression.Constant(t13, typeof(TArg13)),
  20698. Expression.Constant(t14, typeof(TArg14)),
  20699. Expression.Constant(t15, typeof(TArg15)),
  20700. Expression.Constant(t16, typeof(TArg16))
  20701. )
  20702. );
  20703. }
  20704. /// <summary>
  20705. /// 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.
  20706. /// </summary>
  20707. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20708. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20709. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20710. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20711. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20712. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20713. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20714. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20715. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20716. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20717. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20718. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20719. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20720. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20721. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20722. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20723. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20724. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20725. /// <param name="function">Function to convert to an asynchronous function.</param>
  20726. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20727. /// <returns>Asynchronous function.</returns>
  20728. /// <exception cref="ArgumentNullException">
  20729. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20730. 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)
  20731. {
  20732. if (provider == null)
  20733. throw new ArgumentNullException(nameof(provider));
  20734. if (function == null)
  20735. throw new ArgumentNullException(nameof(function));
  20736. if (scheduler == null)
  20737. throw new ArgumentNullException(nameof(scheduler));
  20738. #if CRIPPLED_REFLECTION
  20739. 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)));
  20740. #else
  20741. 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));
  20742. #endif
  20743. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20744. Expression.Invoke(
  20745. Expression.Call(
  20746. null,
  20747. m,
  20748. Expression.Constant(provider, typeof(IQbservableProvider)),
  20749. function,
  20750. Expression.Constant(scheduler, typeof(IScheduler))
  20751. ),
  20752. Expression.Constant(t1, typeof(TArg1)),
  20753. Expression.Constant(t2, typeof(TArg2)),
  20754. Expression.Constant(t3, typeof(TArg3)),
  20755. Expression.Constant(t4, typeof(TArg4)),
  20756. Expression.Constant(t5, typeof(TArg5)),
  20757. Expression.Constant(t6, typeof(TArg6)),
  20758. Expression.Constant(t7, typeof(TArg7)),
  20759. Expression.Constant(t8, typeof(TArg8)),
  20760. Expression.Constant(t9, typeof(TArg9)),
  20761. Expression.Constant(t10, typeof(TArg10)),
  20762. Expression.Constant(t11, typeof(TArg11)),
  20763. Expression.Constant(t12, typeof(TArg12)),
  20764. Expression.Constant(t13, typeof(TArg13)),
  20765. Expression.Constant(t14, typeof(TArg14)),
  20766. Expression.Constant(t15, typeof(TArg15)),
  20767. Expression.Constant(t16, typeof(TArg16))
  20768. )
  20769. );
  20770. }
  20771. /// <summary>
  20772. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20773. /// </summary>
  20774. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20775. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20776. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20777. /// <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>
  20778. /// <exception cref="ArgumentNullException">
  20779. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20780. /// <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>
  20781. #if PREFERASYNC
  20782. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20783. #endif
  20784. public static Func<IQbservable<Unit>> FromAsyncPattern(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  20785. {
  20786. if (provider == null)
  20787. throw new ArgumentNullException(nameof(provider));
  20788. if (begin == null)
  20789. throw new ArgumentNullException(nameof(begin));
  20790. if (end == null)
  20791. throw new ArgumentNullException(nameof(end));
  20792. #if CRIPPLED_REFLECTION
  20793. var m = InfoOf(() => Qbservable.FromAsyncPattern(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20794. #else
  20795. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  20796. #endif
  20797. return () => provider.CreateQuery<Unit>(
  20798. Expression.Invoke(
  20799. Expression.Call(
  20800. null,
  20801. m,
  20802. Expression.Constant(provider, typeof(IQbservableProvider)),
  20803. begin,
  20804. end
  20805. )
  20806. )
  20807. );
  20808. }
  20809. /// <summary>
  20810. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20811. /// </summary>
  20812. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20813. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20814. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20815. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20816. /// <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>
  20817. /// <exception cref="ArgumentNullException">
  20818. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20819. /// <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>
  20820. #if PREFERASYNC
  20821. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20822. #endif
  20823. public static Func<TArg1, IQbservable<Unit>> FromAsyncPattern<TArg1>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  20824. {
  20825. if (provider == null)
  20826. throw new ArgumentNullException(nameof(provider));
  20827. if (begin == null)
  20828. throw new ArgumentNullException(nameof(begin));
  20829. if (end == null)
  20830. throw new ArgumentNullException(nameof(end));
  20831. #if CRIPPLED_REFLECTION
  20832. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20833. #else
  20834. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  20835. #endif
  20836. return (t1) => provider.CreateQuery<Unit>(
  20837. Expression.Invoke(
  20838. Expression.Call(
  20839. null,
  20840. m,
  20841. Expression.Constant(provider, typeof(IQbservableProvider)),
  20842. begin,
  20843. end
  20844. ),
  20845. Expression.Constant(t1, typeof(TArg1))
  20846. )
  20847. );
  20848. }
  20849. /// <summary>
  20850. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20851. /// </summary>
  20852. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20853. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20854. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20855. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20856. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20857. /// <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>
  20858. /// <exception cref="ArgumentNullException">
  20859. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20860. /// <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>
  20861. #if PREFERASYNC
  20862. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20863. #endif
  20864. 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)
  20865. {
  20866. if (provider == null)
  20867. throw new ArgumentNullException(nameof(provider));
  20868. if (begin == null)
  20869. throw new ArgumentNullException(nameof(begin));
  20870. if (end == null)
  20871. throw new ArgumentNullException(nameof(end));
  20872. #if CRIPPLED_REFLECTION
  20873. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20874. #else
  20875. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  20876. #endif
  20877. return (t1, t2) => provider.CreateQuery<Unit>(
  20878. Expression.Invoke(
  20879. Expression.Call(
  20880. null,
  20881. m,
  20882. Expression.Constant(provider, typeof(IQbservableProvider)),
  20883. begin,
  20884. end
  20885. ),
  20886. Expression.Constant(t1, typeof(TArg1)),
  20887. Expression.Constant(t2, typeof(TArg2))
  20888. )
  20889. );
  20890. }
  20891. /// <summary>
  20892. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20893. /// </summary>
  20894. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20895. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20896. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20897. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20898. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20899. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20900. /// <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>
  20901. /// <exception cref="ArgumentNullException">
  20902. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20903. /// <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>
  20904. #if PREFERASYNC
  20905. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20906. #endif
  20907. 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)
  20908. {
  20909. if (provider == null)
  20910. throw new ArgumentNullException(nameof(provider));
  20911. if (begin == null)
  20912. throw new ArgumentNullException(nameof(begin));
  20913. if (end == null)
  20914. throw new ArgumentNullException(nameof(end));
  20915. #if CRIPPLED_REFLECTION
  20916. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20917. #else
  20918. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  20919. #endif
  20920. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  20921. Expression.Invoke(
  20922. Expression.Call(
  20923. null,
  20924. m,
  20925. Expression.Constant(provider, typeof(IQbservableProvider)),
  20926. begin,
  20927. end
  20928. ),
  20929. Expression.Constant(t1, typeof(TArg1)),
  20930. Expression.Constant(t2, typeof(TArg2)),
  20931. Expression.Constant(t3, typeof(TArg3))
  20932. )
  20933. );
  20934. }
  20935. /// <summary>
  20936. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20937. /// </summary>
  20938. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20939. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20940. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20941. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20942. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20943. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20944. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20945. /// <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>
  20946. /// <exception cref="ArgumentNullException">
  20947. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20948. /// <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>
  20949. #if PREFERASYNC
  20950. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20951. #endif
  20952. 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)
  20953. {
  20954. if (provider == null)
  20955. throw new ArgumentNullException(nameof(provider));
  20956. if (begin == null)
  20957. throw new ArgumentNullException(nameof(begin));
  20958. if (end == null)
  20959. throw new ArgumentNullException(nameof(end));
  20960. #if CRIPPLED_REFLECTION
  20961. 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>>)));
  20962. #else
  20963. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  20964. #endif
  20965. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  20966. Expression.Invoke(
  20967. Expression.Call(
  20968. null,
  20969. m,
  20970. Expression.Constant(provider, typeof(IQbservableProvider)),
  20971. begin,
  20972. end
  20973. ),
  20974. Expression.Constant(t1, typeof(TArg1)),
  20975. Expression.Constant(t2, typeof(TArg2)),
  20976. Expression.Constant(t3, typeof(TArg3)),
  20977. Expression.Constant(t4, typeof(TArg4))
  20978. )
  20979. );
  20980. }
  20981. /// <summary>
  20982. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20983. /// </summary>
  20984. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20985. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20986. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20987. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20988. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20989. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20990. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20991. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20992. /// <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>
  20993. /// <exception cref="ArgumentNullException">
  20994. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20995. /// <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>
  20996. #if PREFERASYNC
  20997. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20998. #endif
  20999. 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)
  21000. {
  21001. if (provider == null)
  21002. throw new ArgumentNullException(nameof(provider));
  21003. if (begin == null)
  21004. throw new ArgumentNullException(nameof(begin));
  21005. if (end == null)
  21006. throw new ArgumentNullException(nameof(end));
  21007. #if CRIPPLED_REFLECTION
  21008. 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>>)));
  21009. #else
  21010. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  21011. #endif
  21012. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  21013. Expression.Invoke(
  21014. Expression.Call(
  21015. null,
  21016. m,
  21017. Expression.Constant(provider, typeof(IQbservableProvider)),
  21018. begin,
  21019. end
  21020. ),
  21021. Expression.Constant(t1, typeof(TArg1)),
  21022. Expression.Constant(t2, typeof(TArg2)),
  21023. Expression.Constant(t3, typeof(TArg3)),
  21024. Expression.Constant(t4, typeof(TArg4)),
  21025. Expression.Constant(t5, typeof(TArg5))
  21026. )
  21027. );
  21028. }
  21029. /// <summary>
  21030. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21031. /// </summary>
  21032. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21033. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21034. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21035. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21036. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21037. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21038. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21039. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21040. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21041. /// <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>
  21042. /// <exception cref="ArgumentNullException">
  21043. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21044. /// <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>
  21045. #if PREFERASYNC
  21046. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21047. #endif
  21048. 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)
  21049. {
  21050. if (provider == null)
  21051. throw new ArgumentNullException(nameof(provider));
  21052. if (begin == null)
  21053. throw new ArgumentNullException(nameof(begin));
  21054. if (end == null)
  21055. throw new ArgumentNullException(nameof(end));
  21056. #if CRIPPLED_REFLECTION
  21057. 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>>)));
  21058. #else
  21059. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  21060. #endif
  21061. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  21062. Expression.Invoke(
  21063. Expression.Call(
  21064. null,
  21065. m,
  21066. Expression.Constant(provider, typeof(IQbservableProvider)),
  21067. begin,
  21068. end
  21069. ),
  21070. Expression.Constant(t1, typeof(TArg1)),
  21071. Expression.Constant(t2, typeof(TArg2)),
  21072. Expression.Constant(t3, typeof(TArg3)),
  21073. Expression.Constant(t4, typeof(TArg4)),
  21074. Expression.Constant(t5, typeof(TArg5)),
  21075. Expression.Constant(t6, typeof(TArg6))
  21076. )
  21077. );
  21078. }
  21079. /// <summary>
  21080. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21081. /// </summary>
  21082. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21083. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21084. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21085. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21086. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21087. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21088. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21089. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21090. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21091. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21092. /// <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>
  21093. /// <exception cref="ArgumentNullException">
  21094. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21095. /// <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>
  21096. #if PREFERASYNC
  21097. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21098. #endif
  21099. 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)
  21100. {
  21101. if (provider == null)
  21102. throw new ArgumentNullException(nameof(provider));
  21103. if (begin == null)
  21104. throw new ArgumentNullException(nameof(begin));
  21105. if (end == null)
  21106. throw new ArgumentNullException(nameof(end));
  21107. #if CRIPPLED_REFLECTION
  21108. 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>>)));
  21109. #else
  21110. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  21111. #endif
  21112. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  21113. Expression.Invoke(
  21114. Expression.Call(
  21115. null,
  21116. m,
  21117. Expression.Constant(provider, typeof(IQbservableProvider)),
  21118. begin,
  21119. end
  21120. ),
  21121. Expression.Constant(t1, typeof(TArg1)),
  21122. Expression.Constant(t2, typeof(TArg2)),
  21123. Expression.Constant(t3, typeof(TArg3)),
  21124. Expression.Constant(t4, typeof(TArg4)),
  21125. Expression.Constant(t5, typeof(TArg5)),
  21126. Expression.Constant(t6, typeof(TArg6)),
  21127. Expression.Constant(t7, typeof(TArg7))
  21128. )
  21129. );
  21130. }
  21131. /// <summary>
  21132. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21133. /// </summary>
  21134. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21135. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21136. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21137. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21138. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21139. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21140. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21141. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21142. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21143. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21144. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21145. /// <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>
  21146. /// <exception cref="ArgumentNullException">
  21147. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21148. /// <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>
  21149. #if PREFERASYNC
  21150. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21151. #endif
  21152. 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)
  21153. {
  21154. if (provider == null)
  21155. throw new ArgumentNullException(nameof(provider));
  21156. if (begin == null)
  21157. throw new ArgumentNullException(nameof(begin));
  21158. if (end == null)
  21159. throw new ArgumentNullException(nameof(end));
  21160. #if CRIPPLED_REFLECTION
  21161. 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>>)));
  21162. #else
  21163. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  21164. #endif
  21165. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  21166. Expression.Invoke(
  21167. Expression.Call(
  21168. null,
  21169. m,
  21170. Expression.Constant(provider, typeof(IQbservableProvider)),
  21171. begin,
  21172. end
  21173. ),
  21174. Expression.Constant(t1, typeof(TArg1)),
  21175. Expression.Constant(t2, typeof(TArg2)),
  21176. Expression.Constant(t3, typeof(TArg3)),
  21177. Expression.Constant(t4, typeof(TArg4)),
  21178. Expression.Constant(t5, typeof(TArg5)),
  21179. Expression.Constant(t6, typeof(TArg6)),
  21180. Expression.Constant(t7, typeof(TArg7)),
  21181. Expression.Constant(t8, typeof(TArg8))
  21182. )
  21183. );
  21184. }
  21185. /// <summary>
  21186. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21187. /// </summary>
  21188. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21189. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21190. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21191. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21192. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21193. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21194. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21195. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21196. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21197. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21198. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21199. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21200. /// <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>
  21201. /// <exception cref="ArgumentNullException">
  21202. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21203. /// <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>
  21204. #if PREFERASYNC
  21205. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21206. #endif
  21207. 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)
  21208. {
  21209. if (provider == null)
  21210. throw new ArgumentNullException(nameof(provider));
  21211. if (begin == null)
  21212. throw new ArgumentNullException(nameof(begin));
  21213. if (end == null)
  21214. throw new ArgumentNullException(nameof(end));
  21215. #if CRIPPLED_REFLECTION
  21216. 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>>)));
  21217. #else
  21218. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  21219. #endif
  21220. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  21221. Expression.Invoke(
  21222. Expression.Call(
  21223. null,
  21224. m,
  21225. Expression.Constant(provider, typeof(IQbservableProvider)),
  21226. begin,
  21227. end
  21228. ),
  21229. Expression.Constant(t1, typeof(TArg1)),
  21230. Expression.Constant(t2, typeof(TArg2)),
  21231. Expression.Constant(t3, typeof(TArg3)),
  21232. Expression.Constant(t4, typeof(TArg4)),
  21233. Expression.Constant(t5, typeof(TArg5)),
  21234. Expression.Constant(t6, typeof(TArg6)),
  21235. Expression.Constant(t7, typeof(TArg7)),
  21236. Expression.Constant(t8, typeof(TArg8)),
  21237. Expression.Constant(t9, typeof(TArg9))
  21238. )
  21239. );
  21240. }
  21241. /// <summary>
  21242. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21243. /// </summary>
  21244. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21245. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21246. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21247. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21248. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21249. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21250. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21251. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21252. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21253. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21254. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21255. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21256. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21257. /// <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>
  21258. /// <exception cref="ArgumentNullException">
  21259. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21260. /// <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>
  21261. #if PREFERASYNC
  21262. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21263. #endif
  21264. 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)
  21265. {
  21266. if (provider == null)
  21267. throw new ArgumentNullException(nameof(provider));
  21268. if (begin == null)
  21269. throw new ArgumentNullException(nameof(begin));
  21270. if (end == null)
  21271. throw new ArgumentNullException(nameof(end));
  21272. #if CRIPPLED_REFLECTION
  21273. 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>>)));
  21274. #else
  21275. 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));
  21276. #endif
  21277. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  21278. Expression.Invoke(
  21279. Expression.Call(
  21280. null,
  21281. m,
  21282. Expression.Constant(provider, typeof(IQbservableProvider)),
  21283. begin,
  21284. end
  21285. ),
  21286. Expression.Constant(t1, typeof(TArg1)),
  21287. Expression.Constant(t2, typeof(TArg2)),
  21288. Expression.Constant(t3, typeof(TArg3)),
  21289. Expression.Constant(t4, typeof(TArg4)),
  21290. Expression.Constant(t5, typeof(TArg5)),
  21291. Expression.Constant(t6, typeof(TArg6)),
  21292. Expression.Constant(t7, typeof(TArg7)),
  21293. Expression.Constant(t8, typeof(TArg8)),
  21294. Expression.Constant(t9, typeof(TArg9)),
  21295. Expression.Constant(t10, typeof(TArg10))
  21296. )
  21297. );
  21298. }
  21299. /// <summary>
  21300. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21301. /// </summary>
  21302. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21303. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21304. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21305. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21306. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21307. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21308. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21309. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21310. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21311. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21312. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21313. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21314. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21315. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21316. /// <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>
  21317. /// <exception cref="ArgumentNullException">
  21318. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21319. /// <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>
  21320. #if PREFERASYNC
  21321. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21322. #endif
  21323. 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)
  21324. {
  21325. if (provider == null)
  21326. throw new ArgumentNullException(nameof(provider));
  21327. if (begin == null)
  21328. throw new ArgumentNullException(nameof(begin));
  21329. if (end == null)
  21330. throw new ArgumentNullException(nameof(end));
  21331. #if CRIPPLED_REFLECTION
  21332. 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>>)));
  21333. #else
  21334. 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));
  21335. #endif
  21336. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  21337. Expression.Invoke(
  21338. Expression.Call(
  21339. null,
  21340. m,
  21341. Expression.Constant(provider, typeof(IQbservableProvider)),
  21342. begin,
  21343. end
  21344. ),
  21345. Expression.Constant(t1, typeof(TArg1)),
  21346. Expression.Constant(t2, typeof(TArg2)),
  21347. Expression.Constant(t3, typeof(TArg3)),
  21348. Expression.Constant(t4, typeof(TArg4)),
  21349. Expression.Constant(t5, typeof(TArg5)),
  21350. Expression.Constant(t6, typeof(TArg6)),
  21351. Expression.Constant(t7, typeof(TArg7)),
  21352. Expression.Constant(t8, typeof(TArg8)),
  21353. Expression.Constant(t9, typeof(TArg9)),
  21354. Expression.Constant(t10, typeof(TArg10)),
  21355. Expression.Constant(t11, typeof(TArg11))
  21356. )
  21357. );
  21358. }
  21359. /// <summary>
  21360. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21361. /// </summary>
  21362. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21363. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21364. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21365. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21366. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21367. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21368. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21369. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21370. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21371. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21372. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21373. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21374. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21375. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21376. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21377. /// <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>
  21378. /// <exception cref="ArgumentNullException">
  21379. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21380. /// <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>
  21381. #if PREFERASYNC
  21382. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21383. #endif
  21384. 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)
  21385. {
  21386. if (provider == null)
  21387. throw new ArgumentNullException(nameof(provider));
  21388. if (begin == null)
  21389. throw new ArgumentNullException(nameof(begin));
  21390. if (end == null)
  21391. throw new ArgumentNullException(nameof(end));
  21392. #if CRIPPLED_REFLECTION
  21393. 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>>)));
  21394. #else
  21395. 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));
  21396. #endif
  21397. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  21398. Expression.Invoke(
  21399. Expression.Call(
  21400. null,
  21401. m,
  21402. Expression.Constant(provider, typeof(IQbservableProvider)),
  21403. begin,
  21404. end
  21405. ),
  21406. Expression.Constant(t1, typeof(TArg1)),
  21407. Expression.Constant(t2, typeof(TArg2)),
  21408. Expression.Constant(t3, typeof(TArg3)),
  21409. Expression.Constant(t4, typeof(TArg4)),
  21410. Expression.Constant(t5, typeof(TArg5)),
  21411. Expression.Constant(t6, typeof(TArg6)),
  21412. Expression.Constant(t7, typeof(TArg7)),
  21413. Expression.Constant(t8, typeof(TArg8)),
  21414. Expression.Constant(t9, typeof(TArg9)),
  21415. Expression.Constant(t10, typeof(TArg10)),
  21416. Expression.Constant(t11, typeof(TArg11)),
  21417. Expression.Constant(t12, typeof(TArg12))
  21418. )
  21419. );
  21420. }
  21421. /// <summary>
  21422. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21423. /// </summary>
  21424. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21425. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21426. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21427. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21428. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21429. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21430. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21431. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21432. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21433. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21434. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21435. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21436. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21437. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21438. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21439. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21440. /// <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>
  21441. /// <exception cref="ArgumentNullException">
  21442. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21443. /// <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>
  21444. #if PREFERASYNC
  21445. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21446. #endif
  21447. 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)
  21448. {
  21449. if (provider == null)
  21450. throw new ArgumentNullException(nameof(provider));
  21451. if (begin == null)
  21452. throw new ArgumentNullException(nameof(begin));
  21453. if (end == null)
  21454. throw new ArgumentNullException(nameof(end));
  21455. #if CRIPPLED_REFLECTION
  21456. 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>>)));
  21457. #else
  21458. 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));
  21459. #endif
  21460. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  21461. Expression.Invoke(
  21462. Expression.Call(
  21463. null,
  21464. m,
  21465. Expression.Constant(provider, typeof(IQbservableProvider)),
  21466. begin,
  21467. end
  21468. ),
  21469. Expression.Constant(t1, typeof(TArg1)),
  21470. Expression.Constant(t2, typeof(TArg2)),
  21471. Expression.Constant(t3, typeof(TArg3)),
  21472. Expression.Constant(t4, typeof(TArg4)),
  21473. Expression.Constant(t5, typeof(TArg5)),
  21474. Expression.Constant(t6, typeof(TArg6)),
  21475. Expression.Constant(t7, typeof(TArg7)),
  21476. Expression.Constant(t8, typeof(TArg8)),
  21477. Expression.Constant(t9, typeof(TArg9)),
  21478. Expression.Constant(t10, typeof(TArg10)),
  21479. Expression.Constant(t11, typeof(TArg11)),
  21480. Expression.Constant(t12, typeof(TArg12)),
  21481. Expression.Constant(t13, typeof(TArg13))
  21482. )
  21483. );
  21484. }
  21485. /// <summary>
  21486. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21487. /// </summary>
  21488. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21489. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21490. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21491. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21492. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21493. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21494. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21495. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21496. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21497. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21498. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21499. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21500. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21501. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21502. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  21503. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21504. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21505. /// <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>
  21506. /// <exception cref="ArgumentNullException">
  21507. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21508. /// <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>
  21509. #if PREFERASYNC
  21510. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21511. #endif
  21512. 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)
  21513. {
  21514. if (provider == null)
  21515. throw new ArgumentNullException(nameof(provider));
  21516. if (begin == null)
  21517. throw new ArgumentNullException(nameof(begin));
  21518. if (end == null)
  21519. throw new ArgumentNullException(nameof(end));
  21520. #if CRIPPLED_REFLECTION
  21521. 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>>)));
  21522. #else
  21523. 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));
  21524. #endif
  21525. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  21526. Expression.Invoke(
  21527. Expression.Call(
  21528. null,
  21529. m,
  21530. Expression.Constant(provider, typeof(IQbservableProvider)),
  21531. begin,
  21532. end
  21533. ),
  21534. Expression.Constant(t1, typeof(TArg1)),
  21535. Expression.Constant(t2, typeof(TArg2)),
  21536. Expression.Constant(t3, typeof(TArg3)),
  21537. Expression.Constant(t4, typeof(TArg4)),
  21538. Expression.Constant(t5, typeof(TArg5)),
  21539. Expression.Constant(t6, typeof(TArg6)),
  21540. Expression.Constant(t7, typeof(TArg7)),
  21541. Expression.Constant(t8, typeof(TArg8)),
  21542. Expression.Constant(t9, typeof(TArg9)),
  21543. Expression.Constant(t10, typeof(TArg10)),
  21544. Expression.Constant(t11, typeof(TArg11)),
  21545. Expression.Constant(t12, typeof(TArg12)),
  21546. Expression.Constant(t13, typeof(TArg13)),
  21547. Expression.Constant(t14, typeof(TArg14))
  21548. )
  21549. );
  21550. }
  21551. /// <summary>
  21552. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21553. /// </summary>
  21554. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21555. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21556. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21557. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21558. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21559. /// <exception cref="ArgumentNullException">
  21560. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21561. /// <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>
  21562. #if PREFERASYNC
  21563. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21564. #endif
  21565. public static Func<IQbservable<TResult>> FromAsyncPattern<TResult>(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  21566. {
  21567. if (provider == null)
  21568. throw new ArgumentNullException(nameof(provider));
  21569. if (begin == null)
  21570. throw new ArgumentNullException(nameof(begin));
  21571. if (end == null)
  21572. throw new ArgumentNullException(nameof(end));
  21573. #if CRIPPLED_REFLECTION
  21574. var m = InfoOf(() => Qbservable.FromAsyncPattern<TResult>(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21575. #else
  21576. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  21577. #endif
  21578. return () => provider.CreateQuery<TResult>(
  21579. Expression.Invoke(
  21580. Expression.Call(
  21581. null,
  21582. m,
  21583. Expression.Constant(provider, typeof(IQbservableProvider)),
  21584. begin,
  21585. end
  21586. )
  21587. )
  21588. );
  21589. }
  21590. /// <summary>
  21591. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21592. /// </summary>
  21593. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21594. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21595. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21596. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21597. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21598. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21599. /// <exception cref="ArgumentNullException">
  21600. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21601. /// <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>
  21602. #if PREFERASYNC
  21603. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21604. #endif
  21605. public static Func<TArg1, IQbservable<TResult>> FromAsyncPattern<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  21606. {
  21607. if (provider == null)
  21608. throw new ArgumentNullException(nameof(provider));
  21609. if (begin == null)
  21610. throw new ArgumentNullException(nameof(begin));
  21611. if (end == null)
  21612. throw new ArgumentNullException(nameof(end));
  21613. #if CRIPPLED_REFLECTION
  21614. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21615. #else
  21616. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  21617. #endif
  21618. return (t1) => provider.CreateQuery<TResult>(
  21619. Expression.Invoke(
  21620. Expression.Call(
  21621. null,
  21622. m,
  21623. Expression.Constant(provider, typeof(IQbservableProvider)),
  21624. begin,
  21625. end
  21626. ),
  21627. Expression.Constant(t1, typeof(TArg1))
  21628. )
  21629. );
  21630. }
  21631. /// <summary>
  21632. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21633. /// </summary>
  21634. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21635. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21636. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21637. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21638. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21639. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21640. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21641. /// <exception cref="ArgumentNullException">
  21642. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21643. /// <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>
  21644. #if PREFERASYNC
  21645. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21646. #endif
  21647. 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)
  21648. {
  21649. if (provider == null)
  21650. throw new ArgumentNullException(nameof(provider));
  21651. if (begin == null)
  21652. throw new ArgumentNullException(nameof(begin));
  21653. if (end == null)
  21654. throw new ArgumentNullException(nameof(end));
  21655. #if CRIPPLED_REFLECTION
  21656. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21657. #else
  21658. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  21659. #endif
  21660. return (t1, t2) => provider.CreateQuery<TResult>(
  21661. Expression.Invoke(
  21662. Expression.Call(
  21663. null,
  21664. m,
  21665. Expression.Constant(provider, typeof(IQbservableProvider)),
  21666. begin,
  21667. end
  21668. ),
  21669. Expression.Constant(t1, typeof(TArg1)),
  21670. Expression.Constant(t2, typeof(TArg2))
  21671. )
  21672. );
  21673. }
  21674. /// <summary>
  21675. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21676. /// </summary>
  21677. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21678. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21679. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21680. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21681. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21682. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21683. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21684. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21685. /// <exception cref="ArgumentNullException">
  21686. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21687. /// <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>
  21688. #if PREFERASYNC
  21689. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21690. #endif
  21691. 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)
  21692. {
  21693. if (provider == null)
  21694. throw new ArgumentNullException(nameof(provider));
  21695. if (begin == null)
  21696. throw new ArgumentNullException(nameof(begin));
  21697. if (end == null)
  21698. throw new ArgumentNullException(nameof(end));
  21699. #if CRIPPLED_REFLECTION
  21700. 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>>)));
  21701. #else
  21702. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  21703. #endif
  21704. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  21705. Expression.Invoke(
  21706. Expression.Call(
  21707. null,
  21708. m,
  21709. Expression.Constant(provider, typeof(IQbservableProvider)),
  21710. begin,
  21711. end
  21712. ),
  21713. Expression.Constant(t1, typeof(TArg1)),
  21714. Expression.Constant(t2, typeof(TArg2)),
  21715. Expression.Constant(t3, typeof(TArg3))
  21716. )
  21717. );
  21718. }
  21719. /// <summary>
  21720. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21721. /// </summary>
  21722. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21723. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21724. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21725. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21726. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21727. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21728. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21729. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21730. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21731. /// <exception cref="ArgumentNullException">
  21732. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21733. /// <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>
  21734. #if PREFERASYNC
  21735. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21736. #endif
  21737. 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)
  21738. {
  21739. if (provider == null)
  21740. throw new ArgumentNullException(nameof(provider));
  21741. if (begin == null)
  21742. throw new ArgumentNullException(nameof(begin));
  21743. if (end == null)
  21744. throw new ArgumentNullException(nameof(end));
  21745. #if CRIPPLED_REFLECTION
  21746. 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>>)));
  21747. #else
  21748. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  21749. #endif
  21750. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  21751. Expression.Invoke(
  21752. Expression.Call(
  21753. null,
  21754. m,
  21755. Expression.Constant(provider, typeof(IQbservableProvider)),
  21756. begin,
  21757. end
  21758. ),
  21759. Expression.Constant(t1, typeof(TArg1)),
  21760. Expression.Constant(t2, typeof(TArg2)),
  21761. Expression.Constant(t3, typeof(TArg3)),
  21762. Expression.Constant(t4, typeof(TArg4))
  21763. )
  21764. );
  21765. }
  21766. /// <summary>
  21767. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21768. /// </summary>
  21769. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21770. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21771. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21772. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21773. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21774. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21775. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21776. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21777. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21778. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21779. /// <exception cref="ArgumentNullException">
  21780. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21781. /// <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>
  21782. #if PREFERASYNC
  21783. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21784. #endif
  21785. 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)
  21786. {
  21787. if (provider == null)
  21788. throw new ArgumentNullException(nameof(provider));
  21789. if (begin == null)
  21790. throw new ArgumentNullException(nameof(begin));
  21791. if (end == null)
  21792. throw new ArgumentNullException(nameof(end));
  21793. #if CRIPPLED_REFLECTION
  21794. 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>>)));
  21795. #else
  21796. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  21797. #endif
  21798. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  21799. Expression.Invoke(
  21800. Expression.Call(
  21801. null,
  21802. m,
  21803. Expression.Constant(provider, typeof(IQbservableProvider)),
  21804. begin,
  21805. end
  21806. ),
  21807. Expression.Constant(t1, typeof(TArg1)),
  21808. Expression.Constant(t2, typeof(TArg2)),
  21809. Expression.Constant(t3, typeof(TArg3)),
  21810. Expression.Constant(t4, typeof(TArg4)),
  21811. Expression.Constant(t5, typeof(TArg5))
  21812. )
  21813. );
  21814. }
  21815. /// <summary>
  21816. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21817. /// </summary>
  21818. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21819. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21820. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21821. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21822. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21823. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21824. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21825. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21826. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21827. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21828. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21829. /// <exception cref="ArgumentNullException">
  21830. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21831. /// <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>
  21832. #if PREFERASYNC
  21833. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21834. #endif
  21835. 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)
  21836. {
  21837. if (provider == null)
  21838. throw new ArgumentNullException(nameof(provider));
  21839. if (begin == null)
  21840. throw new ArgumentNullException(nameof(begin));
  21841. if (end == null)
  21842. throw new ArgumentNullException(nameof(end));
  21843. #if CRIPPLED_REFLECTION
  21844. 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>>)));
  21845. #else
  21846. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  21847. #endif
  21848. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  21849. Expression.Invoke(
  21850. Expression.Call(
  21851. null,
  21852. m,
  21853. Expression.Constant(provider, typeof(IQbservableProvider)),
  21854. begin,
  21855. end
  21856. ),
  21857. Expression.Constant(t1, typeof(TArg1)),
  21858. Expression.Constant(t2, typeof(TArg2)),
  21859. Expression.Constant(t3, typeof(TArg3)),
  21860. Expression.Constant(t4, typeof(TArg4)),
  21861. Expression.Constant(t5, typeof(TArg5)),
  21862. Expression.Constant(t6, typeof(TArg6))
  21863. )
  21864. );
  21865. }
  21866. /// <summary>
  21867. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21868. /// </summary>
  21869. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21870. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21871. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21872. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21873. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21874. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21875. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21876. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21877. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21878. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21879. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21880. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21881. /// <exception cref="ArgumentNullException">
  21882. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21883. /// <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>
  21884. #if PREFERASYNC
  21885. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21886. #endif
  21887. 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)
  21888. {
  21889. if (provider == null)
  21890. throw new ArgumentNullException(nameof(provider));
  21891. if (begin == null)
  21892. throw new ArgumentNullException(nameof(begin));
  21893. if (end == null)
  21894. throw new ArgumentNullException(nameof(end));
  21895. #if CRIPPLED_REFLECTION
  21896. 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>>)));
  21897. #else
  21898. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  21899. #endif
  21900. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  21901. Expression.Invoke(
  21902. Expression.Call(
  21903. null,
  21904. m,
  21905. Expression.Constant(provider, typeof(IQbservableProvider)),
  21906. begin,
  21907. end
  21908. ),
  21909. Expression.Constant(t1, typeof(TArg1)),
  21910. Expression.Constant(t2, typeof(TArg2)),
  21911. Expression.Constant(t3, typeof(TArg3)),
  21912. Expression.Constant(t4, typeof(TArg4)),
  21913. Expression.Constant(t5, typeof(TArg5)),
  21914. Expression.Constant(t6, typeof(TArg6)),
  21915. Expression.Constant(t7, typeof(TArg7))
  21916. )
  21917. );
  21918. }
  21919. /// <summary>
  21920. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21921. /// </summary>
  21922. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21923. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21924. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21925. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21926. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21927. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21928. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21929. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21930. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21931. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21932. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21933. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21934. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21935. /// <exception cref="ArgumentNullException">
  21936. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21937. /// <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>
  21938. #if PREFERASYNC
  21939. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21940. #endif
  21941. 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)
  21942. {
  21943. if (provider == null)
  21944. throw new ArgumentNullException(nameof(provider));
  21945. if (begin == null)
  21946. throw new ArgumentNullException(nameof(begin));
  21947. if (end == null)
  21948. throw new ArgumentNullException(nameof(end));
  21949. #if CRIPPLED_REFLECTION
  21950. 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>>)));
  21951. #else
  21952. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  21953. #endif
  21954. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  21955. Expression.Invoke(
  21956. Expression.Call(
  21957. null,
  21958. m,
  21959. Expression.Constant(provider, typeof(IQbservableProvider)),
  21960. begin,
  21961. end
  21962. ),
  21963. Expression.Constant(t1, typeof(TArg1)),
  21964. Expression.Constant(t2, typeof(TArg2)),
  21965. Expression.Constant(t3, typeof(TArg3)),
  21966. Expression.Constant(t4, typeof(TArg4)),
  21967. Expression.Constant(t5, typeof(TArg5)),
  21968. Expression.Constant(t6, typeof(TArg6)),
  21969. Expression.Constant(t7, typeof(TArg7)),
  21970. Expression.Constant(t8, typeof(TArg8))
  21971. )
  21972. );
  21973. }
  21974. /// <summary>
  21975. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21976. /// </summary>
  21977. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21978. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21979. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21980. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21981. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21982. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21983. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21984. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21985. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21986. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21987. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21988. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21989. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21990. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21991. /// <exception cref="ArgumentNullException">
  21992. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21993. /// <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>
  21994. #if PREFERASYNC
  21995. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21996. #endif
  21997. 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)
  21998. {
  21999. if (provider == null)
  22000. throw new ArgumentNullException(nameof(provider));
  22001. if (begin == null)
  22002. throw new ArgumentNullException(nameof(begin));
  22003. if (end == null)
  22004. throw new ArgumentNullException(nameof(end));
  22005. #if CRIPPLED_REFLECTION
  22006. 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>>)));
  22007. #else
  22008. 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));
  22009. #endif
  22010. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  22011. Expression.Invoke(
  22012. Expression.Call(
  22013. null,
  22014. m,
  22015. Expression.Constant(provider, typeof(IQbservableProvider)),
  22016. begin,
  22017. end
  22018. ),
  22019. Expression.Constant(t1, typeof(TArg1)),
  22020. Expression.Constant(t2, typeof(TArg2)),
  22021. Expression.Constant(t3, typeof(TArg3)),
  22022. Expression.Constant(t4, typeof(TArg4)),
  22023. Expression.Constant(t5, typeof(TArg5)),
  22024. Expression.Constant(t6, typeof(TArg6)),
  22025. Expression.Constant(t7, typeof(TArg7)),
  22026. Expression.Constant(t8, typeof(TArg8)),
  22027. Expression.Constant(t9, typeof(TArg9))
  22028. )
  22029. );
  22030. }
  22031. /// <summary>
  22032. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22033. /// </summary>
  22034. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22035. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22036. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22037. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22038. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22039. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22040. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22041. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22042. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22043. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22044. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22045. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22046. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22047. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22048. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22049. /// <exception cref="ArgumentNullException">
  22050. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22051. /// <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>
  22052. #if PREFERASYNC
  22053. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22054. #endif
  22055. 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)
  22056. {
  22057. if (provider == null)
  22058. throw new ArgumentNullException(nameof(provider));
  22059. if (begin == null)
  22060. throw new ArgumentNullException(nameof(begin));
  22061. if (end == null)
  22062. throw new ArgumentNullException(nameof(end));
  22063. #if CRIPPLED_REFLECTION
  22064. 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>>)));
  22065. #else
  22066. 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));
  22067. #endif
  22068. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  22069. Expression.Invoke(
  22070. Expression.Call(
  22071. null,
  22072. m,
  22073. Expression.Constant(provider, typeof(IQbservableProvider)),
  22074. begin,
  22075. end
  22076. ),
  22077. Expression.Constant(t1, typeof(TArg1)),
  22078. Expression.Constant(t2, typeof(TArg2)),
  22079. Expression.Constant(t3, typeof(TArg3)),
  22080. Expression.Constant(t4, typeof(TArg4)),
  22081. Expression.Constant(t5, typeof(TArg5)),
  22082. Expression.Constant(t6, typeof(TArg6)),
  22083. Expression.Constant(t7, typeof(TArg7)),
  22084. Expression.Constant(t8, typeof(TArg8)),
  22085. Expression.Constant(t9, typeof(TArg9)),
  22086. Expression.Constant(t10, typeof(TArg10))
  22087. )
  22088. );
  22089. }
  22090. /// <summary>
  22091. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22092. /// </summary>
  22093. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22094. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22095. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22096. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22097. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22098. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22099. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22100. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22101. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22102. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22103. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22104. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22105. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22106. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22107. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22108. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22109. /// <exception cref="ArgumentNullException">
  22110. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22111. /// <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>
  22112. #if PREFERASYNC
  22113. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22114. #endif
  22115. 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)
  22116. {
  22117. if (provider == null)
  22118. throw new ArgumentNullException(nameof(provider));
  22119. if (begin == null)
  22120. throw new ArgumentNullException(nameof(begin));
  22121. if (end == null)
  22122. throw new ArgumentNullException(nameof(end));
  22123. #if CRIPPLED_REFLECTION
  22124. 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>>)));
  22125. #else
  22126. 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));
  22127. #endif
  22128. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  22129. Expression.Invoke(
  22130. Expression.Call(
  22131. null,
  22132. m,
  22133. Expression.Constant(provider, typeof(IQbservableProvider)),
  22134. begin,
  22135. end
  22136. ),
  22137. Expression.Constant(t1, typeof(TArg1)),
  22138. Expression.Constant(t2, typeof(TArg2)),
  22139. Expression.Constant(t3, typeof(TArg3)),
  22140. Expression.Constant(t4, typeof(TArg4)),
  22141. Expression.Constant(t5, typeof(TArg5)),
  22142. Expression.Constant(t6, typeof(TArg6)),
  22143. Expression.Constant(t7, typeof(TArg7)),
  22144. Expression.Constant(t8, typeof(TArg8)),
  22145. Expression.Constant(t9, typeof(TArg9)),
  22146. Expression.Constant(t10, typeof(TArg10)),
  22147. Expression.Constant(t11, typeof(TArg11))
  22148. )
  22149. );
  22150. }
  22151. /// <summary>
  22152. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22153. /// </summary>
  22154. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22155. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22156. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22157. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22158. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22159. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22160. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22161. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22162. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22163. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22164. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22165. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22166. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22167. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22168. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22169. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22170. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22171. /// <exception cref="ArgumentNullException">
  22172. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22173. /// <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>
  22174. #if PREFERASYNC
  22175. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22176. #endif
  22177. 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)
  22178. {
  22179. if (provider == null)
  22180. throw new ArgumentNullException(nameof(provider));
  22181. if (begin == null)
  22182. throw new ArgumentNullException(nameof(begin));
  22183. if (end == null)
  22184. throw new ArgumentNullException(nameof(end));
  22185. #if CRIPPLED_REFLECTION
  22186. 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>>)));
  22187. #else
  22188. 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));
  22189. #endif
  22190. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  22191. Expression.Invoke(
  22192. Expression.Call(
  22193. null,
  22194. m,
  22195. Expression.Constant(provider, typeof(IQbservableProvider)),
  22196. begin,
  22197. end
  22198. ),
  22199. Expression.Constant(t1, typeof(TArg1)),
  22200. Expression.Constant(t2, typeof(TArg2)),
  22201. Expression.Constant(t3, typeof(TArg3)),
  22202. Expression.Constant(t4, typeof(TArg4)),
  22203. Expression.Constant(t5, typeof(TArg5)),
  22204. Expression.Constant(t6, typeof(TArg6)),
  22205. Expression.Constant(t7, typeof(TArg7)),
  22206. Expression.Constant(t8, typeof(TArg8)),
  22207. Expression.Constant(t9, typeof(TArg9)),
  22208. Expression.Constant(t10, typeof(TArg10)),
  22209. Expression.Constant(t11, typeof(TArg11)),
  22210. Expression.Constant(t12, typeof(TArg12))
  22211. )
  22212. );
  22213. }
  22214. /// <summary>
  22215. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22216. /// </summary>
  22217. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22218. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22219. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22220. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22221. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22222. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22223. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22224. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22225. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22226. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22227. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22228. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22229. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22230. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22231. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22232. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22233. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22234. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22235. /// <exception cref="ArgumentNullException">
  22236. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22237. /// <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>
  22238. #if PREFERASYNC
  22239. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22240. #endif
  22241. 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)
  22242. {
  22243. if (provider == null)
  22244. throw new ArgumentNullException(nameof(provider));
  22245. if (begin == null)
  22246. throw new ArgumentNullException(nameof(begin));
  22247. if (end == null)
  22248. throw new ArgumentNullException(nameof(end));
  22249. #if CRIPPLED_REFLECTION
  22250. 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>>)));
  22251. #else
  22252. 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));
  22253. #endif
  22254. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  22255. Expression.Invoke(
  22256. Expression.Call(
  22257. null,
  22258. m,
  22259. Expression.Constant(provider, typeof(IQbservableProvider)),
  22260. begin,
  22261. end
  22262. ),
  22263. Expression.Constant(t1, typeof(TArg1)),
  22264. Expression.Constant(t2, typeof(TArg2)),
  22265. Expression.Constant(t3, typeof(TArg3)),
  22266. Expression.Constant(t4, typeof(TArg4)),
  22267. Expression.Constant(t5, typeof(TArg5)),
  22268. Expression.Constant(t6, typeof(TArg6)),
  22269. Expression.Constant(t7, typeof(TArg7)),
  22270. Expression.Constant(t8, typeof(TArg8)),
  22271. Expression.Constant(t9, typeof(TArg9)),
  22272. Expression.Constant(t10, typeof(TArg10)),
  22273. Expression.Constant(t11, typeof(TArg11)),
  22274. Expression.Constant(t12, typeof(TArg12)),
  22275. Expression.Constant(t13, typeof(TArg13))
  22276. )
  22277. );
  22278. }
  22279. /// <summary>
  22280. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22281. /// </summary>
  22282. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22283. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22284. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22285. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22286. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22287. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22288. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22289. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22290. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22291. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22292. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22293. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22294. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22295. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22296. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  22297. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22298. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22299. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22300. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22301. /// <exception cref="ArgumentNullException">
  22302. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22303. /// <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>
  22304. #if PREFERASYNC
  22305. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22306. #endif
  22307. 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)
  22308. {
  22309. if (provider == null)
  22310. throw new ArgumentNullException(nameof(provider));
  22311. if (begin == null)
  22312. throw new ArgumentNullException(nameof(begin));
  22313. if (end == null)
  22314. throw new ArgumentNullException(nameof(end));
  22315. #if CRIPPLED_REFLECTION
  22316. 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>>)));
  22317. #else
  22318. 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));
  22319. #endif
  22320. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  22321. Expression.Invoke(
  22322. Expression.Call(
  22323. null,
  22324. m,
  22325. Expression.Constant(provider, typeof(IQbservableProvider)),
  22326. begin,
  22327. end
  22328. ),
  22329. Expression.Constant(t1, typeof(TArg1)),
  22330. Expression.Constant(t2, typeof(TArg2)),
  22331. Expression.Constant(t3, typeof(TArg3)),
  22332. Expression.Constant(t4, typeof(TArg4)),
  22333. Expression.Constant(t5, typeof(TArg5)),
  22334. Expression.Constant(t6, typeof(TArg6)),
  22335. Expression.Constant(t7, typeof(TArg7)),
  22336. Expression.Constant(t8, typeof(TArg8)),
  22337. Expression.Constant(t9, typeof(TArg9)),
  22338. Expression.Constant(t10, typeof(TArg10)),
  22339. Expression.Constant(t11, typeof(TArg11)),
  22340. Expression.Constant(t12, typeof(TArg12)),
  22341. Expression.Constant(t13, typeof(TArg13)),
  22342. Expression.Constant(t14, typeof(TArg14))
  22343. )
  22344. );
  22345. }
  22346. }
  22347. }
  22348. #pragma warning restore 1591