Qbservable.Generated.cs 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684
  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. #nullable enable
  6. #pragma warning disable 1591
  7. using System.Collections.Generic;
  8. using System.Diagnostics.CodeAnalysis;
  9. using System.Linq;
  10. using System.Linq.Expressions;
  11. using System.Reactive.Concurrency;
  12. using System.Reactive.Subjects;
  13. #if !CRIPPLED_REFLECTION
  14. using System.Reflection;
  15. #endif
  16. using System.Threading;
  17. using System.Threading.Tasks;
  18. namespace System.Reactive.Linq
  19. {
  20. [ExcludeFromCodeCoverage]
  21. public static partial class Qbservable
  22. {
  23. /// <summary>
  24. /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence.
  25. /// 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})" />.
  26. /// </summary>
  27. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  28. /// <param name="source">An observable sequence to aggregate over.</param>
  29. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  30. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  31. /// <exception cref="ArgumentNullException">
  32. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  33. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  34. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  35. public static IQbservable<TSource> Aggregate<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  36. {
  37. if (source == null)
  38. throw new ArgumentNullException(nameof(source));
  39. if (accumulator == null)
  40. throw new ArgumentNullException(nameof(accumulator));
  41. return source.Provider.CreateQuery<TSource>(
  42. Expression.Call(
  43. null,
  44. #if CRIPPLED_REFLECTION
  45. InfoOf(() => Qbservable.Aggregate<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  46. #else
  47. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  48. #endif
  49. source.Expression,
  50. accumulator
  51. )
  52. );
  53. }
  54. /// <summary>
  55. /// 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.
  56. /// 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})" />.
  57. /// </summary>
  58. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  59. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  60. /// <param name="source">An observable sequence to aggregate over.</param>
  61. /// <param name="seed">The initial accumulator value.</param>
  62. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  63. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  64. /// <exception cref="ArgumentNullException">
  65. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  66. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  67. public static IQbservable<TAccumulate> Aggregate<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  68. {
  69. if (source == null)
  70. throw new ArgumentNullException(nameof(source));
  71. if (accumulator == null)
  72. throw new ArgumentNullException(nameof(accumulator));
  73. return source.Provider.CreateQuery<TAccumulate>(
  74. Expression.Call(
  75. null,
  76. #if CRIPPLED_REFLECTION
  77. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  78. #else
  79. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  80. #endif
  81. source.Expression,
  82. Expression.Constant(seed, typeof(TAccumulate)),
  83. accumulator
  84. )
  85. );
  86. }
  87. /// <summary>
  88. /// 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,
  89. /// and the specified result selector function is used to select the result value.
  90. /// </summary>
  91. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  92. /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam>
  93. /// <typeparam name="TResult">The type of the resulting value.</typeparam>
  94. /// <param name="source">An observable sequence to aggregate over.</param>
  95. /// <param name="seed">The initial accumulator value.</param>
  96. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  97. /// <param name="resultSelector">A function to transform the final accumulator value into the result value.</param>
  98. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  99. /// <exception cref="ArgumentNullException">
  100. /// <paramref name="source" /> or <paramref name="accumulator" /> or <paramref name="resultSelector" /> is null.</exception>
  101. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  102. 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)
  103. {
  104. if (source == null)
  105. throw new ArgumentNullException(nameof(source));
  106. if (accumulator == null)
  107. throw new ArgumentNullException(nameof(accumulator));
  108. if (resultSelector == null)
  109. throw new ArgumentNullException(nameof(resultSelector));
  110. return source.Provider.CreateQuery<TResult>(
  111. Expression.Call(
  112. null,
  113. #if CRIPPLED_REFLECTION
  114. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate, TResult>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>), default(Expression<Func<TAccumulate, TResult>>))),
  115. #else
  116. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)),
  117. #endif
  118. source.Expression,
  119. Expression.Constant(seed, typeof(TAccumulate)),
  120. accumulator,
  121. resultSelector
  122. )
  123. );
  124. }
  125. /// <summary>
  126. /// Determines whether all elements of an observable sequence satisfy a condition.
  127. /// </summary>
  128. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  129. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  130. /// <param name="predicate">A function to test each element for a condition.</param>
  131. /// <returns>An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.</returns>
  132. /// <exception cref="ArgumentNullException">
  133. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  134. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  135. public static IQbservable<bool> All<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  136. {
  137. if (source == null)
  138. throw new ArgumentNullException(nameof(source));
  139. if (predicate == null)
  140. throw new ArgumentNullException(nameof(predicate));
  141. return source.Provider.CreateQuery<bool>(
  142. Expression.Call(
  143. null,
  144. #if CRIPPLED_REFLECTION
  145. InfoOf(() => Qbservable.All<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  146. #else
  147. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  148. #endif
  149. source.Expression,
  150. predicate
  151. )
  152. );
  153. }
  154. /// <summary>
  155. /// Propagates the observable sequence that reacts first.
  156. /// </summary>
  157. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  158. /// <param name="first">First observable sequence.</param>
  159. /// <param name="second">Second observable sequence.</param>
  160. /// <returns>An observable sequence that surfaces either of the given sequences, whichever reacted first.</returns>
  161. /// <exception cref="ArgumentNullException">
  162. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  163. public static IQbservable<TSource> Amb<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  164. {
  165. if (first == null)
  166. throw new ArgumentNullException(nameof(first));
  167. if (second == null)
  168. throw new ArgumentNullException(nameof(second));
  169. return first.Provider.CreateQuery<TSource>(
  170. Expression.Call(
  171. null,
  172. #if CRIPPLED_REFLECTION
  173. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  174. #else
  175. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  176. #endif
  177. first.Expression,
  178. GetSourceExpression(second)
  179. )
  180. );
  181. }
  182. /// <summary>
  183. /// Propagates the observable sequence that reacts first.
  184. /// </summary>
  185. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  186. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  187. /// <param name="sources">Observable sources competing to react first.</param>
  188. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  189. /// <exception cref="ArgumentNullException">
  190. /// <paramref name="sources" /> is null.</exception>
  191. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  192. {
  193. if (provider == null)
  194. throw new ArgumentNullException(nameof(provider));
  195. if (sources == null)
  196. throw new ArgumentNullException(nameof(sources));
  197. return provider.CreateQuery<TSource>(
  198. Expression.Call(
  199. null,
  200. #if CRIPPLED_REFLECTION
  201. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  202. #else
  203. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  204. #endif
  205. Expression.Constant(provider, typeof(IQbservableProvider)),
  206. GetSourceExpression(sources)
  207. )
  208. );
  209. }
  210. /// <summary>
  211. /// Propagates the observable sequence that reacts first.
  212. /// </summary>
  213. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  214. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  215. /// <param name="sources">Observable sources competing to react first.</param>
  216. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  217. /// <exception cref="ArgumentNullException">
  218. /// <paramref name="sources" /> is null.</exception>
  219. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  220. {
  221. if (provider == null)
  222. throw new ArgumentNullException(nameof(provider));
  223. if (sources == null)
  224. throw new ArgumentNullException(nameof(sources));
  225. return provider.CreateQuery<TSource>(
  226. Expression.Call(
  227. null,
  228. #if CRIPPLED_REFLECTION
  229. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  230. #else
  231. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  232. #endif
  233. Expression.Constant(provider, typeof(IQbservableProvider)),
  234. GetSourceExpression(sources)
  235. )
  236. );
  237. }
  238. /// <summary>
  239. /// Determines whether an observable sequence contains any elements.
  240. /// </summary>
  241. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  242. /// <param name="source">An observable sequence to check for non-emptiness.</param>
  243. /// <returns>An observable sequence containing a single element determining whether the source sequence contains any elements.</returns>
  244. /// <exception cref="ArgumentNullException">
  245. /// <paramref name="source" /> is null.</exception>
  246. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  247. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source)
  248. {
  249. if (source == null)
  250. throw new ArgumentNullException(nameof(source));
  251. return source.Provider.CreateQuery<bool>(
  252. Expression.Call(
  253. null,
  254. #if CRIPPLED_REFLECTION
  255. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>))),
  256. #else
  257. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  258. #endif
  259. source.Expression
  260. )
  261. );
  262. }
  263. /// <summary>
  264. /// Determines whether any element of an observable sequence satisfies a condition.
  265. /// </summary>
  266. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  267. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  268. /// <param name="predicate">A function to test each element for a condition.</param>
  269. /// <returns>An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate.</returns>
  270. /// <exception cref="ArgumentNullException">
  271. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  272. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  273. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  274. {
  275. if (source == null)
  276. throw new ArgumentNullException(nameof(source));
  277. if (predicate == null)
  278. throw new ArgumentNullException(nameof(predicate));
  279. return source.Provider.CreateQuery<bool>(
  280. Expression.Call(
  281. null,
  282. #if CRIPPLED_REFLECTION
  283. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  284. #else
  285. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  286. #endif
  287. source.Expression,
  288. predicate
  289. )
  290. );
  291. }
  292. /// <summary>
  293. /// Append a value to an observable sequence.
  294. /// </summary>
  295. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  296. /// <param name="source">Source sequence to append the value to.</param>
  297. /// <param name="value">Value to append to the specified sequence.</param>
  298. /// <returns>The source sequence appended with the specified value.</returns>
  299. /// <exception cref="ArgumentNullException">
  300. /// <paramref name="source" /> is null.</exception>
  301. public static IQbservable<TSource> Append<TSource>(this IQbservable<TSource> source, TSource value)
  302. {
  303. if (source == null)
  304. throw new ArgumentNullException(nameof(source));
  305. return source.Provider.CreateQuery<TSource>(
  306. Expression.Call(
  307. null,
  308. #if CRIPPLED_REFLECTION
  309. InfoOf(() => Qbservable.Append<TSource>(default(IQbservable<TSource>), default(TSource))),
  310. #else
  311. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  312. #endif
  313. source.Expression,
  314. Expression.Constant(value, typeof(TSource))
  315. )
  316. );
  317. }
  318. /// <summary>
  319. /// Append a value to an observable sequence.
  320. /// </summary>
  321. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  322. /// <param name="source">Source sequence to append the value to.</param>
  323. /// <param name="value">Value to append to the specified sequence.</param>
  324. /// <param name="scheduler">Scheduler to emit the append values on.</param>
  325. /// <returns>The source sequence appended with the specified value.</returns>
  326. /// <exception cref="ArgumentNullException">
  327. /// <paramref name="source" /> is null.</exception>
  328. public static IQbservable<TSource> Append<TSource>(this IQbservable<TSource> source, TSource value, IScheduler scheduler)
  329. {
  330. if (source == null)
  331. throw new ArgumentNullException(nameof(source));
  332. if (scheduler == null)
  333. throw new ArgumentNullException(nameof(scheduler));
  334. return source.Provider.CreateQuery<TSource>(
  335. Expression.Call(
  336. null,
  337. #if CRIPPLED_REFLECTION
  338. InfoOf(() => Qbservable.Append<TSource>(default(IQbservable<TSource>), default(TSource), default(IScheduler))),
  339. #else
  340. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  341. #endif
  342. source.Expression,
  343. Expression.Constant(value, typeof(TSource)),
  344. Expression.Constant(scheduler, typeof(IScheduler))
  345. )
  346. );
  347. }
  348. /// <summary>
  349. /// Automatically connect the upstream IConnectableObservable at most once when the
  350. /// specified number of IObservers have subscribed to this IObservable.
  351. /// </summary>
  352. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  353. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  354. /// <param name="source">Connectable observable sequence.</param>
  355. /// <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>
  356. /// <param name="onConnect">If not null, the connection's IDisposable is provided to it.</param>
  357. /// <returns>An observable sequence that connects to the source at most once when the given number of observers have subscribed to it.</returns>
  358. /// <exception cref="ArgumentNullException">
  359. /// <paramref name="source" /> is null.</exception>
  360. public static IQbservable<TSource> AutoConnect<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, int minObservers, Expression<Action<IDisposable>> onConnect)
  361. {
  362. if (provider == null)
  363. throw new ArgumentNullException(nameof(provider));
  364. if (source == null)
  365. throw new ArgumentNullException(nameof(source));
  366. if (onConnect == null)
  367. throw new ArgumentNullException(nameof(onConnect));
  368. return provider.CreateQuery<TSource>(
  369. Expression.Call(
  370. null,
  371. #if CRIPPLED_REFLECTION
  372. InfoOf(() => Qbservable.AutoConnect<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(int), default(Expression<Action<IDisposable>>))),
  373. #else
  374. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  375. #endif
  376. Expression.Constant(provider, typeof(IQbservableProvider)),
  377. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  378. Expression.Constant(minObservers, typeof(int)),
  379. onConnect
  380. )
  381. );
  382. }
  383. /// <summary>
  384. /// Computes the average of an observable sequence of <see cref="Decimal" /> values.
  385. /// </summary>
  386. /// <param name="source">A sequence of <see cref="Decimal" /> values to calculate the average of.</param>
  387. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  388. /// <exception cref="ArgumentNullException">
  389. /// <paramref name="source" /> is null.</exception>
  390. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  391. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  392. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  393. public static IQbservable<decimal> Average(this IQbservable<decimal> source)
  394. {
  395. if (source == null)
  396. throw new ArgumentNullException(nameof(source));
  397. return source.Provider.CreateQuery<decimal>(
  398. Expression.Call(
  399. null,
  400. #if CRIPPLED_REFLECTION
  401. InfoOf(() => Qbservable.Average(default(IQbservable<decimal>))),
  402. #else
  403. (MethodInfo)MethodInfo.GetCurrentMethod(),
  404. #endif
  405. source.Expression
  406. )
  407. );
  408. }
  409. /// <summary>
  410. /// Computes the average of an observable sequence of <see cref="double" /> values.
  411. /// </summary>
  412. /// <param name="source">A sequence of <see cref="double" /> values to calculate the average of.</param>
  413. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  414. /// <exception cref="ArgumentNullException">
  415. /// <paramref name="source" /> is null.</exception>
  416. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  417. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  418. public static IQbservable<double> Average(this IQbservable<double> source)
  419. {
  420. if (source == null)
  421. throw new ArgumentNullException(nameof(source));
  422. return source.Provider.CreateQuery<double>(
  423. Expression.Call(
  424. null,
  425. #if CRIPPLED_REFLECTION
  426. InfoOf(() => Qbservable.Average(default(IQbservable<double>))),
  427. #else
  428. (MethodInfo)MethodInfo.GetCurrentMethod(),
  429. #endif
  430. source.Expression
  431. )
  432. );
  433. }
  434. /// <summary>
  435. /// Computes the average of an observable sequence of <see cref="int" /> values.
  436. /// </summary>
  437. /// <param name="source">A sequence of <see cref="int" /> values to calculate the average of.</param>
  438. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  439. /// <exception cref="ArgumentNullException">
  440. /// <paramref name="source" /> is null.</exception>
  441. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  442. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  443. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  444. public static IQbservable<double> Average(this IQbservable<int> source)
  445. {
  446. if (source == null)
  447. throw new ArgumentNullException(nameof(source));
  448. return source.Provider.CreateQuery<double>(
  449. Expression.Call(
  450. null,
  451. #if CRIPPLED_REFLECTION
  452. InfoOf(() => Qbservable.Average(default(IQbservable<int>))),
  453. #else
  454. (MethodInfo)MethodInfo.GetCurrentMethod(),
  455. #endif
  456. source.Expression
  457. )
  458. );
  459. }
  460. /// <summary>
  461. /// Computes the average of an observable sequence of <see cref="long" /> values.
  462. /// </summary>
  463. /// <param name="source">A sequence of <see cref="long" /> values to calculate the average of.</param>
  464. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  465. /// <exception cref="ArgumentNullException">
  466. /// <paramref name="source" /> is null.</exception>
  467. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  468. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  469. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  470. public static IQbservable<double> Average(this IQbservable<long> source)
  471. {
  472. if (source == null)
  473. throw new ArgumentNullException(nameof(source));
  474. return source.Provider.CreateQuery<double>(
  475. Expression.Call(
  476. null,
  477. #if CRIPPLED_REFLECTION
  478. InfoOf(() => Qbservable.Average(default(IQbservable<long>))),
  479. #else
  480. (MethodInfo)MethodInfo.GetCurrentMethod(),
  481. #endif
  482. source.Expression
  483. )
  484. );
  485. }
  486. /// <summary>
  487. /// Computes the average of an observable sequence of nullable <see cref="Decimal" /> values.
  488. /// </summary>
  489. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to calculate the average of.</param>
  490. /// <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>
  491. /// <exception cref="ArgumentNullException">
  492. /// <paramref name="source" /> is null.</exception>
  493. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  494. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  495. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  496. public static IQbservable<decimal?> Average(this IQbservable<decimal?> source)
  497. {
  498. if (source == null)
  499. throw new ArgumentNullException(nameof(source));
  500. return source.Provider.CreateQuery<decimal?>(
  501. Expression.Call(
  502. null,
  503. #if CRIPPLED_REFLECTION
  504. InfoOf(() => Qbservable.Average(default(IQbservable<decimal?>))),
  505. #else
  506. (MethodInfo)MethodInfo.GetCurrentMethod(),
  507. #endif
  508. source.Expression
  509. )
  510. );
  511. }
  512. /// <summary>
  513. /// Computes the average of an observable sequence of nullable <see cref="double" /> values.
  514. /// </summary>
  515. /// <param name="source">A sequence of nullable <see cref="double" /> values to calculate the average of.</param>
  516. /// <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>
  517. /// <exception cref="ArgumentNullException">
  518. /// <paramref name="source" /> is null.</exception>
  519. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  520. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  521. public static IQbservable<double?> Average(this IQbservable<double?> source)
  522. {
  523. if (source == null)
  524. throw new ArgumentNullException(nameof(source));
  525. return source.Provider.CreateQuery<double?>(
  526. Expression.Call(
  527. null,
  528. #if CRIPPLED_REFLECTION
  529. InfoOf(() => Qbservable.Average(default(IQbservable<double?>))),
  530. #else
  531. (MethodInfo)MethodInfo.GetCurrentMethod(),
  532. #endif
  533. source.Expression
  534. )
  535. );
  536. }
  537. /// <summary>
  538. /// Computes the average of an observable sequence of nullable <see cref="int" /> values.
  539. /// </summary>
  540. /// <param name="source">A sequence of nullable <see cref="int" /> values to calculate the average of.</param>
  541. /// <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>
  542. /// <exception cref="ArgumentNullException">
  543. /// <paramref name="source" /> is null.</exception>
  544. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  545. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  546. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  547. public static IQbservable<double?> Average(this IQbservable<int?> source)
  548. {
  549. if (source == null)
  550. throw new ArgumentNullException(nameof(source));
  551. return source.Provider.CreateQuery<double?>(
  552. Expression.Call(
  553. null,
  554. #if CRIPPLED_REFLECTION
  555. InfoOf(() => Qbservable.Average(default(IQbservable<int?>))),
  556. #else
  557. (MethodInfo)MethodInfo.GetCurrentMethod(),
  558. #endif
  559. source.Expression
  560. )
  561. );
  562. }
  563. /// <summary>
  564. /// Computes the average of an observable sequence of nullable <see cref="long" /> values.
  565. /// </summary>
  566. /// <param name="source">A sequence of nullable <see cref="long" /> values to calculate the average of.</param>
  567. /// <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>
  568. /// <exception cref="ArgumentNullException">
  569. /// <paramref name="source" /> is null.</exception>
  570. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  571. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  572. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  573. public static IQbservable<double?> Average(this IQbservable<long?> source)
  574. {
  575. if (source == null)
  576. throw new ArgumentNullException(nameof(source));
  577. return source.Provider.CreateQuery<double?>(
  578. Expression.Call(
  579. null,
  580. #if CRIPPLED_REFLECTION
  581. InfoOf(() => Qbservable.Average(default(IQbservable<long?>))),
  582. #else
  583. (MethodInfo)MethodInfo.GetCurrentMethod(),
  584. #endif
  585. source.Expression
  586. )
  587. );
  588. }
  589. /// <summary>
  590. /// Computes the average of an observable sequence of nullable <see cref="Single" /> values.
  591. /// </summary>
  592. /// <param name="source">A sequence of nullable <see cref="Single" /> values to calculate the average of.</param>
  593. /// <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>
  594. /// <exception cref="ArgumentNullException">
  595. /// <paramref name="source" /> is null.</exception>
  596. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  597. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  598. public static IQbservable<float?> Average(this IQbservable<float?> source)
  599. {
  600. if (source == null)
  601. throw new ArgumentNullException(nameof(source));
  602. return source.Provider.CreateQuery<float?>(
  603. Expression.Call(
  604. null,
  605. #if CRIPPLED_REFLECTION
  606. InfoOf(() => Qbservable.Average(default(IQbservable<float?>))),
  607. #else
  608. (MethodInfo)MethodInfo.GetCurrentMethod(),
  609. #endif
  610. source.Expression
  611. )
  612. );
  613. }
  614. /// <summary>
  615. /// Computes the average of an observable sequence of <see cref="Single" /> values.
  616. /// </summary>
  617. /// <param name="source">A sequence of <see cref="Single" /> values to calculate the average of.</param>
  618. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  619. /// <exception cref="ArgumentNullException">
  620. /// <paramref name="source" /> is null.</exception>
  621. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  622. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  623. public static IQbservable<float> Average(this IQbservable<float> source)
  624. {
  625. if (source == null)
  626. throw new ArgumentNullException(nameof(source));
  627. return source.Provider.CreateQuery<float>(
  628. Expression.Call(
  629. null,
  630. #if CRIPPLED_REFLECTION
  631. InfoOf(() => Qbservable.Average(default(IQbservable<float>))),
  632. #else
  633. (MethodInfo)MethodInfo.GetCurrentMethod(),
  634. #endif
  635. source.Expression
  636. )
  637. );
  638. }
  639. /// <summary>
  640. /// 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.
  641. /// </summary>
  642. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  643. /// <param name="source">A sequence of values to calculate the average of.</param>
  644. /// <param name="selector">A transform function to apply to each element.</param>
  645. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  646. /// <exception cref="ArgumentNullException">
  647. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  648. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  649. /// <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>
  650. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  651. public static IQbservable<decimal> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  652. {
  653. if (source == null)
  654. throw new ArgumentNullException(nameof(source));
  655. if (selector == null)
  656. throw new ArgumentNullException(nameof(selector));
  657. return source.Provider.CreateQuery<decimal>(
  658. Expression.Call(
  659. null,
  660. #if CRIPPLED_REFLECTION
  661. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  662. #else
  663. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  664. #endif
  665. source.Expression,
  666. selector
  667. )
  668. );
  669. }
  670. /// <summary>
  671. /// 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.
  672. /// </summary>
  673. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  674. /// <param name="source">A sequence of values to calculate the average of.</param>
  675. /// <param name="selector">A transform function to apply to each element.</param>
  676. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  677. /// <exception cref="ArgumentNullException">
  678. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  679. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  680. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  681. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  682. {
  683. if (source == null)
  684. throw new ArgumentNullException(nameof(source));
  685. if (selector == null)
  686. throw new ArgumentNullException(nameof(selector));
  687. return source.Provider.CreateQuery<double>(
  688. Expression.Call(
  689. null,
  690. #if CRIPPLED_REFLECTION
  691. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  692. #else
  693. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  694. #endif
  695. source.Expression,
  696. selector
  697. )
  698. );
  699. }
  700. /// <summary>
  701. /// 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.
  702. /// </summary>
  703. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  704. /// <param name="source">A sequence of values to calculate the average of.</param>
  705. /// <param name="selector">A transform function to apply to each element.</param>
  706. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  707. /// <exception cref="ArgumentNullException">
  708. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  709. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  710. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  711. public static IQbservable<float> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  712. {
  713. if (source == null)
  714. throw new ArgumentNullException(nameof(source));
  715. if (selector == null)
  716. throw new ArgumentNullException(nameof(selector));
  717. return source.Provider.CreateQuery<float>(
  718. Expression.Call(
  719. null,
  720. #if CRIPPLED_REFLECTION
  721. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  722. #else
  723. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  724. #endif
  725. source.Expression,
  726. selector
  727. )
  728. );
  729. }
  730. /// <summary>
  731. /// 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.
  732. /// </summary>
  733. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  734. /// <param name="source">A sequence of values to calculate the average of.</param>
  735. /// <param name="selector">A transform function to apply to each element.</param>
  736. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  737. /// <exception cref="ArgumentNullException">
  738. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  739. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  740. /// <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>
  741. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  742. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  743. {
  744. if (source == null)
  745. throw new ArgumentNullException(nameof(source));
  746. if (selector == null)
  747. throw new ArgumentNullException(nameof(selector));
  748. return source.Provider.CreateQuery<double>(
  749. Expression.Call(
  750. null,
  751. #if CRIPPLED_REFLECTION
  752. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  753. #else
  754. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  755. #endif
  756. source.Expression,
  757. selector
  758. )
  759. );
  760. }
  761. /// <summary>
  762. /// 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.
  763. /// </summary>
  764. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  765. /// <param name="source">A sequence of values to calculate the average of.</param>
  766. /// <param name="selector">A transform function to apply to each element.</param>
  767. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  768. /// <exception cref="ArgumentNullException">
  769. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  770. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  771. /// <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>
  772. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  773. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  774. {
  775. if (source == null)
  776. throw new ArgumentNullException(nameof(source));
  777. if (selector == null)
  778. throw new ArgumentNullException(nameof(selector));
  779. return source.Provider.CreateQuery<double>(
  780. Expression.Call(
  781. null,
  782. #if CRIPPLED_REFLECTION
  783. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  784. #else
  785. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  786. #endif
  787. source.Expression,
  788. selector
  789. )
  790. );
  791. }
  792. /// <summary>
  793. /// 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.
  794. /// </summary>
  795. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  796. /// <param name="source">A sequence of values to calculate the average of.</param>
  797. /// <param name="selector">A transform function to apply to each element.</param>
  798. /// <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>
  799. /// <exception cref="ArgumentNullException">
  800. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  801. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  802. /// <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>
  803. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  804. public static IQbservable<decimal?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  805. {
  806. if (source == null)
  807. throw new ArgumentNullException(nameof(source));
  808. if (selector == null)
  809. throw new ArgumentNullException(nameof(selector));
  810. return source.Provider.CreateQuery<decimal?>(
  811. Expression.Call(
  812. null,
  813. #if CRIPPLED_REFLECTION
  814. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  815. #else
  816. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  817. #endif
  818. source.Expression,
  819. selector
  820. )
  821. );
  822. }
  823. /// <summary>
  824. /// 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.
  825. /// </summary>
  826. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  827. /// <param name="source">A sequence of values to calculate the average of.</param>
  828. /// <param name="selector">A transform function to apply to each element.</param>
  829. /// <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>
  830. /// <exception cref="ArgumentNullException">
  831. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  832. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  833. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  834. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  835. {
  836. if (source == null)
  837. throw new ArgumentNullException(nameof(source));
  838. if (selector == null)
  839. throw new ArgumentNullException(nameof(selector));
  840. return source.Provider.CreateQuery<double?>(
  841. Expression.Call(
  842. null,
  843. #if CRIPPLED_REFLECTION
  844. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  845. #else
  846. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  847. #endif
  848. source.Expression,
  849. selector
  850. )
  851. );
  852. }
  853. /// <summary>
  854. /// 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.
  855. /// </summary>
  856. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  857. /// <param name="source">A sequence of values to calculate the average of.</param>
  858. /// <param name="selector">A transform function to apply to each element.</param>
  859. /// <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>
  860. /// <exception cref="ArgumentNullException">
  861. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  862. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  863. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  864. public static IQbservable<float?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  865. {
  866. if (source == null)
  867. throw new ArgumentNullException(nameof(source));
  868. if (selector == null)
  869. throw new ArgumentNullException(nameof(selector));
  870. return source.Provider.CreateQuery<float?>(
  871. Expression.Call(
  872. null,
  873. #if CRIPPLED_REFLECTION
  874. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  875. #else
  876. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  877. #endif
  878. source.Expression,
  879. selector
  880. )
  881. );
  882. }
  883. /// <summary>
  884. /// 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.
  885. /// </summary>
  886. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  887. /// <param name="source">A sequence of values to calculate the average of.</param>
  888. /// <param name="selector">A transform function to apply to each element.</param>
  889. /// <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>
  890. /// <exception cref="ArgumentNullException">
  891. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  892. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  893. /// <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>
  894. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  895. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  896. {
  897. if (source == null)
  898. throw new ArgumentNullException(nameof(source));
  899. if (selector == null)
  900. throw new ArgumentNullException(nameof(selector));
  901. return source.Provider.CreateQuery<double?>(
  902. Expression.Call(
  903. null,
  904. #if CRIPPLED_REFLECTION
  905. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  906. #else
  907. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  908. #endif
  909. source.Expression,
  910. selector
  911. )
  912. );
  913. }
  914. /// <summary>
  915. /// 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.
  916. /// </summary>
  917. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  918. /// <param name="source">A sequence of values to calculate the average of.</param>
  919. /// <param name="selector">A transform function to apply to each element.</param>
  920. /// <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>
  921. /// <exception cref="ArgumentNullException">
  922. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  923. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  924. /// <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>
  925. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  926. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  927. {
  928. if (source == null)
  929. throw new ArgumentNullException(nameof(source));
  930. if (selector == null)
  931. throw new ArgumentNullException(nameof(selector));
  932. return source.Provider.CreateQuery<double?>(
  933. Expression.Call(
  934. null,
  935. #if CRIPPLED_REFLECTION
  936. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  937. #else
  938. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  939. #endif
  940. source.Expression,
  941. selector
  942. )
  943. );
  944. }
  945. /// <summary>
  946. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on element count information.
  947. /// </summary>
  948. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  949. /// <param name="source">Source sequence to produce buffers over.</param>
  950. /// <param name="count">Length of each buffer.</param>
  951. /// <returns>An observable sequence of buffers.</returns>
  952. /// <exception cref="ArgumentNullException">
  953. /// <paramref name="source" /> is null.</exception>
  954. /// <exception cref="ArgumentOutOfRangeException">
  955. /// <paramref name="count" /> is less than or equal to zero.</exception>
  956. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count)
  957. {
  958. if (source == null)
  959. throw new ArgumentNullException(nameof(source));
  960. return source.Provider.CreateQuery<IList<TSource>>(
  961. Expression.Call(
  962. null,
  963. #if CRIPPLED_REFLECTION
  964. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int))),
  965. #else
  966. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  967. #endif
  968. source.Expression,
  969. Expression.Constant(count, typeof(int))
  970. )
  971. );
  972. }
  973. /// <summary>
  974. /// Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
  975. /// </summary>
  976. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  977. /// <param name="source">Source sequence to produce buffers over.</param>
  978. /// <param name="count">Length of each buffer.</param>
  979. /// <param name="skip">Number of elements to skip between creation of consecutive buffers.</param>
  980. /// <returns>An observable sequence of buffers.</returns>
  981. /// <exception cref="ArgumentNullException">
  982. /// <paramref name="source" /> is null.</exception>
  983. /// <exception cref="ArgumentOutOfRangeException">
  984. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  985. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count, int skip)
  986. {
  987. if (source == null)
  988. throw new ArgumentNullException(nameof(source));
  989. return source.Provider.CreateQuery<IList<TSource>>(
  990. Expression.Call(
  991. null,
  992. #if CRIPPLED_REFLECTION
  993. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  994. #else
  995. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  996. #endif
  997. source.Expression,
  998. Expression.Constant(count, typeof(int)),
  999. Expression.Constant(skip, typeof(int))
  1000. )
  1001. );
  1002. }
  1003. /// <summary>
  1004. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information.
  1005. /// </summary>
  1006. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1007. /// <param name="source">Source sequence to produce buffers over.</param>
  1008. /// <param name="timeSpan">Length of each buffer.</param>
  1009. /// <returns>An observable sequence of buffers.</returns>
  1010. /// <exception cref="ArgumentNullException">
  1011. /// <paramref name="source" /> is null.</exception>
  1012. /// <exception cref="ArgumentOutOfRangeException">
  1013. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1014. /// <remarks>
  1015. /// 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.
  1016. /// 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
  1017. /// 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.
  1018. /// </remarks>
  1019. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  1020. {
  1021. if (source == null)
  1022. throw new ArgumentNullException(nameof(source));
  1023. return source.Provider.CreateQuery<IList<TSource>>(
  1024. Expression.Call(
  1025. null,
  1026. #if CRIPPLED_REFLECTION
  1027. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  1028. #else
  1029. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1030. #endif
  1031. source.Expression,
  1032. Expression.Constant(timeSpan, typeof(TimeSpan))
  1033. )
  1034. );
  1035. }
  1036. /// <summary>
  1037. /// 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.
  1038. /// 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.
  1039. /// </summary>
  1040. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1041. /// <param name="source">Source sequence to produce buffers over.</param>
  1042. /// <param name="timeSpan">Maximum time length of a window.</param>
  1043. /// <param name="count">Maximum element count of a window.</param>
  1044. /// <returns>An observable sequence of buffers.</returns>
  1045. /// <exception cref="ArgumentNullException">
  1046. /// <paramref name="source" /> is null.</exception>
  1047. /// <exception cref="ArgumentOutOfRangeException">
  1048. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  1049. /// <remarks>
  1050. /// 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.
  1051. /// 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
  1052. /// 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.
  1053. /// </remarks>
  1054. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  1055. {
  1056. if (source == null)
  1057. throw new ArgumentNullException(nameof(source));
  1058. return source.Provider.CreateQuery<IList<TSource>>(
  1059. Expression.Call(
  1060. null,
  1061. #if CRIPPLED_REFLECTION
  1062. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  1063. #else
  1064. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1065. #endif
  1066. source.Expression,
  1067. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1068. Expression.Constant(count, typeof(int))
  1069. )
  1070. );
  1071. }
  1072. /// <summary>
  1073. /// 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.
  1074. /// 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.
  1075. /// </summary>
  1076. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1077. /// <param name="source">Source sequence to produce buffers over.</param>
  1078. /// <param name="timeSpan">Maximum time length of a buffer.</param>
  1079. /// <param name="count">Maximum element count of a buffer.</param>
  1080. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1081. /// <returns>An observable sequence of buffers.</returns>
  1082. /// <exception cref="ArgumentNullException">
  1083. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1084. /// <exception cref="ArgumentOutOfRangeException">
  1085. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  1086. /// <remarks>
  1087. /// 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.
  1088. /// 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
  1089. /// 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.
  1090. /// </remarks>
  1091. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  1092. {
  1093. if (source == null)
  1094. throw new ArgumentNullException(nameof(source));
  1095. if (scheduler == null)
  1096. throw new ArgumentNullException(nameof(scheduler));
  1097. return source.Provider.CreateQuery<IList<TSource>>(
  1098. Expression.Call(
  1099. null,
  1100. #if CRIPPLED_REFLECTION
  1101. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  1102. #else
  1103. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1104. #endif
  1105. source.Expression,
  1106. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1107. Expression.Constant(count, typeof(int)),
  1108. Expression.Constant(scheduler, typeof(IScheduler))
  1109. )
  1110. );
  1111. }
  1112. /// <summary>
  1113. /// 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.
  1114. /// </summary>
  1115. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1116. /// <param name="source">Source sequence to produce buffers over.</param>
  1117. /// <param name="timeSpan">Length of each buffer.</param>
  1118. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1119. /// <returns>An observable sequence of buffers.</returns>
  1120. /// <exception cref="ArgumentNullException">
  1121. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1122. /// <exception cref="ArgumentOutOfRangeException">
  1123. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1124. /// <remarks>
  1125. /// 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.
  1126. /// 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
  1127. /// 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.
  1128. /// </remarks>
  1129. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  1130. {
  1131. if (source == null)
  1132. throw new ArgumentNullException(nameof(source));
  1133. if (scheduler == null)
  1134. throw new ArgumentNullException(nameof(scheduler));
  1135. return source.Provider.CreateQuery<IList<TSource>>(
  1136. Expression.Call(
  1137. null,
  1138. #if CRIPPLED_REFLECTION
  1139. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  1140. #else
  1141. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1142. #endif
  1143. source.Expression,
  1144. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1145. Expression.Constant(scheduler, typeof(IScheduler))
  1146. )
  1147. );
  1148. }
  1149. /// <summary>
  1150. /// Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
  1151. /// </summary>
  1152. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1153. /// <param name="source">Source sequence to produce buffers over.</param>
  1154. /// <param name="timeSpan">Length of each buffer.</param>
  1155. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1156. /// <returns>An observable sequence of buffers.</returns>
  1157. /// <exception cref="ArgumentNullException">
  1158. /// <paramref name="source" /> is null.</exception>
  1159. /// <exception cref="ArgumentOutOfRangeException">
  1160. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1161. /// <remarks>
  1162. /// <para>
  1163. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1164. /// 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
  1165. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1166. /// </para>
  1167. /// <para>
  1168. /// 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.
  1169. /// 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,
  1170. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1171. /// </para>
  1172. /// </remarks>
  1173. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  1174. {
  1175. if (source == null)
  1176. throw new ArgumentNullException(nameof(source));
  1177. return source.Provider.CreateQuery<IList<TSource>>(
  1178. Expression.Call(
  1179. null,
  1180. #if CRIPPLED_REFLECTION
  1181. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  1182. #else
  1183. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1184. #endif
  1185. source.Expression,
  1186. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1187. Expression.Constant(timeShift, typeof(TimeSpan))
  1188. )
  1189. );
  1190. }
  1191. /// <summary>
  1192. /// 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.
  1193. /// </summary>
  1194. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1195. /// <param name="source">Source sequence to produce buffers over.</param>
  1196. /// <param name="timeSpan">Length of each buffer.</param>
  1197. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1198. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1199. /// <returns>An observable sequence of buffers.</returns>
  1200. /// <exception cref="ArgumentNullException">
  1201. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1202. /// <exception cref="ArgumentOutOfRangeException">
  1203. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1204. /// <remarks>
  1205. /// <para>
  1206. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1207. /// 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
  1208. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1209. /// </para>
  1210. /// <para>
  1211. /// 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.
  1212. /// 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,
  1213. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1214. /// </para>
  1215. /// </remarks>
  1216. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  1217. {
  1218. if (source == null)
  1219. throw new ArgumentNullException(nameof(source));
  1220. if (scheduler == null)
  1221. throw new ArgumentNullException(nameof(scheduler));
  1222. return source.Provider.CreateQuery<IList<TSource>>(
  1223. Expression.Call(
  1224. null,
  1225. #if CRIPPLED_REFLECTION
  1226. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  1227. #else
  1228. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1229. #endif
  1230. source.Expression,
  1231. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1232. Expression.Constant(timeShift, typeof(TimeSpan)),
  1233. Expression.Constant(scheduler, typeof(IScheduler))
  1234. )
  1235. );
  1236. }
  1237. /// <summary>
  1238. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  1239. /// </summary>
  1240. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1241. /// <typeparam name="TBufferBoundary">The type of the elements in the sequences indicating buffer boundary events.</typeparam>
  1242. /// <param name="source">Source sequence to produce buffers over.</param>
  1243. /// <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>
  1244. /// <returns>An observable sequence of buffers.</returns>
  1245. /// <exception cref="ArgumentNullException">
  1246. /// <paramref name="source" /> or <paramref name="bufferBoundaries" /> is null.</exception>
  1247. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferBoundary>(this IQbservable<TSource> source, IObservable<TBufferBoundary> bufferBoundaries)
  1248. {
  1249. if (source == null)
  1250. throw new ArgumentNullException(nameof(source));
  1251. if (bufferBoundaries == null)
  1252. throw new ArgumentNullException(nameof(bufferBoundaries));
  1253. return source.Provider.CreateQuery<IList<TSource>>(
  1254. Expression.Call(
  1255. null,
  1256. #if CRIPPLED_REFLECTION
  1257. InfoOf(() => Qbservable.Buffer<TSource, TBufferBoundary>(default(IQbservable<TSource>), default(IObservable<TBufferBoundary>))),
  1258. #else
  1259. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferBoundary)),
  1260. #endif
  1261. source.Expression,
  1262. GetSourceExpression(bufferBoundaries)
  1263. )
  1264. );
  1265. }
  1266. /// <summary>
  1267. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  1268. /// </summary>
  1269. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1270. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1271. /// <param name="source">Source sequence to produce buffers over.</param>
  1272. /// <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>
  1273. /// <returns>An observable sequence of buffers.</returns>
  1274. /// <exception cref="ArgumentNullException">
  1275. /// <paramref name="source" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1276. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TBufferClosing>>> bufferClosingSelector)
  1277. {
  1278. if (source == null)
  1279. throw new ArgumentNullException(nameof(source));
  1280. if (bufferClosingSelector == null)
  1281. throw new ArgumentNullException(nameof(bufferClosingSelector));
  1282. return source.Provider.CreateQuery<IList<TSource>>(
  1283. Expression.Call(
  1284. null,
  1285. #if CRIPPLED_REFLECTION
  1286. InfoOf(() => Qbservable.Buffer<TSource, TBufferClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TBufferClosing>>>))),
  1287. #else
  1288. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferClosing)),
  1289. #endif
  1290. source.Expression,
  1291. bufferClosingSelector
  1292. )
  1293. );
  1294. }
  1295. /// <summary>
  1296. /// Projects each element of an observable sequence into zero or more buffers.
  1297. /// </summary>
  1298. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1299. /// <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>
  1300. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1301. /// <param name="source">Source sequence to produce buffers over.</param>
  1302. /// <param name="bufferOpenings">Observable sequence whose elements denote the creation of new buffers.</param>
  1303. /// <param name="bufferClosingSelector">A function invoked to define the closing of each produced buffer.</param>
  1304. /// <returns>An observable sequence of buffers.</returns>
  1305. /// <exception cref="ArgumentNullException">
  1306. /// <paramref name="source" /> or <paramref name="bufferOpenings" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1307. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferOpening, TBufferClosing>(this IQbservable<TSource> source, IObservable<TBufferOpening> bufferOpenings, Expression<Func<TBufferOpening, IObservable<TBufferClosing>>> bufferClosingSelector)
  1308. {
  1309. if (source == null)
  1310. throw new ArgumentNullException(nameof(source));
  1311. if (bufferOpenings == null)
  1312. throw new ArgumentNullException(nameof(bufferOpenings));
  1313. if (bufferClosingSelector == null)
  1314. throw new ArgumentNullException(nameof(bufferClosingSelector));
  1315. return source.Provider.CreateQuery<IList<TSource>>(
  1316. Expression.Call(
  1317. null,
  1318. #if CRIPPLED_REFLECTION
  1319. InfoOf(() => Qbservable.Buffer<TSource, TBufferOpening, TBufferClosing>(default(IQbservable<TSource>), default(IObservable<TBufferOpening>), default(Expression<Func<TBufferOpening, IObservable<TBufferClosing>>>))),
  1320. #else
  1321. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferOpening), typeof(TBufferClosing)),
  1322. #endif
  1323. source.Expression,
  1324. GetSourceExpression(bufferOpenings),
  1325. bufferClosingSelector
  1326. )
  1327. );
  1328. }
  1329. /// <summary>
  1330. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing an empty sequence if no match is found.
  1331. /// </summary>
  1332. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1333. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1334. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1335. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1336. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1337. /// <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>
  1338. /// <exception cref="ArgumentNullException">
  1339. /// <paramref name="selector" /> or <paramref name="sources" /> is null.</exception>
  1340. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources)
  1341. where TValue : notnull
  1342. {
  1343. if (provider == null)
  1344. throw new ArgumentNullException(nameof(provider));
  1345. if (selector == null)
  1346. throw new ArgumentNullException(nameof(selector));
  1347. if (sources == null)
  1348. throw new ArgumentNullException(nameof(sources));
  1349. return provider.CreateQuery<TResult>(
  1350. Expression.Call(
  1351. null,
  1352. #if CRIPPLED_REFLECTION
  1353. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>))),
  1354. #else
  1355. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1356. #endif
  1357. Expression.Constant(provider, typeof(IQbservableProvider)),
  1358. selector,
  1359. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>))
  1360. )
  1361. );
  1362. }
  1363. /// <summary>
  1364. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing <paramref name="defaultSource" /> if no match is found.
  1365. /// </summary>
  1366. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1367. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1368. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1369. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1370. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1371. /// <param name="defaultSource">Default source to select in case no matching source in <paramref name="sources" /> is found.</param>
  1372. /// <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>
  1373. /// <exception cref="ArgumentNullException">
  1374. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="defaultSource" /> is null.</exception>
  1375. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IObservable<TResult> defaultSource)
  1376. where TValue : notnull
  1377. {
  1378. if (provider == null)
  1379. throw new ArgumentNullException(nameof(provider));
  1380. if (selector == null)
  1381. throw new ArgumentNullException(nameof(selector));
  1382. if (sources == null)
  1383. throw new ArgumentNullException(nameof(sources));
  1384. if (defaultSource == null)
  1385. throw new ArgumentNullException(nameof(defaultSource));
  1386. return provider.CreateQuery<TResult>(
  1387. Expression.Call(
  1388. null,
  1389. #if CRIPPLED_REFLECTION
  1390. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IObservable<TResult>))),
  1391. #else
  1392. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1393. #endif
  1394. Expression.Constant(provider, typeof(IQbservableProvider)),
  1395. selector,
  1396. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1397. GetSourceExpression(defaultSource)
  1398. )
  1399. );
  1400. }
  1401. /// <summary>
  1402. /// 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.
  1403. /// </summary>
  1404. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1405. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1406. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1407. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1408. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1409. /// <param name="scheduler">Scheduler to generate an empty sequence on in case no matching source in <paramref name="sources" /> is found.</param>
  1410. /// <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>
  1411. /// <exception cref="ArgumentNullException">
  1412. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  1413. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IScheduler scheduler)
  1414. where TValue : notnull
  1415. {
  1416. if (provider == null)
  1417. throw new ArgumentNullException(nameof(provider));
  1418. if (selector == null)
  1419. throw new ArgumentNullException(nameof(selector));
  1420. if (sources == null)
  1421. throw new ArgumentNullException(nameof(sources));
  1422. if (scheduler == null)
  1423. throw new ArgumentNullException(nameof(scheduler));
  1424. return provider.CreateQuery<TResult>(
  1425. Expression.Call(
  1426. null,
  1427. #if CRIPPLED_REFLECTION
  1428. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IScheduler))),
  1429. #else
  1430. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1431. #endif
  1432. Expression.Constant(provider, typeof(IQbservableProvider)),
  1433. selector,
  1434. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1435. Expression.Constant(scheduler, typeof(IScheduler))
  1436. )
  1437. );
  1438. }
  1439. /// <summary>
  1440. /// Converts the elements of an observable sequence to the specified type.
  1441. /// </summary>
  1442. /// <typeparam name="TResult">The type to convert the elements in the source sequence to.</typeparam>
  1443. /// <param name="source">The observable sequence that contains the elements to be converted.</param>
  1444. /// <returns>An observable sequence that contains each element of the source sequence converted to the specified type.</returns>
  1445. /// <exception cref="ArgumentNullException">
  1446. /// <paramref name="source" /> is null.</exception>
  1447. public static IQbservable<TResult> Cast<TResult>(this IQbservable<object> source)
  1448. {
  1449. if (source == null)
  1450. throw new ArgumentNullException(nameof(source));
  1451. return source.Provider.CreateQuery<TResult>(
  1452. Expression.Call(
  1453. null,
  1454. #if CRIPPLED_REFLECTION
  1455. InfoOf(() => Qbservable.Cast<TResult>(default(IQbservable<object>))),
  1456. #else
  1457. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  1458. #endif
  1459. source.Expression
  1460. )
  1461. );
  1462. }
  1463. /// <summary>
  1464. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1465. /// </summary>
  1466. /// <typeparam name="TSource">The type of the elements in the source sequence and handler sequence.</typeparam>
  1467. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  1468. /// <param name="second">Second observable sequence used to produce results when an error occurred in the first sequence.</param>
  1469. /// <returns>An observable sequence containing the first sequence's elements, followed by the elements of the second sequence in case an exception occurred.</returns>
  1470. /// <exception cref="ArgumentNullException">
  1471. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  1472. public static IQbservable<TSource> Catch<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  1473. {
  1474. if (first == null)
  1475. throw new ArgumentNullException(nameof(first));
  1476. if (second == null)
  1477. throw new ArgumentNullException(nameof(second));
  1478. return first.Provider.CreateQuery<TSource>(
  1479. Expression.Call(
  1480. null,
  1481. #if CRIPPLED_REFLECTION
  1482. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  1483. #else
  1484. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1485. #endif
  1486. first.Expression,
  1487. GetSourceExpression(second)
  1488. )
  1489. );
  1490. }
  1491. /// <summary>
  1492. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1493. /// </summary>
  1494. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1495. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1496. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1497. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1498. /// <exception cref="ArgumentNullException">
  1499. /// <paramref name="sources" /> is null.</exception>
  1500. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1501. {
  1502. if (provider == null)
  1503. throw new ArgumentNullException(nameof(provider));
  1504. if (sources == null)
  1505. throw new ArgumentNullException(nameof(sources));
  1506. return provider.CreateQuery<TSource>(
  1507. Expression.Call(
  1508. null,
  1509. #if CRIPPLED_REFLECTION
  1510. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1511. #else
  1512. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1513. #endif
  1514. Expression.Constant(provider, typeof(IQbservableProvider)),
  1515. GetSourceExpression(sources)
  1516. )
  1517. );
  1518. }
  1519. /// <summary>
  1520. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1521. /// </summary>
  1522. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1523. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1524. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1525. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1526. /// <exception cref="ArgumentNullException">
  1527. /// <paramref name="sources" /> is null.</exception>
  1528. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1529. {
  1530. if (provider == null)
  1531. throw new ArgumentNullException(nameof(provider));
  1532. if (sources == null)
  1533. throw new ArgumentNullException(nameof(sources));
  1534. return provider.CreateQuery<TSource>(
  1535. Expression.Call(
  1536. null,
  1537. #if CRIPPLED_REFLECTION
  1538. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1539. #else
  1540. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1541. #endif
  1542. Expression.Constant(provider, typeof(IQbservableProvider)),
  1543. GetSourceExpression(sources)
  1544. )
  1545. );
  1546. }
  1547. /// <summary>
  1548. /// Continues an observable sequence that is terminated by an exception of the specified type with the observable sequence produced by the handler.
  1549. /// </summary>
  1550. /// <typeparam name="TSource">The type of the elements in the source sequence and sequences returned by the exception handler function.</typeparam>
  1551. /// <typeparam name="TException">The type of the exception to catch and handle. Needs to derive from <see cref="Exception" />.</typeparam>
  1552. /// <param name="source">Source sequence.</param>
  1553. /// <param name="handler">Exception handler function, producing another observable sequence.</param>
  1554. /// <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>
  1555. /// <exception cref="ArgumentNullException">
  1556. /// <paramref name="source" /> or <paramref name="handler" /> is null.</exception>
  1557. public static IQbservable<TSource> Catch<TSource, TException>(this IQbservable<TSource> source, Expression<Func<TException, IObservable<TSource>>> handler)
  1558. where TException : Exception
  1559. {
  1560. if (source == null)
  1561. throw new ArgumentNullException(nameof(source));
  1562. if (handler == null)
  1563. throw new ArgumentNullException(nameof(handler));
  1564. return source.Provider.CreateQuery<TSource>(
  1565. Expression.Call(
  1566. null,
  1567. #if CRIPPLED_REFLECTION
  1568. InfoOf(() => Qbservable.Catch<TSource, TException>(default(IQbservable<TSource>), default(Expression<Func<TException, IObservable<TSource>>>))),
  1569. #else
  1570. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)),
  1571. #endif
  1572. source.Expression,
  1573. handler
  1574. )
  1575. );
  1576. }
  1577. /// <summary>
  1578. /// Produces an enumerable sequence of consecutive (possibly empty) chunks of the source sequence.
  1579. /// </summary>
  1580. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1581. /// <param name="source">Source observable sequence.</param>
  1582. /// <returns>The enumerable sequence that returns consecutive (possibly empty) chunks upon each iteration.</returns>
  1583. /// <exception cref="ArgumentNullException">
  1584. /// <paramref name="source" /> is null.</exception>
  1585. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1586. public static IQueryable<IList<TSource>> Chunkify<TSource>(this IQbservable<TSource> source)
  1587. {
  1588. if (source == null)
  1589. throw new ArgumentNullException(nameof(source));
  1590. return ((IQueryProvider)source.Provider).CreateQuery<IList<TSource>>(
  1591. Expression.Call(
  1592. null,
  1593. #if CRIPPLED_REFLECTION
  1594. InfoOf(() => Qbservable.Chunkify<TSource>(default(IQbservable<TSource>))),
  1595. #else
  1596. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1597. #endif
  1598. source.Expression
  1599. )
  1600. );
  1601. }
  1602. /// <summary>
  1603. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1604. /// </summary>
  1605. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1606. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1607. /// <param name="source">Source observable sequence.</param>
  1608. /// <param name="getInitialCollector">Factory to create the initial collector object.</param>
  1609. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1610. /// <param name="getNewCollector">Factory to replace the current collector by a new collector.</param>
  1611. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1612. /// <exception cref="ArgumentNullException">
  1613. /// <paramref name="source" /> or <paramref name="getInitialCollector" /> or <paramref name="merge" /> or <paramref name="getNewCollector" /> is null.</exception>
  1614. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1615. 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)
  1616. {
  1617. if (source == null)
  1618. throw new ArgumentNullException(nameof(source));
  1619. if (getInitialCollector == null)
  1620. throw new ArgumentNullException(nameof(getInitialCollector));
  1621. if (merge == null)
  1622. throw new ArgumentNullException(nameof(merge));
  1623. if (getNewCollector == null)
  1624. throw new ArgumentNullException(nameof(getNewCollector));
  1625. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1626. Expression.Call(
  1627. null,
  1628. #if CRIPPLED_REFLECTION
  1629. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>), default(Expression<Func<TResult, TResult>>))),
  1630. #else
  1631. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1632. #endif
  1633. source.Expression,
  1634. getInitialCollector,
  1635. merge,
  1636. getNewCollector
  1637. )
  1638. );
  1639. }
  1640. /// <summary>
  1641. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1642. /// </summary>
  1643. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1644. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1645. /// <param name="source">Source observable sequence.</param>
  1646. /// <param name="newCollector">Factory to create a new collector object.</param>
  1647. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1648. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1649. /// <exception cref="ArgumentNullException">
  1650. /// <paramref name="source" /> or <paramref name="newCollector" /> or <paramref name="merge" /> is null.</exception>
  1651. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1652. public static IQueryable<TResult> Collect<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TResult>> newCollector, Expression<Func<TResult, TSource, TResult>> merge)
  1653. {
  1654. if (source == null)
  1655. throw new ArgumentNullException(nameof(source));
  1656. if (newCollector == null)
  1657. throw new ArgumentNullException(nameof(newCollector));
  1658. if (merge == null)
  1659. throw new ArgumentNullException(nameof(merge));
  1660. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1661. Expression.Call(
  1662. null,
  1663. #if CRIPPLED_REFLECTION
  1664. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>))),
  1665. #else
  1666. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1667. #endif
  1668. source.Expression,
  1669. newCollector,
  1670. merge
  1671. )
  1672. );
  1673. }
  1674. /// <summary>
  1675. /// 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.
  1676. /// </summary>
  1677. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1678. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1679. /// <param name="sources">Observable sources.</param>
  1680. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1681. /// <exception cref="ArgumentNullException">
  1682. /// <paramref name="sources" /> is null.</exception>
  1683. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  1684. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1685. {
  1686. if (provider == null)
  1687. throw new ArgumentNullException(nameof(provider));
  1688. if (sources == null)
  1689. throw new ArgumentNullException(nameof(sources));
  1690. return provider.CreateQuery<IList<TSource>>(
  1691. Expression.Call(
  1692. null,
  1693. #if CRIPPLED_REFLECTION
  1694. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1695. #else
  1696. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1697. #endif
  1698. Expression.Constant(provider, typeof(IQbservableProvider)),
  1699. GetSourceExpression(sources)
  1700. )
  1701. );
  1702. }
  1703. /// <summary>
  1704. /// 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.
  1705. /// </summary>
  1706. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1707. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1708. /// <param name="sources">Observable sources.</param>
  1709. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1710. /// <exception cref="ArgumentNullException">
  1711. /// <paramref name="sources" /> is null.</exception>
  1712. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  1713. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1714. {
  1715. if (provider == null)
  1716. throw new ArgumentNullException(nameof(provider));
  1717. if (sources == null)
  1718. throw new ArgumentNullException(nameof(sources));
  1719. return provider.CreateQuery<IList<TSource>>(
  1720. Expression.Call(
  1721. null,
  1722. #if CRIPPLED_REFLECTION
  1723. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1724. #else
  1725. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1726. #endif
  1727. Expression.Constant(provider, typeof(IQbservableProvider)),
  1728. GetSourceExpression(sources)
  1729. )
  1730. );
  1731. }
  1732. /// <summary>
  1733. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1734. /// </summary>
  1735. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1736. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  1737. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1738. /// <param name="sources">Observable sources.</param>
  1739. /// <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>
  1740. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1741. /// <exception cref="ArgumentNullException">
  1742. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  1743. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  1744. public static IQbservable<TResult> CombineLatest<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  1745. {
  1746. if (provider == null)
  1747. throw new ArgumentNullException(nameof(provider));
  1748. if (sources == null)
  1749. throw new ArgumentNullException(nameof(sources));
  1750. if (resultSelector == null)
  1751. throw new ArgumentNullException(nameof(resultSelector));
  1752. return provider.CreateQuery<TResult>(
  1753. Expression.Call(
  1754. null,
  1755. #if CRIPPLED_REFLECTION
  1756. InfoOf(() => Qbservable.CombineLatest<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  1757. #else
  1758. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1759. #endif
  1760. Expression.Constant(provider, typeof(IQbservableProvider)),
  1761. GetSourceExpression(sources),
  1762. resultSelector
  1763. )
  1764. );
  1765. }
  1766. /// <summary>
  1767. /// Merges two observable sequences into one observable sequence by using the selector function whenever one of the observable sequences produces an element.
  1768. /// </summary>
  1769. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1770. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1771. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1772. /// <param name="first">First observable source.</param>
  1773. /// <param name="second">Second observable source.</param>
  1774. /// <param name="resultSelector">Function to invoke whenever either of the sources produces an element.</param>
  1775. /// <returns>An observable sequence containing the result of combining elements of both sources using the specified result selector function.</returns>
  1776. /// <exception cref="ArgumentNullException">
  1777. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  1778. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  1779. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  1780. {
  1781. if (first == null)
  1782. throw new ArgumentNullException(nameof(first));
  1783. if (second == null)
  1784. throw new ArgumentNullException(nameof(second));
  1785. if (resultSelector == null)
  1786. throw new ArgumentNullException(nameof(resultSelector));
  1787. return first.Provider.CreateQuery<TResult>(
  1788. Expression.Call(
  1789. null,
  1790. #if CRIPPLED_REFLECTION
  1791. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  1792. #else
  1793. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  1794. #endif
  1795. first.Expression,
  1796. GetSourceExpression(second),
  1797. resultSelector
  1798. )
  1799. );
  1800. }
  1801. /// <summary>
  1802. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1803. /// </summary>
  1804. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1805. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1806. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1807. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1808. /// <param name="source1">First observable source.</param>
  1809. /// <param name="source2">Second observable source.</param>
  1810. /// <param name="source3">Third observable source.</param>
  1811. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1812. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1813. /// <exception cref="ArgumentNullException">
  1814. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  1815. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  1816. 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)
  1817. {
  1818. if (source1 == null)
  1819. throw new ArgumentNullException(nameof(source1));
  1820. if (source2 == null)
  1821. throw new ArgumentNullException(nameof(source2));
  1822. if (source3 == null)
  1823. throw new ArgumentNullException(nameof(source3));
  1824. if (resultSelector == null)
  1825. throw new ArgumentNullException(nameof(resultSelector));
  1826. return source1.Provider.CreateQuery<TResult>(
  1827. Expression.Call(
  1828. null,
  1829. #if CRIPPLED_REFLECTION
  1830. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  1831. #else
  1832. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  1833. #endif
  1834. source1.Expression,
  1835. GetSourceExpression(source2),
  1836. GetSourceExpression(source3),
  1837. resultSelector
  1838. )
  1839. );
  1840. }
  1841. /// <summary>
  1842. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1843. /// </summary>
  1844. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1845. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1846. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1847. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1848. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1849. /// <param name="source1">First observable source.</param>
  1850. /// <param name="source2">Second observable source.</param>
  1851. /// <param name="source3">Third observable source.</param>
  1852. /// <param name="source4">Fourth observable source.</param>
  1853. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1854. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1855. /// <exception cref="ArgumentNullException">
  1856. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  1857. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  1858. 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)
  1859. {
  1860. if (source1 == null)
  1861. throw new ArgumentNullException(nameof(source1));
  1862. if (source2 == null)
  1863. throw new ArgumentNullException(nameof(source2));
  1864. if (source3 == null)
  1865. throw new ArgumentNullException(nameof(source3));
  1866. if (source4 == null)
  1867. throw new ArgumentNullException(nameof(source4));
  1868. if (resultSelector == null)
  1869. throw new ArgumentNullException(nameof(resultSelector));
  1870. return source1.Provider.CreateQuery<TResult>(
  1871. Expression.Call(
  1872. null,
  1873. #if CRIPPLED_REFLECTION
  1874. 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>>))),
  1875. #else
  1876. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  1877. #endif
  1878. source1.Expression,
  1879. GetSourceExpression(source2),
  1880. GetSourceExpression(source3),
  1881. GetSourceExpression(source4),
  1882. resultSelector
  1883. )
  1884. );
  1885. }
  1886. /// <summary>
  1887. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1888. /// </summary>
  1889. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1890. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1891. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1892. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1893. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1894. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1895. /// <param name="source1">First observable source.</param>
  1896. /// <param name="source2">Second observable source.</param>
  1897. /// <param name="source3">Third observable source.</param>
  1898. /// <param name="source4">Fourth observable source.</param>
  1899. /// <param name="source5">Fifth observable source.</param>
  1900. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1901. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1902. /// <exception cref="ArgumentNullException">
  1903. /// <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>
  1904. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  1905. 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)
  1906. {
  1907. if (source1 == null)
  1908. throw new ArgumentNullException(nameof(source1));
  1909. if (source2 == null)
  1910. throw new ArgumentNullException(nameof(source2));
  1911. if (source3 == null)
  1912. throw new ArgumentNullException(nameof(source3));
  1913. if (source4 == null)
  1914. throw new ArgumentNullException(nameof(source4));
  1915. if (source5 == null)
  1916. throw new ArgumentNullException(nameof(source5));
  1917. if (resultSelector == null)
  1918. throw new ArgumentNullException(nameof(resultSelector));
  1919. return source1.Provider.CreateQuery<TResult>(
  1920. Expression.Call(
  1921. null,
  1922. #if CRIPPLED_REFLECTION
  1923. 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>>))),
  1924. #else
  1925. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  1926. #endif
  1927. source1.Expression,
  1928. GetSourceExpression(source2),
  1929. GetSourceExpression(source3),
  1930. GetSourceExpression(source4),
  1931. GetSourceExpression(source5),
  1932. resultSelector
  1933. )
  1934. );
  1935. }
  1936. /// <summary>
  1937. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1938. /// </summary>
  1939. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1940. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1941. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1942. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1943. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1944. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1945. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1946. /// <param name="source1">First observable source.</param>
  1947. /// <param name="source2">Second observable source.</param>
  1948. /// <param name="source3">Third observable source.</param>
  1949. /// <param name="source4">Fourth observable source.</param>
  1950. /// <param name="source5">Fifth observable source.</param>
  1951. /// <param name="source6">Sixth observable source.</param>
  1952. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1953. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1954. /// <exception cref="ArgumentNullException">
  1955. /// <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>
  1956. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  1957. 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)
  1958. {
  1959. if (source1 == null)
  1960. throw new ArgumentNullException(nameof(source1));
  1961. if (source2 == null)
  1962. throw new ArgumentNullException(nameof(source2));
  1963. if (source3 == null)
  1964. throw new ArgumentNullException(nameof(source3));
  1965. if (source4 == null)
  1966. throw new ArgumentNullException(nameof(source4));
  1967. if (source5 == null)
  1968. throw new ArgumentNullException(nameof(source5));
  1969. if (source6 == null)
  1970. throw new ArgumentNullException(nameof(source6));
  1971. if (resultSelector == null)
  1972. throw new ArgumentNullException(nameof(resultSelector));
  1973. return source1.Provider.CreateQuery<TResult>(
  1974. Expression.Call(
  1975. null,
  1976. #if CRIPPLED_REFLECTION
  1977. 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>>))),
  1978. #else
  1979. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  1980. #endif
  1981. source1.Expression,
  1982. GetSourceExpression(source2),
  1983. GetSourceExpression(source3),
  1984. GetSourceExpression(source4),
  1985. GetSourceExpression(source5),
  1986. GetSourceExpression(source6),
  1987. resultSelector
  1988. )
  1989. );
  1990. }
  1991. /// <summary>
  1992. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1993. /// </summary>
  1994. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1995. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1996. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1997. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1998. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1999. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2000. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2001. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2002. /// <param name="source1">First observable source.</param>
  2003. /// <param name="source2">Second observable source.</param>
  2004. /// <param name="source3">Third observable source.</param>
  2005. /// <param name="source4">Fourth observable source.</param>
  2006. /// <param name="source5">Fifth observable source.</param>
  2007. /// <param name="source6">Sixth observable source.</param>
  2008. /// <param name="source7">Seventh observable source.</param>
  2009. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2010. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2011. /// <exception cref="ArgumentNullException">
  2012. /// <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>
  2013. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  2014. 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)
  2015. {
  2016. if (source1 == null)
  2017. throw new ArgumentNullException(nameof(source1));
  2018. if (source2 == null)
  2019. throw new ArgumentNullException(nameof(source2));
  2020. if (source3 == null)
  2021. throw new ArgumentNullException(nameof(source3));
  2022. if (source4 == null)
  2023. throw new ArgumentNullException(nameof(source4));
  2024. if (source5 == null)
  2025. throw new ArgumentNullException(nameof(source5));
  2026. if (source6 == null)
  2027. throw new ArgumentNullException(nameof(source6));
  2028. if (source7 == null)
  2029. throw new ArgumentNullException(nameof(source7));
  2030. if (resultSelector == null)
  2031. throw new ArgumentNullException(nameof(resultSelector));
  2032. return source1.Provider.CreateQuery<TResult>(
  2033. Expression.Call(
  2034. null,
  2035. #if CRIPPLED_REFLECTION
  2036. 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>>))),
  2037. #else
  2038. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  2039. #endif
  2040. source1.Expression,
  2041. GetSourceExpression(source2),
  2042. GetSourceExpression(source3),
  2043. GetSourceExpression(source4),
  2044. GetSourceExpression(source5),
  2045. GetSourceExpression(source6),
  2046. GetSourceExpression(source7),
  2047. resultSelector
  2048. )
  2049. );
  2050. }
  2051. /// <summary>
  2052. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2053. /// </summary>
  2054. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2055. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2056. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2057. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2058. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2059. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2060. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2061. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2062. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2063. /// <param name="source1">First observable source.</param>
  2064. /// <param name="source2">Second observable source.</param>
  2065. /// <param name="source3">Third observable source.</param>
  2066. /// <param name="source4">Fourth observable source.</param>
  2067. /// <param name="source5">Fifth observable source.</param>
  2068. /// <param name="source6">Sixth observable source.</param>
  2069. /// <param name="source7">Seventh observable source.</param>
  2070. /// <param name="source8">Eighth observable source.</param>
  2071. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2072. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2073. /// <exception cref="ArgumentNullException">
  2074. /// <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>
  2075. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  2076. 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)
  2077. {
  2078. if (source1 == null)
  2079. throw new ArgumentNullException(nameof(source1));
  2080. if (source2 == null)
  2081. throw new ArgumentNullException(nameof(source2));
  2082. if (source3 == null)
  2083. throw new ArgumentNullException(nameof(source3));
  2084. if (source4 == null)
  2085. throw new ArgumentNullException(nameof(source4));
  2086. if (source5 == null)
  2087. throw new ArgumentNullException(nameof(source5));
  2088. if (source6 == null)
  2089. throw new ArgumentNullException(nameof(source6));
  2090. if (source7 == null)
  2091. throw new ArgumentNullException(nameof(source7));
  2092. if (source8 == null)
  2093. throw new ArgumentNullException(nameof(source8));
  2094. if (resultSelector == null)
  2095. throw new ArgumentNullException(nameof(resultSelector));
  2096. return source1.Provider.CreateQuery<TResult>(
  2097. Expression.Call(
  2098. null,
  2099. #if CRIPPLED_REFLECTION
  2100. 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>>))),
  2101. #else
  2102. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  2103. #endif
  2104. source1.Expression,
  2105. GetSourceExpression(source2),
  2106. GetSourceExpression(source3),
  2107. GetSourceExpression(source4),
  2108. GetSourceExpression(source5),
  2109. GetSourceExpression(source6),
  2110. GetSourceExpression(source7),
  2111. GetSourceExpression(source8),
  2112. resultSelector
  2113. )
  2114. );
  2115. }
  2116. /// <summary>
  2117. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2118. /// </summary>
  2119. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2120. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2121. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2122. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2123. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2124. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2125. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2126. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2127. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2128. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2129. /// <param name="source1">First observable source.</param>
  2130. /// <param name="source2">Second observable source.</param>
  2131. /// <param name="source3">Third observable source.</param>
  2132. /// <param name="source4">Fourth observable source.</param>
  2133. /// <param name="source5">Fifth observable source.</param>
  2134. /// <param name="source6">Sixth observable source.</param>
  2135. /// <param name="source7">Seventh observable source.</param>
  2136. /// <param name="source8">Eighth observable source.</param>
  2137. /// <param name="source9">Ninth observable source.</param>
  2138. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2139. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2140. /// <exception cref="ArgumentNullException">
  2141. /// <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>
  2142. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  2143. 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)
  2144. {
  2145. if (source1 == null)
  2146. throw new ArgumentNullException(nameof(source1));
  2147. if (source2 == null)
  2148. throw new ArgumentNullException(nameof(source2));
  2149. if (source3 == null)
  2150. throw new ArgumentNullException(nameof(source3));
  2151. if (source4 == null)
  2152. throw new ArgumentNullException(nameof(source4));
  2153. if (source5 == null)
  2154. throw new ArgumentNullException(nameof(source5));
  2155. if (source6 == null)
  2156. throw new ArgumentNullException(nameof(source6));
  2157. if (source7 == null)
  2158. throw new ArgumentNullException(nameof(source7));
  2159. if (source8 == null)
  2160. throw new ArgumentNullException(nameof(source8));
  2161. if (source9 == null)
  2162. throw new ArgumentNullException(nameof(source9));
  2163. if (resultSelector == null)
  2164. throw new ArgumentNullException(nameof(resultSelector));
  2165. return source1.Provider.CreateQuery<TResult>(
  2166. Expression.Call(
  2167. null,
  2168. #if CRIPPLED_REFLECTION
  2169. 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>>))),
  2170. #else
  2171. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  2172. #endif
  2173. source1.Expression,
  2174. GetSourceExpression(source2),
  2175. GetSourceExpression(source3),
  2176. GetSourceExpression(source4),
  2177. GetSourceExpression(source5),
  2178. GetSourceExpression(source6),
  2179. GetSourceExpression(source7),
  2180. GetSourceExpression(source8),
  2181. GetSourceExpression(source9),
  2182. resultSelector
  2183. )
  2184. );
  2185. }
  2186. /// <summary>
  2187. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2188. /// </summary>
  2189. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2190. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2191. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2192. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2193. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2194. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2195. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2196. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2197. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2198. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2199. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2200. /// <param name="source1">First observable source.</param>
  2201. /// <param name="source2">Second observable source.</param>
  2202. /// <param name="source3">Third observable source.</param>
  2203. /// <param name="source4">Fourth observable source.</param>
  2204. /// <param name="source5">Fifth observable source.</param>
  2205. /// <param name="source6">Sixth observable source.</param>
  2206. /// <param name="source7">Seventh observable source.</param>
  2207. /// <param name="source8">Eighth observable source.</param>
  2208. /// <param name="source9">Ninth observable source.</param>
  2209. /// <param name="source10">Tenth observable source.</param>
  2210. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2211. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2212. /// <exception cref="ArgumentNullException">
  2213. /// <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>
  2214. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  2215. 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)
  2216. {
  2217. if (source1 == null)
  2218. throw new ArgumentNullException(nameof(source1));
  2219. if (source2 == null)
  2220. throw new ArgumentNullException(nameof(source2));
  2221. if (source3 == null)
  2222. throw new ArgumentNullException(nameof(source3));
  2223. if (source4 == null)
  2224. throw new ArgumentNullException(nameof(source4));
  2225. if (source5 == null)
  2226. throw new ArgumentNullException(nameof(source5));
  2227. if (source6 == null)
  2228. throw new ArgumentNullException(nameof(source6));
  2229. if (source7 == null)
  2230. throw new ArgumentNullException(nameof(source7));
  2231. if (source8 == null)
  2232. throw new ArgumentNullException(nameof(source8));
  2233. if (source9 == null)
  2234. throw new ArgumentNullException(nameof(source9));
  2235. if (source10 == null)
  2236. throw new ArgumentNullException(nameof(source10));
  2237. if (resultSelector == null)
  2238. throw new ArgumentNullException(nameof(resultSelector));
  2239. return source1.Provider.CreateQuery<TResult>(
  2240. Expression.Call(
  2241. null,
  2242. #if CRIPPLED_REFLECTION
  2243. 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>>))),
  2244. #else
  2245. ((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)),
  2246. #endif
  2247. source1.Expression,
  2248. GetSourceExpression(source2),
  2249. GetSourceExpression(source3),
  2250. GetSourceExpression(source4),
  2251. GetSourceExpression(source5),
  2252. GetSourceExpression(source6),
  2253. GetSourceExpression(source7),
  2254. GetSourceExpression(source8),
  2255. GetSourceExpression(source9),
  2256. GetSourceExpression(source10),
  2257. resultSelector
  2258. )
  2259. );
  2260. }
  2261. /// <summary>
  2262. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2263. /// </summary>
  2264. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2265. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2266. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2267. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2268. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2269. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2270. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2271. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2272. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2273. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2274. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2275. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2276. /// <param name="source1">First observable source.</param>
  2277. /// <param name="source2">Second observable source.</param>
  2278. /// <param name="source3">Third observable source.</param>
  2279. /// <param name="source4">Fourth observable source.</param>
  2280. /// <param name="source5">Fifth observable source.</param>
  2281. /// <param name="source6">Sixth observable source.</param>
  2282. /// <param name="source7">Seventh observable source.</param>
  2283. /// <param name="source8">Eighth observable source.</param>
  2284. /// <param name="source9">Ninth observable source.</param>
  2285. /// <param name="source10">Tenth observable source.</param>
  2286. /// <param name="source11">Eleventh observable source.</param>
  2287. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2288. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2289. /// <exception cref="ArgumentNullException">
  2290. /// <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>
  2291. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  2292. 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)
  2293. {
  2294. if (source1 == null)
  2295. throw new ArgumentNullException(nameof(source1));
  2296. if (source2 == null)
  2297. throw new ArgumentNullException(nameof(source2));
  2298. if (source3 == null)
  2299. throw new ArgumentNullException(nameof(source3));
  2300. if (source4 == null)
  2301. throw new ArgumentNullException(nameof(source4));
  2302. if (source5 == null)
  2303. throw new ArgumentNullException(nameof(source5));
  2304. if (source6 == null)
  2305. throw new ArgumentNullException(nameof(source6));
  2306. if (source7 == null)
  2307. throw new ArgumentNullException(nameof(source7));
  2308. if (source8 == null)
  2309. throw new ArgumentNullException(nameof(source8));
  2310. if (source9 == null)
  2311. throw new ArgumentNullException(nameof(source9));
  2312. if (source10 == null)
  2313. throw new ArgumentNullException(nameof(source10));
  2314. if (source11 == null)
  2315. throw new ArgumentNullException(nameof(source11));
  2316. if (resultSelector == null)
  2317. throw new ArgumentNullException(nameof(resultSelector));
  2318. return source1.Provider.CreateQuery<TResult>(
  2319. Expression.Call(
  2320. null,
  2321. #if CRIPPLED_REFLECTION
  2322. 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>>))),
  2323. #else
  2324. ((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)),
  2325. #endif
  2326. source1.Expression,
  2327. GetSourceExpression(source2),
  2328. GetSourceExpression(source3),
  2329. GetSourceExpression(source4),
  2330. GetSourceExpression(source5),
  2331. GetSourceExpression(source6),
  2332. GetSourceExpression(source7),
  2333. GetSourceExpression(source8),
  2334. GetSourceExpression(source9),
  2335. GetSourceExpression(source10),
  2336. GetSourceExpression(source11),
  2337. resultSelector
  2338. )
  2339. );
  2340. }
  2341. /// <summary>
  2342. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2343. /// </summary>
  2344. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2345. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2346. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2347. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2348. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2349. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2350. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2351. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2352. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2353. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2354. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2355. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2356. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2357. /// <param name="source1">First observable source.</param>
  2358. /// <param name="source2">Second observable source.</param>
  2359. /// <param name="source3">Third observable source.</param>
  2360. /// <param name="source4">Fourth observable source.</param>
  2361. /// <param name="source5">Fifth observable source.</param>
  2362. /// <param name="source6">Sixth observable source.</param>
  2363. /// <param name="source7">Seventh observable source.</param>
  2364. /// <param name="source8">Eighth observable source.</param>
  2365. /// <param name="source9">Ninth observable source.</param>
  2366. /// <param name="source10">Tenth observable source.</param>
  2367. /// <param name="source11">Eleventh observable source.</param>
  2368. /// <param name="source12">Twelfth observable source.</param>
  2369. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2370. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2371. /// <exception cref="ArgumentNullException">
  2372. /// <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>
  2373. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  2374. 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)
  2375. {
  2376. if (source1 == null)
  2377. throw new ArgumentNullException(nameof(source1));
  2378. if (source2 == null)
  2379. throw new ArgumentNullException(nameof(source2));
  2380. if (source3 == null)
  2381. throw new ArgumentNullException(nameof(source3));
  2382. if (source4 == null)
  2383. throw new ArgumentNullException(nameof(source4));
  2384. if (source5 == null)
  2385. throw new ArgumentNullException(nameof(source5));
  2386. if (source6 == null)
  2387. throw new ArgumentNullException(nameof(source6));
  2388. if (source7 == null)
  2389. throw new ArgumentNullException(nameof(source7));
  2390. if (source8 == null)
  2391. throw new ArgumentNullException(nameof(source8));
  2392. if (source9 == null)
  2393. throw new ArgumentNullException(nameof(source9));
  2394. if (source10 == null)
  2395. throw new ArgumentNullException(nameof(source10));
  2396. if (source11 == null)
  2397. throw new ArgumentNullException(nameof(source11));
  2398. if (source12 == null)
  2399. throw new ArgumentNullException(nameof(source12));
  2400. if (resultSelector == null)
  2401. throw new ArgumentNullException(nameof(resultSelector));
  2402. return source1.Provider.CreateQuery<TResult>(
  2403. Expression.Call(
  2404. null,
  2405. #if CRIPPLED_REFLECTION
  2406. 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>>))),
  2407. #else
  2408. ((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)),
  2409. #endif
  2410. source1.Expression,
  2411. GetSourceExpression(source2),
  2412. GetSourceExpression(source3),
  2413. GetSourceExpression(source4),
  2414. GetSourceExpression(source5),
  2415. GetSourceExpression(source6),
  2416. GetSourceExpression(source7),
  2417. GetSourceExpression(source8),
  2418. GetSourceExpression(source9),
  2419. GetSourceExpression(source10),
  2420. GetSourceExpression(source11),
  2421. GetSourceExpression(source12),
  2422. resultSelector
  2423. )
  2424. );
  2425. }
  2426. /// <summary>
  2427. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2428. /// </summary>
  2429. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2430. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2431. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2432. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2433. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2434. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2435. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2436. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2437. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2438. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2439. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2440. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2441. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2442. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2443. /// <param name="source1">First observable source.</param>
  2444. /// <param name="source2">Second observable source.</param>
  2445. /// <param name="source3">Third observable source.</param>
  2446. /// <param name="source4">Fourth observable source.</param>
  2447. /// <param name="source5">Fifth observable source.</param>
  2448. /// <param name="source6">Sixth observable source.</param>
  2449. /// <param name="source7">Seventh observable source.</param>
  2450. /// <param name="source8">Eighth observable source.</param>
  2451. /// <param name="source9">Ninth observable source.</param>
  2452. /// <param name="source10">Tenth observable source.</param>
  2453. /// <param name="source11">Eleventh observable source.</param>
  2454. /// <param name="source12">Twelfth observable source.</param>
  2455. /// <param name="source13">Thirteenth observable source.</param>
  2456. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2457. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2458. /// <exception cref="ArgumentNullException">
  2459. /// <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>
  2460. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  2461. 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)
  2462. {
  2463. if (source1 == null)
  2464. throw new ArgumentNullException(nameof(source1));
  2465. if (source2 == null)
  2466. throw new ArgumentNullException(nameof(source2));
  2467. if (source3 == null)
  2468. throw new ArgumentNullException(nameof(source3));
  2469. if (source4 == null)
  2470. throw new ArgumentNullException(nameof(source4));
  2471. if (source5 == null)
  2472. throw new ArgumentNullException(nameof(source5));
  2473. if (source6 == null)
  2474. throw new ArgumentNullException(nameof(source6));
  2475. if (source7 == null)
  2476. throw new ArgumentNullException(nameof(source7));
  2477. if (source8 == null)
  2478. throw new ArgumentNullException(nameof(source8));
  2479. if (source9 == null)
  2480. throw new ArgumentNullException(nameof(source9));
  2481. if (source10 == null)
  2482. throw new ArgumentNullException(nameof(source10));
  2483. if (source11 == null)
  2484. throw new ArgumentNullException(nameof(source11));
  2485. if (source12 == null)
  2486. throw new ArgumentNullException(nameof(source12));
  2487. if (source13 == null)
  2488. throw new ArgumentNullException(nameof(source13));
  2489. if (resultSelector == null)
  2490. throw new ArgumentNullException(nameof(resultSelector));
  2491. return source1.Provider.CreateQuery<TResult>(
  2492. Expression.Call(
  2493. null,
  2494. #if CRIPPLED_REFLECTION
  2495. 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>>))),
  2496. #else
  2497. ((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)),
  2498. #endif
  2499. source1.Expression,
  2500. GetSourceExpression(source2),
  2501. GetSourceExpression(source3),
  2502. GetSourceExpression(source4),
  2503. GetSourceExpression(source5),
  2504. GetSourceExpression(source6),
  2505. GetSourceExpression(source7),
  2506. GetSourceExpression(source8),
  2507. GetSourceExpression(source9),
  2508. GetSourceExpression(source10),
  2509. GetSourceExpression(source11),
  2510. GetSourceExpression(source12),
  2511. GetSourceExpression(source13),
  2512. resultSelector
  2513. )
  2514. );
  2515. }
  2516. /// <summary>
  2517. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2518. /// </summary>
  2519. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2520. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2521. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2522. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2523. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2524. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2525. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2526. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2527. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2528. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2529. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2530. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2531. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2532. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2533. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2534. /// <param name="source1">First observable source.</param>
  2535. /// <param name="source2">Second observable source.</param>
  2536. /// <param name="source3">Third observable source.</param>
  2537. /// <param name="source4">Fourth observable source.</param>
  2538. /// <param name="source5">Fifth observable source.</param>
  2539. /// <param name="source6">Sixth observable source.</param>
  2540. /// <param name="source7">Seventh observable source.</param>
  2541. /// <param name="source8">Eighth observable source.</param>
  2542. /// <param name="source9">Ninth observable source.</param>
  2543. /// <param name="source10">Tenth observable source.</param>
  2544. /// <param name="source11">Eleventh observable source.</param>
  2545. /// <param name="source12">Twelfth observable source.</param>
  2546. /// <param name="source13">Thirteenth observable source.</param>
  2547. /// <param name="source14">Fourteenth observable source.</param>
  2548. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2549. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2550. /// <exception cref="ArgumentNullException">
  2551. /// <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>
  2552. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  2553. 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)
  2554. {
  2555. if (source1 == null)
  2556. throw new ArgumentNullException(nameof(source1));
  2557. if (source2 == null)
  2558. throw new ArgumentNullException(nameof(source2));
  2559. if (source3 == null)
  2560. throw new ArgumentNullException(nameof(source3));
  2561. if (source4 == null)
  2562. throw new ArgumentNullException(nameof(source4));
  2563. if (source5 == null)
  2564. throw new ArgumentNullException(nameof(source5));
  2565. if (source6 == null)
  2566. throw new ArgumentNullException(nameof(source6));
  2567. if (source7 == null)
  2568. throw new ArgumentNullException(nameof(source7));
  2569. if (source8 == null)
  2570. throw new ArgumentNullException(nameof(source8));
  2571. if (source9 == null)
  2572. throw new ArgumentNullException(nameof(source9));
  2573. if (source10 == null)
  2574. throw new ArgumentNullException(nameof(source10));
  2575. if (source11 == null)
  2576. throw new ArgumentNullException(nameof(source11));
  2577. if (source12 == null)
  2578. throw new ArgumentNullException(nameof(source12));
  2579. if (source13 == null)
  2580. throw new ArgumentNullException(nameof(source13));
  2581. if (source14 == null)
  2582. throw new ArgumentNullException(nameof(source14));
  2583. if (resultSelector == null)
  2584. throw new ArgumentNullException(nameof(resultSelector));
  2585. return source1.Provider.CreateQuery<TResult>(
  2586. Expression.Call(
  2587. null,
  2588. #if CRIPPLED_REFLECTION
  2589. 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>>))),
  2590. #else
  2591. ((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)),
  2592. #endif
  2593. source1.Expression,
  2594. GetSourceExpression(source2),
  2595. GetSourceExpression(source3),
  2596. GetSourceExpression(source4),
  2597. GetSourceExpression(source5),
  2598. GetSourceExpression(source6),
  2599. GetSourceExpression(source7),
  2600. GetSourceExpression(source8),
  2601. GetSourceExpression(source9),
  2602. GetSourceExpression(source10),
  2603. GetSourceExpression(source11),
  2604. GetSourceExpression(source12),
  2605. GetSourceExpression(source13),
  2606. GetSourceExpression(source14),
  2607. resultSelector
  2608. )
  2609. );
  2610. }
  2611. /// <summary>
  2612. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2613. /// </summary>
  2614. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2615. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2616. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2617. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2618. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2619. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2620. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2621. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2622. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2623. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2624. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2625. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2626. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2627. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2628. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2629. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2630. /// <param name="source1">First observable source.</param>
  2631. /// <param name="source2">Second observable source.</param>
  2632. /// <param name="source3">Third observable source.</param>
  2633. /// <param name="source4">Fourth observable source.</param>
  2634. /// <param name="source5">Fifth observable source.</param>
  2635. /// <param name="source6">Sixth observable source.</param>
  2636. /// <param name="source7">Seventh observable source.</param>
  2637. /// <param name="source8">Eighth observable source.</param>
  2638. /// <param name="source9">Ninth observable source.</param>
  2639. /// <param name="source10">Tenth observable source.</param>
  2640. /// <param name="source11">Eleventh observable source.</param>
  2641. /// <param name="source12">Twelfth observable source.</param>
  2642. /// <param name="source13">Thirteenth observable source.</param>
  2643. /// <param name="source14">Fourteenth observable source.</param>
  2644. /// <param name="source15">Fifteenth observable source.</param>
  2645. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2646. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2647. /// <exception cref="ArgumentNullException">
  2648. /// <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>
  2649. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  2650. 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)
  2651. {
  2652. if (source1 == null)
  2653. throw new ArgumentNullException(nameof(source1));
  2654. if (source2 == null)
  2655. throw new ArgumentNullException(nameof(source2));
  2656. if (source3 == null)
  2657. throw new ArgumentNullException(nameof(source3));
  2658. if (source4 == null)
  2659. throw new ArgumentNullException(nameof(source4));
  2660. if (source5 == null)
  2661. throw new ArgumentNullException(nameof(source5));
  2662. if (source6 == null)
  2663. throw new ArgumentNullException(nameof(source6));
  2664. if (source7 == null)
  2665. throw new ArgumentNullException(nameof(source7));
  2666. if (source8 == null)
  2667. throw new ArgumentNullException(nameof(source8));
  2668. if (source9 == null)
  2669. throw new ArgumentNullException(nameof(source9));
  2670. if (source10 == null)
  2671. throw new ArgumentNullException(nameof(source10));
  2672. if (source11 == null)
  2673. throw new ArgumentNullException(nameof(source11));
  2674. if (source12 == null)
  2675. throw new ArgumentNullException(nameof(source12));
  2676. if (source13 == null)
  2677. throw new ArgumentNullException(nameof(source13));
  2678. if (source14 == null)
  2679. throw new ArgumentNullException(nameof(source14));
  2680. if (source15 == null)
  2681. throw new ArgumentNullException(nameof(source15));
  2682. if (resultSelector == null)
  2683. throw new ArgumentNullException(nameof(resultSelector));
  2684. return source1.Provider.CreateQuery<TResult>(
  2685. Expression.Call(
  2686. null,
  2687. #if CRIPPLED_REFLECTION
  2688. 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>>))),
  2689. #else
  2690. ((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)),
  2691. #endif
  2692. source1.Expression,
  2693. GetSourceExpression(source2),
  2694. GetSourceExpression(source3),
  2695. GetSourceExpression(source4),
  2696. GetSourceExpression(source5),
  2697. GetSourceExpression(source6),
  2698. GetSourceExpression(source7),
  2699. GetSourceExpression(source8),
  2700. GetSourceExpression(source9),
  2701. GetSourceExpression(source10),
  2702. GetSourceExpression(source11),
  2703. GetSourceExpression(source12),
  2704. GetSourceExpression(source13),
  2705. GetSourceExpression(source14),
  2706. GetSourceExpression(source15),
  2707. resultSelector
  2708. )
  2709. );
  2710. }
  2711. /// <summary>
  2712. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2713. /// </summary>
  2714. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2715. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2716. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2717. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2718. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2719. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2720. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2721. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2722. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2723. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2724. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2725. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2726. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2727. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2728. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2729. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  2730. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2731. /// <param name="source1">First observable source.</param>
  2732. /// <param name="source2">Second observable source.</param>
  2733. /// <param name="source3">Third observable source.</param>
  2734. /// <param name="source4">Fourth observable source.</param>
  2735. /// <param name="source5">Fifth observable source.</param>
  2736. /// <param name="source6">Sixth observable source.</param>
  2737. /// <param name="source7">Seventh observable source.</param>
  2738. /// <param name="source8">Eighth observable source.</param>
  2739. /// <param name="source9">Ninth observable source.</param>
  2740. /// <param name="source10">Tenth observable source.</param>
  2741. /// <param name="source11">Eleventh observable source.</param>
  2742. /// <param name="source12">Twelfth observable source.</param>
  2743. /// <param name="source13">Thirteenth observable source.</param>
  2744. /// <param name="source14">Fourteenth observable source.</param>
  2745. /// <param name="source15">Fifteenth observable source.</param>
  2746. /// <param name="source16">Sixteenth observable source.</param>
  2747. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2748. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2749. /// <exception cref="ArgumentNullException">
  2750. /// <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>
  2751. /// <remarks>If a non-empty source completes, its very last value will be used for creating subsequent combinations until all sources terminate.</remarks>
  2752. 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)
  2753. {
  2754. if (source1 == null)
  2755. throw new ArgumentNullException(nameof(source1));
  2756. if (source2 == null)
  2757. throw new ArgumentNullException(nameof(source2));
  2758. if (source3 == null)
  2759. throw new ArgumentNullException(nameof(source3));
  2760. if (source4 == null)
  2761. throw new ArgumentNullException(nameof(source4));
  2762. if (source5 == null)
  2763. throw new ArgumentNullException(nameof(source5));
  2764. if (source6 == null)
  2765. throw new ArgumentNullException(nameof(source6));
  2766. if (source7 == null)
  2767. throw new ArgumentNullException(nameof(source7));
  2768. if (source8 == null)
  2769. throw new ArgumentNullException(nameof(source8));
  2770. if (source9 == null)
  2771. throw new ArgumentNullException(nameof(source9));
  2772. if (source10 == null)
  2773. throw new ArgumentNullException(nameof(source10));
  2774. if (source11 == null)
  2775. throw new ArgumentNullException(nameof(source11));
  2776. if (source12 == null)
  2777. throw new ArgumentNullException(nameof(source12));
  2778. if (source13 == null)
  2779. throw new ArgumentNullException(nameof(source13));
  2780. if (source14 == null)
  2781. throw new ArgumentNullException(nameof(source14));
  2782. if (source15 == null)
  2783. throw new ArgumentNullException(nameof(source15));
  2784. if (source16 == null)
  2785. throw new ArgumentNullException(nameof(source16));
  2786. if (resultSelector == null)
  2787. throw new ArgumentNullException(nameof(resultSelector));
  2788. return source1.Provider.CreateQuery<TResult>(
  2789. Expression.Call(
  2790. null,
  2791. #if CRIPPLED_REFLECTION
  2792. 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>>))),
  2793. #else
  2794. ((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)),
  2795. #endif
  2796. source1.Expression,
  2797. GetSourceExpression(source2),
  2798. GetSourceExpression(source3),
  2799. GetSourceExpression(source4),
  2800. GetSourceExpression(source5),
  2801. GetSourceExpression(source6),
  2802. GetSourceExpression(source7),
  2803. GetSourceExpression(source8),
  2804. GetSourceExpression(source9),
  2805. GetSourceExpression(source10),
  2806. GetSourceExpression(source11),
  2807. GetSourceExpression(source12),
  2808. GetSourceExpression(source13),
  2809. GetSourceExpression(source14),
  2810. GetSourceExpression(source15),
  2811. GetSourceExpression(source16),
  2812. resultSelector
  2813. )
  2814. );
  2815. }
  2816. /// <summary>
  2817. /// Concatenates the second observable sequence to the first observable sequence upon successful termination of the first.
  2818. /// </summary>
  2819. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2820. /// <param name="first">First observable sequence.</param>
  2821. /// <param name="second">Second observable sequence.</param>
  2822. /// <returns>An observable sequence that contains the elements of the first sequence, followed by those of the second the sequence.</returns>
  2823. /// <exception cref="ArgumentNullException">
  2824. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  2825. public static IQbservable<TSource> Concat<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  2826. {
  2827. if (first == null)
  2828. throw new ArgumentNullException(nameof(first));
  2829. if (second == null)
  2830. throw new ArgumentNullException(nameof(second));
  2831. return first.Provider.CreateQuery<TSource>(
  2832. Expression.Call(
  2833. null,
  2834. #if CRIPPLED_REFLECTION
  2835. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  2836. #else
  2837. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2838. #endif
  2839. first.Expression,
  2840. GetSourceExpression(second)
  2841. )
  2842. );
  2843. }
  2844. /// <summary>
  2845. /// Concatenates all of the specified observable sequences, as long as the previous observable sequence terminated successfully.
  2846. /// </summary>
  2847. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  2848. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2849. /// <param name="sources">Observable sequences to concatenate.</param>
  2850. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2851. /// <exception cref="ArgumentNullException">
  2852. /// <paramref name="sources" /> is null.</exception>
  2853. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  2854. {
  2855. if (provider == null)
  2856. throw new ArgumentNullException(nameof(provider));
  2857. if (sources == null)
  2858. throw new ArgumentNullException(nameof(sources));
  2859. return provider.CreateQuery<TSource>(
  2860. Expression.Call(
  2861. null,
  2862. #if CRIPPLED_REFLECTION
  2863. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  2864. #else
  2865. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2866. #endif
  2867. Expression.Constant(provider, typeof(IQbservableProvider)),
  2868. GetSourceExpression(sources)
  2869. )
  2870. );
  2871. }
  2872. /// <summary>
  2873. /// Concatenates all observable sequences in the given enumerable sequence, as long as the previous observable sequence terminated successfully.
  2874. /// </summary>
  2875. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  2876. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2877. /// <param name="sources">Observable sequences to concatenate.</param>
  2878. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2879. /// <exception cref="ArgumentNullException">
  2880. /// <paramref name="sources" /> is null.</exception>
  2881. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  2882. {
  2883. if (provider == null)
  2884. throw new ArgumentNullException(nameof(provider));
  2885. if (sources == null)
  2886. throw new ArgumentNullException(nameof(sources));
  2887. return provider.CreateQuery<TSource>(
  2888. Expression.Call(
  2889. null,
  2890. #if CRIPPLED_REFLECTION
  2891. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  2892. #else
  2893. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2894. #endif
  2895. Expression.Constant(provider, typeof(IQbservableProvider)),
  2896. GetSourceExpression(sources)
  2897. )
  2898. );
  2899. }
  2900. /// <summary>
  2901. /// Concatenates all inner observable sequences, as long as the previous observable sequence terminated successfully.
  2902. /// </summary>
  2903. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2904. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  2905. /// <returns>An observable sequence that contains the elements of each observed inner sequence, in sequential order.</returns>
  2906. /// <exception cref="ArgumentNullException">
  2907. /// <paramref name="sources" /> is null.</exception>
  2908. public static IQbservable<TSource> Concat<TSource>(this IQbservable<IObservable<TSource>> sources)
  2909. {
  2910. if (sources == null)
  2911. throw new ArgumentNullException(nameof(sources));
  2912. return sources.Provider.CreateQuery<TSource>(
  2913. Expression.Call(
  2914. null,
  2915. #if CRIPPLED_REFLECTION
  2916. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<IObservable<TSource>>))),
  2917. #else
  2918. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2919. #endif
  2920. sources.Expression
  2921. )
  2922. );
  2923. }
  2924. /// <summary>
  2925. /// Concatenates all task results, as long as the previous task terminated successfully.
  2926. /// </summary>
  2927. /// <typeparam name="TSource">The type of the results produced by the tasks.</typeparam>
  2928. /// <param name="sources">Observable sequence of tasks.</param>
  2929. /// <returns>An observable sequence that contains the results of each task, in sequential order.</returns>
  2930. /// <exception cref="ArgumentNullException">
  2931. /// <paramref name="sources" /> is null.</exception>
  2932. /// <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>
  2933. public static IQbservable<TSource> Concat<TSource>(this IQbservable<Task<TSource>> sources)
  2934. {
  2935. if (sources == null)
  2936. throw new ArgumentNullException(nameof(sources));
  2937. return sources.Provider.CreateQuery<TSource>(
  2938. Expression.Call(
  2939. null,
  2940. #if CRIPPLED_REFLECTION
  2941. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<Task<TSource>>))),
  2942. #else
  2943. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2944. #endif
  2945. sources.Expression
  2946. )
  2947. );
  2948. }
  2949. /// <summary>
  2950. /// Determines whether an observable sequence contains a specified element by using the default equality comparer.
  2951. /// </summary>
  2952. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2953. /// <param name="source">An observable sequence in which to locate a value.</param>
  2954. /// <param name="value">The value to locate in the source sequence.</param>
  2955. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2956. /// <exception cref="ArgumentNullException">
  2957. /// <paramref name="source" /> is null.</exception>
  2958. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2959. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value)
  2960. {
  2961. if (source == null)
  2962. throw new ArgumentNullException(nameof(source));
  2963. return source.Provider.CreateQuery<bool>(
  2964. Expression.Call(
  2965. null,
  2966. #if CRIPPLED_REFLECTION
  2967. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource))),
  2968. #else
  2969. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2970. #endif
  2971. source.Expression,
  2972. Expression.Constant(value, typeof(TSource))
  2973. )
  2974. );
  2975. }
  2976. /// <summary>
  2977. /// Determines whether an observable sequence contains a specified element by using a specified System.Collections.Generic.IEqualityComparer{T}.
  2978. /// </summary>
  2979. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2980. /// <param name="source">An observable sequence in which to locate a value.</param>
  2981. /// <param name="value">The value to locate in the source sequence.</param>
  2982. /// <param name="comparer">An equality comparer to compare elements.</param>
  2983. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2984. /// <exception cref="ArgumentNullException">
  2985. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  2986. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2987. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
  2988. {
  2989. if (source == null)
  2990. throw new ArgumentNullException(nameof(source));
  2991. if (comparer == null)
  2992. throw new ArgumentNullException(nameof(comparer));
  2993. return source.Provider.CreateQuery<bool>(
  2994. Expression.Call(
  2995. null,
  2996. #if CRIPPLED_REFLECTION
  2997. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource), default(IEqualityComparer<TSource>))),
  2998. #else
  2999. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3000. #endif
  3001. source.Expression,
  3002. Expression.Constant(value, typeof(TSource)),
  3003. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  3004. )
  3005. );
  3006. }
  3007. /// <summary>
  3008. /// Returns an observable sequence containing an <see cref="int" /> that represents the total number of elements in an observable sequence.
  3009. /// </summary>
  3010. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3011. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  3012. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  3013. /// <exception cref="ArgumentNullException">
  3014. /// <paramref name="source" /> is null.</exception>
  3015. /// <exception cref="OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  3016. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  3017. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source)
  3018. {
  3019. if (source == null)
  3020. throw new ArgumentNullException(nameof(source));
  3021. return source.Provider.CreateQuery<int>(
  3022. Expression.Call(
  3023. null,
  3024. #if CRIPPLED_REFLECTION
  3025. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>))),
  3026. #else
  3027. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3028. #endif
  3029. source.Expression
  3030. )
  3031. );
  3032. }
  3033. /// <summary>
  3034. /// Returns an observable sequence containing an <see cref="int" /> that represents how many elements in the specified observable sequence satisfy a condition.
  3035. /// </summary>
  3036. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3037. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  3038. /// <param name="predicate">A function to test each element for a condition.</param>
  3039. /// <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>
  3040. /// <exception cref="ArgumentNullException">
  3041. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  3042. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  3043. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  3044. {
  3045. if (source == null)
  3046. throw new ArgumentNullException(nameof(source));
  3047. if (predicate == null)
  3048. throw new ArgumentNullException(nameof(predicate));
  3049. return source.Provider.CreateQuery<int>(
  3050. Expression.Call(
  3051. null,
  3052. #if CRIPPLED_REFLECTION
  3053. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  3054. #else
  3055. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3056. #endif
  3057. source.Expression,
  3058. predicate
  3059. )
  3060. );
  3061. }
  3062. /// <summary>
  3063. /// Creates an observable sequence from a specified Subscribe method implementation.
  3064. /// </summary>
  3065. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3066. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3067. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method.</param>
  3068. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3069. /// <exception cref="ArgumentNullException">
  3070. /// <paramref name="subscribe" /> is null.</exception>
  3071. /// <remarks>
  3072. /// Use of this operator is preferred over manual implementation of the <see cref="IObservable{T}" /> interface. In case
  3073. /// you need a type implementing <see cref="IObservable{T}" /> rather than an anonymous implementation, consider using
  3074. /// the <see cref="T:System.Reactive.ObservableBase`1" /> abstract base class.
  3075. /// </remarks>
  3076. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, IDisposable>> subscribe)
  3077. {
  3078. if (provider == null)
  3079. throw new ArgumentNullException(nameof(provider));
  3080. if (subscribe == null)
  3081. throw new ArgumentNullException(nameof(subscribe));
  3082. return provider.CreateQuery<TResult>(
  3083. Expression.Call(
  3084. null,
  3085. #if CRIPPLED_REFLECTION
  3086. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, IDisposable>>))),
  3087. #else
  3088. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3089. #endif
  3090. Expression.Constant(provider, typeof(IQbservableProvider)),
  3091. subscribe
  3092. )
  3093. );
  3094. }
  3095. /// <summary>
  3096. /// Creates an observable sequence from a specified Subscribe method implementation.
  3097. /// </summary>
  3098. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3099. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3100. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable.</param>
  3101. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3102. /// <exception cref="ArgumentNullException">
  3103. /// <paramref name="subscribe" /> is null.</exception>
  3104. /// <remarks>
  3105. /// Use of this operator is preferred over manual implementation of the <see cref="IObservable{T}" /> interface. In case
  3106. /// you need a type implementing <see cref="IObservable{T}" /> rather than an anonymous implementation, consider using
  3107. /// the <see cref="T:System.Reactive.ObservableBase`1" /> abstract base class.
  3108. /// </remarks>
  3109. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Action>> subscribe)
  3110. {
  3111. if (provider == null)
  3112. throw new ArgumentNullException(nameof(provider));
  3113. if (subscribe == null)
  3114. throw new ArgumentNullException(nameof(subscribe));
  3115. return provider.CreateQuery<TResult>(
  3116. Expression.Call(
  3117. null,
  3118. #if CRIPPLED_REFLECTION
  3119. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Action>>))),
  3120. #else
  3121. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3122. #endif
  3123. Expression.Constant(provider, typeof(IQbservableProvider)),
  3124. subscribe
  3125. )
  3126. );
  3127. }
  3128. /// <summary>
  3129. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3130. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3131. /// </summary>
  3132. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3133. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3134. /// <param name="subscribeAsync">Asynchronous method used to produce elements.</param>
  3135. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3136. /// <exception cref="ArgumentNullException">
  3137. /// <paramref name="subscribeAsync" /> is null.</exception>
  3138. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3139. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3140. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task>> subscribeAsync)
  3141. {
  3142. if (provider == null)
  3143. throw new ArgumentNullException(nameof(provider));
  3144. if (subscribeAsync == null)
  3145. throw new ArgumentNullException(nameof(subscribeAsync));
  3146. return provider.CreateQuery<TResult>(
  3147. Expression.Call(
  3148. null,
  3149. #if CRIPPLED_REFLECTION
  3150. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task>>))),
  3151. #else
  3152. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3153. #endif
  3154. Expression.Constant(provider, typeof(IQbservableProvider)),
  3155. subscribeAsync
  3156. )
  3157. );
  3158. }
  3159. /// <summary>
  3160. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3161. /// </summary>
  3162. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3163. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3164. /// <param name="subscribeAsync">Asynchronous method used to produce elements.</param>
  3165. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3166. /// <exception cref="ArgumentNullException">
  3167. /// <paramref name="subscribeAsync" /> is null.</exception>
  3168. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3169. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task>> subscribeAsync)
  3170. {
  3171. if (provider == null)
  3172. throw new ArgumentNullException(nameof(provider));
  3173. if (subscribeAsync == null)
  3174. throw new ArgumentNullException(nameof(subscribeAsync));
  3175. return provider.CreateQuery<TResult>(
  3176. Expression.Call(
  3177. null,
  3178. #if CRIPPLED_REFLECTION
  3179. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task>>))),
  3180. #else
  3181. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3182. #endif
  3183. Expression.Constant(provider, typeof(IQbservableProvider)),
  3184. subscribeAsync
  3185. )
  3186. );
  3187. }
  3188. /// <summary>
  3189. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3190. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3191. /// </summary>
  3192. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3193. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3194. /// <param name="subscribeAsync">Asynchronous method used to implement the resulting sequence's Subscribe method.</param>
  3195. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3196. /// <exception cref="ArgumentNullException">
  3197. /// <paramref name="subscribeAsync" /> is null.</exception>
  3198. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3199. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3200. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task<IDisposable>>> subscribeAsync)
  3201. {
  3202. if (provider == null)
  3203. throw new ArgumentNullException(nameof(provider));
  3204. if (subscribeAsync == null)
  3205. throw new ArgumentNullException(nameof(subscribeAsync));
  3206. return provider.CreateQuery<TResult>(
  3207. Expression.Call(
  3208. null,
  3209. #if CRIPPLED_REFLECTION
  3210. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task<IDisposable>>>))),
  3211. #else
  3212. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3213. #endif
  3214. Expression.Constant(provider, typeof(IQbservableProvider)),
  3215. subscribeAsync
  3216. )
  3217. );
  3218. }
  3219. /// <summary>
  3220. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3221. /// </summary>
  3222. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3223. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3224. /// <param name="subscribeAsync">Asynchronous method used to implement the resulting sequence's Subscribe method.</param>
  3225. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3226. /// <exception cref="ArgumentNullException">
  3227. /// <paramref name="subscribeAsync" /> is null.</exception>
  3228. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3229. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task<IDisposable>>> subscribeAsync)
  3230. {
  3231. if (provider == null)
  3232. throw new ArgumentNullException(nameof(provider));
  3233. if (subscribeAsync == null)
  3234. throw new ArgumentNullException(nameof(subscribeAsync));
  3235. return provider.CreateQuery<TResult>(
  3236. Expression.Call(
  3237. null,
  3238. #if CRIPPLED_REFLECTION
  3239. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task<IDisposable>>>))),
  3240. #else
  3241. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3242. #endif
  3243. Expression.Constant(provider, typeof(IQbservableProvider)),
  3244. subscribeAsync
  3245. )
  3246. );
  3247. }
  3248. /// <summary>
  3249. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3250. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3251. /// </summary>
  3252. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3253. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3254. /// <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>
  3255. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3256. /// <exception cref="ArgumentNullException">
  3257. /// <paramref name="subscribeAsync" /> is null.</exception>
  3258. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3259. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3260. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task<Action>>> subscribeAsync)
  3261. {
  3262. if (provider == null)
  3263. throw new ArgumentNullException(nameof(provider));
  3264. if (subscribeAsync == null)
  3265. throw new ArgumentNullException(nameof(subscribeAsync));
  3266. return provider.CreateQuery<TResult>(
  3267. Expression.Call(
  3268. null,
  3269. #if CRIPPLED_REFLECTION
  3270. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task<Action>>>))),
  3271. #else
  3272. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3273. #endif
  3274. Expression.Constant(provider, typeof(IQbservableProvider)),
  3275. subscribeAsync
  3276. )
  3277. );
  3278. }
  3279. /// <summary>
  3280. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3281. /// </summary>
  3282. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3283. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3284. /// <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>
  3285. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3286. /// <exception cref="ArgumentNullException">
  3287. /// <paramref name="subscribeAsync" /> is null.</exception>
  3288. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3289. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task<Action>>> subscribeAsync)
  3290. {
  3291. if (provider == null)
  3292. throw new ArgumentNullException(nameof(provider));
  3293. if (subscribeAsync == null)
  3294. throw new ArgumentNullException(nameof(subscribeAsync));
  3295. return provider.CreateQuery<TResult>(
  3296. Expression.Call(
  3297. null,
  3298. #if CRIPPLED_REFLECTION
  3299. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task<Action>>>))),
  3300. #else
  3301. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3302. #endif
  3303. Expression.Constant(provider, typeof(IQbservableProvider)),
  3304. subscribeAsync
  3305. )
  3306. );
  3307. }
  3308. /// <summary>
  3309. /// Returns the elements of the specified sequence or the type parameter's default 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), whose default value will be taken if the sequence is empty.</typeparam>
  3312. /// <param name="source">The sequence to return a default value for if it is empty.</param>
  3313. /// <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>
  3314. /// <exception cref="ArgumentNullException">
  3315. /// <paramref name="source" /> is null.</exception>
  3316. public static IQbservable<TSource?> DefaultIfEmpty<TSource>(this IQbservable<TSource> source)
  3317. {
  3318. if (source == null)
  3319. throw new ArgumentNullException(nameof(source));
  3320. return source.Provider.CreateQuery<TSource>(
  3321. Expression.Call(
  3322. null,
  3323. #if CRIPPLED_REFLECTION
  3324. InfoOf(() => Qbservable.DefaultIfEmpty<TSource>(default(IQbservable<TSource>))),
  3325. #else
  3326. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3327. #endif
  3328. source.Expression
  3329. )
  3330. );
  3331. }
  3332. /// <summary>
  3333. /// Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
  3334. /// </summary>
  3335. /// <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>
  3336. /// <param name="source">The sequence to return the specified value for if it is empty.</param>
  3337. /// <param name="defaultValue">The value to return if the sequence is empty.</param>
  3338. /// <returns>An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.</returns>
  3339. /// <exception cref="ArgumentNullException">
  3340. /// <paramref name="source" /> is null.</exception>
  3341. public static IQbservable<TSource> DefaultIfEmpty<TSource>(this IQbservable<TSource> source, TSource defaultValue)
  3342. {
  3343. if (source == null)
  3344. throw new ArgumentNullException(nameof(source));
  3345. return source.Provider.CreateQuery<TSource>(
  3346. Expression.Call(
  3347. null,
  3348. #if CRIPPLED_REFLECTION
  3349. InfoOf(() => Qbservable.DefaultIfEmpty<TSource>(default(IQbservable<TSource>), default(TSource))),
  3350. #else
  3351. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3352. #endif
  3353. source.Expression,
  3354. Expression.Constant(defaultValue, typeof(TSource))
  3355. )
  3356. );
  3357. }
  3358. /// <summary>
  3359. /// Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
  3360. /// </summary>
  3361. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3362. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3363. /// <param name="observableFactory">Observable factory function to invoke for each observer that subscribes to the resulting sequence.</param>
  3364. /// <returns>An observable sequence whose observers trigger an invocation of the given observable factory function.</returns>
  3365. /// <exception cref="ArgumentNullException">
  3366. /// <paramref name="observableFactory" /> is null.</exception>
  3367. public static IQbservable<TResult> Defer<TResult>(this IQbservableProvider provider, Expression<Func<IObservable<TResult>>> observableFactory)
  3368. {
  3369. if (provider == null)
  3370. throw new ArgumentNullException(nameof(provider));
  3371. if (observableFactory == null)
  3372. throw new ArgumentNullException(nameof(observableFactory));
  3373. return provider.CreateQuery<TResult>(
  3374. Expression.Call(
  3375. null,
  3376. #if CRIPPLED_REFLECTION
  3377. InfoOf(() => Qbservable.Defer<TResult>(default(IQbservableProvider), default(Expression<Func<IObservable<TResult>>>))),
  3378. #else
  3379. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3380. #endif
  3381. Expression.Constant(provider, typeof(IQbservableProvider)),
  3382. observableFactory
  3383. )
  3384. );
  3385. }
  3386. /// <summary>
  3387. /// Returns an observable sequence that starts the specified asynchronous factory function whenever a new observer subscribes.
  3388. /// </summary>
  3389. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3390. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3391. /// <param name="observableFactoryAsync">Asynchronous factory function to start for each observer that subscribes to the resulting sequence.</param>
  3392. /// <returns>An observable sequence whose observers trigger the given asynchronous observable factory function to be started.</returns>
  3393. /// <exception cref="ArgumentNullException">
  3394. /// <paramref name="observableFactoryAsync" /> is null.</exception>
  3395. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3396. public static IQbservable<TResult> Defer<TResult>(this IQbservableProvider provider, Expression<Func<Task<IObservable<TResult>>>> observableFactoryAsync)
  3397. {
  3398. if (provider == null)
  3399. throw new ArgumentNullException(nameof(provider));
  3400. if (observableFactoryAsync == null)
  3401. throw new ArgumentNullException(nameof(observableFactoryAsync));
  3402. return provider.CreateQuery<TResult>(
  3403. Expression.Call(
  3404. null,
  3405. #if CRIPPLED_REFLECTION
  3406. InfoOf(() => Qbservable.Defer<TResult>(default(IQbservableProvider), default(Expression<Func<Task<IObservable<TResult>>>>))),
  3407. #else
  3408. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3409. #endif
  3410. Expression.Constant(provider, typeof(IQbservableProvider)),
  3411. observableFactoryAsync
  3412. )
  3413. );
  3414. }
  3415. /// <summary>
  3416. /// Returns an observable sequence that starts the specified cancellable asynchronous factory function whenever a new observer subscribes.
  3417. /// The CancellationToken passed to the asynchronous factory function is tied to the returned disposable subscription, allowing best-effort cancellation.
  3418. /// </summary>
  3419. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3420. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3421. /// <param name="observableFactoryAsync">Asynchronous factory function to start for each observer that subscribes to the resulting sequence.</param>
  3422. /// <returns>An observable sequence whose observers trigger the given asynchronous observable factory function to be started.</returns>
  3423. /// <exception cref="ArgumentNullException">
  3424. /// <paramref name="observableFactoryAsync" /> is null.</exception>
  3425. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3426. /// <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>
  3427. public static IQbservable<TResult> DeferAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  3428. {
  3429. if (provider == null)
  3430. throw new ArgumentNullException(nameof(provider));
  3431. if (observableFactoryAsync == null)
  3432. throw new ArgumentNullException(nameof(observableFactoryAsync));
  3433. return provider.CreateQuery<TResult>(
  3434. Expression.Call(
  3435. null,
  3436. #if CRIPPLED_REFLECTION
  3437. InfoOf(() => Qbservable.DeferAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<IObservable<TResult>>>>))),
  3438. #else
  3439. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3440. #endif
  3441. Expression.Constant(provider, typeof(IQbservableProvider)),
  3442. observableFactoryAsync
  3443. )
  3444. );
  3445. }
  3446. /// <summary>
  3447. /// Time shifts the observable sequence to start propagating notifications at the specified absolute time.
  3448. /// The relative time intervals between the values are preserved.
  3449. /// </summary>
  3450. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3451. /// <param name="source">Source sequence to delay values for.</param>
  3452. /// <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>
  3453. /// <returns>Time-shifted sequence.</returns>
  3454. /// <exception cref="ArgumentNullException">
  3455. /// <paramref name="source" /> is null.</exception>
  3456. /// <remarks>
  3457. /// <para>
  3458. /// 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.
  3459. /// </para>
  3460. /// <para>
  3461. /// Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
  3462. /// </para>
  3463. /// <para>
  3464. /// 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.
  3465. /// 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>.
  3466. /// </para>
  3467. /// </remarks>
  3468. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  3469. {
  3470. if (source == null)
  3471. throw new ArgumentNullException(nameof(source));
  3472. return source.Provider.CreateQuery<TSource>(
  3473. Expression.Call(
  3474. null,
  3475. #if CRIPPLED_REFLECTION
  3476. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  3477. #else
  3478. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3479. #endif
  3480. source.Expression,
  3481. Expression.Constant(dueTime, typeof(DateTimeOffset))
  3482. )
  3483. );
  3484. }
  3485. /// <summary>
  3486. /// Time shifts the observable sequence to start propagating notifications at the specified absolute time, using the specified scheduler to run timers.
  3487. /// The relative time intervals between the values are preserved.
  3488. /// </summary>
  3489. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3490. /// <param name="source">Source sequence to delay values for.</param>
  3491. /// <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>
  3492. /// <param name="scheduler">Scheduler to run the delay timers on.</param>
  3493. /// <returns>Time-shifted sequence.</returns>
  3494. /// <exception cref="ArgumentNullException">
  3495. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3496. /// <remarks>
  3497. /// <para>
  3498. /// 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.
  3499. /// </para>
  3500. /// <para>
  3501. /// Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
  3502. /// </para>
  3503. /// <para>
  3504. /// 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.
  3505. /// 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>.
  3506. /// </para>
  3507. /// </remarks>
  3508. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  3509. {
  3510. if (source == null)
  3511. throw new ArgumentNullException(nameof(source));
  3512. if (scheduler == null)
  3513. throw new ArgumentNullException(nameof(scheduler));
  3514. return source.Provider.CreateQuery<TSource>(
  3515. Expression.Call(
  3516. null,
  3517. #if CRIPPLED_REFLECTION
  3518. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  3519. #else
  3520. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3521. #endif
  3522. source.Expression,
  3523. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  3524. Expression.Constant(scheduler, typeof(IScheduler))
  3525. )
  3526. );
  3527. }
  3528. /// <summary>
  3529. /// Time shifts the observable sequence by the specified relative time duration.
  3530. /// The relative time intervals between the values are preserved.
  3531. /// </summary>
  3532. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3533. /// <param name="source">Source sequence to delay values for.</param>
  3534. /// <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>
  3535. /// <returns>Time-shifted sequence.</returns>
  3536. /// <exception cref="ArgumentNullException">
  3537. /// <paramref name="source" /> is null.</exception>
  3538. /// <exception cref="ArgumentOutOfRangeException">
  3539. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3540. /// <remarks>
  3541. /// <para>
  3542. /// 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.
  3543. /// </para>
  3544. /// <para>
  3545. /// Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
  3546. /// </para>
  3547. /// <para>
  3548. /// 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.
  3549. /// 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>.
  3550. /// </para>
  3551. /// </remarks>
  3552. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  3553. {
  3554. if (source == null)
  3555. throw new ArgumentNullException(nameof(source));
  3556. return source.Provider.CreateQuery<TSource>(
  3557. Expression.Call(
  3558. null,
  3559. #if CRIPPLED_REFLECTION
  3560. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  3561. #else
  3562. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3563. #endif
  3564. source.Expression,
  3565. Expression.Constant(dueTime, typeof(TimeSpan))
  3566. )
  3567. );
  3568. }
  3569. /// <summary>
  3570. /// Time shifts the observable sequence by the specified relative time duration, using the specified scheduler to run timers.
  3571. /// The relative time intervals between the values are preserved.
  3572. /// </summary>
  3573. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3574. /// <param name="source">Source sequence to delay values for.</param>
  3575. /// <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>
  3576. /// <param name="scheduler">Scheduler to run the delay timers on.</param>
  3577. /// <returns>Time-shifted sequence.</returns>
  3578. /// <exception cref="ArgumentNullException">
  3579. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3580. /// <exception cref="ArgumentOutOfRangeException">
  3581. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3582. /// <remarks>
  3583. /// <para>
  3584. /// 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.
  3585. /// </para>
  3586. /// <para>
  3587. /// Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
  3588. /// </para>
  3589. /// <para>
  3590. /// 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.
  3591. /// </para>
  3592. /// <para>
  3593. /// 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.
  3594. /// 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>.
  3595. /// </para>
  3596. /// </remarks>
  3597. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  3598. {
  3599. if (source == null)
  3600. throw new ArgumentNullException(nameof(source));
  3601. if (scheduler == null)
  3602. throw new ArgumentNullException(nameof(scheduler));
  3603. return source.Provider.CreateQuery<TSource>(
  3604. Expression.Call(
  3605. null,
  3606. #if CRIPPLED_REFLECTION
  3607. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  3608. #else
  3609. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3610. #endif
  3611. source.Expression,
  3612. Expression.Constant(dueTime, typeof(TimeSpan)),
  3613. Expression.Constant(scheduler, typeof(IScheduler))
  3614. )
  3615. );
  3616. }
  3617. /// <summary>
  3618. /// Time shifts the observable sequence based on a delay selector function for each element.
  3619. /// </summary>
  3620. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3621. /// <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>
  3622. /// <param name="source">Source sequence to delay values for.</param>
  3623. /// <param name="delayDurationSelector">Selector function to retrieve a sequence indicating the delay for each given element.</param>
  3624. /// <returns>Time-shifted sequence.</returns>
  3625. /// <exception cref="ArgumentNullException">
  3626. /// <paramref name="source" /> or <paramref name="delayDurationSelector" /> is null.</exception>
  3627. public static IQbservable<TSource> Delay<TSource, TDelay>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TDelay>>> delayDurationSelector)
  3628. {
  3629. if (source == null)
  3630. throw new ArgumentNullException(nameof(source));
  3631. if (delayDurationSelector == null)
  3632. throw new ArgumentNullException(nameof(delayDurationSelector));
  3633. return source.Provider.CreateQuery<TSource>(
  3634. Expression.Call(
  3635. null,
  3636. #if CRIPPLED_REFLECTION
  3637. InfoOf(() => Qbservable.Delay<TSource, TDelay>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TDelay>>>))),
  3638. #else
  3639. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TDelay)),
  3640. #endif
  3641. source.Expression,
  3642. delayDurationSelector
  3643. )
  3644. );
  3645. }
  3646. /// <summary>
  3647. /// Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
  3648. /// </summary>
  3649. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3650. /// <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>
  3651. /// <param name="source">Source sequence to delay values for.</param>
  3652. /// <param name="subscriptionDelay">Sequence indicating the delay for the subscription to the source.</param>
  3653. /// <param name="delayDurationSelector">Selector function to retrieve a sequence indicating the delay for each given element.</param>
  3654. /// <returns>Time-shifted sequence.</returns>
  3655. /// <exception cref="ArgumentNullException">
  3656. /// <paramref name="source" /> or <paramref name="subscriptionDelay" /> or <paramref name="delayDurationSelector" /> is null.</exception>
  3657. public static IQbservable<TSource> Delay<TSource, TDelay>(this IQbservable<TSource> source, IObservable<TDelay> subscriptionDelay, Expression<Func<TSource, IObservable<TDelay>>> delayDurationSelector)
  3658. {
  3659. if (source == null)
  3660. throw new ArgumentNullException(nameof(source));
  3661. if (subscriptionDelay == null)
  3662. throw new ArgumentNullException(nameof(subscriptionDelay));
  3663. if (delayDurationSelector == null)
  3664. throw new ArgumentNullException(nameof(delayDurationSelector));
  3665. return source.Provider.CreateQuery<TSource>(
  3666. Expression.Call(
  3667. null,
  3668. #if CRIPPLED_REFLECTION
  3669. InfoOf(() => Qbservable.Delay<TSource, TDelay>(default(IQbservable<TSource>), default(IObservable<TDelay>), default(Expression<Func<TSource, IObservable<TDelay>>>))),
  3670. #else
  3671. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TDelay)),
  3672. #endif
  3673. source.Expression,
  3674. GetSourceExpression(subscriptionDelay),
  3675. delayDurationSelector
  3676. )
  3677. );
  3678. }
  3679. /// <summary>
  3680. /// Time shifts the observable sequence by delaying the subscription to the specified absolute time.
  3681. /// </summary>
  3682. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3683. /// <param name="source">Source sequence to delay subscription for.</param>
  3684. /// <param name="dueTime">Absolute time to perform the subscription at.</param>
  3685. /// <returns>Time-shifted sequence.</returns>
  3686. /// <exception cref="ArgumentNullException">
  3687. /// <paramref name="source" /> is null.</exception>
  3688. /// <remarks>
  3689. /// <para>
  3690. /// 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.
  3691. /// </para>
  3692. /// <para>
  3693. /// The side-effects of subscribing to the source sequence will be run on the default scheduler. Observer callbacks will not be affected.
  3694. /// </para>
  3695. /// </remarks>
  3696. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  3697. {
  3698. if (source == null)
  3699. throw new ArgumentNullException(nameof(source));
  3700. return source.Provider.CreateQuery<TSource>(
  3701. Expression.Call(
  3702. null,
  3703. #if CRIPPLED_REFLECTION
  3704. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  3705. #else
  3706. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3707. #endif
  3708. source.Expression,
  3709. Expression.Constant(dueTime, typeof(DateTimeOffset))
  3710. )
  3711. );
  3712. }
  3713. /// <summary>
  3714. /// Time shifts the observable sequence by delaying the subscription to the specified absolute time, using the specified scheduler to run timers.
  3715. /// </summary>
  3716. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3717. /// <param name="source">Source sequence to delay subscription for.</param>
  3718. /// <param name="dueTime">Absolute time to perform the subscription at.</param>
  3719. /// <param name="scheduler">Scheduler to run the subscription delay timer on.</param>
  3720. /// <returns>Time-shifted sequence.</returns>
  3721. /// <exception cref="ArgumentNullException">
  3722. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3723. /// <remarks>
  3724. /// <para>
  3725. /// 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.
  3726. /// </para>
  3727. /// <para>
  3728. /// The side-effects of subscribing to the source sequence will be run on the specified scheduler. Observer callbacks will not be affected.
  3729. /// </para>
  3730. /// </remarks>
  3731. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  3732. {
  3733. if (source == null)
  3734. throw new ArgumentNullException(nameof(source));
  3735. if (scheduler == null)
  3736. throw new ArgumentNullException(nameof(scheduler));
  3737. return source.Provider.CreateQuery<TSource>(
  3738. Expression.Call(
  3739. null,
  3740. #if CRIPPLED_REFLECTION
  3741. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  3742. #else
  3743. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3744. #endif
  3745. source.Expression,
  3746. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  3747. Expression.Constant(scheduler, typeof(IScheduler))
  3748. )
  3749. );
  3750. }
  3751. /// <summary>
  3752. /// Time shifts the observable sequence by delaying the subscription with the specified relative time duration.
  3753. /// </summary>
  3754. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3755. /// <param name="source">Source sequence to delay subscription for.</param>
  3756. /// <param name="dueTime">Relative time shift of the subscription.</param>
  3757. /// <returns>Time-shifted sequence.</returns>
  3758. /// <exception cref="ArgumentNullException">
  3759. /// <paramref name="source" /> is null.</exception>
  3760. /// <exception cref="ArgumentOutOfRangeException">
  3761. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3762. /// <remarks>
  3763. /// <para>
  3764. /// 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.
  3765. /// </para>
  3766. /// <para>
  3767. /// The side-effects of subscribing to the source sequence will be run on the default scheduler. Observer callbacks will not be affected.
  3768. /// </para>
  3769. /// </remarks>
  3770. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  3771. {
  3772. if (source == null)
  3773. throw new ArgumentNullException(nameof(source));
  3774. return source.Provider.CreateQuery<TSource>(
  3775. Expression.Call(
  3776. null,
  3777. #if CRIPPLED_REFLECTION
  3778. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  3779. #else
  3780. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3781. #endif
  3782. source.Expression,
  3783. Expression.Constant(dueTime, typeof(TimeSpan))
  3784. )
  3785. );
  3786. }
  3787. /// <summary>
  3788. /// Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.
  3789. /// </summary>
  3790. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3791. /// <param name="source">Source sequence to delay subscription for.</param>
  3792. /// <param name="dueTime">Relative time shift of the subscription.</param>
  3793. /// <param name="scheduler">Scheduler to run the subscription delay timer on.</param>
  3794. /// <returns>Time-shifted sequence.</returns>
  3795. /// <exception cref="ArgumentNullException">
  3796. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3797. /// <exception cref="ArgumentOutOfRangeException">
  3798. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3799. /// <remarks>
  3800. /// <para>
  3801. /// 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.
  3802. /// </para>
  3803. /// <para>
  3804. /// The side-effects of subscribing to the source sequence will be run on the specified scheduler. Observer callbacks will not be affected.
  3805. /// </para>
  3806. /// </remarks>
  3807. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  3808. {
  3809. if (source == null)
  3810. throw new ArgumentNullException(nameof(source));
  3811. if (scheduler == null)
  3812. throw new ArgumentNullException(nameof(scheduler));
  3813. return source.Provider.CreateQuery<TSource>(
  3814. Expression.Call(
  3815. null,
  3816. #if CRIPPLED_REFLECTION
  3817. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  3818. #else
  3819. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3820. #endif
  3821. source.Expression,
  3822. Expression.Constant(dueTime, typeof(TimeSpan)),
  3823. Expression.Constant(scheduler, typeof(IScheduler))
  3824. )
  3825. );
  3826. }
  3827. /// <summary>
  3828. /// Dematerializes the explicit notification values of an observable sequence as implicit notifications.
  3829. /// </summary>
  3830. /// <typeparam name="TSource">The type of the elements materialized in the source sequence notification objects.</typeparam>
  3831. /// <param name="source">An observable sequence containing explicit notification values which have to be turned into implicit notifications.</param>
  3832. /// <returns>An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.</returns>
  3833. /// <exception cref="ArgumentNullException">
  3834. /// <paramref name="source" /> is null.</exception>
  3835. public static IQbservable<TSource> Dematerialize<TSource>(this IQbservable<Notification<TSource>> source)
  3836. {
  3837. if (source == null)
  3838. throw new ArgumentNullException(nameof(source));
  3839. return source.Provider.CreateQuery<TSource>(
  3840. Expression.Call(
  3841. null,
  3842. #if CRIPPLED_REFLECTION
  3843. InfoOf(() => Qbservable.Dematerialize<TSource>(default(IQbservable<Notification<TSource>>))),
  3844. #else
  3845. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3846. #endif
  3847. source.Expression
  3848. )
  3849. );
  3850. }
  3851. /// <summary>
  3852. /// Returns an observable sequence that contains only distinct elements.
  3853. /// </summary>
  3854. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3855. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3856. /// <returns>An observable sequence only containing the distinct elements from the source sequence.</returns>
  3857. /// <exception cref="ArgumentNullException">
  3858. /// <paramref name="source" /> is null.</exception>
  3859. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3860. public static IQbservable<TSource> Distinct<TSource>(this IQbservable<TSource> source)
  3861. {
  3862. if (source == null)
  3863. throw new ArgumentNullException(nameof(source));
  3864. return source.Provider.CreateQuery<TSource>(
  3865. Expression.Call(
  3866. null,
  3867. #if CRIPPLED_REFLECTION
  3868. InfoOf(() => Qbservable.Distinct<TSource>(default(IQbservable<TSource>))),
  3869. #else
  3870. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3871. #endif
  3872. source.Expression
  3873. )
  3874. );
  3875. }
  3876. /// <summary>
  3877. /// Returns an observable sequence that contains only distinct elements according to the comparer.
  3878. /// </summary>
  3879. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3880. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3881. /// <param name="comparer">Equality comparer for source elements.</param>
  3882. /// <returns>An observable sequence only containing the distinct elements from the source sequence.</returns>
  3883. /// <exception cref="ArgumentNullException">
  3884. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  3885. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3886. public static IQbservable<TSource> Distinct<TSource>(this IQbservable<TSource> source, IEqualityComparer<TSource> comparer)
  3887. {
  3888. if (source == null)
  3889. throw new ArgumentNullException(nameof(source));
  3890. if (comparer == null)
  3891. throw new ArgumentNullException(nameof(comparer));
  3892. return source.Provider.CreateQuery<TSource>(
  3893. Expression.Call(
  3894. null,
  3895. #if CRIPPLED_REFLECTION
  3896. InfoOf(() => Qbservable.Distinct<TSource>(default(IQbservable<TSource>), default(IEqualityComparer<TSource>))),
  3897. #else
  3898. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3899. #endif
  3900. source.Expression,
  3901. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  3902. )
  3903. );
  3904. }
  3905. /// <summary>
  3906. /// Returns an observable sequence that contains only distinct elements according to the keySelector.
  3907. /// </summary>
  3908. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3909. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3910. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3911. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3912. /// <returns>An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.</returns>
  3913. /// <exception cref="ArgumentNullException">
  3914. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  3915. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3916. public static IQbservable<TSource> Distinct<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  3917. {
  3918. if (source == null)
  3919. throw new ArgumentNullException(nameof(source));
  3920. if (keySelector == null)
  3921. throw new ArgumentNullException(nameof(keySelector));
  3922. return source.Provider.CreateQuery<TSource>(
  3923. Expression.Call(
  3924. null,
  3925. #if CRIPPLED_REFLECTION
  3926. InfoOf(() => Qbservable.Distinct<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  3927. #else
  3928. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3929. #endif
  3930. source.Expression,
  3931. keySelector
  3932. )
  3933. );
  3934. }
  3935. /// <summary>
  3936. /// Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.
  3937. /// </summary>
  3938. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3939. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3940. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3941. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3942. /// <param name="comparer">Equality comparer for source elements.</param>
  3943. /// <returns>An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.</returns>
  3944. /// <exception cref="ArgumentNullException">
  3945. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  3946. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3947. public static IQbservable<TSource> Distinct<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  3948. {
  3949. if (source == null)
  3950. throw new ArgumentNullException(nameof(source));
  3951. if (keySelector == null)
  3952. throw new ArgumentNullException(nameof(keySelector));
  3953. if (comparer == null)
  3954. throw new ArgumentNullException(nameof(comparer));
  3955. return source.Provider.CreateQuery<TSource>(
  3956. Expression.Call(
  3957. null,
  3958. #if CRIPPLED_REFLECTION
  3959. InfoOf(() => Qbservable.Distinct<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  3960. #else
  3961. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3962. #endif
  3963. source.Expression,
  3964. keySelector,
  3965. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  3966. )
  3967. );
  3968. }
  3969. /// <summary>
  3970. /// Returns an observable sequence that contains only distinct contiguous elements.
  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. /// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
  3975. /// <exception cref="ArgumentNullException">
  3976. /// <paramref name="source" /> is null.</exception>
  3977. public static IQbservable<TSource> DistinctUntilChanged<TSource>(this IQbservable<TSource> source)
  3978. {
  3979. if (source == null)
  3980. throw new ArgumentNullException(nameof(source));
  3981. return source.Provider.CreateQuery<TSource>(
  3982. Expression.Call(
  3983. null,
  3984. #if CRIPPLED_REFLECTION
  3985. InfoOf(() => Qbservable.DistinctUntilChanged<TSource>(default(IQbservable<TSource>))),
  3986. #else
  3987. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3988. #endif
  3989. source.Expression
  3990. )
  3991. );
  3992. }
  3993. /// <summary>
  3994. /// Returns an observable sequence that contains only distinct contiguous elements according to the comparer.
  3995. /// </summary>
  3996. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3997. /// <param name="source">An observable sequence to retain distinct contiguous elements for.</param>
  3998. /// <param name="comparer">Equality comparer for source elements.</param>
  3999. /// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
  4000. /// <exception cref="ArgumentNullException">
  4001. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  4002. public static IQbservable<TSource> DistinctUntilChanged<TSource>(this IQbservable<TSource> source, IEqualityComparer<TSource> comparer)
  4003. {
  4004. if (source == null)
  4005. throw new ArgumentNullException(nameof(source));
  4006. if (comparer == null)
  4007. throw new ArgumentNullException(nameof(comparer));
  4008. return source.Provider.CreateQuery<TSource>(
  4009. Expression.Call(
  4010. null,
  4011. #if CRIPPLED_REFLECTION
  4012. InfoOf(() => Qbservable.DistinctUntilChanged<TSource>(default(IQbservable<TSource>), default(IEqualityComparer<TSource>))),
  4013. #else
  4014. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4015. #endif
  4016. source.Expression,
  4017. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  4018. )
  4019. );
  4020. }
  4021. /// <summary>
  4022. /// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector.
  4023. /// </summary>
  4024. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4025. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  4026. /// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
  4027. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  4028. /// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
  4029. /// <exception cref="ArgumentNullException">
  4030. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  4031. public static IQbservable<TSource> DistinctUntilChanged<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  4032. {
  4033. if (source == null)
  4034. throw new ArgumentNullException(nameof(source));
  4035. if (keySelector == null)
  4036. throw new ArgumentNullException(nameof(keySelector));
  4037. return source.Provider.CreateQuery<TSource>(
  4038. Expression.Call(
  4039. null,
  4040. #if CRIPPLED_REFLECTION
  4041. InfoOf(() => Qbservable.DistinctUntilChanged<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  4042. #else
  4043. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  4044. #endif
  4045. source.Expression,
  4046. keySelector
  4047. )
  4048. );
  4049. }
  4050. /// <summary>
  4051. /// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
  4052. /// </summary>
  4053. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4054. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  4055. /// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
  4056. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  4057. /// <param name="comparer">Equality comparer for computed key values.</param>
  4058. /// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
  4059. /// <exception cref="ArgumentNullException">
  4060. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  4061. public static IQbservable<TSource> DistinctUntilChanged<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  4062. {
  4063. if (source == null)
  4064. throw new ArgumentNullException(nameof(source));
  4065. if (keySelector == null)
  4066. throw new ArgumentNullException(nameof(keySelector));
  4067. if (comparer == null)
  4068. throw new ArgumentNullException(nameof(comparer));
  4069. return source.Provider.CreateQuery<TSource>(
  4070. Expression.Call(
  4071. null,
  4072. #if CRIPPLED_REFLECTION
  4073. InfoOf(() => Qbservable.DistinctUntilChanged<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  4074. #else
  4075. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  4076. #endif
  4077. source.Expression,
  4078. keySelector,
  4079. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  4080. )
  4081. );
  4082. }
  4083. /// <summary>
  4084. /// Invokes the observer's methods for each message in the source sequence.
  4085. /// 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.
  4086. /// </summary>
  4087. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4088. /// <param name="source">Source sequence.</param>
  4089. /// <param name="observer">Observer whose methods to invoke as part of the source sequence's observation.</param>
  4090. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4091. /// <exception cref="ArgumentNullException">
  4092. /// <paramref name="source" /> or <paramref name="observer" /> is null.</exception>
  4093. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, IObserver<TSource> observer)
  4094. {
  4095. if (source == null)
  4096. throw new ArgumentNullException(nameof(source));
  4097. if (observer == null)
  4098. throw new ArgumentNullException(nameof(observer));
  4099. return source.Provider.CreateQuery<TSource>(
  4100. Expression.Call(
  4101. null,
  4102. #if CRIPPLED_REFLECTION
  4103. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(IObserver<TSource>))),
  4104. #else
  4105. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4106. #endif
  4107. source.Expression,
  4108. Expression.Constant(observer, typeof(IObserver<TSource>))
  4109. )
  4110. );
  4111. }
  4112. /// <summary>
  4113. /// Invokes an action for each element in the observable sequence, and propagates all observer messages through the result sequence.
  4114. /// 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.
  4115. /// </summary>
  4116. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4117. /// <param name="source">Source sequence.</param>
  4118. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4119. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4120. /// <exception cref="ArgumentNullException">
  4121. /// <paramref name="source" /> or <paramref name="onNext" /> is null.</exception>
  4122. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext)
  4123. {
  4124. if (source == null)
  4125. throw new ArgumentNullException(nameof(source));
  4126. if (onNext == null)
  4127. throw new ArgumentNullException(nameof(onNext));
  4128. return source.Provider.CreateQuery<TSource>(
  4129. Expression.Call(
  4130. null,
  4131. #if CRIPPLED_REFLECTION
  4132. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>))),
  4133. #else
  4134. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4135. #endif
  4136. source.Expression,
  4137. onNext
  4138. )
  4139. );
  4140. }
  4141. /// <summary>
  4142. /// Invokes an action for each element in the observable sequence and invokes an action upon graceful termination of the observable sequence.
  4143. /// 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.
  4144. /// </summary>
  4145. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4146. /// <param name="source">Source sequence.</param>
  4147. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4148. /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
  4149. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4150. /// <exception cref="ArgumentNullException">
  4151. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onCompleted" /> is null.</exception>
  4152. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action> onCompleted)
  4153. {
  4154. if (source == null)
  4155. throw new ArgumentNullException(nameof(source));
  4156. if (onNext == null)
  4157. throw new ArgumentNullException(nameof(onNext));
  4158. if (onCompleted == null)
  4159. throw new ArgumentNullException(nameof(onCompleted));
  4160. return source.Provider.CreateQuery<TSource>(
  4161. Expression.Call(
  4162. null,
  4163. #if CRIPPLED_REFLECTION
  4164. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action>))),
  4165. #else
  4166. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4167. #endif
  4168. source.Expression,
  4169. onNext,
  4170. onCompleted
  4171. )
  4172. );
  4173. }
  4174. /// <summary>
  4175. /// Invokes an action for each element in the observable sequence and invokes an action upon exceptional termination of the observable sequence.
  4176. /// 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.
  4177. /// </summary>
  4178. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4179. /// <param name="source">Source sequence.</param>
  4180. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4181. /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
  4182. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4183. /// <exception cref="ArgumentNullException">
  4184. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> is null.</exception>
  4185. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError)
  4186. {
  4187. if (source == null)
  4188. throw new ArgumentNullException(nameof(source));
  4189. if (onNext == null)
  4190. throw new ArgumentNullException(nameof(onNext));
  4191. if (onError == null)
  4192. throw new ArgumentNullException(nameof(onError));
  4193. return source.Provider.CreateQuery<TSource>(
  4194. Expression.Call(
  4195. null,
  4196. #if CRIPPLED_REFLECTION
  4197. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>))),
  4198. #else
  4199. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4200. #endif
  4201. source.Expression,
  4202. onNext,
  4203. onError
  4204. )
  4205. );
  4206. }
  4207. /// <summary>
  4208. /// Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
  4209. /// 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.
  4210. /// </summary>
  4211. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4212. /// <param name="source">Source sequence.</param>
  4213. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4214. /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
  4215. /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
  4216. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4217. /// <exception cref="ArgumentNullException">
  4218. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  4219. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError, Expression<Action> onCompleted)
  4220. {
  4221. if (source == null)
  4222. throw new ArgumentNullException(nameof(source));
  4223. if (onNext == null)
  4224. throw new ArgumentNullException(nameof(onNext));
  4225. if (onError == null)
  4226. throw new ArgumentNullException(nameof(onError));
  4227. if (onCompleted == null)
  4228. throw new ArgumentNullException(nameof(onCompleted));
  4229. return source.Provider.CreateQuery<TSource>(
  4230. Expression.Call(
  4231. null,
  4232. #if CRIPPLED_REFLECTION
  4233. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>), default(Expression<Action>))),
  4234. #else
  4235. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4236. #endif
  4237. source.Expression,
  4238. onNext,
  4239. onError,
  4240. onCompleted
  4241. )
  4242. );
  4243. }
  4244. /// <summary>
  4245. /// 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.
  4246. /// </summary>
  4247. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4248. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  4249. /// <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>
  4250. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  4251. /// <exception cref="ArgumentNullException">
  4252. /// <paramref name="source" /> or <paramref name="condition" /> is null.</exception>
  4253. public static IQbservable<TSource> DoWhile<TSource>(this IQbservable<TSource> source, Expression<Func<bool>> condition)
  4254. {
  4255. if (source == null)
  4256. throw new ArgumentNullException(nameof(source));
  4257. if (condition == null)
  4258. throw new ArgumentNullException(nameof(condition));
  4259. return source.Provider.CreateQuery<TSource>(
  4260. Expression.Call(
  4261. null,
  4262. #if CRIPPLED_REFLECTION
  4263. InfoOf(() => Qbservable.DoWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<bool>>))),
  4264. #else
  4265. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4266. #endif
  4267. source.Expression,
  4268. condition
  4269. )
  4270. );
  4271. }
  4272. /// <summary>
  4273. /// Returns the element at a specified index in a sequence.
  4274. /// </summary>
  4275. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4276. /// <param name="source">Observable sequence to return the element from.</param>
  4277. /// <param name="index">The zero-based index of the element to retrieve.</param>
  4278. /// <returns>An observable sequence that produces the element at the specified position in the source sequence.</returns>
  4279. /// <exception cref="ArgumentNullException">
  4280. /// <paramref name="source" /> is null.</exception>
  4281. /// <exception cref="ArgumentOutOfRangeException">
  4282. /// <paramref name="index" /> is less than zero.</exception>
  4283. /// <exception cref="ArgumentOutOfRangeException">(Asynchronous) <paramref name="index" /> is greater than or equal to the number of elements in the source sequence.</exception>
  4284. public static IQbservable<TSource> ElementAt<TSource>(this IQbservable<TSource> source, int index)
  4285. {
  4286. if (source == null)
  4287. throw new ArgumentNullException(nameof(source));
  4288. return source.Provider.CreateQuery<TSource>(
  4289. Expression.Call(
  4290. null,
  4291. #if CRIPPLED_REFLECTION
  4292. InfoOf(() => Qbservable.ElementAt<TSource>(default(IQbservable<TSource>), default(int))),
  4293. #else
  4294. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4295. #endif
  4296. source.Expression,
  4297. Expression.Constant(index, typeof(int))
  4298. )
  4299. );
  4300. }
  4301. /// <summary>
  4302. /// Returns the element at a specified index in a sequence or a default value if the index is out of range.
  4303. /// </summary>
  4304. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4305. /// <param name="source">Observable sequence to return the element from.</param>
  4306. /// <param name="index">The zero-based index of the element to retrieve.</param>
  4307. /// <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>
  4308. /// <exception cref="ArgumentNullException">
  4309. /// <paramref name="source" /> is null.</exception>
  4310. /// <exception cref="ArgumentOutOfRangeException">
  4311. /// <paramref name="index" /> is less than zero.</exception>
  4312. public static IQbservable<TSource?> ElementAtOrDefault<TSource>(this IQbservable<TSource> source, int index)
  4313. {
  4314. if (source == null)
  4315. throw new ArgumentNullException(nameof(source));
  4316. return source.Provider.CreateQuery<TSource>(
  4317. Expression.Call(
  4318. null,
  4319. #if CRIPPLED_REFLECTION
  4320. InfoOf(() => Qbservable.ElementAtOrDefault<TSource>(default(IQbservable<TSource>), default(int))),
  4321. #else
  4322. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4323. #endif
  4324. source.Expression,
  4325. Expression.Constant(index, typeof(int))
  4326. )
  4327. );
  4328. }
  4329. /// <summary>
  4330. /// Returns an empty observable sequence.
  4331. /// </summary>
  4332. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4333. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4334. /// <returns>An observable sequence with no elements.</returns>
  4335. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider)
  4336. {
  4337. if (provider == null)
  4338. throw new ArgumentNullException(nameof(provider));
  4339. return provider.CreateQuery<TResult>(
  4340. Expression.Call(
  4341. null,
  4342. #if CRIPPLED_REFLECTION
  4343. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider))),
  4344. #else
  4345. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4346. #endif
  4347. Expression.Constant(provider, typeof(IQbservableProvider))
  4348. )
  4349. );
  4350. }
  4351. /// <summary>
  4352. /// Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
  4353. /// </summary>
  4354. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4355. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4356. /// <param name="scheduler">Scheduler to send the termination call on.</param>
  4357. /// <returns>An observable sequence with no elements.</returns>
  4358. /// <exception cref="ArgumentNullException">
  4359. /// <paramref name="scheduler" /> is null.</exception>
  4360. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, IScheduler scheduler)
  4361. {
  4362. if (provider == null)
  4363. throw new ArgumentNullException(nameof(provider));
  4364. if (scheduler == null)
  4365. throw new ArgumentNullException(nameof(scheduler));
  4366. return provider.CreateQuery<TResult>(
  4367. Expression.Call(
  4368. null,
  4369. #if CRIPPLED_REFLECTION
  4370. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(IScheduler))),
  4371. #else
  4372. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4373. #endif
  4374. Expression.Constant(provider, typeof(IQbservableProvider)),
  4375. Expression.Constant(scheduler, typeof(IScheduler))
  4376. )
  4377. );
  4378. }
  4379. /// <summary>
  4380. /// Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
  4381. /// </summary>
  4382. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4383. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4384. /// <param name="scheduler">Scheduler to send the termination call on.</param>
  4385. /// <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>
  4386. /// <returns>An observable sequence with no elements.</returns>
  4387. /// <exception cref="ArgumentNullException">
  4388. /// <paramref name="scheduler" /> is null.</exception>
  4389. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, IScheduler scheduler, TResult witness)
  4390. {
  4391. if (provider == null)
  4392. throw new ArgumentNullException(nameof(provider));
  4393. if (scheduler == null)
  4394. throw new ArgumentNullException(nameof(scheduler));
  4395. return provider.CreateQuery<TResult>(
  4396. Expression.Call(
  4397. null,
  4398. #if CRIPPLED_REFLECTION
  4399. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(IScheduler), default(TResult))),
  4400. #else
  4401. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4402. #endif
  4403. Expression.Constant(provider, typeof(IQbservableProvider)),
  4404. Expression.Constant(scheduler, typeof(IScheduler)),
  4405. Expression.Constant(witness, typeof(TResult))
  4406. )
  4407. );
  4408. }
  4409. /// <summary>
  4410. /// Returns an empty observable sequence.
  4411. /// </summary>
  4412. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4413. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  4414. /// <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>
  4415. /// <returns>An observable sequence with no elements.</returns>
  4416. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, TResult witness)
  4417. {
  4418. if (provider == null)
  4419. throw new ArgumentNullException(nameof(provider));
  4420. return provider.CreateQuery<TResult>(
  4421. Expression.Call(
  4422. null,
  4423. #if CRIPPLED_REFLECTION
  4424. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(TResult))),
  4425. #else
  4426. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4427. #endif
  4428. Expression.Constant(provider, typeof(IQbservableProvider)),
  4429. Expression.Constant(witness, typeof(TResult))
  4430. )
  4431. );
  4432. }
  4433. /// <summary>
  4434. /// Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
  4435. /// </summary>
  4436. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4437. /// <param name="source">Source sequence.</param>
  4438. /// <param name="finallyAction">Action to invoke after the source observable sequence terminates.</param>
  4439. /// <returns>Source sequence with the action-invoking termination behavior applied.</returns>
  4440. /// <exception cref="ArgumentNullException">
  4441. /// <paramref name="source" /> or <paramref name="finallyAction" /> is null.</exception>
  4442. public static IQbservable<TSource> Finally<TSource>(this IQbservable<TSource> source, Expression<Action> finallyAction)
  4443. {
  4444. if (source == null)
  4445. throw new ArgumentNullException(nameof(source));
  4446. if (finallyAction == null)
  4447. throw new ArgumentNullException(nameof(finallyAction));
  4448. return source.Provider.CreateQuery<TSource>(
  4449. Expression.Call(
  4450. null,
  4451. #if CRIPPLED_REFLECTION
  4452. InfoOf(() => Qbservable.Finally<TSource>(default(IQbservable<TSource>), default(Expression<Action>))),
  4453. #else
  4454. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4455. #endif
  4456. source.Expression,
  4457. finallyAction
  4458. )
  4459. );
  4460. }
  4461. /// <summary>
  4462. /// Returns the first element of an observable sequence.
  4463. /// </summary>
  4464. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4465. /// <param name="source">Source observable sequence.</param>
  4466. /// <returns>Sequence containing the first element in the observable sequence.</returns>
  4467. /// <exception cref="ArgumentNullException">
  4468. /// <paramref name="source" /> is null.</exception>
  4469. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  4470. public static IQbservable<TSource> FirstAsync<TSource>(this IQbservable<TSource> source)
  4471. {
  4472. if (source == null)
  4473. throw new ArgumentNullException(nameof(source));
  4474. return source.Provider.CreateQuery<TSource>(
  4475. Expression.Call(
  4476. null,
  4477. #if CRIPPLED_REFLECTION
  4478. InfoOf(() => Qbservable.FirstAsync<TSource>(default(IQbservable<TSource>))),
  4479. #else
  4480. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4481. #endif
  4482. source.Expression
  4483. )
  4484. );
  4485. }
  4486. /// <summary>
  4487. /// Returns the first element of an observable sequence that satisfies the condition in the predicate.
  4488. /// </summary>
  4489. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4490. /// <param name="source">Source observable sequence.</param>
  4491. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  4492. /// <returns>Sequence containing the first element in the observable sequence that satisfies the condition in the predicate.</returns>
  4493. /// <exception cref="ArgumentNullException">
  4494. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  4495. /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  4496. public static IQbservable<TSource> FirstAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  4497. {
  4498. if (source == null)
  4499. throw new ArgumentNullException(nameof(source));
  4500. if (predicate == null)
  4501. throw new ArgumentNullException(nameof(predicate));
  4502. return source.Provider.CreateQuery<TSource>(
  4503. Expression.Call(
  4504. null,
  4505. #if CRIPPLED_REFLECTION
  4506. InfoOf(() => Qbservable.FirstAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  4507. #else
  4508. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4509. #endif
  4510. source.Expression,
  4511. predicate
  4512. )
  4513. );
  4514. }
  4515. /// <summary>
  4516. /// Returns the first element of an observable sequence, 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. /// <returns>Sequence containing the first element in the observable sequence, or a default value if no such element exists.</returns>
  4521. /// <exception cref="ArgumentNullException">
  4522. /// <paramref name="source" /> is null.</exception>
  4523. public static IQbservable<TSource?> FirstOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  4524. {
  4525. if (source == null)
  4526. throw new ArgumentNullException(nameof(source));
  4527. return source.Provider.CreateQuery<TSource>(
  4528. Expression.Call(
  4529. null,
  4530. #if CRIPPLED_REFLECTION
  4531. InfoOf(() => Qbservable.FirstOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  4532. #else
  4533. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4534. #endif
  4535. source.Expression
  4536. )
  4537. );
  4538. }
  4539. /// <summary>
  4540. /// Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  4541. /// </summary>
  4542. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4543. /// <param name="source">Source observable sequence.</param>
  4544. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  4545. /// <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>
  4546. /// <exception cref="ArgumentNullException">
  4547. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  4548. public static IQbservable<TSource?> FirstOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  4549. {
  4550. if (source == null)
  4551. throw new ArgumentNullException(nameof(source));
  4552. if (predicate == null)
  4553. throw new ArgumentNullException(nameof(predicate));
  4554. return source.Provider.CreateQuery<TSource>(
  4555. Expression.Call(
  4556. null,
  4557. #if CRIPPLED_REFLECTION
  4558. InfoOf(() => Qbservable.FirstOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  4559. #else
  4560. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4561. #endif
  4562. source.Expression,
  4563. predicate
  4564. )
  4565. );
  4566. }
  4567. /// <summary>
  4568. /// Concatenates the observable sequences obtained by running the <paramref name="resultSelector" /> for each element in the given enumerable <paramref name="source" />.
  4569. /// </summary>
  4570. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4571. /// <typeparam name="TSource">The type of the elements in the enumerable source sequence.</typeparam>
  4572. /// <typeparam name="TResult">The type of the elements in the observable result sequence.</typeparam>
  4573. /// <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>
  4574. /// <param name="resultSelector">Function to select an observable source for each element in the <paramref name="source" />.</param>
  4575. /// <returns>The observable sequence obtained by concatenating the sources returned by <paramref name="resultSelector" /> for each element in the <paramref name="source" />.</returns>
  4576. /// <exception cref="ArgumentNullException">
  4577. /// <paramref name="source" /> or <paramref name="resultSelector" /> is null.</exception>
  4578. public static IQbservable<TResult> For<TSource, TResult>(this IQbservableProvider provider, IEnumerable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> resultSelector)
  4579. {
  4580. if (provider == null)
  4581. throw new ArgumentNullException(nameof(provider));
  4582. if (source == null)
  4583. throw new ArgumentNullException(nameof(source));
  4584. if (resultSelector == null)
  4585. throw new ArgumentNullException(nameof(resultSelector));
  4586. return provider.CreateQuery<TResult>(
  4587. Expression.Call(
  4588. null,
  4589. #if CRIPPLED_REFLECTION
  4590. InfoOf(() => Qbservable.For<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  4591. #else
  4592. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  4593. #endif
  4594. Expression.Constant(provider, typeof(IQbservableProvider)),
  4595. GetSourceExpression(source),
  4596. resultSelector
  4597. )
  4598. );
  4599. }
  4600. /// <summary>
  4601. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4602. /// </summary>
  4603. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4604. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4605. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4606. /// <exception cref="ArgumentNullException">
  4607. /// <paramref name="actionAsync" /> is null.</exception>
  4608. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  4609. {
  4610. if (provider == null)
  4611. throw new ArgumentNullException(nameof(provider));
  4612. if (actionAsync == null)
  4613. throw new ArgumentNullException(nameof(actionAsync));
  4614. return provider.CreateQuery<Unit>(
  4615. Expression.Call(
  4616. null,
  4617. #if CRIPPLED_REFLECTION
  4618. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  4619. #else
  4620. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4621. #endif
  4622. Expression.Constant(provider, typeof(IQbservableProvider)),
  4623. actionAsync
  4624. )
  4625. );
  4626. }
  4627. /// <summary>
  4628. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4629. /// </summary>
  4630. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4631. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4632. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4633. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4634. /// <exception cref="ArgumentNullException">
  4635. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4636. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync, IScheduler scheduler)
  4637. {
  4638. if (provider == null)
  4639. throw new ArgumentNullException(nameof(provider));
  4640. if (actionAsync == null)
  4641. throw new ArgumentNullException(nameof(actionAsync));
  4642. if (scheduler == null)
  4643. throw new ArgumentNullException(nameof(scheduler));
  4644. return provider.CreateQuery<Unit>(
  4645. Expression.Call(
  4646. null,
  4647. #if CRIPPLED_REFLECTION
  4648. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<Task>>), default(IScheduler))),
  4649. #else
  4650. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4651. #endif
  4652. Expression.Constant(provider, typeof(IQbservableProvider)),
  4653. actionAsync,
  4654. Expression.Constant(scheduler, typeof(IScheduler))
  4655. )
  4656. );
  4657. }
  4658. /// <summary>
  4659. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4660. /// 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.
  4661. /// </summary>
  4662. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4663. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4664. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4665. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4666. /// <exception cref="ArgumentNullException">
  4667. /// <paramref name="actionAsync" /> is null.</exception>
  4668. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  4669. {
  4670. if (provider == null)
  4671. throw new ArgumentNullException(nameof(provider));
  4672. if (actionAsync == null)
  4673. throw new ArgumentNullException(nameof(actionAsync));
  4674. return provider.CreateQuery<Unit>(
  4675. Expression.Call(
  4676. null,
  4677. #if CRIPPLED_REFLECTION
  4678. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  4679. #else
  4680. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4681. #endif
  4682. Expression.Constant(provider, typeof(IQbservableProvider)),
  4683. actionAsync
  4684. )
  4685. );
  4686. }
  4687. /// <summary>
  4688. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4689. /// 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.
  4690. /// </summary>
  4691. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4692. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4693. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4694. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4695. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4696. /// <exception cref="ArgumentNullException">
  4697. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4698. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync, IScheduler scheduler)
  4699. {
  4700. if (provider == null)
  4701. throw new ArgumentNullException(nameof(provider));
  4702. if (actionAsync == null)
  4703. throw new ArgumentNullException(nameof(actionAsync));
  4704. if (scheduler == null)
  4705. throw new ArgumentNullException(nameof(scheduler));
  4706. return provider.CreateQuery<Unit>(
  4707. Expression.Call(
  4708. null,
  4709. #if CRIPPLED_REFLECTION
  4710. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>), default(IScheduler))),
  4711. #else
  4712. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4713. #endif
  4714. Expression.Constant(provider, typeof(IQbservableProvider)),
  4715. actionAsync,
  4716. Expression.Constant(scheduler, typeof(IScheduler))
  4717. )
  4718. );
  4719. }
  4720. /// <summary>
  4721. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4722. /// </summary>
  4723. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4724. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4725. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4726. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4727. /// <exception cref="ArgumentNullException">
  4728. /// <paramref name="functionAsync" /> is null.</exception>
  4729. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  4730. {
  4731. if (provider == null)
  4732. throw new ArgumentNullException(nameof(provider));
  4733. if (functionAsync == null)
  4734. throw new ArgumentNullException(nameof(functionAsync));
  4735. return provider.CreateQuery<TResult>(
  4736. Expression.Call(
  4737. null,
  4738. #if CRIPPLED_REFLECTION
  4739. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  4740. #else
  4741. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4742. #endif
  4743. Expression.Constant(provider, typeof(IQbservableProvider)),
  4744. functionAsync
  4745. )
  4746. );
  4747. }
  4748. /// <summary>
  4749. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4750. /// 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.
  4751. /// </summary>
  4752. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4753. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4754. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4755. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4756. /// <exception cref="ArgumentNullException">
  4757. /// <paramref name="functionAsync" /> is null.</exception>
  4758. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4759. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  4760. {
  4761. if (provider == null)
  4762. throw new ArgumentNullException(nameof(provider));
  4763. if (functionAsync == null)
  4764. throw new ArgumentNullException(nameof(functionAsync));
  4765. return provider.CreateQuery<TResult>(
  4766. Expression.Call(
  4767. null,
  4768. #if CRIPPLED_REFLECTION
  4769. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  4770. #else
  4771. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4772. #endif
  4773. Expression.Constant(provider, typeof(IQbservableProvider)),
  4774. functionAsync
  4775. )
  4776. );
  4777. }
  4778. /// <summary>
  4779. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4780. /// </summary>
  4781. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4782. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4783. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4784. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4785. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4786. /// <exception cref="ArgumentNullException">
  4787. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4788. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync, IScheduler scheduler)
  4789. {
  4790. if (provider == null)
  4791. throw new ArgumentNullException(nameof(provider));
  4792. if (functionAsync == null)
  4793. throw new ArgumentNullException(nameof(functionAsync));
  4794. if (scheduler == null)
  4795. throw new ArgumentNullException(nameof(scheduler));
  4796. return provider.CreateQuery<TResult>(
  4797. Expression.Call(
  4798. null,
  4799. #if CRIPPLED_REFLECTION
  4800. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>), default(IScheduler))),
  4801. #else
  4802. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4803. #endif
  4804. Expression.Constant(provider, typeof(IQbservableProvider)),
  4805. functionAsync,
  4806. Expression.Constant(scheduler, typeof(IScheduler))
  4807. )
  4808. );
  4809. }
  4810. /// <summary>
  4811. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4812. /// 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.
  4813. /// </summary>
  4814. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4815. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4816. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4817. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4818. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4819. /// <exception cref="ArgumentNullException">
  4820. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4821. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4822. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync, IScheduler scheduler)
  4823. {
  4824. if (provider == null)
  4825. throw new ArgumentNullException(nameof(provider));
  4826. if (functionAsync == null)
  4827. throw new ArgumentNullException(nameof(functionAsync));
  4828. if (scheduler == null)
  4829. throw new ArgumentNullException(nameof(scheduler));
  4830. return provider.CreateQuery<TResult>(
  4831. Expression.Call(
  4832. null,
  4833. #if CRIPPLED_REFLECTION
  4834. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>), default(IScheduler))),
  4835. #else
  4836. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4837. #endif
  4838. Expression.Constant(provider, typeof(IQbservableProvider)),
  4839. functionAsync,
  4840. Expression.Constant(scheduler, typeof(IScheduler))
  4841. )
  4842. );
  4843. }
  4844. /// <summary>
  4845. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4846. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4847. /// </summary>
  4848. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4849. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4850. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4851. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4852. /// <exception cref="ArgumentNullException">
  4853. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4854. /// <remarks>
  4855. /// <para>
  4856. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4857. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4858. /// </para>
  4859. /// <para>
  4860. /// 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.
  4861. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4862. /// </para>
  4863. /// <para>
  4864. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4865. /// making the Subscribe or Dispose call, respectively.
  4866. /// </para>
  4867. /// <para>
  4868. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4869. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4870. /// more concise and easier to understand.
  4871. /// </para>
  4872. /// </remarks>
  4873. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4874. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler)
  4875. {
  4876. if (provider == null)
  4877. throw new ArgumentNullException(nameof(provider));
  4878. if (addHandler == null)
  4879. throw new ArgumentNullException(nameof(addHandler));
  4880. if (removeHandler == null)
  4881. throw new ArgumentNullException(nameof(removeHandler));
  4882. return provider.CreateQuery<Unit>(
  4883. Expression.Call(
  4884. null,
  4885. #if CRIPPLED_REFLECTION
  4886. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>))),
  4887. #else
  4888. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4889. #endif
  4890. Expression.Constant(provider, typeof(IQbservableProvider)),
  4891. addHandler,
  4892. removeHandler
  4893. )
  4894. );
  4895. }
  4896. /// <summary>
  4897. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4898. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4899. /// </summary>
  4900. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4901. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4902. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4903. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4904. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4905. /// <exception cref="ArgumentNullException">
  4906. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4907. /// <remarks>
  4908. /// <para>
  4909. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4910. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4911. /// </para>
  4912. /// <para>
  4913. /// 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
  4914. /// accessed from the same context, as required by some UI frameworks.
  4915. /// </para>
  4916. /// <para>
  4917. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4918. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4919. /// parameter. For more information, see the remarks section on those overloads.
  4920. /// </para>
  4921. /// </remarks>
  4922. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4923. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler, IScheduler scheduler)
  4924. {
  4925. if (provider == null)
  4926. throw new ArgumentNullException(nameof(provider));
  4927. if (addHandler == null)
  4928. throw new ArgumentNullException(nameof(addHandler));
  4929. if (removeHandler == null)
  4930. throw new ArgumentNullException(nameof(removeHandler));
  4931. if (scheduler == null)
  4932. throw new ArgumentNullException(nameof(scheduler));
  4933. return provider.CreateQuery<Unit>(
  4934. Expression.Call(
  4935. null,
  4936. #if CRIPPLED_REFLECTION
  4937. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>), default(IScheduler))),
  4938. #else
  4939. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4940. #endif
  4941. Expression.Constant(provider, typeof(IQbservableProvider)),
  4942. addHandler,
  4943. removeHandler,
  4944. Expression.Constant(scheduler, typeof(IScheduler))
  4945. )
  4946. );
  4947. }
  4948. /// <summary>
  4949. /// 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.
  4950. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4951. /// </summary>
  4952. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4953. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4954. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4955. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4956. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4957. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4958. /// <exception cref="ArgumentNullException">
  4959. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4960. /// <remarks>
  4961. /// <para>
  4962. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4963. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4964. /// </para>
  4965. /// <para>
  4966. /// 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.
  4967. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4968. /// </para>
  4969. /// <para>
  4970. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4971. /// making the Subscribe or Dispose call, respectively.
  4972. /// </para>
  4973. /// <para>
  4974. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4975. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4976. /// more concise and easier to understand.
  4977. /// </para>
  4978. /// </remarks>
  4979. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  4980. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  4981. {
  4982. if (provider == null)
  4983. throw new ArgumentNullException(nameof(provider));
  4984. if (addHandler == null)
  4985. throw new ArgumentNullException(nameof(addHandler));
  4986. if (removeHandler == null)
  4987. throw new ArgumentNullException(nameof(removeHandler));
  4988. return provider.CreateQuery<TEventArgs>(
  4989. Expression.Call(
  4990. null,
  4991. #if CRIPPLED_REFLECTION
  4992. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  4993. #else
  4994. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4995. #endif
  4996. Expression.Constant(provider, typeof(IQbservableProvider)),
  4997. addHandler,
  4998. removeHandler
  4999. )
  5000. );
  5001. }
  5002. /// <summary>
  5003. /// 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.
  5004. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5005. /// </summary>
  5006. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5007. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5008. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5009. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5010. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5011. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5012. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5013. /// <exception cref="ArgumentNullException">
  5014. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5015. /// <remarks>
  5016. /// <para>
  5017. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5018. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5019. /// </para>
  5020. /// <para>
  5021. /// 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
  5022. /// accessed from the same context, as required by some UI frameworks.
  5023. /// </para>
  5024. /// <para>
  5025. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5026. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5027. /// parameter. For more information, see the remarks section on those overloads.
  5028. /// </para>
  5029. /// </remarks>
  5030. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5031. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5032. {
  5033. if (provider == null)
  5034. throw new ArgumentNullException(nameof(provider));
  5035. if (addHandler == null)
  5036. throw new ArgumentNullException(nameof(addHandler));
  5037. if (removeHandler == null)
  5038. throw new ArgumentNullException(nameof(removeHandler));
  5039. if (scheduler == null)
  5040. throw new ArgumentNullException(nameof(scheduler));
  5041. return provider.CreateQuery<TEventArgs>(
  5042. Expression.Call(
  5043. null,
  5044. #if CRIPPLED_REFLECTION
  5045. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5046. #else
  5047. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5048. #endif
  5049. Expression.Constant(provider, typeof(IQbservableProvider)),
  5050. addHandler,
  5051. removeHandler,
  5052. Expression.Constant(scheduler, typeof(IScheduler))
  5053. )
  5054. );
  5055. }
  5056. /// <summary>
  5057. /// 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.
  5058. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5059. /// </summary>
  5060. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5061. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5062. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5063. /// <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>
  5064. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5065. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5066. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5067. /// <exception cref="ArgumentNullException">
  5068. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5069. /// <remarks>
  5070. /// <para>
  5071. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5072. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5073. /// </para>
  5074. /// <para>
  5075. /// 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.
  5076. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5077. /// </para>
  5078. /// <para>
  5079. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  5080. /// making the Subscribe or Dispose call, respectively.
  5081. /// </para>
  5082. /// <para>
  5083. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5084. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5085. /// more concise and easier to understand.
  5086. /// </para>
  5087. /// </remarks>
  5088. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5089. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5090. {
  5091. if (provider == null)
  5092. throw new ArgumentNullException(nameof(provider));
  5093. if (conversion == null)
  5094. throw new ArgumentNullException(nameof(conversion));
  5095. if (addHandler == null)
  5096. throw new ArgumentNullException(nameof(addHandler));
  5097. if (removeHandler == null)
  5098. throw new ArgumentNullException(nameof(removeHandler));
  5099. return provider.CreateQuery<TEventArgs>(
  5100. Expression.Call(
  5101. null,
  5102. #if CRIPPLED_REFLECTION
  5103. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5104. #else
  5105. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5106. #endif
  5107. Expression.Constant(provider, typeof(IQbservableProvider)),
  5108. conversion,
  5109. addHandler,
  5110. removeHandler
  5111. )
  5112. );
  5113. }
  5114. /// <summary>
  5115. /// 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.
  5116. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5117. /// </summary>
  5118. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5119. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5120. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5121. /// <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>
  5122. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5123. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5124. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5125. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5126. /// <exception cref="ArgumentNullException">
  5127. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5128. /// <remarks>
  5129. /// <para>
  5130. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5131. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5132. /// </para>
  5133. /// <para>
  5134. /// 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
  5135. /// accessed from the same context, as required by some UI frameworks.
  5136. /// </para>
  5137. /// <para>
  5138. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5139. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5140. /// parameter. For more information, see the remarks section on those overloads.
  5141. /// </para>
  5142. /// </remarks>
  5143. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5144. 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)
  5145. {
  5146. if (provider == null)
  5147. throw new ArgumentNullException(nameof(provider));
  5148. if (conversion == null)
  5149. throw new ArgumentNullException(nameof(conversion));
  5150. if (addHandler == null)
  5151. throw new ArgumentNullException(nameof(addHandler));
  5152. if (removeHandler == null)
  5153. throw new ArgumentNullException(nameof(removeHandler));
  5154. if (scheduler == null)
  5155. throw new ArgumentNullException(nameof(scheduler));
  5156. return provider.CreateQuery<TEventArgs>(
  5157. Expression.Call(
  5158. null,
  5159. #if CRIPPLED_REFLECTION
  5160. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5161. #else
  5162. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5163. #endif
  5164. Expression.Constant(provider, typeof(IQbservableProvider)),
  5165. conversion,
  5166. addHandler,
  5167. removeHandler,
  5168. Expression.Constant(scheduler, typeof(IScheduler))
  5169. )
  5170. );
  5171. }
  5172. /// <summary>
  5173. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5174. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5175. /// </summary>
  5176. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5177. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5178. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5179. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5180. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5181. /// <exception cref="ArgumentNullException">
  5182. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5183. /// <remarks>
  5184. /// <para>
  5185. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5186. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5187. /// </para>
  5188. /// <para>
  5189. /// 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.
  5190. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5191. /// </para>
  5192. /// <para>
  5193. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  5194. /// making the Subscribe or Dispose call, respectively.
  5195. /// </para>
  5196. /// <para>
  5197. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5198. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5199. /// more concise and easier to understand.
  5200. /// </para>
  5201. /// </remarks>
  5202. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5203. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler)
  5204. {
  5205. if (provider == null)
  5206. throw new ArgumentNullException(nameof(provider));
  5207. if (addHandler == null)
  5208. throw new ArgumentNullException(nameof(addHandler));
  5209. if (removeHandler == null)
  5210. throw new ArgumentNullException(nameof(removeHandler));
  5211. return provider.CreateQuery<TEventArgs>(
  5212. Expression.Call(
  5213. null,
  5214. #if CRIPPLED_REFLECTION
  5215. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>))),
  5216. #else
  5217. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5218. #endif
  5219. Expression.Constant(provider, typeof(IQbservableProvider)),
  5220. addHandler,
  5221. removeHandler
  5222. )
  5223. );
  5224. }
  5225. /// <summary>
  5226. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5227. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5228. /// </summary>
  5229. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5230. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5231. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5232. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5233. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5234. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5235. /// <exception cref="ArgumentNullException">
  5236. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5237. /// <remarks>
  5238. /// <para>
  5239. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5240. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5241. /// </para>
  5242. /// <para>
  5243. /// 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
  5244. /// accessed from the same context, as required by some UI frameworks.
  5245. /// </para>
  5246. /// <para>
  5247. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5248. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5249. /// parameter. For more information, see the remarks section on those overloads.
  5250. /// </para>
  5251. /// </remarks>
  5252. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEvent(System.IObservable{System.Reactive.Unit})" />
  5253. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler, IScheduler scheduler)
  5254. {
  5255. if (provider == null)
  5256. throw new ArgumentNullException(nameof(provider));
  5257. if (addHandler == null)
  5258. throw new ArgumentNullException(nameof(addHandler));
  5259. if (removeHandler == null)
  5260. throw new ArgumentNullException(nameof(removeHandler));
  5261. if (scheduler == null)
  5262. throw new ArgumentNullException(nameof(scheduler));
  5263. return provider.CreateQuery<TEventArgs>(
  5264. Expression.Call(
  5265. null,
  5266. #if CRIPPLED_REFLECTION
  5267. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>), default(IScheduler))),
  5268. #else
  5269. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5270. #endif
  5271. Expression.Constant(provider, typeof(IQbservableProvider)),
  5272. addHandler,
  5273. removeHandler,
  5274. Expression.Constant(scheduler, typeof(IScheduler))
  5275. )
  5276. );
  5277. }
  5278. /// <summary>
  5279. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler" />, to an observable sequence.
  5280. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5281. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5282. /// </summary>
  5283. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5284. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5285. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5286. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5287. /// <exception cref="ArgumentNullException">
  5288. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5289. /// <remarks>
  5290. /// <para>
  5291. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5292. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5293. /// </para>
  5294. /// <para>
  5295. /// 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.
  5296. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5297. /// </para>
  5298. /// <para>
  5299. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5300. /// making the Subscribe or Dispose call, respectively.
  5301. /// </para>
  5302. /// <para>
  5303. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5304. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5305. /// more concise and easier to understand.
  5306. /// </para>
  5307. /// </remarks>
  5308. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5309. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)
  5310. {
  5311. if (provider == null)
  5312. throw new ArgumentNullException(nameof(provider));
  5313. if (addHandler == null)
  5314. throw new ArgumentNullException(nameof(addHandler));
  5315. if (removeHandler == null)
  5316. throw new ArgumentNullException(nameof(removeHandler));
  5317. return provider.CreateQuery<EventPattern<object>>(
  5318. Expression.Call(
  5319. null,
  5320. #if CRIPPLED_REFLECTION
  5321. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>))),
  5322. #else
  5323. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5324. #endif
  5325. Expression.Constant(provider, typeof(IQbservableProvider)),
  5326. addHandler,
  5327. removeHandler
  5328. )
  5329. );
  5330. }
  5331. /// <summary>
  5332. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler" />, to an observable sequence.
  5333. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5334. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5335. /// </summary>
  5336. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5337. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5338. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5339. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5340. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5341. /// <exception cref="ArgumentNullException">
  5342. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5343. /// <remarks>
  5344. /// <para>
  5345. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5346. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5347. /// </para>
  5348. /// <para>
  5349. /// 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
  5350. /// accessed from the same context, as required by some UI frameworks.
  5351. /// </para>
  5352. /// <para>
  5353. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5354. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5355. /// parameter. For more information, see the remarks section on those overloads.
  5356. /// </para>
  5357. /// </remarks>
  5358. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5359. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)
  5360. {
  5361. if (provider == null)
  5362. throw new ArgumentNullException(nameof(provider));
  5363. if (addHandler == null)
  5364. throw new ArgumentNullException(nameof(addHandler));
  5365. if (removeHandler == null)
  5366. throw new ArgumentNullException(nameof(removeHandler));
  5367. if (scheduler == null)
  5368. throw new ArgumentNullException(nameof(scheduler));
  5369. return provider.CreateQuery<EventPattern<object>>(
  5370. Expression.Call(
  5371. null,
  5372. #if CRIPPLED_REFLECTION
  5373. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>), default(IScheduler))),
  5374. #else
  5375. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5376. #endif
  5377. Expression.Constant(provider, typeof(IQbservableProvider)),
  5378. addHandler,
  5379. removeHandler,
  5380. Expression.Constant(scheduler, typeof(IScheduler))
  5381. )
  5382. );
  5383. }
  5384. /// <summary>
  5385. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5386. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5387. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5388. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5389. /// </summary>
  5390. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5391. /// <param name="target">Object instance that exposes the event to convert.</param>
  5392. /// <param name="eventName">Name of the event to convert.</param>
  5393. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5394. /// <exception cref="ArgumentNullException">
  5395. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  5396. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5397. /// <remarks>
  5398. /// <para>
  5399. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5400. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5401. /// </para>
  5402. /// <para>
  5403. /// 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.
  5404. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5405. /// </para>
  5406. /// <para>
  5407. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5408. /// making the Subscribe or Dispose call, respectively.
  5409. /// </para>
  5410. /// <para>
  5411. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5412. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5413. /// more concise and easier to understand.
  5414. /// </para>
  5415. /// </remarks>
  5416. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5417. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)
  5418. {
  5419. if (provider == null)
  5420. throw new ArgumentNullException(nameof(provider));
  5421. if (target == null)
  5422. throw new ArgumentNullException(nameof(target));
  5423. if (eventName == null)
  5424. throw new ArgumentNullException(nameof(eventName));
  5425. return provider.CreateQuery<EventPattern<object>>(
  5426. Expression.Call(
  5427. null,
  5428. #if CRIPPLED_REFLECTION
  5429. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string))),
  5430. #else
  5431. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5432. #endif
  5433. Expression.Constant(provider, typeof(IQbservableProvider)),
  5434. Expression.Constant(target, typeof(object)),
  5435. Expression.Constant(eventName, typeof(string))
  5436. )
  5437. );
  5438. }
  5439. /// <summary>
  5440. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5441. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5442. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5443. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5444. /// </summary>
  5445. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5446. /// <param name="target">Object instance that exposes the event to convert.</param>
  5447. /// <param name="eventName">Name of the event to convert.</param>
  5448. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5449. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5450. /// <exception cref="ArgumentNullException">
  5451. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5452. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5453. /// <remarks>
  5454. /// <para>
  5455. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5456. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5457. /// </para>
  5458. /// <para>
  5459. /// 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
  5460. /// accessed from the same context, as required by some UI frameworks.
  5461. /// </para>
  5462. /// <para>
  5463. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5464. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5465. /// parameter. For more information, see the remarks section on those overloads.
  5466. /// </para>
  5467. /// </remarks>
  5468. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5469. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  5470. {
  5471. if (provider == null)
  5472. throw new ArgumentNullException(nameof(provider));
  5473. if (target == null)
  5474. throw new ArgumentNullException(nameof(target));
  5475. if (eventName == null)
  5476. throw new ArgumentNullException(nameof(eventName));
  5477. if (scheduler == null)
  5478. throw new ArgumentNullException(nameof(scheduler));
  5479. return provider.CreateQuery<EventPattern<object>>(
  5480. Expression.Call(
  5481. null,
  5482. #if CRIPPLED_REFLECTION
  5483. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  5484. #else
  5485. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5486. #endif
  5487. Expression.Constant(provider, typeof(IQbservableProvider)),
  5488. Expression.Constant(target, typeof(object)),
  5489. Expression.Constant(eventName, typeof(string)),
  5490. Expression.Constant(scheduler, typeof(IScheduler))
  5491. )
  5492. );
  5493. }
  5494. /// <summary>
  5495. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5496. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5497. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5498. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5499. /// </summary>
  5500. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5501. /// <param name="type">Type that exposes the static event to convert.</param>
  5502. /// <param name="eventName">Name of the event to convert.</param>
  5503. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5504. /// <exception cref="ArgumentNullException">
  5505. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  5506. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5507. /// <remarks>
  5508. /// <para>
  5509. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5510. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5511. /// </para>
  5512. /// <para>
  5513. /// 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.
  5514. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5515. /// </para>
  5516. /// <para>
  5517. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5518. /// making the Subscribe or Dispose call, respectively.
  5519. /// </para>
  5520. /// <para>
  5521. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5522. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5523. /// more concise and easier to understand.
  5524. /// </para>
  5525. /// </remarks>
  5526. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5527. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)
  5528. {
  5529. if (provider == null)
  5530. throw new ArgumentNullException(nameof(provider));
  5531. if (type == null)
  5532. throw new ArgumentNullException(nameof(type));
  5533. if (eventName == null)
  5534. throw new ArgumentNullException(nameof(eventName));
  5535. return provider.CreateQuery<EventPattern<object>>(
  5536. Expression.Call(
  5537. null,
  5538. #if CRIPPLED_REFLECTION
  5539. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string))),
  5540. #else
  5541. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5542. #endif
  5543. Expression.Constant(provider, typeof(IQbservableProvider)),
  5544. Expression.Constant(type, typeof(Type)),
  5545. Expression.Constant(eventName, typeof(string))
  5546. )
  5547. );
  5548. }
  5549. /// <summary>
  5550. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5551. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5552. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5553. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5554. /// </summary>
  5555. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5556. /// <param name="type">Type that exposes the static event to convert.</param>
  5557. /// <param name="eventName">Name of the event to convert.</param>
  5558. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5559. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5560. /// <exception cref="ArgumentNullException">
  5561. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5562. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5563. /// <remarks>
  5564. /// <para>
  5565. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5566. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5567. /// </para>
  5568. /// <para>
  5569. /// 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
  5570. /// accessed from the same context, as required by some UI frameworks.
  5571. /// </para>
  5572. /// <para>
  5573. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5574. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5575. /// parameter. For more information, see the remarks section on those overloads.
  5576. /// </para>
  5577. /// </remarks>
  5578. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5579. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  5580. {
  5581. if (provider == null)
  5582. throw new ArgumentNullException(nameof(provider));
  5583. if (type == null)
  5584. throw new ArgumentNullException(nameof(type));
  5585. if (eventName == null)
  5586. throw new ArgumentNullException(nameof(eventName));
  5587. if (scheduler == null)
  5588. throw new ArgumentNullException(nameof(scheduler));
  5589. return provider.CreateQuery<EventPattern<object>>(
  5590. Expression.Call(
  5591. null,
  5592. #if CRIPPLED_REFLECTION
  5593. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  5594. #else
  5595. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5596. #endif
  5597. Expression.Constant(provider, typeof(IQbservableProvider)),
  5598. Expression.Constant(type, typeof(Type)),
  5599. Expression.Constant(eventName, typeof(string)),
  5600. Expression.Constant(scheduler, typeof(IScheduler))
  5601. )
  5602. );
  5603. }
  5604. /// <summary>
  5605. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5606. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5607. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5608. /// </summary>
  5609. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5610. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5611. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5612. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5613. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5614. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5615. /// <exception cref="ArgumentNullException">
  5616. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5617. /// <remarks>
  5618. /// <para>
  5619. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5620. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5621. /// </para>
  5622. /// <para>
  5623. /// 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.
  5624. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5625. /// </para>
  5626. /// <para>
  5627. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5628. /// making the Subscribe or Dispose call, respectively.
  5629. /// </para>
  5630. /// <para>
  5631. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5632. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5633. /// more concise and easier to understand.
  5634. /// </para>
  5635. /// </remarks>
  5636. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5637. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5638. {
  5639. if (provider == null)
  5640. throw new ArgumentNullException(nameof(provider));
  5641. if (addHandler == null)
  5642. throw new ArgumentNullException(nameof(addHandler));
  5643. if (removeHandler == null)
  5644. throw new ArgumentNullException(nameof(removeHandler));
  5645. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5646. Expression.Call(
  5647. null,
  5648. #if CRIPPLED_REFLECTION
  5649. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5650. #else
  5651. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5652. #endif
  5653. Expression.Constant(provider, typeof(IQbservableProvider)),
  5654. addHandler,
  5655. removeHandler
  5656. )
  5657. );
  5658. }
  5659. /// <summary>
  5660. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5661. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5662. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5663. /// </summary>
  5664. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5665. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5666. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5667. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5668. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5669. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5670. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5671. /// <exception cref="ArgumentNullException">
  5672. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5673. /// <remarks>
  5674. /// <para>
  5675. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5676. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5677. /// </para>
  5678. /// <para>
  5679. /// 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
  5680. /// accessed from the same context, as required by some UI frameworks.
  5681. /// </para>
  5682. /// <para>
  5683. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5684. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5685. /// parameter. For more information, see the remarks section on those overloads.
  5686. /// </para>
  5687. /// </remarks>
  5688. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5689. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5690. {
  5691. if (provider == null)
  5692. throw new ArgumentNullException(nameof(provider));
  5693. if (addHandler == null)
  5694. throw new ArgumentNullException(nameof(addHandler));
  5695. if (removeHandler == null)
  5696. throw new ArgumentNullException(nameof(removeHandler));
  5697. if (scheduler == null)
  5698. throw new ArgumentNullException(nameof(scheduler));
  5699. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5700. Expression.Call(
  5701. null,
  5702. #if CRIPPLED_REFLECTION
  5703. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5704. #else
  5705. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5706. #endif
  5707. Expression.Constant(provider, typeof(IQbservableProvider)),
  5708. addHandler,
  5709. removeHandler,
  5710. Expression.Constant(scheduler, typeof(IScheduler))
  5711. )
  5712. );
  5713. }
  5714. /// <summary>
  5715. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5716. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5717. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5718. /// </summary>
  5719. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5720. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5721. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5722. /// <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>
  5723. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5724. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5725. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5726. /// <exception cref="ArgumentNullException">
  5727. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5728. /// <remarks>
  5729. /// <para>
  5730. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5731. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5732. /// </para>
  5733. /// <para>
  5734. /// 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.
  5735. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5736. /// </para>
  5737. /// <para>
  5738. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5739. /// making the Subscribe or Dispose call, respectively.
  5740. /// </para>
  5741. /// <para>
  5742. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5743. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5744. /// more concise and easier to understand.
  5745. /// </para>
  5746. /// </remarks>
  5747. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5748. 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)
  5749. {
  5750. if (provider == null)
  5751. throw new ArgumentNullException(nameof(provider));
  5752. if (conversion == null)
  5753. throw new ArgumentNullException(nameof(conversion));
  5754. if (addHandler == null)
  5755. throw new ArgumentNullException(nameof(addHandler));
  5756. if (removeHandler == null)
  5757. throw new ArgumentNullException(nameof(removeHandler));
  5758. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5759. Expression.Call(
  5760. null,
  5761. #if CRIPPLED_REFLECTION
  5762. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5763. #else
  5764. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5765. #endif
  5766. Expression.Constant(provider, typeof(IQbservableProvider)),
  5767. conversion,
  5768. addHandler,
  5769. removeHandler
  5770. )
  5771. );
  5772. }
  5773. /// <summary>
  5774. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5775. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5776. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5777. /// </summary>
  5778. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5779. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5780. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5781. /// <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>
  5782. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5783. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5784. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5785. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5786. /// <exception cref="ArgumentNullException">
  5787. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5788. /// <remarks>
  5789. /// <para>
  5790. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5791. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5792. /// </para>
  5793. /// <para>
  5794. /// 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
  5795. /// accessed from the same context, as required by some UI frameworks.
  5796. /// </para>
  5797. /// <para>
  5798. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5799. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5800. /// parameter. For more information, see the remarks section on those overloads.
  5801. /// </para>
  5802. /// </remarks>
  5803. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5804. 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)
  5805. {
  5806. if (provider == null)
  5807. throw new ArgumentNullException(nameof(provider));
  5808. if (conversion == null)
  5809. throw new ArgumentNullException(nameof(conversion));
  5810. if (addHandler == null)
  5811. throw new ArgumentNullException(nameof(addHandler));
  5812. if (removeHandler == null)
  5813. throw new ArgumentNullException(nameof(removeHandler));
  5814. if (scheduler == null)
  5815. throw new ArgumentNullException(nameof(scheduler));
  5816. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5817. Expression.Call(
  5818. null,
  5819. #if CRIPPLED_REFLECTION
  5820. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5821. #else
  5822. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5823. #endif
  5824. Expression.Constant(provider, typeof(IQbservableProvider)),
  5825. conversion,
  5826. addHandler,
  5827. removeHandler,
  5828. Expression.Constant(scheduler, typeof(IScheduler))
  5829. )
  5830. );
  5831. }
  5832. /// <summary>
  5833. /// 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.
  5834. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5835. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5836. /// </summary>
  5837. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5838. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5839. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  5840. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5841. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5842. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5843. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5844. /// <exception cref="ArgumentNullException">
  5845. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5846. /// <remarks>
  5847. /// <para>
  5848. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5849. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5850. /// </para>
  5851. /// <para>
  5852. /// 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.
  5853. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5854. /// </para>
  5855. /// <para>
  5856. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5857. /// making the Subscribe or Dispose call, respectively.
  5858. /// </para>
  5859. /// <para>
  5860. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5861. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5862. /// more concise and easier to understand.
  5863. /// </para>
  5864. /// </remarks>
  5865. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5866. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5867. {
  5868. if (provider == null)
  5869. throw new ArgumentNullException(nameof(provider));
  5870. if (addHandler == null)
  5871. throw new ArgumentNullException(nameof(addHandler));
  5872. if (removeHandler == null)
  5873. throw new ArgumentNullException(nameof(removeHandler));
  5874. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  5875. Expression.Call(
  5876. null,
  5877. #if CRIPPLED_REFLECTION
  5878. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5879. #else
  5880. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  5881. #endif
  5882. Expression.Constant(provider, typeof(IQbservableProvider)),
  5883. addHandler,
  5884. removeHandler
  5885. )
  5886. );
  5887. }
  5888. /// <summary>
  5889. /// 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.
  5890. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5891. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5892. /// </summary>
  5893. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5894. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5895. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  5896. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5897. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5898. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5899. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5900. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5901. /// <exception cref="ArgumentNullException">
  5902. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5903. /// <remarks>
  5904. /// <para>
  5905. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5906. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5907. /// </para>
  5908. /// <para>
  5909. /// 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
  5910. /// accessed from the same context, as required by some UI frameworks.
  5911. /// </para>
  5912. /// <para>
  5913. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5914. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5915. /// parameter. For more information, see the remarks section on those overloads.
  5916. /// </para>
  5917. /// </remarks>
  5918. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5919. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5920. {
  5921. if (provider == null)
  5922. throw new ArgumentNullException(nameof(provider));
  5923. if (addHandler == null)
  5924. throw new ArgumentNullException(nameof(addHandler));
  5925. if (removeHandler == null)
  5926. throw new ArgumentNullException(nameof(removeHandler));
  5927. if (scheduler == null)
  5928. throw new ArgumentNullException(nameof(scheduler));
  5929. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  5930. Expression.Call(
  5931. null,
  5932. #if CRIPPLED_REFLECTION
  5933. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5934. #else
  5935. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  5936. #endif
  5937. Expression.Constant(provider, typeof(IQbservableProvider)),
  5938. addHandler,
  5939. removeHandler,
  5940. Expression.Constant(scheduler, typeof(IScheduler))
  5941. )
  5942. );
  5943. }
  5944. /// <summary>
  5945. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5946. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5947. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5948. /// </summary>
  5949. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5950. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5951. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5952. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5953. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5954. /// <remarks>
  5955. /// <para>
  5956. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5957. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5958. /// </para>
  5959. /// <para>
  5960. /// 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.
  5961. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5962. /// </para>
  5963. /// <para>
  5964. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5965. /// making the Subscribe or Dispose call, respectively.
  5966. /// </para>
  5967. /// <para>
  5968. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5969. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5970. /// more concise and easier to understand.
  5971. /// </para>
  5972. /// </remarks>
  5973. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  5974. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler)
  5975. {
  5976. if (provider == null)
  5977. throw new ArgumentNullException(nameof(provider));
  5978. if (addHandler == null)
  5979. throw new ArgumentNullException(nameof(addHandler));
  5980. if (removeHandler == null)
  5981. throw new ArgumentNullException(nameof(removeHandler));
  5982. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5983. Expression.Call(
  5984. null,
  5985. #if CRIPPLED_REFLECTION
  5986. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>))),
  5987. #else
  5988. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5989. #endif
  5990. Expression.Constant(provider, typeof(IQbservableProvider)),
  5991. addHandler,
  5992. removeHandler
  5993. )
  5994. );
  5995. }
  5996. /// <summary>
  5997. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="T:System.EventHandler`1" />, to an observable sequence.
  5998. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5999. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6000. /// </summary>
  6001. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6002. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6003. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  6004. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  6005. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6006. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6007. /// <remarks>
  6008. /// <para>
  6009. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6010. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6011. /// </para>
  6012. /// <para>
  6013. /// 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
  6014. /// accessed from the same context, as required by some UI frameworks.
  6015. /// </para>
  6016. /// <para>
  6017. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6018. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6019. /// parameter. For more information, see the remarks section on those overloads.
  6020. /// </para>
  6021. /// </remarks>
  6022. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6023. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler, IScheduler scheduler)
  6024. {
  6025. if (provider == null)
  6026. throw new ArgumentNullException(nameof(provider));
  6027. if (addHandler == null)
  6028. throw new ArgumentNullException(nameof(addHandler));
  6029. if (removeHandler == null)
  6030. throw new ArgumentNullException(nameof(removeHandler));
  6031. if (scheduler == null)
  6032. throw new ArgumentNullException(nameof(scheduler));
  6033. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6034. Expression.Call(
  6035. null,
  6036. #if CRIPPLED_REFLECTION
  6037. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>), default(IScheduler))),
  6038. #else
  6039. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6040. #endif
  6041. Expression.Constant(provider, typeof(IQbservableProvider)),
  6042. addHandler,
  6043. removeHandler,
  6044. Expression.Constant(scheduler, typeof(IScheduler))
  6045. )
  6046. );
  6047. }
  6048. /// <summary>
  6049. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6050. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6051. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6052. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6053. /// </summary>
  6054. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6055. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6056. /// <param name="target">Object instance that exposes the event to convert.</param>
  6057. /// <param name="eventName">Name of the event to convert.</param>
  6058. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6059. /// <exception cref="ArgumentNullException">
  6060. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6061. /// <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>
  6062. /// <remarks>
  6063. /// <para>
  6064. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6065. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6066. /// </para>
  6067. /// <para>
  6068. /// 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.
  6069. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6070. /// </para>
  6071. /// <para>
  6072. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6073. /// making the Subscribe or Dispose call, respectively.
  6074. /// </para>
  6075. /// <para>
  6076. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6077. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6078. /// more concise and easier to understand.
  6079. /// </para>
  6080. /// </remarks>
  6081. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6082. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6083. {
  6084. if (provider == null)
  6085. throw new ArgumentNullException(nameof(provider));
  6086. if (target == null)
  6087. throw new ArgumentNullException(nameof(target));
  6088. if (eventName == null)
  6089. throw new ArgumentNullException(nameof(eventName));
  6090. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6091. Expression.Call(
  6092. null,
  6093. #if CRIPPLED_REFLECTION
  6094. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6095. #else
  6096. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6097. #endif
  6098. Expression.Constant(provider, typeof(IQbservableProvider)),
  6099. Expression.Constant(target, typeof(object)),
  6100. Expression.Constant(eventName, typeof(string))
  6101. )
  6102. );
  6103. }
  6104. /// <summary>
  6105. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6106. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6107. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6108. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6109. /// </summary>
  6110. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6111. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6112. /// <param name="target">Object instance that exposes the event to convert.</param>
  6113. /// <param name="eventName">Name of the event to convert.</param>
  6114. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6115. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6116. /// <exception cref="ArgumentNullException">
  6117. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6118. /// <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>
  6119. /// <remarks>
  6120. /// <para>
  6121. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6122. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6123. /// </para>
  6124. /// <para>
  6125. /// 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
  6126. /// accessed from the same context, as required by some UI frameworks.
  6127. /// </para>
  6128. /// <para>
  6129. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6130. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6131. /// parameter. For more information, see the remarks section on those overloads.
  6132. /// </para>
  6133. /// </remarks>
  6134. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6135. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6136. {
  6137. if (provider == null)
  6138. throw new ArgumentNullException(nameof(provider));
  6139. if (target == null)
  6140. throw new ArgumentNullException(nameof(target));
  6141. if (eventName == null)
  6142. throw new ArgumentNullException(nameof(eventName));
  6143. if (scheduler == null)
  6144. throw new ArgumentNullException(nameof(scheduler));
  6145. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6146. Expression.Call(
  6147. null,
  6148. #if CRIPPLED_REFLECTION
  6149. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6150. #else
  6151. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6152. #endif
  6153. Expression.Constant(provider, typeof(IQbservableProvider)),
  6154. Expression.Constant(target, typeof(object)),
  6155. Expression.Constant(eventName, typeof(string)),
  6156. Expression.Constant(scheduler, typeof(IScheduler))
  6157. )
  6158. );
  6159. }
  6160. /// <summary>
  6161. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6162. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6163. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6164. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6165. /// </summary>
  6166. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6167. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6168. /// <param name="type">Type that exposes the static event to convert.</param>
  6169. /// <param name="eventName">Name of the event to convert.</param>
  6170. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6171. /// <exception cref="ArgumentNullException">
  6172. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6173. /// <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>
  6174. /// <remarks>
  6175. /// <para>
  6176. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6177. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6178. /// </para>
  6179. /// <para>
  6180. /// 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.
  6181. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6182. /// </para>
  6183. /// <para>
  6184. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6185. /// making the Subscribe or Dispose call, respectively.
  6186. /// </para>
  6187. /// <para>
  6188. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6189. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6190. /// more concise and easier to understand.
  6191. /// </para>
  6192. /// </remarks>
  6193. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6194. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6195. {
  6196. if (provider == null)
  6197. throw new ArgumentNullException(nameof(provider));
  6198. if (type == null)
  6199. throw new ArgumentNullException(nameof(type));
  6200. if (eventName == null)
  6201. throw new ArgumentNullException(nameof(eventName));
  6202. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6203. Expression.Call(
  6204. null,
  6205. #if CRIPPLED_REFLECTION
  6206. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6207. #else
  6208. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6209. #endif
  6210. Expression.Constant(provider, typeof(IQbservableProvider)),
  6211. Expression.Constant(type, typeof(Type)),
  6212. Expression.Constant(eventName, typeof(string))
  6213. )
  6214. );
  6215. }
  6216. /// <summary>
  6217. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6218. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6219. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6220. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6221. /// </summary>
  6222. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6223. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6224. /// <param name="type">Type that exposes the static event to convert.</param>
  6225. /// <param name="eventName">Name of the event to convert.</param>
  6226. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6227. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6228. /// <exception cref="ArgumentNullException">
  6229. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6230. /// <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>
  6231. /// <remarks>
  6232. /// <para>
  6233. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6234. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6235. /// </para>
  6236. /// <para>
  6237. /// 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
  6238. /// accessed from the same context, as required by some UI frameworks.
  6239. /// </para>
  6240. /// <para>
  6241. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6242. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6243. /// parameter. For more information, see the remarks section on those overloads.
  6244. /// </para>
  6245. /// </remarks>
  6246. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6247. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6248. {
  6249. if (provider == null)
  6250. throw new ArgumentNullException(nameof(provider));
  6251. if (type == null)
  6252. throw new ArgumentNullException(nameof(type));
  6253. if (eventName == null)
  6254. throw new ArgumentNullException(nameof(eventName));
  6255. if (scheduler == null)
  6256. throw new ArgumentNullException(nameof(scheduler));
  6257. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6258. Expression.Call(
  6259. null,
  6260. #if CRIPPLED_REFLECTION
  6261. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6262. #else
  6263. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6264. #endif
  6265. Expression.Constant(provider, typeof(IQbservableProvider)),
  6266. Expression.Constant(type, typeof(Type)),
  6267. Expression.Constant(eventName, typeof(string)),
  6268. Expression.Constant(scheduler, typeof(IScheduler))
  6269. )
  6270. );
  6271. }
  6272. /// <summary>
  6273. /// 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.
  6274. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6275. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6276. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6277. /// </summary>
  6278. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6279. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6280. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6281. /// <param name="target">Object instance that exposes the event to convert.</param>
  6282. /// <param name="eventName">Name of the event to convert.</param>
  6283. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6284. /// <exception cref="ArgumentNullException">
  6285. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6286. /// <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>
  6287. /// <remarks>
  6288. /// <para>
  6289. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6290. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6291. /// </para>
  6292. /// <para>
  6293. /// 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.
  6294. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6295. /// </para>
  6296. /// <para>
  6297. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6298. /// making the Subscribe or Dispose call, respectively.
  6299. /// </para>
  6300. /// <para>
  6301. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6302. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6303. /// more concise and easier to understand.
  6304. /// </para>
  6305. /// </remarks>
  6306. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6307. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6308. {
  6309. if (provider == null)
  6310. throw new ArgumentNullException(nameof(provider));
  6311. if (target == null)
  6312. throw new ArgumentNullException(nameof(target));
  6313. if (eventName == null)
  6314. throw new ArgumentNullException(nameof(eventName));
  6315. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6316. Expression.Call(
  6317. null,
  6318. #if CRIPPLED_REFLECTION
  6319. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6320. #else
  6321. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6322. #endif
  6323. Expression.Constant(provider, typeof(IQbservableProvider)),
  6324. Expression.Constant(target, typeof(object)),
  6325. Expression.Constant(eventName, typeof(string))
  6326. )
  6327. );
  6328. }
  6329. /// <summary>
  6330. /// 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.
  6331. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6332. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6333. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6334. /// </summary>
  6335. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6336. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6337. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6338. /// <param name="target">Object instance that exposes the event to convert.</param>
  6339. /// <param name="eventName">Name of the event to convert.</param>
  6340. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6341. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6342. /// <exception cref="ArgumentNullException">
  6343. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6344. /// <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>
  6345. /// <remarks>
  6346. /// <para>
  6347. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6348. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6349. /// </para>
  6350. /// <para>
  6351. /// 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
  6352. /// accessed from the same context, as required by some UI frameworks.
  6353. /// </para>
  6354. /// <para>
  6355. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6356. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6357. /// parameter. For more information, see the remarks section on those overloads.
  6358. /// </para>
  6359. /// </remarks>
  6360. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6361. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6362. {
  6363. if (provider == null)
  6364. throw new ArgumentNullException(nameof(provider));
  6365. if (target == null)
  6366. throw new ArgumentNullException(nameof(target));
  6367. if (eventName == null)
  6368. throw new ArgumentNullException(nameof(eventName));
  6369. if (scheduler == null)
  6370. throw new ArgumentNullException(nameof(scheduler));
  6371. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6372. Expression.Call(
  6373. null,
  6374. #if CRIPPLED_REFLECTION
  6375. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6376. #else
  6377. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6378. #endif
  6379. Expression.Constant(provider, typeof(IQbservableProvider)),
  6380. Expression.Constant(target, typeof(object)),
  6381. Expression.Constant(eventName, typeof(string)),
  6382. Expression.Constant(scheduler, typeof(IScheduler))
  6383. )
  6384. );
  6385. }
  6386. /// <summary>
  6387. /// 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.
  6388. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6389. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6390. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6391. /// </summary>
  6392. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6393. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6394. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6395. /// <param name="type">Type that exposes the static event to convert.</param>
  6396. /// <param name="eventName">Name of the event to convert.</param>
  6397. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6398. /// <exception cref="ArgumentNullException">
  6399. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6400. /// <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>
  6401. /// <remarks>
  6402. /// <para>
  6403. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6404. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6405. /// </para>
  6406. /// <para>
  6407. /// 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.
  6408. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6409. /// </para>
  6410. /// <para>
  6411. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6412. /// making the Subscribe or Dispose call, respectively.
  6413. /// </para>
  6414. /// <para>
  6415. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6416. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6417. /// more concise and easier to understand.
  6418. /// </para>
  6419. /// </remarks>
  6420. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6421. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6422. {
  6423. if (provider == null)
  6424. throw new ArgumentNullException(nameof(provider));
  6425. if (type == null)
  6426. throw new ArgumentNullException(nameof(type));
  6427. if (eventName == null)
  6428. throw new ArgumentNullException(nameof(eventName));
  6429. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6430. Expression.Call(
  6431. null,
  6432. #if CRIPPLED_REFLECTION
  6433. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6434. #else
  6435. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6436. #endif
  6437. Expression.Constant(provider, typeof(IQbservableProvider)),
  6438. Expression.Constant(type, typeof(Type)),
  6439. Expression.Constant(eventName, typeof(string))
  6440. )
  6441. );
  6442. }
  6443. /// <summary>
  6444. /// 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.
  6445. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6446. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6447. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6448. /// </summary>
  6449. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6450. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6451. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6452. /// <param name="type">Type that exposes the static event to convert.</param>
  6453. /// <param name="eventName">Name of the event to convert.</param>
  6454. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6455. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6456. /// <exception cref="ArgumentNullException">
  6457. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6458. /// <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>
  6459. /// <remarks>
  6460. /// <para>
  6461. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6462. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6463. /// </para>
  6464. /// <para>
  6465. /// 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
  6466. /// accessed from the same context, as required by some UI frameworks.
  6467. /// </para>
  6468. /// <para>
  6469. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6470. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6471. /// parameter. For more information, see the remarks section on those overloads.
  6472. /// </para>
  6473. /// </remarks>
  6474. /// <seealso cref="M:System.Reactive.Linq.Observable.ToEventPattern``1(System.IObservable{System.Reactive.EventPattern{``0}})" />
  6475. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6476. {
  6477. if (provider == null)
  6478. throw new ArgumentNullException(nameof(provider));
  6479. if (type == null)
  6480. throw new ArgumentNullException(nameof(type));
  6481. if (eventName == null)
  6482. throw new ArgumentNullException(nameof(eventName));
  6483. if (scheduler == null)
  6484. throw new ArgumentNullException(nameof(scheduler));
  6485. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6486. Expression.Call(
  6487. null,
  6488. #if CRIPPLED_REFLECTION
  6489. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6490. #else
  6491. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6492. #endif
  6493. Expression.Constant(provider, typeof(IQbservableProvider)),
  6494. Expression.Constant(type, typeof(Type)),
  6495. Expression.Constant(eventName, typeof(string)),
  6496. Expression.Constant(scheduler, typeof(IScheduler))
  6497. )
  6498. );
  6499. }
  6500. /// <summary>
  6501. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements.
  6502. /// </summary>
  6503. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6504. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6505. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6506. /// <param name="initialState">Initial state.</param>
  6507. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6508. /// <param name="iterate">Iteration step function.</param>
  6509. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6510. /// <returns>The generated sequence.</returns>
  6511. /// <exception cref="ArgumentNullException">
  6512. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> is null.</exception>
  6513. 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)
  6514. {
  6515. if (provider == null)
  6516. throw new ArgumentNullException(nameof(provider));
  6517. if (condition == null)
  6518. throw new ArgumentNullException(nameof(condition));
  6519. if (iterate == null)
  6520. throw new ArgumentNullException(nameof(iterate));
  6521. if (resultSelector == null)
  6522. throw new ArgumentNullException(nameof(resultSelector));
  6523. return provider.CreateQuery<TResult>(
  6524. Expression.Call(
  6525. null,
  6526. #if CRIPPLED_REFLECTION
  6527. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>))),
  6528. #else
  6529. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6530. #endif
  6531. Expression.Constant(provider, typeof(IQbservableProvider)),
  6532. Expression.Constant(initialState, typeof(TState)),
  6533. condition,
  6534. iterate,
  6535. resultSelector
  6536. )
  6537. );
  6538. }
  6539. /// <summary>
  6540. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
  6541. /// </summary>
  6542. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6543. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6544. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6545. /// <param name="initialState">Initial state.</param>
  6546. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6547. /// <param name="iterate">Iteration step function.</param>
  6548. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6549. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6550. /// <returns>The generated sequence.</returns>
  6551. /// <exception cref="ArgumentNullException">
  6552. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6553. 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)
  6554. {
  6555. if (provider == null)
  6556. throw new ArgumentNullException(nameof(provider));
  6557. if (condition == null)
  6558. throw new ArgumentNullException(nameof(condition));
  6559. if (iterate == null)
  6560. throw new ArgumentNullException(nameof(iterate));
  6561. if (resultSelector == null)
  6562. throw new ArgumentNullException(nameof(resultSelector));
  6563. if (scheduler == null)
  6564. throw new ArgumentNullException(nameof(scheduler));
  6565. return provider.CreateQuery<TResult>(
  6566. Expression.Call(
  6567. null,
  6568. #if CRIPPLED_REFLECTION
  6569. 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))),
  6570. #else
  6571. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6572. #endif
  6573. Expression.Constant(provider, typeof(IQbservableProvider)),
  6574. Expression.Constant(initialState, typeof(TState)),
  6575. condition,
  6576. iterate,
  6577. resultSelector,
  6578. Expression.Constant(scheduler, typeof(IScheduler))
  6579. )
  6580. );
  6581. }
  6582. /// <summary>
  6583. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6584. /// </summary>
  6585. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6586. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6587. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6588. /// <param name="initialState">Initial state.</param>
  6589. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6590. /// <param name="iterate">Iteration step function.</param>
  6591. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6592. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6593. /// <returns>The generated sequence.</returns>
  6594. /// <exception cref="ArgumentNullException">
  6595. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6596. 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)
  6597. {
  6598. if (provider == null)
  6599. throw new ArgumentNullException(nameof(provider));
  6600. if (condition == null)
  6601. throw new ArgumentNullException(nameof(condition));
  6602. if (iterate == null)
  6603. throw new ArgumentNullException(nameof(iterate));
  6604. if (resultSelector == null)
  6605. throw new ArgumentNullException(nameof(resultSelector));
  6606. if (timeSelector == null)
  6607. throw new ArgumentNullException(nameof(timeSelector));
  6608. return provider.CreateQuery<TResult>(
  6609. Expression.Call(
  6610. null,
  6611. #if CRIPPLED_REFLECTION
  6612. 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>>))),
  6613. #else
  6614. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6615. #endif
  6616. Expression.Constant(provider, typeof(IQbservableProvider)),
  6617. Expression.Constant(initialState, typeof(TState)),
  6618. condition,
  6619. iterate,
  6620. resultSelector,
  6621. timeSelector
  6622. )
  6623. );
  6624. }
  6625. /// <summary>
  6626. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6627. /// </summary>
  6628. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6629. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6630. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6631. /// <param name="initialState">Initial state.</param>
  6632. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6633. /// <param name="iterate">Iteration step function.</param>
  6634. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6635. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6636. /// <returns>The generated sequence.</returns>
  6637. /// <exception cref="ArgumentNullException">
  6638. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6639. 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)
  6640. {
  6641. if (provider == null)
  6642. throw new ArgumentNullException(nameof(provider));
  6643. if (condition == null)
  6644. throw new ArgumentNullException(nameof(condition));
  6645. if (iterate == null)
  6646. throw new ArgumentNullException(nameof(iterate));
  6647. if (resultSelector == null)
  6648. throw new ArgumentNullException(nameof(resultSelector));
  6649. if (timeSelector == null)
  6650. throw new ArgumentNullException(nameof(timeSelector));
  6651. return provider.CreateQuery<TResult>(
  6652. Expression.Call(
  6653. null,
  6654. #if CRIPPLED_REFLECTION
  6655. 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>>))),
  6656. #else
  6657. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6658. #endif
  6659. Expression.Constant(provider, typeof(IQbservableProvider)),
  6660. Expression.Constant(initialState, typeof(TState)),
  6661. condition,
  6662. iterate,
  6663. resultSelector,
  6664. timeSelector
  6665. )
  6666. );
  6667. }
  6668. /// <summary>
  6669. /// 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.
  6670. /// </summary>
  6671. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6672. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6673. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6674. /// <param name="initialState">Initial state.</param>
  6675. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6676. /// <param name="iterate">Iteration step function.</param>
  6677. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6678. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6679. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6680. /// <returns>The generated sequence.</returns>
  6681. /// <exception cref="ArgumentNullException">
  6682. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6683. 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)
  6684. {
  6685. if (provider == null)
  6686. throw new ArgumentNullException(nameof(provider));
  6687. if (condition == null)
  6688. throw new ArgumentNullException(nameof(condition));
  6689. if (iterate == null)
  6690. throw new ArgumentNullException(nameof(iterate));
  6691. if (resultSelector == null)
  6692. throw new ArgumentNullException(nameof(resultSelector));
  6693. if (timeSelector == null)
  6694. throw new ArgumentNullException(nameof(timeSelector));
  6695. if (scheduler == null)
  6696. throw new ArgumentNullException(nameof(scheduler));
  6697. return provider.CreateQuery<TResult>(
  6698. Expression.Call(
  6699. null,
  6700. #if CRIPPLED_REFLECTION
  6701. 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))),
  6702. #else
  6703. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6704. #endif
  6705. Expression.Constant(provider, typeof(IQbservableProvider)),
  6706. Expression.Constant(initialState, typeof(TState)),
  6707. condition,
  6708. iterate,
  6709. resultSelector,
  6710. timeSelector,
  6711. Expression.Constant(scheduler, typeof(IScheduler))
  6712. )
  6713. );
  6714. }
  6715. /// <summary>
  6716. /// 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.
  6717. /// </summary>
  6718. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6719. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6720. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6721. /// <param name="initialState">Initial state.</param>
  6722. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6723. /// <param name="iterate">Iteration step function.</param>
  6724. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6725. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6726. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6727. /// <returns>The generated sequence.</returns>
  6728. /// <exception cref="ArgumentNullException">
  6729. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6730. 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)
  6731. {
  6732. if (provider == null)
  6733. throw new ArgumentNullException(nameof(provider));
  6734. if (condition == null)
  6735. throw new ArgumentNullException(nameof(condition));
  6736. if (iterate == null)
  6737. throw new ArgumentNullException(nameof(iterate));
  6738. if (resultSelector == null)
  6739. throw new ArgumentNullException(nameof(resultSelector));
  6740. if (timeSelector == null)
  6741. throw new ArgumentNullException(nameof(timeSelector));
  6742. if (scheduler == null)
  6743. throw new ArgumentNullException(nameof(scheduler));
  6744. return provider.CreateQuery<TResult>(
  6745. Expression.Call(
  6746. null,
  6747. #if CRIPPLED_REFLECTION
  6748. 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))),
  6749. #else
  6750. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6751. #endif
  6752. Expression.Constant(provider, typeof(IQbservableProvider)),
  6753. Expression.Constant(initialState, typeof(TState)),
  6754. condition,
  6755. iterate,
  6756. resultSelector,
  6757. timeSelector,
  6758. Expression.Constant(scheduler, typeof(IScheduler))
  6759. )
  6760. );
  6761. }
  6762. /// <summary>
  6763. /// Groups the elements of an observable sequence according to a specified key selector function.
  6764. /// </summary>
  6765. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6766. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6767. /// <param name="source">An observable sequence whose elements to group.</param>
  6768. /// <param name="keySelector">A function to extract the key for each element.</param>
  6769. /// <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>
  6770. /// <exception cref="ArgumentNullException">
  6771. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  6772. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  6773. {
  6774. if (source == null)
  6775. throw new ArgumentNullException(nameof(source));
  6776. if (keySelector == null)
  6777. throw new ArgumentNullException(nameof(keySelector));
  6778. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6779. Expression.Call(
  6780. null,
  6781. #if CRIPPLED_REFLECTION
  6782. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  6783. #else
  6784. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6785. #endif
  6786. source.Expression,
  6787. keySelector
  6788. )
  6789. );
  6790. }
  6791. /// <summary>
  6792. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  6793. /// </summary>
  6794. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6795. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6796. /// <param name="source">An observable sequence whose elements to group.</param>
  6797. /// <param name="keySelector">A function to extract the key for each element.</param>
  6798. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6799. /// <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>
  6800. /// <exception cref="ArgumentNullException">
  6801. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  6802. /// <exception cref="ArgumentOutOfRangeException">
  6803. /// <paramref name="capacity" /> is less than 0.</exception>
  6804. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity)
  6805. {
  6806. if (source == null)
  6807. throw new ArgumentNullException(nameof(source));
  6808. if (keySelector == null)
  6809. throw new ArgumentNullException(nameof(keySelector));
  6810. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6811. Expression.Call(
  6812. null,
  6813. #if CRIPPLED_REFLECTION
  6814. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int))),
  6815. #else
  6816. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6817. #endif
  6818. source.Expression,
  6819. keySelector,
  6820. Expression.Constant(capacity, typeof(int))
  6821. )
  6822. );
  6823. }
  6824. /// <summary>
  6825. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  6826. /// </summary>
  6827. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6828. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6829. /// <param name="source">An observable sequence whose elements to group.</param>
  6830. /// <param name="keySelector">A function to extract the key for each element.</param>
  6831. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6832. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6833. /// <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>
  6834. /// <exception cref="ArgumentNullException">
  6835. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  6836. /// <exception cref="ArgumentOutOfRangeException">
  6837. /// <paramref name="capacity" /> is less than 0.</exception>
  6838. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity, IEqualityComparer<TKey> comparer)
  6839. {
  6840. if (source == null)
  6841. throw new ArgumentNullException(nameof(source));
  6842. if (keySelector == null)
  6843. throw new ArgumentNullException(nameof(keySelector));
  6844. if (comparer == null)
  6845. throw new ArgumentNullException(nameof(comparer));
  6846. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6847. Expression.Call(
  6848. null,
  6849. #if CRIPPLED_REFLECTION
  6850. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int), default(IEqualityComparer<TKey>))),
  6851. #else
  6852. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6853. #endif
  6854. source.Expression,
  6855. keySelector,
  6856. Expression.Constant(capacity, typeof(int)),
  6857. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6858. )
  6859. );
  6860. }
  6861. /// <summary>
  6862. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  6863. /// </summary>
  6864. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6865. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6866. /// <param name="source">An observable sequence whose elements to group.</param>
  6867. /// <param name="keySelector">A function to extract the key for each element.</param>
  6868. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6869. /// <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>
  6870. /// <exception cref="ArgumentNullException">
  6871. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  6872. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  6873. {
  6874. if (source == null)
  6875. throw new ArgumentNullException(nameof(source));
  6876. if (keySelector == null)
  6877. throw new ArgumentNullException(nameof(keySelector));
  6878. if (comparer == null)
  6879. throw new ArgumentNullException(nameof(comparer));
  6880. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6881. Expression.Call(
  6882. null,
  6883. #if CRIPPLED_REFLECTION
  6884. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  6885. #else
  6886. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6887. #endif
  6888. source.Expression,
  6889. keySelector,
  6890. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6891. )
  6892. );
  6893. }
  6894. /// <summary>
  6895. /// Groups the elements of an observable sequence and selects the resulting elements by using a specified function.
  6896. /// </summary>
  6897. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6898. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6899. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6900. /// <param name="source">An observable sequence whose elements to group.</param>
  6901. /// <param name="keySelector">A function to extract the key for each element.</param>
  6902. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6903. /// <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>
  6904. /// <exception cref="ArgumentNullException">
  6905. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  6906. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  6907. {
  6908. if (source == null)
  6909. throw new ArgumentNullException(nameof(source));
  6910. if (keySelector == null)
  6911. throw new ArgumentNullException(nameof(keySelector));
  6912. if (elementSelector == null)
  6913. throw new ArgumentNullException(nameof(elementSelector));
  6914. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6915. Expression.Call(
  6916. null,
  6917. #if CRIPPLED_REFLECTION
  6918. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  6919. #else
  6920. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6921. #endif
  6922. source.Expression,
  6923. keySelector,
  6924. elementSelector
  6925. )
  6926. );
  6927. }
  6928. /// <summary>
  6929. /// Groups the elements of an observable sequence with the specified initial capacity and selects the resulting elements by using a specified function.
  6930. /// </summary>
  6931. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6932. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6933. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6934. /// <param name="source">An observable sequence whose elements to group.</param>
  6935. /// <param name="keySelector">A function to extract the key for each element.</param>
  6936. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6937. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6938. /// <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>
  6939. /// <exception cref="ArgumentNullException">
  6940. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  6941. /// <exception cref="ArgumentOutOfRangeException">
  6942. /// <paramref name="capacity" /> is less than 0.</exception>
  6943. 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)
  6944. {
  6945. if (source == null)
  6946. throw new ArgumentNullException(nameof(source));
  6947. if (keySelector == null)
  6948. throw new ArgumentNullException(nameof(keySelector));
  6949. if (elementSelector == null)
  6950. throw new ArgumentNullException(nameof(elementSelector));
  6951. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6952. Expression.Call(
  6953. null,
  6954. #if CRIPPLED_REFLECTION
  6955. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int))),
  6956. #else
  6957. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6958. #endif
  6959. source.Expression,
  6960. keySelector,
  6961. elementSelector,
  6962. Expression.Constant(capacity, typeof(int))
  6963. )
  6964. );
  6965. }
  6966. /// <summary>
  6967. /// 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.
  6968. /// </summary>
  6969. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6970. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6971. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6972. /// <param name="source">An observable sequence whose elements to group.</param>
  6973. /// <param name="keySelector">A function to extract the key for each element.</param>
  6974. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6975. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6976. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6977. /// <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>
  6978. /// <exception cref="ArgumentNullException">
  6979. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  6980. /// <exception cref="ArgumentOutOfRangeException">
  6981. /// <paramref name="capacity" /> is less than 0.</exception>
  6982. 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)
  6983. {
  6984. if (source == null)
  6985. throw new ArgumentNullException(nameof(source));
  6986. if (keySelector == null)
  6987. throw new ArgumentNullException(nameof(keySelector));
  6988. if (elementSelector == null)
  6989. throw new ArgumentNullException(nameof(elementSelector));
  6990. if (comparer == null)
  6991. throw new ArgumentNullException(nameof(comparer));
  6992. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6993. Expression.Call(
  6994. null,
  6995. #if CRIPPLED_REFLECTION
  6996. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int), default(IEqualityComparer<TKey>))),
  6997. #else
  6998. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6999. #endif
  7000. source.Expression,
  7001. keySelector,
  7002. elementSelector,
  7003. Expression.Constant(capacity, typeof(int)),
  7004. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7005. )
  7006. );
  7007. }
  7008. /// <summary>
  7009. /// 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.
  7010. /// </summary>
  7011. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7012. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7013. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7014. /// <param name="source">An observable sequence whose elements to group.</param>
  7015. /// <param name="keySelector">A function to extract the key for each element.</param>
  7016. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7017. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7018. /// <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>
  7019. /// <exception cref="ArgumentNullException">
  7020. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  7021. 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)
  7022. {
  7023. if (source == null)
  7024. throw new ArgumentNullException(nameof(source));
  7025. if (keySelector == null)
  7026. throw new ArgumentNullException(nameof(keySelector));
  7027. if (elementSelector == null)
  7028. throw new ArgumentNullException(nameof(elementSelector));
  7029. if (comparer == null)
  7030. throw new ArgumentNullException(nameof(comparer));
  7031. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7032. Expression.Call(
  7033. null,
  7034. #if CRIPPLED_REFLECTION
  7035. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  7036. #else
  7037. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  7038. #endif
  7039. source.Expression,
  7040. keySelector,
  7041. elementSelector,
  7042. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7043. )
  7044. );
  7045. }
  7046. /// <summary>
  7047. /// Groups the elements of an observable sequence according to a specified key selector function.
  7048. /// 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
  7049. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7050. /// </summary>
  7051. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7052. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7053. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7054. /// <param name="source">An observable sequence whose elements to group.</param>
  7055. /// <param name="keySelector">A function to extract the key for each element.</param>
  7056. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7057. /// <returns>
  7058. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7059. /// 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.
  7060. /// </returns>
  7061. /// <exception cref="ArgumentNullException">
  7062. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7063. 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)
  7064. {
  7065. if (source == null)
  7066. throw new ArgumentNullException(nameof(source));
  7067. if (keySelector == null)
  7068. throw new ArgumentNullException(nameof(keySelector));
  7069. if (durationSelector == null)
  7070. throw new ArgumentNullException(nameof(durationSelector));
  7071. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7072. Expression.Call(
  7073. null,
  7074. #if CRIPPLED_REFLECTION
  7075. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>))),
  7076. #else
  7077. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7078. #endif
  7079. source.Expression,
  7080. keySelector,
  7081. durationSelector
  7082. )
  7083. );
  7084. }
  7085. /// <summary>
  7086. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  7087. /// 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
  7088. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7089. /// </summary>
  7090. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7091. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7092. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7093. /// <param name="source">An observable sequence whose elements to group.</param>
  7094. /// <param name="keySelector">A function to extract the key for each element.</param>
  7095. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7096. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7097. /// <returns>
  7098. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7099. /// 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.
  7100. /// </returns>
  7101. /// <exception cref="ArgumentNullException">
  7102. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7103. /// <exception cref="ArgumentOutOfRangeException">
  7104. /// <paramref name="capacity" /> is less than 0.</exception>
  7105. 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)
  7106. {
  7107. if (source == null)
  7108. throw new ArgumentNullException(nameof(source));
  7109. if (keySelector == null)
  7110. throw new ArgumentNullException(nameof(keySelector));
  7111. if (durationSelector == null)
  7112. throw new ArgumentNullException(nameof(durationSelector));
  7113. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7114. Expression.Call(
  7115. null,
  7116. #if CRIPPLED_REFLECTION
  7117. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(int))),
  7118. #else
  7119. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7120. #endif
  7121. source.Expression,
  7122. keySelector,
  7123. durationSelector,
  7124. Expression.Constant(capacity, typeof(int))
  7125. )
  7126. );
  7127. }
  7128. /// <summary>
  7129. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  7130. /// 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
  7131. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7132. /// </summary>
  7133. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7134. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7135. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7136. /// <param name="source">An observable sequence whose elements to group.</param>
  7137. /// <param name="keySelector">A function to extract the key for each element.</param>
  7138. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7139. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7140. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7141. /// <returns>
  7142. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7143. /// 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.
  7144. /// </returns>
  7145. /// <exception cref="ArgumentNullException">
  7146. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7147. /// <exception cref="ArgumentOutOfRangeException">
  7148. /// <paramref name="capacity" /> is less than 0.</exception>
  7149. 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)
  7150. {
  7151. if (source == null)
  7152. throw new ArgumentNullException(nameof(source));
  7153. if (keySelector == null)
  7154. throw new ArgumentNullException(nameof(keySelector));
  7155. if (durationSelector == null)
  7156. throw new ArgumentNullException(nameof(durationSelector));
  7157. if (comparer == null)
  7158. throw new ArgumentNullException(nameof(comparer));
  7159. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7160. Expression.Call(
  7161. null,
  7162. #if CRIPPLED_REFLECTION
  7163. 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>))),
  7164. #else
  7165. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7166. #endif
  7167. source.Expression,
  7168. keySelector,
  7169. durationSelector,
  7170. Expression.Constant(capacity, typeof(int)),
  7171. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7172. )
  7173. );
  7174. }
  7175. /// <summary>
  7176. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  7177. /// 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
  7178. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7179. /// </summary>
  7180. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7181. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7182. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7183. /// <param name="source">An observable sequence whose elements to group.</param>
  7184. /// <param name="keySelector">A function to extract the key for each element.</param>
  7185. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7186. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7187. /// <returns>
  7188. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7189. /// 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.
  7190. /// </returns>
  7191. /// <exception cref="ArgumentNullException">
  7192. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7193. 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)
  7194. {
  7195. if (source == null)
  7196. throw new ArgumentNullException(nameof(source));
  7197. if (keySelector == null)
  7198. throw new ArgumentNullException(nameof(keySelector));
  7199. if (durationSelector == null)
  7200. throw new ArgumentNullException(nameof(durationSelector));
  7201. if (comparer == null)
  7202. throw new ArgumentNullException(nameof(comparer));
  7203. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7204. Expression.Call(
  7205. null,
  7206. #if CRIPPLED_REFLECTION
  7207. 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>))),
  7208. #else
  7209. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7210. #endif
  7211. source.Expression,
  7212. keySelector,
  7213. durationSelector,
  7214. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7215. )
  7216. );
  7217. }
  7218. /// <summary>
  7219. /// Groups the elements of an observable sequence according to a specified key selector function and selects the resulting elements by using a specified function.
  7220. /// 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
  7221. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7222. /// </summary>
  7223. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7224. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7225. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7226. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7227. /// <param name="source">An observable sequence whose elements to group.</param>
  7228. /// <param name="keySelector">A function to extract the key for each element.</param>
  7229. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7230. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7231. /// <returns>
  7232. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7233. /// 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.
  7234. /// </returns>
  7235. /// <exception cref="ArgumentNullException">
  7236. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7237. 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)
  7238. {
  7239. if (source == null)
  7240. throw new ArgumentNullException(nameof(source));
  7241. if (keySelector == null)
  7242. throw new ArgumentNullException(nameof(keySelector));
  7243. if (elementSelector == null)
  7244. throw new ArgumentNullException(nameof(elementSelector));
  7245. if (durationSelector == null)
  7246. throw new ArgumentNullException(nameof(durationSelector));
  7247. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7248. Expression.Call(
  7249. null,
  7250. #if CRIPPLED_REFLECTION
  7251. 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>>>))),
  7252. #else
  7253. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7254. #endif
  7255. source.Expression,
  7256. keySelector,
  7257. elementSelector,
  7258. durationSelector
  7259. )
  7260. );
  7261. }
  7262. /// <summary>
  7263. /// 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.
  7264. /// 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
  7265. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7266. /// </summary>
  7267. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7268. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7269. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7270. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7271. /// <param name="source">An observable sequence whose elements to group.</param>
  7272. /// <param name="keySelector">A function to extract the key for each element.</param>
  7273. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7274. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7275. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7276. /// <returns>
  7277. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7278. /// 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.
  7279. /// </returns>
  7280. /// <exception cref="ArgumentNullException">
  7281. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7282. /// <exception cref="ArgumentOutOfRangeException">
  7283. /// <paramref name="capacity" /> is less than 0.</exception>
  7284. 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)
  7285. {
  7286. if (source == null)
  7287. throw new ArgumentNullException(nameof(source));
  7288. if (keySelector == null)
  7289. throw new ArgumentNullException(nameof(keySelector));
  7290. if (elementSelector == null)
  7291. throw new ArgumentNullException(nameof(elementSelector));
  7292. if (durationSelector == null)
  7293. throw new ArgumentNullException(nameof(durationSelector));
  7294. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7295. Expression.Call(
  7296. null,
  7297. #if CRIPPLED_REFLECTION
  7298. 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))),
  7299. #else
  7300. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7301. #endif
  7302. source.Expression,
  7303. keySelector,
  7304. elementSelector,
  7305. durationSelector,
  7306. Expression.Constant(capacity, typeof(int))
  7307. )
  7308. );
  7309. }
  7310. /// <summary>
  7311. /// 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.
  7312. /// 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
  7313. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7314. /// </summary>
  7315. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7316. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7317. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7318. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7319. /// <param name="source">An observable sequence whose elements to group.</param>
  7320. /// <param name="keySelector">A function to extract the key for each element.</param>
  7321. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7322. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7323. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7324. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7325. /// <returns>
  7326. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7327. /// 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.
  7328. /// </returns>
  7329. /// <exception cref="ArgumentNullException">
  7330. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7331. /// <exception cref="ArgumentOutOfRangeException">
  7332. /// <paramref name="capacity" /> is less than 0.</exception>
  7333. 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)
  7334. {
  7335. if (source == null)
  7336. throw new ArgumentNullException(nameof(source));
  7337. if (keySelector == null)
  7338. throw new ArgumentNullException(nameof(keySelector));
  7339. if (elementSelector == null)
  7340. throw new ArgumentNullException(nameof(elementSelector));
  7341. if (durationSelector == null)
  7342. throw new ArgumentNullException(nameof(durationSelector));
  7343. if (comparer == null)
  7344. throw new ArgumentNullException(nameof(comparer));
  7345. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7346. Expression.Call(
  7347. null,
  7348. #if CRIPPLED_REFLECTION
  7349. 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>))),
  7350. #else
  7351. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7352. #endif
  7353. source.Expression,
  7354. keySelector,
  7355. elementSelector,
  7356. durationSelector,
  7357. Expression.Constant(capacity, typeof(int)),
  7358. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7359. )
  7360. );
  7361. }
  7362. /// <summary>
  7363. /// 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.
  7364. /// 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
  7365. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7366. /// </summary>
  7367. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7368. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7369. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7370. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7371. /// <param name="source">An observable sequence whose elements to group.</param>
  7372. /// <param name="keySelector">A function to extract the key for each element.</param>
  7373. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7374. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7375. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7376. /// <returns>
  7377. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7378. /// 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.
  7379. /// </returns>
  7380. /// <exception cref="ArgumentNullException">
  7381. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7382. 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)
  7383. {
  7384. if (source == null)
  7385. throw new ArgumentNullException(nameof(source));
  7386. if (keySelector == null)
  7387. throw new ArgumentNullException(nameof(keySelector));
  7388. if (elementSelector == null)
  7389. throw new ArgumentNullException(nameof(elementSelector));
  7390. if (durationSelector == null)
  7391. throw new ArgumentNullException(nameof(durationSelector));
  7392. if (comparer == null)
  7393. throw new ArgumentNullException(nameof(comparer));
  7394. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7395. Expression.Call(
  7396. null,
  7397. #if CRIPPLED_REFLECTION
  7398. 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>))),
  7399. #else
  7400. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7401. #endif
  7402. source.Expression,
  7403. keySelector,
  7404. elementSelector,
  7405. durationSelector,
  7406. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7407. )
  7408. );
  7409. }
  7410. /// <summary>
  7411. /// Correlates the elements of two sequences based on overlapping durations, and groups the results.
  7412. /// </summary>
  7413. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7414. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7415. /// <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>
  7416. /// <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>
  7417. /// <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>
  7418. /// <param name="left">The left observable sequence to join elements for.</param>
  7419. /// <param name="right">The right observable sequence to join elements for.</param>
  7420. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7421. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7422. /// <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>
  7423. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7424. /// <exception cref="ArgumentNullException">
  7425. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7426. 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)
  7427. {
  7428. if (left == null)
  7429. throw new ArgumentNullException(nameof(left));
  7430. if (right == null)
  7431. throw new ArgumentNullException(nameof(right));
  7432. if (leftDurationSelector == null)
  7433. throw new ArgumentNullException(nameof(leftDurationSelector));
  7434. if (rightDurationSelector == null)
  7435. throw new ArgumentNullException(nameof(rightDurationSelector));
  7436. if (resultSelector == null)
  7437. throw new ArgumentNullException(nameof(resultSelector));
  7438. return left.Provider.CreateQuery<TResult>(
  7439. Expression.Call(
  7440. null,
  7441. #if CRIPPLED_REFLECTION
  7442. 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>>))),
  7443. #else
  7444. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7445. #endif
  7446. left.Expression,
  7447. GetSourceExpression(right),
  7448. leftDurationSelector,
  7449. rightDurationSelector,
  7450. resultSelector
  7451. )
  7452. );
  7453. }
  7454. /// <summary>
  7455. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence.
  7456. /// </summary>
  7457. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7458. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7459. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7460. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7461. /// <returns>
  7462. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7463. /// <exception cref="ArgumentNullException">
  7464. /// <paramref name="condition" /> or <paramref name="thenSource" /> is null.</exception>
  7465. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource)
  7466. {
  7467. if (provider == null)
  7468. throw new ArgumentNullException(nameof(provider));
  7469. if (condition == null)
  7470. throw new ArgumentNullException(nameof(condition));
  7471. if (thenSource == null)
  7472. throw new ArgumentNullException(nameof(thenSource));
  7473. return provider.CreateQuery<TResult>(
  7474. Expression.Call(
  7475. null,
  7476. #if CRIPPLED_REFLECTION
  7477. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>))),
  7478. #else
  7479. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7480. #endif
  7481. Expression.Constant(provider, typeof(IQbservableProvider)),
  7482. condition,
  7483. GetSourceExpression(thenSource)
  7484. )
  7485. );
  7486. }
  7487. /// <summary>
  7488. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, select the <paramref name="elseSource" /> sequence.
  7489. /// </summary>
  7490. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7491. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7492. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7493. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7494. /// <param name="elseSource">Sequence returned in case <paramref name="condition" /> evaluates false.</param>
  7495. /// <returns>
  7496. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; <paramref name="elseSource" /> otherwise.</returns>
  7497. /// <exception cref="ArgumentNullException">
  7498. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="elseSource" /> is null.</exception>
  7499. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IObservable<TResult> elseSource)
  7500. {
  7501. if (provider == null)
  7502. throw new ArgumentNullException(nameof(provider));
  7503. if (condition == null)
  7504. throw new ArgumentNullException(nameof(condition));
  7505. if (thenSource == null)
  7506. throw new ArgumentNullException(nameof(thenSource));
  7507. if (elseSource == null)
  7508. throw new ArgumentNullException(nameof(elseSource));
  7509. return provider.CreateQuery<TResult>(
  7510. Expression.Call(
  7511. null,
  7512. #if CRIPPLED_REFLECTION
  7513. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IObservable<TResult>))),
  7514. #else
  7515. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7516. #endif
  7517. Expression.Constant(provider, typeof(IQbservableProvider)),
  7518. condition,
  7519. GetSourceExpression(thenSource),
  7520. GetSourceExpression(elseSource)
  7521. )
  7522. );
  7523. }
  7524. /// <summary>
  7525. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence generated on the specified scheduler.
  7526. /// </summary>
  7527. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7528. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7529. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7530. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7531. /// <param name="scheduler">Scheduler to generate an empty sequence on in case <paramref name="condition" /> evaluates false.</param>
  7532. /// <returns>
  7533. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7534. /// <exception cref="ArgumentNullException">
  7535. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="scheduler" /> is null.</exception>
  7536. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IScheduler scheduler)
  7537. {
  7538. if (provider == null)
  7539. throw new ArgumentNullException(nameof(provider));
  7540. if (condition == null)
  7541. throw new ArgumentNullException(nameof(condition));
  7542. if (thenSource == null)
  7543. throw new ArgumentNullException(nameof(thenSource));
  7544. if (scheduler == null)
  7545. throw new ArgumentNullException(nameof(scheduler));
  7546. return provider.CreateQuery<TResult>(
  7547. Expression.Call(
  7548. null,
  7549. #if CRIPPLED_REFLECTION
  7550. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IScheduler))),
  7551. #else
  7552. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7553. #endif
  7554. Expression.Constant(provider, typeof(IQbservableProvider)),
  7555. condition,
  7556. GetSourceExpression(thenSource),
  7557. Expression.Constant(scheduler, typeof(IScheduler))
  7558. )
  7559. );
  7560. }
  7561. /// <summary>
  7562. /// Ignores all elements in an observable sequence leaving only the termination messages.
  7563. /// </summary>
  7564. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7565. /// <param name="source">Source sequence.</param>
  7566. /// <returns>An empty observable sequence that signals termination, successful or exceptional, of the source sequence.</returns>
  7567. /// <exception cref="ArgumentNullException">
  7568. /// <paramref name="source" /> is null.</exception>
  7569. public static IQbservable<TSource> IgnoreElements<TSource>(this IQbservable<TSource> source)
  7570. {
  7571. if (source == null)
  7572. throw new ArgumentNullException(nameof(source));
  7573. return source.Provider.CreateQuery<TSource>(
  7574. Expression.Call(
  7575. null,
  7576. #if CRIPPLED_REFLECTION
  7577. InfoOf(() => Qbservable.IgnoreElements<TSource>(default(IQbservable<TSource>))),
  7578. #else
  7579. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7580. #endif
  7581. source.Expression
  7582. )
  7583. );
  7584. }
  7585. /// <summary>
  7586. /// Returns an observable sequence that produces a value after each period.
  7587. /// </summary>
  7588. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7589. /// <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>
  7590. /// <returns>An observable sequence that produces a value after each period.</returns>
  7591. /// <exception cref="ArgumentOutOfRangeException">
  7592. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7593. /// <remarks>
  7594. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7595. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7596. /// 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
  7597. /// <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})" />
  7598. /// operator instead.
  7599. /// </remarks>
  7600. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period)
  7601. {
  7602. if (provider == null)
  7603. throw new ArgumentNullException(nameof(provider));
  7604. return provider.CreateQuery<long>(
  7605. Expression.Call(
  7606. null,
  7607. #if CRIPPLED_REFLECTION
  7608. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan))),
  7609. #else
  7610. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7611. #endif
  7612. Expression.Constant(provider, typeof(IQbservableProvider)),
  7613. Expression.Constant(period, typeof(TimeSpan))
  7614. )
  7615. );
  7616. }
  7617. /// <summary>
  7618. /// Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.
  7619. /// </summary>
  7620. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7621. /// <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>
  7622. /// <param name="scheduler">Scheduler to run the timer on.</param>
  7623. /// <returns>An observable sequence that produces a value after each period.</returns>
  7624. /// <exception cref="ArgumentOutOfRangeException">
  7625. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7626. /// <exception cref="ArgumentNullException">
  7627. /// <paramref name="scheduler" /> is null.</exception>
  7628. /// <remarks>
  7629. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7630. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7631. /// 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
  7632. /// <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)" />
  7633. /// operator instead.
  7634. /// </remarks>
  7635. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period, IScheduler scheduler)
  7636. {
  7637. if (provider == null)
  7638. throw new ArgumentNullException(nameof(provider));
  7639. if (scheduler == null)
  7640. throw new ArgumentNullException(nameof(scheduler));
  7641. return provider.CreateQuery<long>(
  7642. Expression.Call(
  7643. null,
  7644. #if CRIPPLED_REFLECTION
  7645. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  7646. #else
  7647. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7648. #endif
  7649. Expression.Constant(provider, typeof(IQbservableProvider)),
  7650. Expression.Constant(period, typeof(TimeSpan)),
  7651. Expression.Constant(scheduler, typeof(IScheduler))
  7652. )
  7653. );
  7654. }
  7655. /// <summary>
  7656. /// Determines whether an observable sequence is empty.
  7657. /// </summary>
  7658. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7659. /// <param name="source">An observable sequence to check for emptiness.</param>
  7660. /// <returns>An observable sequence containing a single element determining whether the source sequence is empty.</returns>
  7661. /// <exception cref="ArgumentNullException">
  7662. /// <paramref name="source" /> is null.</exception>
  7663. public static IQbservable<bool> IsEmpty<TSource>(this IQbservable<TSource> source)
  7664. {
  7665. if (source == null)
  7666. throw new ArgumentNullException(nameof(source));
  7667. return source.Provider.CreateQuery<bool>(
  7668. Expression.Call(
  7669. null,
  7670. #if CRIPPLED_REFLECTION
  7671. InfoOf(() => Qbservable.IsEmpty<TSource>(default(IQbservable<TSource>))),
  7672. #else
  7673. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7674. #endif
  7675. source.Expression
  7676. )
  7677. );
  7678. }
  7679. /// <summary>
  7680. /// Correlates the elements of two sequences based on overlapping durations.
  7681. /// </summary>
  7682. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7683. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7684. /// <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>
  7685. /// <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>
  7686. /// <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>
  7687. /// <param name="left">The left observable sequence to join elements for.</param>
  7688. /// <param name="right">The right observable sequence to join elements for.</param>
  7689. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7690. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7691. /// <param name="resultSelector">A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences.</param>
  7692. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7693. /// <exception cref="ArgumentNullException">
  7694. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7695. 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)
  7696. {
  7697. if (left == null)
  7698. throw new ArgumentNullException(nameof(left));
  7699. if (right == null)
  7700. throw new ArgumentNullException(nameof(right));
  7701. if (leftDurationSelector == null)
  7702. throw new ArgumentNullException(nameof(leftDurationSelector));
  7703. if (rightDurationSelector == null)
  7704. throw new ArgumentNullException(nameof(rightDurationSelector));
  7705. if (resultSelector == null)
  7706. throw new ArgumentNullException(nameof(resultSelector));
  7707. return left.Provider.CreateQuery<TResult>(
  7708. Expression.Call(
  7709. null,
  7710. #if CRIPPLED_REFLECTION
  7711. 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>>))),
  7712. #else
  7713. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7714. #endif
  7715. left.Expression,
  7716. GetSourceExpression(right),
  7717. leftDurationSelector,
  7718. rightDurationSelector,
  7719. resultSelector
  7720. )
  7721. );
  7722. }
  7723. /// <summary>
  7724. /// Returns the last element of an observable sequence.
  7725. /// </summary>
  7726. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7727. /// <param name="source">Source observable sequence.</param>
  7728. /// <returns>Sequence containing the last element in the observable sequence.</returns>
  7729. /// <exception cref="ArgumentNullException">
  7730. /// <paramref name="source" /> is null.</exception>
  7731. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  7732. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source)
  7733. {
  7734. if (source == null)
  7735. throw new ArgumentNullException(nameof(source));
  7736. return source.Provider.CreateQuery<TSource>(
  7737. Expression.Call(
  7738. null,
  7739. #if CRIPPLED_REFLECTION
  7740. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>))),
  7741. #else
  7742. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7743. #endif
  7744. source.Expression
  7745. )
  7746. );
  7747. }
  7748. /// <summary>
  7749. /// Returns the last element of an observable sequence that satisfies the condition in the predicate.
  7750. /// </summary>
  7751. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7752. /// <param name="source">Source observable sequence.</param>
  7753. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7754. /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.</returns>
  7755. /// <exception cref="ArgumentNullException">
  7756. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7757. /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  7758. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7759. {
  7760. if (source == null)
  7761. throw new ArgumentNullException(nameof(source));
  7762. if (predicate == null)
  7763. throw new ArgumentNullException(nameof(predicate));
  7764. return source.Provider.CreateQuery<TSource>(
  7765. Expression.Call(
  7766. null,
  7767. #if CRIPPLED_REFLECTION
  7768. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7769. #else
  7770. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7771. #endif
  7772. source.Expression,
  7773. predicate
  7774. )
  7775. );
  7776. }
  7777. /// <summary>
  7778. /// Returns the last element of an observable sequence, 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. /// <returns>Sequence containing the last element in the observable sequence, or a default value if no such element exists.</returns>
  7783. /// <exception cref="ArgumentNullException">
  7784. /// <paramref name="source" /> is null.</exception>
  7785. public static IQbservable<TSource?> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  7786. {
  7787. if (source == null)
  7788. throw new ArgumentNullException(nameof(source));
  7789. return source.Provider.CreateQuery<TSource>(
  7790. Expression.Call(
  7791. null,
  7792. #if CRIPPLED_REFLECTION
  7793. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  7794. #else
  7795. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7796. #endif
  7797. source.Expression
  7798. )
  7799. );
  7800. }
  7801. /// <summary>
  7802. /// Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  7803. /// </summary>
  7804. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7805. /// <param name="source">Source observable sequence.</param>
  7806. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7807. /// <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>
  7808. /// <exception cref="ArgumentNullException">
  7809. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7810. public static IQbservable<TSource?> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7811. {
  7812. if (source == null)
  7813. throw new ArgumentNullException(nameof(source));
  7814. if (predicate == null)
  7815. throw new ArgumentNullException(nameof(predicate));
  7816. return source.Provider.CreateQuery<TSource>(
  7817. Expression.Call(
  7818. null,
  7819. #if CRIPPLED_REFLECTION
  7820. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7821. #else
  7822. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7823. #endif
  7824. source.Expression,
  7825. predicate
  7826. )
  7827. );
  7828. }
  7829. /// <summary>
  7830. /// Returns an enumerable sequence whose enumeration returns the latest observed element in the source observable sequence.
  7831. /// Enumerators on the resulting sequence will never produce the same element repeatedly, and will block until the next element becomes available.
  7832. /// </summary>
  7833. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7834. /// <param name="source">Source observable sequence.</param>
  7835. /// <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>
  7836. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  7837. public static IQueryable<TSource> Latest<TSource>(this IQbservable<TSource> source)
  7838. {
  7839. if (source == null)
  7840. throw new ArgumentNullException(nameof(source));
  7841. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  7842. Expression.Call(
  7843. null,
  7844. #if CRIPPLED_REFLECTION
  7845. InfoOf(() => Qbservable.Latest<TSource>(default(IQbservable<TSource>))),
  7846. #else
  7847. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7848. #endif
  7849. source.Expression
  7850. )
  7851. );
  7852. }
  7853. /// <summary>
  7854. /// Returns an observable sequence containing an <see cref="long" /> that represents the total number of elements in an observable sequence.
  7855. /// </summary>
  7856. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7857. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  7858. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  7859. /// <exception cref="ArgumentNullException">
  7860. /// <paramref name="source" /> is null.</exception>
  7861. /// <exception cref="OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  7862. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7863. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source)
  7864. {
  7865. if (source == null)
  7866. throw new ArgumentNullException(nameof(source));
  7867. return source.Provider.CreateQuery<long>(
  7868. Expression.Call(
  7869. null,
  7870. #if CRIPPLED_REFLECTION
  7871. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>))),
  7872. #else
  7873. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7874. #endif
  7875. source.Expression
  7876. )
  7877. );
  7878. }
  7879. /// <summary>
  7880. /// Returns an observable sequence containing an <see cref="long" /> that represents how many elements in the specified observable sequence satisfy a condition.
  7881. /// </summary>
  7882. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7883. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  7884. /// <param name="predicate">A function to test each element for a condition.</param>
  7885. /// <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>
  7886. /// <exception cref="ArgumentNullException">
  7887. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7888. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7889. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7890. {
  7891. if (source == null)
  7892. throw new ArgumentNullException(nameof(source));
  7893. if (predicate == null)
  7894. throw new ArgumentNullException(nameof(predicate));
  7895. return source.Provider.CreateQuery<long>(
  7896. Expression.Call(
  7897. null,
  7898. #if CRIPPLED_REFLECTION
  7899. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7900. #else
  7901. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7902. #endif
  7903. source.Expression,
  7904. predicate
  7905. )
  7906. );
  7907. }
  7908. /// <summary>
  7909. /// Materializes the implicit notifications of an observable sequence as explicit notification values.
  7910. /// </summary>
  7911. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7912. /// <param name="source">An observable sequence to get notification values for.</param>
  7913. /// <returns>An observable sequence containing the materialized notification values from the source sequence.</returns>
  7914. /// <exception cref="ArgumentNullException">
  7915. /// <paramref name="source" /> is null.</exception>
  7916. public static IQbservable<Notification<TSource>> Materialize<TSource>(this IQbservable<TSource> source)
  7917. {
  7918. if (source == null)
  7919. throw new ArgumentNullException(nameof(source));
  7920. return source.Provider.CreateQuery<Notification<TSource>>(
  7921. Expression.Call(
  7922. null,
  7923. #if CRIPPLED_REFLECTION
  7924. InfoOf(() => Qbservable.Materialize<TSource>(default(IQbservable<TSource>))),
  7925. #else
  7926. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7927. #endif
  7928. source.Expression
  7929. )
  7930. );
  7931. }
  7932. /// <summary>
  7933. /// Returns the maximum value in an observable sequence of <see cref="Decimal" /> values.
  7934. /// </summary>
  7935. /// <param name="source">A sequence of <see cref="Decimal" /> 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<decimal> Max(this IQbservable<decimal> source)
  7941. {
  7942. if (source == null)
  7943. throw new ArgumentNullException(nameof(source));
  7944. return source.Provider.CreateQuery<decimal>(
  7945. Expression.Call(
  7946. null,
  7947. #if CRIPPLED_REFLECTION
  7948. InfoOf(() => Qbservable.Max(default(IQbservable<decimal>))),
  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="double" /> values.
  7958. /// </summary>
  7959. /// <param name="source">A sequence of <see cref="double" /> 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<double> Max(this IQbservable<double> source)
  7965. {
  7966. if (source == null)
  7967. throw new ArgumentNullException(nameof(source));
  7968. return source.Provider.CreateQuery<double>(
  7969. Expression.Call(
  7970. null,
  7971. #if CRIPPLED_REFLECTION
  7972. InfoOf(() => Qbservable.Max(default(IQbservable<double>))),
  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="int" /> values.
  7982. /// </summary>
  7983. /// <param name="source">A sequence of <see cref="int" /> 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<int> Max(this IQbservable<int> source)
  7989. {
  7990. if (source == null)
  7991. throw new ArgumentNullException(nameof(source));
  7992. return source.Provider.CreateQuery<int>(
  7993. Expression.Call(
  7994. null,
  7995. #if CRIPPLED_REFLECTION
  7996. InfoOf(() => Qbservable.Max(default(IQbservable<int>))),
  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 <see cref="long" /> values.
  8006. /// </summary>
  8007. /// <param name="source">A sequence of <see cref="long" /> 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<long> Max(this IQbservable<long> source)
  8013. {
  8014. if (source == null)
  8015. throw new ArgumentNullException(nameof(source));
  8016. return source.Provider.CreateQuery<long>(
  8017. Expression.Call(
  8018. null,
  8019. #if CRIPPLED_REFLECTION
  8020. InfoOf(() => Qbservable.Max(default(IQbservable<long>))),
  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="Decimal" /> values.
  8030. /// </summary>
  8031. /// <param name="source">A sequence of nullable <see cref="Decimal" /> 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<decimal?> Max(this IQbservable<decimal?> source)
  8037. {
  8038. if (source == null)
  8039. throw new ArgumentNullException(nameof(source));
  8040. return source.Provider.CreateQuery<decimal?>(
  8041. Expression.Call(
  8042. null,
  8043. #if CRIPPLED_REFLECTION
  8044. InfoOf(() => Qbservable.Max(default(IQbservable<decimal?>))),
  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="double" /> values.
  8054. /// </summary>
  8055. /// <param name="source">A sequence of nullable <see cref="double" /> 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<double?> Max(this IQbservable<double?> source)
  8061. {
  8062. if (source == null)
  8063. throw new ArgumentNullException(nameof(source));
  8064. return source.Provider.CreateQuery<double?>(
  8065. Expression.Call(
  8066. null,
  8067. #if CRIPPLED_REFLECTION
  8068. InfoOf(() => Qbservable.Max(default(IQbservable<double?>))),
  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="int" /> values.
  8078. /// </summary>
  8079. /// <param name="source">A sequence of nullable <see cref="int" /> 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<int?> Max(this IQbservable<int?> source)
  8085. {
  8086. if (source == null)
  8087. throw new ArgumentNullException(nameof(source));
  8088. return source.Provider.CreateQuery<int?>(
  8089. Expression.Call(
  8090. null,
  8091. #if CRIPPLED_REFLECTION
  8092. InfoOf(() => Qbservable.Max(default(IQbservable<int?>))),
  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="long" /> values.
  8102. /// </summary>
  8103. /// <param name="source">A sequence of nullable <see cref="long" /> 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<long?> Max(this IQbservable<long?> source)
  8109. {
  8110. if (source == null)
  8111. throw new ArgumentNullException(nameof(source));
  8112. return source.Provider.CreateQuery<long?>(
  8113. Expression.Call(
  8114. null,
  8115. #if CRIPPLED_REFLECTION
  8116. InfoOf(() => Qbservable.Max(default(IQbservable<long?>))),
  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 nullable <see cref="Single" /> values.
  8126. /// </summary>
  8127. /// <param name="source">A sequence of nullable <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 value in an observable sequence of <see cref="Single" /> values.
  8150. /// </summary>
  8151. /// <param name="source">A sequence of <see cref="Single" /> values to determine the maximum value of.</param>
  8152. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8153. /// <exception cref="ArgumentNullException">
  8154. /// <paramref name="source" /> is null.</exception>
  8155. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8156. public static IQbservable<float> Max(this IQbservable<float> source)
  8157. {
  8158. if (source == null)
  8159. throw new ArgumentNullException(nameof(source));
  8160. return source.Provider.CreateQuery<float>(
  8161. Expression.Call(
  8162. null,
  8163. #if CRIPPLED_REFLECTION
  8164. InfoOf(() => Qbservable.Max(default(IQbservable<float>))),
  8165. #else
  8166. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8167. #endif
  8168. source.Expression
  8169. )
  8170. );
  8171. }
  8172. /// <summary>
  8173. /// Returns the maximum element in an observable sequence.
  8174. /// </summary>
  8175. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8176. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8177. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8178. /// <exception cref="ArgumentNullException">
  8179. /// <paramref name="source" /> is null.</exception>
  8180. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8181. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source)
  8182. {
  8183. if (source == null)
  8184. throw new ArgumentNullException(nameof(source));
  8185. return source.Provider.CreateQuery<TSource>(
  8186. Expression.Call(
  8187. null,
  8188. #if CRIPPLED_REFLECTION
  8189. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>))),
  8190. #else
  8191. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8192. #endif
  8193. source.Expression
  8194. )
  8195. );
  8196. }
  8197. /// <summary>
  8198. /// Returns the maximum value in an observable sequence according to the specified comparer.
  8199. /// </summary>
  8200. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8201. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8202. /// <param name="comparer">Comparer used to compare elements.</param>
  8203. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8204. /// <exception cref="ArgumentNullException">
  8205. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  8206. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8207. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  8208. {
  8209. if (source == null)
  8210. throw new ArgumentNullException(nameof(source));
  8211. if (comparer == null)
  8212. throw new ArgumentNullException(nameof(comparer));
  8213. return source.Provider.CreateQuery<TSource>(
  8214. Expression.Call(
  8215. null,
  8216. #if CRIPPLED_REFLECTION
  8217. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  8218. #else
  8219. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8220. #endif
  8221. source.Expression,
  8222. Expression.Constant(comparer, typeof(IComparer<TSource>))
  8223. )
  8224. );
  8225. }
  8226. /// <summary>
  8227. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="double" /> value.
  8228. /// </summary>
  8229. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8230. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8231. /// <param name="selector">A transform function to apply to each element.</param>
  8232. /// <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>
  8233. /// <exception cref="ArgumentNullException">
  8234. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8235. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8236. public static IQbservable<double> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  8237. {
  8238. if (source == null)
  8239. throw new ArgumentNullException(nameof(source));
  8240. if (selector == null)
  8241. throw new ArgumentNullException(nameof(selector));
  8242. return source.Provider.CreateQuery<double>(
  8243. Expression.Call(
  8244. null,
  8245. #if CRIPPLED_REFLECTION
  8246. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  8247. #else
  8248. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8249. #endif
  8250. source.Expression,
  8251. selector
  8252. )
  8253. );
  8254. }
  8255. /// <summary>
  8256. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="Single" /> value.
  8257. /// </summary>
  8258. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8259. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8260. /// <param name="selector">A transform function to apply to each element.</param>
  8261. /// <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>
  8262. /// <exception cref="ArgumentNullException">
  8263. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8264. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8265. public static IQbservable<float> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  8266. {
  8267. if (source == null)
  8268. throw new ArgumentNullException(nameof(source));
  8269. if (selector == null)
  8270. throw new ArgumentNullException(nameof(selector));
  8271. return source.Provider.CreateQuery<float>(
  8272. Expression.Call(
  8273. null,
  8274. #if CRIPPLED_REFLECTION
  8275. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  8276. #else
  8277. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8278. #endif
  8279. source.Expression,
  8280. selector
  8281. )
  8282. );
  8283. }
  8284. /// <summary>
  8285. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="Decimal" /> value.
  8286. /// </summary>
  8287. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8288. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8289. /// <param name="selector">A transform function to apply to each element.</param>
  8290. /// <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>
  8291. /// <exception cref="ArgumentNullException">
  8292. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8293. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8294. public static IQbservable<decimal> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  8295. {
  8296. if (source == null)
  8297. throw new ArgumentNullException(nameof(source));
  8298. if (selector == null)
  8299. throw new ArgumentNullException(nameof(selector));
  8300. return source.Provider.CreateQuery<decimal>(
  8301. Expression.Call(
  8302. null,
  8303. #if CRIPPLED_REFLECTION
  8304. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  8305. #else
  8306. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8307. #endif
  8308. source.Expression,
  8309. selector
  8310. )
  8311. );
  8312. }
  8313. /// <summary>
  8314. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="int" /> value.
  8315. /// </summary>
  8316. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8317. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8318. /// <param name="selector">A transform function to apply to each element.</param>
  8319. /// <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>
  8320. /// <exception cref="ArgumentNullException">
  8321. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8322. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8323. public static IQbservable<int> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  8324. {
  8325. if (source == null)
  8326. throw new ArgumentNullException(nameof(source));
  8327. if (selector == null)
  8328. throw new ArgumentNullException(nameof(selector));
  8329. return source.Provider.CreateQuery<int>(
  8330. Expression.Call(
  8331. null,
  8332. #if CRIPPLED_REFLECTION
  8333. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  8334. #else
  8335. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8336. #endif
  8337. source.Expression,
  8338. selector
  8339. )
  8340. );
  8341. }
  8342. /// <summary>
  8343. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="long" /> value.
  8344. /// </summary>
  8345. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8346. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8347. /// <param name="selector">A transform function to apply to each element.</param>
  8348. /// <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>
  8349. /// <exception cref="ArgumentNullException">
  8350. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8351. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8352. public static IQbservable<long> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  8353. {
  8354. if (source == null)
  8355. throw new ArgumentNullException(nameof(source));
  8356. if (selector == null)
  8357. throw new ArgumentNullException(nameof(selector));
  8358. return source.Provider.CreateQuery<long>(
  8359. Expression.Call(
  8360. null,
  8361. #if CRIPPLED_REFLECTION
  8362. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  8363. #else
  8364. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8365. #endif
  8366. source.Expression,
  8367. selector
  8368. )
  8369. );
  8370. }
  8371. /// <summary>
  8372. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="double" /> value.
  8373. /// </summary>
  8374. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8375. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8376. /// <param name="selector">A transform function to apply to each element.</param>
  8377. /// <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>
  8378. /// <exception cref="ArgumentNullException">
  8379. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8380. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8381. public static IQbservable<double?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  8382. {
  8383. if (source == null)
  8384. throw new ArgumentNullException(nameof(source));
  8385. if (selector == null)
  8386. throw new ArgumentNullException(nameof(selector));
  8387. return source.Provider.CreateQuery<double?>(
  8388. Expression.Call(
  8389. null,
  8390. #if CRIPPLED_REFLECTION
  8391. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  8392. #else
  8393. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8394. #endif
  8395. source.Expression,
  8396. selector
  8397. )
  8398. );
  8399. }
  8400. /// <summary>
  8401. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="Single" /> value.
  8402. /// </summary>
  8403. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8404. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8405. /// <param name="selector">A transform function to apply to each element.</param>
  8406. /// <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>
  8407. /// <exception cref="ArgumentNullException">
  8408. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8409. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8410. public static IQbservable<float?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  8411. {
  8412. if (source == null)
  8413. throw new ArgumentNullException(nameof(source));
  8414. if (selector == null)
  8415. throw new ArgumentNullException(nameof(selector));
  8416. return source.Provider.CreateQuery<float?>(
  8417. Expression.Call(
  8418. null,
  8419. #if CRIPPLED_REFLECTION
  8420. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  8421. #else
  8422. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8423. #endif
  8424. source.Expression,
  8425. selector
  8426. )
  8427. );
  8428. }
  8429. /// <summary>
  8430. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="Decimal" /> value.
  8431. /// </summary>
  8432. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8433. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8434. /// <param name="selector">A transform function to apply to each element.</param>
  8435. /// <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>
  8436. /// <exception cref="ArgumentNullException">
  8437. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8438. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8439. public static IQbservable<decimal?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  8440. {
  8441. if (source == null)
  8442. throw new ArgumentNullException(nameof(source));
  8443. if (selector == null)
  8444. throw new ArgumentNullException(nameof(selector));
  8445. return source.Provider.CreateQuery<decimal?>(
  8446. Expression.Call(
  8447. null,
  8448. #if CRIPPLED_REFLECTION
  8449. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  8450. #else
  8451. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8452. #endif
  8453. source.Expression,
  8454. selector
  8455. )
  8456. );
  8457. }
  8458. /// <summary>
  8459. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="int" /> value.
  8460. /// </summary>
  8461. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8462. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8463. /// <param name="selector">A transform function to apply to each element.</param>
  8464. /// <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>
  8465. /// <exception cref="ArgumentNullException">
  8466. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8467. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8468. public static IQbservable<int?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  8469. {
  8470. if (source == null)
  8471. throw new ArgumentNullException(nameof(source));
  8472. if (selector == null)
  8473. throw new ArgumentNullException(nameof(selector));
  8474. return source.Provider.CreateQuery<int?>(
  8475. Expression.Call(
  8476. null,
  8477. #if CRIPPLED_REFLECTION
  8478. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  8479. #else
  8480. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8481. #endif
  8482. source.Expression,
  8483. selector
  8484. )
  8485. );
  8486. }
  8487. /// <summary>
  8488. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="long" /> value.
  8489. /// </summary>
  8490. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8491. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8492. /// <param name="selector">A transform function to apply to each element.</param>
  8493. /// <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>
  8494. /// <exception cref="ArgumentNullException">
  8495. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8496. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8497. public static IQbservable<long?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  8498. {
  8499. if (source == null)
  8500. throw new ArgumentNullException(nameof(source));
  8501. if (selector == null)
  8502. throw new ArgumentNullException(nameof(selector));
  8503. return source.Provider.CreateQuery<long?>(
  8504. Expression.Call(
  8505. null,
  8506. #if CRIPPLED_REFLECTION
  8507. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  8508. #else
  8509. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8510. #endif
  8511. source.Expression,
  8512. selector
  8513. )
  8514. );
  8515. }
  8516. /// <summary>
  8517. /// Invokes a transform function on each element of a sequence and returns the maximum value.
  8518. /// </summary>
  8519. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8520. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8521. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  8522. /// <param name="selector">A transform function to apply to each element.</param>
  8523. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8524. /// <exception cref="ArgumentNullException">
  8525. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8526. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8527. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  8528. {
  8529. if (source == null)
  8530. throw new ArgumentNullException(nameof(source));
  8531. if (selector == null)
  8532. throw new ArgumentNullException(nameof(selector));
  8533. return source.Provider.CreateQuery<TResult>(
  8534. Expression.Call(
  8535. null,
  8536. #if CRIPPLED_REFLECTION
  8537. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  8538. #else
  8539. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8540. #endif
  8541. source.Expression,
  8542. selector
  8543. )
  8544. );
  8545. }
  8546. /// <summary>
  8547. /// Invokes a transform function on each element of a sequence and returns the maximum value according to the specified comparer.
  8548. /// </summary>
  8549. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8550. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8551. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  8552. /// <param name="selector">A transform function to apply to each element.</param>
  8553. /// <param name="comparer">Comparer used to compare elements.</param>
  8554. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8555. /// <exception cref="ArgumentNullException">
  8556. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  8557. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8558. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  8559. {
  8560. if (source == null)
  8561. throw new ArgumentNullException(nameof(source));
  8562. if (selector == null)
  8563. throw new ArgumentNullException(nameof(selector));
  8564. if (comparer == null)
  8565. throw new ArgumentNullException(nameof(comparer));
  8566. return source.Provider.CreateQuery<TResult>(
  8567. Expression.Call(
  8568. null,
  8569. #if CRIPPLED_REFLECTION
  8570. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  8571. #else
  8572. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8573. #endif
  8574. source.Expression,
  8575. selector,
  8576. Expression.Constant(comparer, typeof(IComparer<TResult>))
  8577. )
  8578. );
  8579. }
  8580. /// <summary>
  8581. /// Returns the elements in an observable sequence with the maximum key value.
  8582. /// </summary>
  8583. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8584. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8585. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8586. /// <param name="keySelector">Key selector function.</param>
  8587. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8588. /// <exception cref="ArgumentNullException">
  8589. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  8590. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8591. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  8592. {
  8593. if (source == null)
  8594. throw new ArgumentNullException(nameof(source));
  8595. if (keySelector == null)
  8596. throw new ArgumentNullException(nameof(keySelector));
  8597. return source.Provider.CreateQuery<IList<TSource>>(
  8598. Expression.Call(
  8599. null,
  8600. #if CRIPPLED_REFLECTION
  8601. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  8602. #else
  8603. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8604. #endif
  8605. source.Expression,
  8606. keySelector
  8607. )
  8608. );
  8609. }
  8610. /// <summary>
  8611. /// Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
  8612. /// </summary>
  8613. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8614. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8615. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8616. /// <param name="keySelector">Key selector function.</param>
  8617. /// <param name="comparer">Comparer used to compare key values.</param>
  8618. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8619. /// <exception cref="ArgumentNullException">
  8620. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  8621. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8622. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  8623. {
  8624. if (source == null)
  8625. throw new ArgumentNullException(nameof(source));
  8626. if (keySelector == null)
  8627. throw new ArgumentNullException(nameof(keySelector));
  8628. if (comparer == null)
  8629. throw new ArgumentNullException(nameof(comparer));
  8630. return source.Provider.CreateQuery<IList<TSource>>(
  8631. Expression.Call(
  8632. null,
  8633. #if CRIPPLED_REFLECTION
  8634. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  8635. #else
  8636. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8637. #endif
  8638. source.Expression,
  8639. keySelector,
  8640. Expression.Constant(comparer, typeof(IComparer<TKey>))
  8641. )
  8642. );
  8643. }
  8644. /// <summary>
  8645. /// Merges elements from two observable sequences into a single observable sequence.
  8646. /// </summary>
  8647. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8648. /// <param name="first">First observable sequence.</param>
  8649. /// <param name="second">Second observable sequence.</param>
  8650. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8651. /// <exception cref="ArgumentNullException">
  8652. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  8653. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  8654. {
  8655. if (first == null)
  8656. throw new ArgumentNullException(nameof(first));
  8657. if (second == null)
  8658. throw new ArgumentNullException(nameof(second));
  8659. return first.Provider.CreateQuery<TSource>(
  8660. Expression.Call(
  8661. null,
  8662. #if CRIPPLED_REFLECTION
  8663. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  8664. #else
  8665. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8666. #endif
  8667. first.Expression,
  8668. GetSourceExpression(second)
  8669. )
  8670. );
  8671. }
  8672. /// <summary>
  8673. /// Merges elements from two observable sequences into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  8674. /// </summary>
  8675. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8676. /// <param name="first">First observable sequence.</param>
  8677. /// <param name="second">Second observable sequence.</param>
  8678. /// <param name="scheduler">Scheduler used to introduce concurrency for making subscriptions to the given sequences.</param>
  8679. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8680. /// <exception cref="ArgumentNullException">
  8681. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="scheduler" /> is null.</exception>
  8682. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IScheduler scheduler)
  8683. {
  8684. if (first == null)
  8685. throw new ArgumentNullException(nameof(first));
  8686. if (second == null)
  8687. throw new ArgumentNullException(nameof(second));
  8688. if (scheduler == null)
  8689. throw new ArgumentNullException(nameof(scheduler));
  8690. return first.Provider.CreateQuery<TSource>(
  8691. Expression.Call(
  8692. null,
  8693. #if CRIPPLED_REFLECTION
  8694. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IScheduler))),
  8695. #else
  8696. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8697. #endif
  8698. first.Expression,
  8699. GetSourceExpression(second),
  8700. Expression.Constant(scheduler, typeof(IScheduler))
  8701. )
  8702. );
  8703. }
  8704. /// <summary>
  8705. /// 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.
  8706. /// </summary>
  8707. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8708. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8709. /// <param name="sources">Observable sequences.</param>
  8710. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8711. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8712. /// <exception cref="ArgumentNullException">
  8713. /// <paramref name="scheduler" /> or <paramref name="sources" /> is null.</exception>
  8714. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IScheduler scheduler, params IObservable<TSource>[] sources)
  8715. {
  8716. if (provider == null)
  8717. throw new ArgumentNullException(nameof(provider));
  8718. if (scheduler == null)
  8719. throw new ArgumentNullException(nameof(scheduler));
  8720. if (sources == null)
  8721. throw new ArgumentNullException(nameof(sources));
  8722. return provider.CreateQuery<TSource>(
  8723. Expression.Call(
  8724. null,
  8725. #if CRIPPLED_REFLECTION
  8726. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IScheduler), default(IObservable<TSource>[]))),
  8727. #else
  8728. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8729. #endif
  8730. Expression.Constant(provider, typeof(IQbservableProvider)),
  8731. Expression.Constant(scheduler, typeof(IScheduler)),
  8732. GetSourceExpression(sources)
  8733. )
  8734. );
  8735. }
  8736. /// <summary>
  8737. /// Merges elements from all inner observable sequences into a single observable sequence.
  8738. /// </summary>
  8739. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8740. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8741. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8742. /// <exception cref="ArgumentNullException">
  8743. /// <paramref name="sources" /> is null.</exception>
  8744. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources)
  8745. {
  8746. if (sources == null)
  8747. throw new ArgumentNullException(nameof(sources));
  8748. return sources.Provider.CreateQuery<TSource>(
  8749. Expression.Call(
  8750. null,
  8751. #if CRIPPLED_REFLECTION
  8752. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>))),
  8753. #else
  8754. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8755. #endif
  8756. sources.Expression
  8757. )
  8758. );
  8759. }
  8760. /// <summary>
  8761. /// Merges results from all source tasks into a single observable sequence.
  8762. /// </summary>
  8763. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  8764. /// <param name="sources">Observable sequence of tasks.</param>
  8765. /// <returns>The observable sequence that merges the results of the source tasks.</returns>
  8766. /// <exception cref="ArgumentNullException">
  8767. /// <paramref name="sources" /> is null.</exception>
  8768. /// <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>
  8769. public static IQbservable<TSource> Merge<TSource>(this IQbservable<Task<TSource>> sources)
  8770. {
  8771. if (sources == null)
  8772. throw new ArgumentNullException(nameof(sources));
  8773. return sources.Provider.CreateQuery<TSource>(
  8774. Expression.Call(
  8775. null,
  8776. #if CRIPPLED_REFLECTION
  8777. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<Task<TSource>>))),
  8778. #else
  8779. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8780. #endif
  8781. sources.Expression
  8782. )
  8783. );
  8784. }
  8785. /// <summary>
  8786. /// Merges elements from all of the specified observable sequences into a single observable sequence.
  8787. /// </summary>
  8788. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8789. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8790. /// <param name="sources">Observable sequences.</param>
  8791. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8792. /// <exception cref="ArgumentNullException">
  8793. /// <paramref name="sources" /> is null.</exception>
  8794. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  8795. {
  8796. if (provider == null)
  8797. throw new ArgumentNullException(nameof(provider));
  8798. if (sources == null)
  8799. throw new ArgumentNullException(nameof(sources));
  8800. return provider.CreateQuery<TSource>(
  8801. Expression.Call(
  8802. null,
  8803. #if CRIPPLED_REFLECTION
  8804. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  8805. #else
  8806. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8807. #endif
  8808. Expression.Constant(provider, typeof(IQbservableProvider)),
  8809. GetSourceExpression(sources)
  8810. )
  8811. );
  8812. }
  8813. /// <summary>
  8814. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence.
  8815. /// </summary>
  8816. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8817. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8818. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8819. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8820. /// <exception cref="ArgumentNullException">
  8821. /// <paramref name="sources" /> is null.</exception>
  8822. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  8823. {
  8824. if (provider == null)
  8825. throw new ArgumentNullException(nameof(provider));
  8826. if (sources == null)
  8827. throw new ArgumentNullException(nameof(sources));
  8828. return provider.CreateQuery<TSource>(
  8829. Expression.Call(
  8830. null,
  8831. #if CRIPPLED_REFLECTION
  8832. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  8833. #else
  8834. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8835. #endif
  8836. Expression.Constant(provider, typeof(IQbservableProvider)),
  8837. GetSourceExpression(sources)
  8838. )
  8839. );
  8840. }
  8841. /// <summary>
  8842. /// Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  8843. /// </summary>
  8844. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8845. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8846. /// <param name="maxConcurrent">Maximum number of inner observable sequences being subscribed to concurrently.</param>
  8847. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8848. /// <exception cref="ArgumentNullException">
  8849. /// <paramref name="sources" /> is null.</exception>
  8850. /// <exception cref="ArgumentOutOfRangeException">
  8851. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8852. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources, int maxConcurrent)
  8853. {
  8854. if (sources == null)
  8855. throw new ArgumentNullException(nameof(sources));
  8856. return sources.Provider.CreateQuery<TSource>(
  8857. Expression.Call(
  8858. null,
  8859. #if CRIPPLED_REFLECTION
  8860. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>), default(int))),
  8861. #else
  8862. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8863. #endif
  8864. sources.Expression,
  8865. Expression.Constant(maxConcurrent, typeof(int))
  8866. )
  8867. );
  8868. }
  8869. /// <summary>
  8870. /// 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.
  8871. /// </summary>
  8872. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8873. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8874. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8875. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  8876. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8877. /// <exception cref="ArgumentNullException">
  8878. /// <paramref name="sources" /> is null.</exception>
  8879. /// <exception cref="ArgumentOutOfRangeException">
  8880. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8881. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent)
  8882. {
  8883. if (provider == null)
  8884. throw new ArgumentNullException(nameof(provider));
  8885. if (sources == null)
  8886. throw new ArgumentNullException(nameof(sources));
  8887. return provider.CreateQuery<TSource>(
  8888. Expression.Call(
  8889. null,
  8890. #if CRIPPLED_REFLECTION
  8891. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int))),
  8892. #else
  8893. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8894. #endif
  8895. Expression.Constant(provider, typeof(IQbservableProvider)),
  8896. GetSourceExpression(sources),
  8897. Expression.Constant(maxConcurrent, typeof(int))
  8898. )
  8899. );
  8900. }
  8901. /// <summary>
  8902. /// 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.
  8903. /// </summary>
  8904. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8905. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8906. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8907. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  8908. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8909. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8910. /// <exception cref="ArgumentNullException">
  8911. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  8912. /// <exception cref="ArgumentOutOfRangeException">
  8913. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8914. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent, IScheduler scheduler)
  8915. {
  8916. if (provider == null)
  8917. throw new ArgumentNullException(nameof(provider));
  8918. if (sources == null)
  8919. throw new ArgumentNullException(nameof(sources));
  8920. if (scheduler == null)
  8921. throw new ArgumentNullException(nameof(scheduler));
  8922. return provider.CreateQuery<TSource>(
  8923. Expression.Call(
  8924. null,
  8925. #if CRIPPLED_REFLECTION
  8926. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int), default(IScheduler))),
  8927. #else
  8928. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8929. #endif
  8930. Expression.Constant(provider, typeof(IQbservableProvider)),
  8931. GetSourceExpression(sources),
  8932. Expression.Constant(maxConcurrent, typeof(int)),
  8933. Expression.Constant(scheduler, typeof(IScheduler))
  8934. )
  8935. );
  8936. }
  8937. /// <summary>
  8938. /// 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.
  8939. /// </summary>
  8940. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8941. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8942. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8943. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8944. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8945. /// <exception cref="ArgumentNullException">
  8946. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  8947. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, IScheduler scheduler)
  8948. {
  8949. if (provider == null)
  8950. throw new ArgumentNullException(nameof(provider));
  8951. if (sources == null)
  8952. throw new ArgumentNullException(nameof(sources));
  8953. if (scheduler == null)
  8954. throw new ArgumentNullException(nameof(scheduler));
  8955. return provider.CreateQuery<TSource>(
  8956. Expression.Call(
  8957. null,
  8958. #if CRIPPLED_REFLECTION
  8959. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(IScheduler))),
  8960. #else
  8961. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8962. #endif
  8963. Expression.Constant(provider, typeof(IQbservableProvider)),
  8964. GetSourceExpression(sources),
  8965. Expression.Constant(scheduler, typeof(IScheduler))
  8966. )
  8967. );
  8968. }
  8969. /// <summary>
  8970. /// Returns the minimum value in an observable sequence of <see cref="Decimal" /> values.
  8971. /// </summary>
  8972. /// <param name="source">A sequence of <see cref="Decimal" /> 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<decimal> Min(this IQbservable<decimal> source)
  8978. {
  8979. if (source == null)
  8980. throw new ArgumentNullException(nameof(source));
  8981. return source.Provider.CreateQuery<decimal>(
  8982. Expression.Call(
  8983. null,
  8984. #if CRIPPLED_REFLECTION
  8985. InfoOf(() => Qbservable.Min(default(IQbservable<decimal>))),
  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="double" /> values.
  8995. /// </summary>
  8996. /// <param name="source">A sequence of <see cref="double" /> 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<double> Min(this IQbservable<double> source)
  9002. {
  9003. if (source == null)
  9004. throw new ArgumentNullException(nameof(source));
  9005. return source.Provider.CreateQuery<double>(
  9006. Expression.Call(
  9007. null,
  9008. #if CRIPPLED_REFLECTION
  9009. InfoOf(() => Qbservable.Min(default(IQbservable<double>))),
  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="int" /> values.
  9019. /// </summary>
  9020. /// <param name="source">A sequence of <see cref="int" /> 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<int> Min(this IQbservable<int> source)
  9026. {
  9027. if (source == null)
  9028. throw new ArgumentNullException(nameof(source));
  9029. return source.Provider.CreateQuery<int>(
  9030. Expression.Call(
  9031. null,
  9032. #if CRIPPLED_REFLECTION
  9033. InfoOf(() => Qbservable.Min(default(IQbservable<int>))),
  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 <see cref="long" /> values.
  9043. /// </summary>
  9044. /// <param name="source">A sequence of <see cref="long" /> 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<long> Min(this IQbservable<long> source)
  9050. {
  9051. if (source == null)
  9052. throw new ArgumentNullException(nameof(source));
  9053. return source.Provider.CreateQuery<long>(
  9054. Expression.Call(
  9055. null,
  9056. #if CRIPPLED_REFLECTION
  9057. InfoOf(() => Qbservable.Min(default(IQbservable<long>))),
  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="Decimal" /> values.
  9067. /// </summary>
  9068. /// <param name="source">A sequence of nullable <see cref="Decimal" /> 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<decimal?> Min(this IQbservable<decimal?> source)
  9074. {
  9075. if (source == null)
  9076. throw new ArgumentNullException(nameof(source));
  9077. return source.Provider.CreateQuery<decimal?>(
  9078. Expression.Call(
  9079. null,
  9080. #if CRIPPLED_REFLECTION
  9081. InfoOf(() => Qbservable.Min(default(IQbservable<decimal?>))),
  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="double" /> values.
  9091. /// </summary>
  9092. /// <param name="source">A sequence of nullable <see cref="double" /> 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<double?> Min(this IQbservable<double?> source)
  9098. {
  9099. if (source == null)
  9100. throw new ArgumentNullException(nameof(source));
  9101. return source.Provider.CreateQuery<double?>(
  9102. Expression.Call(
  9103. null,
  9104. #if CRIPPLED_REFLECTION
  9105. InfoOf(() => Qbservable.Min(default(IQbservable<double?>))),
  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="int" /> values.
  9115. /// </summary>
  9116. /// <param name="source">A sequence of nullable <see cref="int" /> 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<int?> Min(this IQbservable<int?> source)
  9122. {
  9123. if (source == null)
  9124. throw new ArgumentNullException(nameof(source));
  9125. return source.Provider.CreateQuery<int?>(
  9126. Expression.Call(
  9127. null,
  9128. #if CRIPPLED_REFLECTION
  9129. InfoOf(() => Qbservable.Min(default(IQbservable<int?>))),
  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="long" /> values.
  9139. /// </summary>
  9140. /// <param name="source">A sequence of nullable <see cref="long" /> 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<long?> Min(this IQbservable<long?> source)
  9146. {
  9147. if (source == null)
  9148. throw new ArgumentNullException(nameof(source));
  9149. return source.Provider.CreateQuery<long?>(
  9150. Expression.Call(
  9151. null,
  9152. #if CRIPPLED_REFLECTION
  9153. InfoOf(() => Qbservable.Min(default(IQbservable<long?>))),
  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 nullable <see cref="Single" /> values.
  9163. /// </summary>
  9164. /// <param name="source">A sequence of nullable <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 value in an observable sequence of <see cref="Single" /> values.
  9187. /// </summary>
  9188. /// <param name="source">A sequence of <see cref="Single" /> values to determine the minimum value of.</param>
  9189. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9190. /// <exception cref="ArgumentNullException">
  9191. /// <paramref name="source" /> is null.</exception>
  9192. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9193. public static IQbservable<float> Min(this IQbservable<float> source)
  9194. {
  9195. if (source == null)
  9196. throw new ArgumentNullException(nameof(source));
  9197. return source.Provider.CreateQuery<float>(
  9198. Expression.Call(
  9199. null,
  9200. #if CRIPPLED_REFLECTION
  9201. InfoOf(() => Qbservable.Min(default(IQbservable<float>))),
  9202. #else
  9203. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9204. #endif
  9205. source.Expression
  9206. )
  9207. );
  9208. }
  9209. /// <summary>
  9210. /// Returns the minimum element in an observable sequence.
  9211. /// </summary>
  9212. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9213. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9214. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9215. /// <exception cref="ArgumentNullException">
  9216. /// <paramref name="source" /> is null.</exception>
  9217. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9218. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source)
  9219. {
  9220. if (source == null)
  9221. throw new ArgumentNullException(nameof(source));
  9222. return source.Provider.CreateQuery<TSource>(
  9223. Expression.Call(
  9224. null,
  9225. #if CRIPPLED_REFLECTION
  9226. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>))),
  9227. #else
  9228. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9229. #endif
  9230. source.Expression
  9231. )
  9232. );
  9233. }
  9234. /// <summary>
  9235. /// Returns the minimum element in an observable sequence according to the specified comparer.
  9236. /// </summary>
  9237. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9238. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9239. /// <param name="comparer">Comparer used to compare elements.</param>
  9240. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9241. /// <exception cref="ArgumentNullException">
  9242. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  9243. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9244. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  9245. {
  9246. if (source == null)
  9247. throw new ArgumentNullException(nameof(source));
  9248. if (comparer == null)
  9249. throw new ArgumentNullException(nameof(comparer));
  9250. return source.Provider.CreateQuery<TSource>(
  9251. Expression.Call(
  9252. null,
  9253. #if CRIPPLED_REFLECTION
  9254. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  9255. #else
  9256. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9257. #endif
  9258. source.Expression,
  9259. Expression.Constant(comparer, typeof(IComparer<TSource>))
  9260. )
  9261. );
  9262. }
  9263. /// <summary>
  9264. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="double" /> value.
  9265. /// </summary>
  9266. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9267. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9268. /// <param name="selector">A transform function to apply to each element.</param>
  9269. /// <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>
  9270. /// <exception cref="ArgumentNullException">
  9271. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9272. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9273. public static IQbservable<double> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  9274. {
  9275. if (source == null)
  9276. throw new ArgumentNullException(nameof(source));
  9277. if (selector == null)
  9278. throw new ArgumentNullException(nameof(selector));
  9279. return source.Provider.CreateQuery<double>(
  9280. Expression.Call(
  9281. null,
  9282. #if CRIPPLED_REFLECTION
  9283. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  9284. #else
  9285. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9286. #endif
  9287. source.Expression,
  9288. selector
  9289. )
  9290. );
  9291. }
  9292. /// <summary>
  9293. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="Single" /> value.
  9294. /// </summary>
  9295. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9296. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9297. /// <param name="selector">A transform function to apply to each element.</param>
  9298. /// <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>
  9299. /// <exception cref="ArgumentNullException">
  9300. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9301. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9302. public static IQbservable<float> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  9303. {
  9304. if (source == null)
  9305. throw new ArgumentNullException(nameof(source));
  9306. if (selector == null)
  9307. throw new ArgumentNullException(nameof(selector));
  9308. return source.Provider.CreateQuery<float>(
  9309. Expression.Call(
  9310. null,
  9311. #if CRIPPLED_REFLECTION
  9312. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  9313. #else
  9314. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9315. #endif
  9316. source.Expression,
  9317. selector
  9318. )
  9319. );
  9320. }
  9321. /// <summary>
  9322. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="Decimal" /> value.
  9323. /// </summary>
  9324. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9325. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9326. /// <param name="selector">A transform function to apply to each element.</param>
  9327. /// <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>
  9328. /// <exception cref="ArgumentNullException">
  9329. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9330. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9331. public static IQbservable<decimal> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  9332. {
  9333. if (source == null)
  9334. throw new ArgumentNullException(nameof(source));
  9335. if (selector == null)
  9336. throw new ArgumentNullException(nameof(selector));
  9337. return source.Provider.CreateQuery<decimal>(
  9338. Expression.Call(
  9339. null,
  9340. #if CRIPPLED_REFLECTION
  9341. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  9342. #else
  9343. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9344. #endif
  9345. source.Expression,
  9346. selector
  9347. )
  9348. );
  9349. }
  9350. /// <summary>
  9351. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="int" /> value.
  9352. /// </summary>
  9353. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9354. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9355. /// <param name="selector">A transform function to apply to each element.</param>
  9356. /// <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>
  9357. /// <exception cref="ArgumentNullException">
  9358. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9359. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9360. public static IQbservable<int> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  9361. {
  9362. if (source == null)
  9363. throw new ArgumentNullException(nameof(source));
  9364. if (selector == null)
  9365. throw new ArgumentNullException(nameof(selector));
  9366. return source.Provider.CreateQuery<int>(
  9367. Expression.Call(
  9368. null,
  9369. #if CRIPPLED_REFLECTION
  9370. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  9371. #else
  9372. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9373. #endif
  9374. source.Expression,
  9375. selector
  9376. )
  9377. );
  9378. }
  9379. /// <summary>
  9380. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="long" /> value.
  9381. /// </summary>
  9382. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9383. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9384. /// <param name="selector">A transform function to apply to each element.</param>
  9385. /// <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>
  9386. /// <exception cref="ArgumentNullException">
  9387. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9388. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9389. public static IQbservable<long> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  9390. {
  9391. if (source == null)
  9392. throw new ArgumentNullException(nameof(source));
  9393. if (selector == null)
  9394. throw new ArgumentNullException(nameof(selector));
  9395. return source.Provider.CreateQuery<long>(
  9396. Expression.Call(
  9397. null,
  9398. #if CRIPPLED_REFLECTION
  9399. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  9400. #else
  9401. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9402. #endif
  9403. source.Expression,
  9404. selector
  9405. )
  9406. );
  9407. }
  9408. /// <summary>
  9409. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="double" /> value.
  9410. /// </summary>
  9411. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9412. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9413. /// <param name="selector">A transform function to apply to each element.</param>
  9414. /// <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>
  9415. /// <exception cref="ArgumentNullException">
  9416. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9417. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9418. public static IQbservable<double?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  9419. {
  9420. if (source == null)
  9421. throw new ArgumentNullException(nameof(source));
  9422. if (selector == null)
  9423. throw new ArgumentNullException(nameof(selector));
  9424. return source.Provider.CreateQuery<double?>(
  9425. Expression.Call(
  9426. null,
  9427. #if CRIPPLED_REFLECTION
  9428. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  9429. #else
  9430. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9431. #endif
  9432. source.Expression,
  9433. selector
  9434. )
  9435. );
  9436. }
  9437. /// <summary>
  9438. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="Single" /> value.
  9439. /// </summary>
  9440. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9441. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9442. /// <param name="selector">A transform function to apply to each element.</param>
  9443. /// <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>
  9444. /// <exception cref="ArgumentNullException">
  9445. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9446. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9447. public static IQbservable<float?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  9448. {
  9449. if (source == null)
  9450. throw new ArgumentNullException(nameof(source));
  9451. if (selector == null)
  9452. throw new ArgumentNullException(nameof(selector));
  9453. return source.Provider.CreateQuery<float?>(
  9454. Expression.Call(
  9455. null,
  9456. #if CRIPPLED_REFLECTION
  9457. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  9458. #else
  9459. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9460. #endif
  9461. source.Expression,
  9462. selector
  9463. )
  9464. );
  9465. }
  9466. /// <summary>
  9467. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="Decimal" /> value.
  9468. /// </summary>
  9469. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9470. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9471. /// <param name="selector">A transform function to apply to each element.</param>
  9472. /// <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>
  9473. /// <exception cref="ArgumentNullException">
  9474. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9475. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9476. public static IQbservable<decimal?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  9477. {
  9478. if (source == null)
  9479. throw new ArgumentNullException(nameof(source));
  9480. if (selector == null)
  9481. throw new ArgumentNullException(nameof(selector));
  9482. return source.Provider.CreateQuery<decimal?>(
  9483. Expression.Call(
  9484. null,
  9485. #if CRIPPLED_REFLECTION
  9486. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  9487. #else
  9488. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9489. #endif
  9490. source.Expression,
  9491. selector
  9492. )
  9493. );
  9494. }
  9495. /// <summary>
  9496. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="int" /> value.
  9497. /// </summary>
  9498. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9499. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9500. /// <param name="selector">A transform function to apply to each element.</param>
  9501. /// <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>
  9502. /// <exception cref="ArgumentNullException">
  9503. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9504. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9505. public static IQbservable<int?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  9506. {
  9507. if (source == null)
  9508. throw new ArgumentNullException(nameof(source));
  9509. if (selector == null)
  9510. throw new ArgumentNullException(nameof(selector));
  9511. return source.Provider.CreateQuery<int?>(
  9512. Expression.Call(
  9513. null,
  9514. #if CRIPPLED_REFLECTION
  9515. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  9516. #else
  9517. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9518. #endif
  9519. source.Expression,
  9520. selector
  9521. )
  9522. );
  9523. }
  9524. /// <summary>
  9525. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="long" /> value.
  9526. /// </summary>
  9527. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9528. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9529. /// <param name="selector">A transform function to apply to each element.</param>
  9530. /// <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>
  9531. /// <exception cref="ArgumentNullException">
  9532. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9533. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9534. public static IQbservable<long?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  9535. {
  9536. if (source == null)
  9537. throw new ArgumentNullException(nameof(source));
  9538. if (selector == null)
  9539. throw new ArgumentNullException(nameof(selector));
  9540. return source.Provider.CreateQuery<long?>(
  9541. Expression.Call(
  9542. null,
  9543. #if CRIPPLED_REFLECTION
  9544. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  9545. #else
  9546. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9547. #endif
  9548. source.Expression,
  9549. selector
  9550. )
  9551. );
  9552. }
  9553. /// <summary>
  9554. /// Invokes a transform function on each element of a sequence and returns the minimum value.
  9555. /// </summary>
  9556. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9557. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9558. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9559. /// <param name="selector">A transform function to apply to each element.</param>
  9560. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9561. /// <exception cref="ArgumentNullException">
  9562. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9563. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9564. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  9565. {
  9566. if (source == null)
  9567. throw new ArgumentNullException(nameof(source));
  9568. if (selector == null)
  9569. throw new ArgumentNullException(nameof(selector));
  9570. return source.Provider.CreateQuery<TResult>(
  9571. Expression.Call(
  9572. null,
  9573. #if CRIPPLED_REFLECTION
  9574. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  9575. #else
  9576. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9577. #endif
  9578. source.Expression,
  9579. selector
  9580. )
  9581. );
  9582. }
  9583. /// <summary>
  9584. /// Invokes a transform function on each element of a sequence and returns the minimum value according to the specified comparer.
  9585. /// </summary>
  9586. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9587. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9588. /// <param name="source">An observable sequence to determine the minimum element of.</param>
  9589. /// <param name="selector">A transform function to apply to each element.</param>
  9590. /// <param name="comparer">Comparer used to compare elements.</param>
  9591. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9592. /// <exception cref="ArgumentNullException">
  9593. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  9594. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9595. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  9596. {
  9597. if (source == null)
  9598. throw new ArgumentNullException(nameof(source));
  9599. if (selector == null)
  9600. throw new ArgumentNullException(nameof(selector));
  9601. if (comparer == null)
  9602. throw new ArgumentNullException(nameof(comparer));
  9603. return source.Provider.CreateQuery<TResult>(
  9604. Expression.Call(
  9605. null,
  9606. #if CRIPPLED_REFLECTION
  9607. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  9608. #else
  9609. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9610. #endif
  9611. source.Expression,
  9612. selector,
  9613. Expression.Constant(comparer, typeof(IComparer<TResult>))
  9614. )
  9615. );
  9616. }
  9617. /// <summary>
  9618. /// Returns the elements in an observable sequence with the minimum key value.
  9619. /// </summary>
  9620. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9621. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9622. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9623. /// <param name="keySelector">Key selector function.</param>
  9624. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9625. /// <exception cref="ArgumentNullException">
  9626. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  9627. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9628. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  9629. {
  9630. if (source == null)
  9631. throw new ArgumentNullException(nameof(source));
  9632. if (keySelector == null)
  9633. throw new ArgumentNullException(nameof(keySelector));
  9634. return source.Provider.CreateQuery<IList<TSource>>(
  9635. Expression.Call(
  9636. null,
  9637. #if CRIPPLED_REFLECTION
  9638. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  9639. #else
  9640. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9641. #endif
  9642. source.Expression,
  9643. keySelector
  9644. )
  9645. );
  9646. }
  9647. /// <summary>
  9648. /// Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
  9649. /// </summary>
  9650. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9651. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9652. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9653. /// <param name="keySelector">Key selector function.</param>
  9654. /// <param name="comparer">Comparer used to compare key values.</param>
  9655. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9656. /// <exception cref="ArgumentNullException">
  9657. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  9658. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9659. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  9660. {
  9661. if (source == null)
  9662. throw new ArgumentNullException(nameof(source));
  9663. if (keySelector == null)
  9664. throw new ArgumentNullException(nameof(keySelector));
  9665. if (comparer == null)
  9666. throw new ArgumentNullException(nameof(comparer));
  9667. return source.Provider.CreateQuery<IList<TSource>>(
  9668. Expression.Call(
  9669. null,
  9670. #if CRIPPLED_REFLECTION
  9671. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  9672. #else
  9673. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9674. #endif
  9675. source.Expression,
  9676. keySelector,
  9677. Expression.Constant(comparer, typeof(IComparer<TKey>))
  9678. )
  9679. );
  9680. }
  9681. /// <summary>
  9682. /// 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.
  9683. /// Enumerators on the resulting sequence never block and can produce the same element repeatedly.
  9684. /// </summary>
  9685. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9686. /// <param name="source">Source observable sequence.</param>
  9687. /// <param name="initialValue">Initial value that will be yielded by the enumerable sequence if no element has been sampled yet.</param>
  9688. /// <returns>The enumerable sequence that returns the last sampled element upon each iteration.</returns>
  9689. /// <exception cref="ArgumentNullException">
  9690. /// <paramref name="source" /> is null.</exception>
  9691. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9692. public static IQueryable<TSource> MostRecent<TSource>(this IQbservable<TSource> source, TSource initialValue)
  9693. {
  9694. if (source == null)
  9695. throw new ArgumentNullException(nameof(source));
  9696. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9697. Expression.Call(
  9698. null,
  9699. #if CRIPPLED_REFLECTION
  9700. InfoOf(() => Qbservable.MostRecent<TSource>(default(IQbservable<TSource>), default(TSource))),
  9701. #else
  9702. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9703. #endif
  9704. source.Expression,
  9705. Expression.Constant(initialValue, typeof(TSource))
  9706. )
  9707. );
  9708. }
  9709. /// <summary>
  9710. /// Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
  9711. /// subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
  9712. /// invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
  9713. /// </summary>
  9714. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9715. /// <typeparam name="TIntermediate">The type of the elements produced by the intermediate subject.</typeparam>
  9716. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9717. /// <param name="source">Source sequence which will be multicasted in the specified selector function.</param>
  9718. /// <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>
  9719. /// <param name="selector">Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject.</param>
  9720. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9721. /// <exception cref="ArgumentNullException">
  9722. /// <paramref name="source" /> or <paramref name="subjectSelector" /> or <paramref name="selector" /> is null.</exception>
  9723. 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)
  9724. {
  9725. if (source == null)
  9726. throw new ArgumentNullException(nameof(source));
  9727. if (subjectSelector == null)
  9728. throw new ArgumentNullException(nameof(subjectSelector));
  9729. if (selector == null)
  9730. throw new ArgumentNullException(nameof(selector));
  9731. return source.Provider.CreateQuery<TResult>(
  9732. Expression.Call(
  9733. null,
  9734. #if CRIPPLED_REFLECTION
  9735. InfoOf(() => Qbservable.Multicast<TSource, TIntermediate, TResult>(default(IQbservable<TSource>), default(Expression<Func<ISubject<TSource, TIntermediate>>>), default(Expression<Func<IObservable<TIntermediate>, IObservable<TResult>>>))),
  9736. #else
  9737. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TIntermediate), typeof(TResult)),
  9738. #endif
  9739. source.Expression,
  9740. subjectSelector,
  9741. selector
  9742. )
  9743. );
  9744. }
  9745. /// <summary>
  9746. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9747. /// </summary>
  9748. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9749. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  9750. /// <returns>An observable sequence whose observers will never get called.</returns>
  9751. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider)
  9752. {
  9753. if (provider == null)
  9754. throw new ArgumentNullException(nameof(provider));
  9755. return provider.CreateQuery<TResult>(
  9756. Expression.Call(
  9757. null,
  9758. #if CRIPPLED_REFLECTION
  9759. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider))),
  9760. #else
  9761. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9762. #endif
  9763. Expression.Constant(provider, typeof(IQbservableProvider))
  9764. )
  9765. );
  9766. }
  9767. /// <summary>
  9768. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9769. /// </summary>
  9770. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9771. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  9772. /// <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>
  9773. /// <returns>An observable sequence whose observers will never get called.</returns>
  9774. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider, TResult witness)
  9775. {
  9776. if (provider == null)
  9777. throw new ArgumentNullException(nameof(provider));
  9778. return provider.CreateQuery<TResult>(
  9779. Expression.Call(
  9780. null,
  9781. #if CRIPPLED_REFLECTION
  9782. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider), default(TResult))),
  9783. #else
  9784. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9785. #endif
  9786. Expression.Constant(provider, typeof(IQbservableProvider)),
  9787. Expression.Constant(witness, typeof(TResult))
  9788. )
  9789. );
  9790. }
  9791. /// <summary>
  9792. /// Returns an enumerable sequence whose enumeration blocks until the next element in the source observable sequence becomes available.
  9793. /// Enumerators on the resulting sequence will block until the next element becomes available.
  9794. /// </summary>
  9795. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9796. /// <param name="source">Source observable sequence.</param>
  9797. /// <returns>The enumerable sequence that blocks upon each iteration until the next element in the observable source sequence becomes available.</returns>
  9798. /// <exception cref="ArgumentNullException">
  9799. /// <paramref name="source" /> is null.</exception>
  9800. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9801. public static IQueryable<TSource> Next<TSource>(this IQbservable<TSource> source)
  9802. {
  9803. if (source == null)
  9804. throw new ArgumentNullException(nameof(source));
  9805. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9806. Expression.Call(
  9807. null,
  9808. #if CRIPPLED_REFLECTION
  9809. InfoOf(() => Qbservable.Next<TSource>(default(IQbservable<TSource>))),
  9810. #else
  9811. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9812. #endif
  9813. source.Expression
  9814. )
  9815. );
  9816. }
  9817. /// <summary>
  9818. /// Wraps the source sequence in order to run its observer callbacks on the specified synchronization context.
  9819. /// </summary>
  9820. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9821. /// <param name="source">Source sequence.</param>
  9822. /// <param name="context">Synchronization context to notify observers on.</param>
  9823. /// <returns>The source sequence whose observations happen on the specified synchronization context.</returns>
  9824. /// <exception cref="ArgumentNullException">
  9825. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  9826. /// <remarks>
  9827. /// This only invokes observer callbacks on a synchronization context. In case the subscription and/or unsubscription actions have side-effects
  9828. /// 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)" />.
  9829. /// </remarks>
  9830. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  9831. {
  9832. if (source == null)
  9833. throw new ArgumentNullException(nameof(source));
  9834. if (context == null)
  9835. throw new ArgumentNullException(nameof(context));
  9836. return source.Provider.CreateQuery<TSource>(
  9837. Expression.Call(
  9838. null,
  9839. #if CRIPPLED_REFLECTION
  9840. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  9841. #else
  9842. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9843. #endif
  9844. source.Expression,
  9845. Expression.Constant(context, typeof(SynchronizationContext))
  9846. )
  9847. );
  9848. }
  9849. /// <summary>
  9850. /// Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
  9851. /// </summary>
  9852. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9853. /// <param name="source">Source sequence.</param>
  9854. /// <param name="scheduler">Scheduler to notify observers on.</param>
  9855. /// <returns>The source sequence whose observations happen on the specified scheduler.</returns>
  9856. /// <exception cref="ArgumentNullException">
  9857. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  9858. /// <remarks>
  9859. /// This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
  9860. /// 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)" />.
  9861. /// </remarks>
  9862. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  9863. {
  9864. if (source == null)
  9865. throw new ArgumentNullException(nameof(source));
  9866. if (scheduler == null)
  9867. throw new ArgumentNullException(nameof(scheduler));
  9868. return source.Provider.CreateQuery<TSource>(
  9869. Expression.Call(
  9870. null,
  9871. #if CRIPPLED_REFLECTION
  9872. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  9873. #else
  9874. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9875. #endif
  9876. source.Expression,
  9877. Expression.Constant(scheduler, typeof(IScheduler))
  9878. )
  9879. );
  9880. }
  9881. /// <summary>
  9882. /// Filters the elements of an observable sequence based on the specified type.
  9883. /// </summary>
  9884. /// <typeparam name="TResult">The type to filter the elements in the source sequence on.</typeparam>
  9885. /// <param name="source">The observable sequence that contains the elements to be filtered.</param>
  9886. /// <returns>An observable sequence that contains elements from the input sequence of type TResult.</returns>
  9887. /// <exception cref="ArgumentNullException">
  9888. /// <paramref name="source" /> is null.</exception>
  9889. public static IQbservable<TResult> OfType<TResult>(this IQbservable<object> source)
  9890. {
  9891. if (source == null)
  9892. throw new ArgumentNullException(nameof(source));
  9893. return source.Provider.CreateQuery<TResult>(
  9894. Expression.Call(
  9895. null,
  9896. #if CRIPPLED_REFLECTION
  9897. InfoOf(() => Qbservable.OfType<TResult>(default(IQbservable<object>))),
  9898. #else
  9899. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9900. #endif
  9901. source.Expression
  9902. )
  9903. );
  9904. }
  9905. /// <summary>
  9906. /// Concatenates the second observable sequence to the first observable sequence upon successful or exceptional termination of the first.
  9907. /// </summary>
  9908. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9909. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  9910. /// <param name="second">Second observable sequence used to produce results after the first sequence terminates.</param>
  9911. /// <returns>An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.</returns>
  9912. /// <exception cref="ArgumentNullException">
  9913. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  9914. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  9915. {
  9916. if (first == null)
  9917. throw new ArgumentNullException(nameof(first));
  9918. if (second == null)
  9919. throw new ArgumentNullException(nameof(second));
  9920. return first.Provider.CreateQuery<TSource>(
  9921. Expression.Call(
  9922. null,
  9923. #if CRIPPLED_REFLECTION
  9924. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  9925. #else
  9926. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9927. #endif
  9928. first.Expression,
  9929. GetSourceExpression(second)
  9930. )
  9931. );
  9932. }
  9933. /// <summary>
  9934. /// Concatenates all of the specified observable sequences, even if the previous observable sequence terminated exceptionally.
  9935. /// </summary>
  9936. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9937. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9938. /// <param name="sources">Observable sequences to concatenate.</param>
  9939. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  9940. /// <exception cref="ArgumentNullException">
  9941. /// <paramref name="sources" /> is null.</exception>
  9942. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  9943. {
  9944. if (provider == null)
  9945. throw new ArgumentNullException(nameof(provider));
  9946. if (sources == null)
  9947. throw new ArgumentNullException(nameof(sources));
  9948. return provider.CreateQuery<TSource>(
  9949. Expression.Call(
  9950. null,
  9951. #if CRIPPLED_REFLECTION
  9952. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  9953. #else
  9954. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9955. #endif
  9956. Expression.Constant(provider, typeof(IQbservableProvider)),
  9957. GetSourceExpression(sources)
  9958. )
  9959. );
  9960. }
  9961. /// <summary>
  9962. /// Concatenates all observable sequences in the given enumerable sequence, even if the previous observable sequence terminated exceptionally.
  9963. /// </summary>
  9964. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9965. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9966. /// <param name="sources">Observable sequences to concatenate.</param>
  9967. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  9968. /// <exception cref="ArgumentNullException">
  9969. /// <paramref name="sources" /> is null.</exception>
  9970. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  9971. {
  9972. if (provider == null)
  9973. throw new ArgumentNullException(nameof(provider));
  9974. if (sources == null)
  9975. throw new ArgumentNullException(nameof(sources));
  9976. return provider.CreateQuery<TSource>(
  9977. Expression.Call(
  9978. null,
  9979. #if CRIPPLED_REFLECTION
  9980. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  9981. #else
  9982. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9983. #endif
  9984. Expression.Constant(provider, typeof(IQbservableProvider)),
  9985. GetSourceExpression(sources)
  9986. )
  9987. );
  9988. }
  9989. /// <summary>
  9990. /// Prepend a value to an observable sequence.
  9991. /// </summary>
  9992. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9993. /// <param name="source">Source sequence to prepend the value to.</param>
  9994. /// <param name="value">Value to prepend to the specified sequence.</param>
  9995. /// <returns>The source sequence prepended with the specified value.</returns>
  9996. /// <exception cref="ArgumentNullException">
  9997. /// <paramref name="source" /> is null.</exception>
  9998. public static IQbservable<TSource> Prepend<TSource>(this IQbservable<TSource> source, TSource value)
  9999. {
  10000. if (source == null)
  10001. throw new ArgumentNullException(nameof(source));
  10002. return source.Provider.CreateQuery<TSource>(
  10003. Expression.Call(
  10004. null,
  10005. #if CRIPPLED_REFLECTION
  10006. InfoOf(() => Qbservable.Prepend<TSource>(default(IQbservable<TSource>), default(TSource))),
  10007. #else
  10008. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10009. #endif
  10010. source.Expression,
  10011. Expression.Constant(value, typeof(TSource))
  10012. )
  10013. );
  10014. }
  10015. /// <summary>
  10016. /// Prepend a value to an observable sequence.
  10017. /// </summary>
  10018. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10019. /// <param name="source">Source sequence to prepend the value to.</param>
  10020. /// <param name="value">Value to prepend to the specified sequence.</param>
  10021. /// <param name="scheduler">Scheduler to emit the prepend values on.</param>
  10022. /// <returns>The source sequence prepended with the specified value.</returns>
  10023. /// <exception cref="ArgumentNullException">
  10024. /// <paramref name="source" /> is null.</exception>
  10025. public static IQbservable<TSource> Prepend<TSource>(this IQbservable<TSource> source, TSource value, IScheduler scheduler)
  10026. {
  10027. if (source == null)
  10028. throw new ArgumentNullException(nameof(source));
  10029. if (scheduler == null)
  10030. throw new ArgumentNullException(nameof(scheduler));
  10031. return source.Provider.CreateQuery<TSource>(
  10032. Expression.Call(
  10033. null,
  10034. #if CRIPPLED_REFLECTION
  10035. InfoOf(() => Qbservable.Prepend<TSource>(default(IQbservable<TSource>), default(TSource), default(IScheduler))),
  10036. #else
  10037. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10038. #endif
  10039. source.Expression,
  10040. Expression.Constant(value, typeof(TSource)),
  10041. Expression.Constant(scheduler, typeof(IScheduler))
  10042. )
  10043. );
  10044. }
  10045. /// <summary>
  10046. /// 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.
  10047. /// This operator is a specialization of Multicast using a regular <see cref="T:System.Reactive.Subjects.Subject`1" />.
  10048. /// </summary>
  10049. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10050. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10051. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10052. /// <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>
  10053. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10054. /// <exception cref="ArgumentNullException">
  10055. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10056. /// <seealso cref="T:System.Reactive.Subjects.Subject`1" />
  10057. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10058. {
  10059. if (source == null)
  10060. throw new ArgumentNullException(nameof(source));
  10061. if (selector == null)
  10062. throw new ArgumentNullException(nameof(selector));
  10063. return source.Provider.CreateQuery<TResult>(
  10064. Expression.Call(
  10065. null,
  10066. #if CRIPPLED_REFLECTION
  10067. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10068. #else
  10069. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10070. #endif
  10071. source.Expression,
  10072. selector
  10073. )
  10074. );
  10075. }
  10076. /// <summary>
  10077. /// 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.
  10078. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.BehaviorSubject`1" />.
  10079. /// </summary>
  10080. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10081. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10082. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10083. /// <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>
  10084. /// <param name="initialValue">Initial value received by observers upon subscription.</param>
  10085. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10086. /// <exception cref="ArgumentNullException">
  10087. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10088. /// <seealso cref="T:System.Reactive.Subjects.BehaviorSubject`1" />
  10089. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TSource initialValue)
  10090. {
  10091. if (source == null)
  10092. throw new ArgumentNullException(nameof(source));
  10093. if (selector == null)
  10094. throw new ArgumentNullException(nameof(selector));
  10095. return source.Provider.CreateQuery<TResult>(
  10096. Expression.Call(
  10097. null,
  10098. #if CRIPPLED_REFLECTION
  10099. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TSource))),
  10100. #else
  10101. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10102. #endif
  10103. source.Expression,
  10104. selector,
  10105. Expression.Constant(initialValue, typeof(TSource))
  10106. )
  10107. );
  10108. }
  10109. /// <summary>
  10110. /// 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.
  10111. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.AsyncSubject`1" />.
  10112. /// </summary>
  10113. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10114. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10115. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10116. /// <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>
  10117. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10118. /// <exception cref="ArgumentNullException">
  10119. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10120. /// <seealso cref="T:System.Reactive.Subjects.AsyncSubject`1" />
  10121. public static IQbservable<TResult> PublishLast<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10122. {
  10123. if (source == null)
  10124. throw new ArgumentNullException(nameof(source));
  10125. if (selector == null)
  10126. throw new ArgumentNullException(nameof(selector));
  10127. return source.Provider.CreateQuery<TResult>(
  10128. Expression.Call(
  10129. null,
  10130. #if CRIPPLED_REFLECTION
  10131. InfoOf(() => Qbservable.PublishLast<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10132. #else
  10133. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10134. #endif
  10135. source.Expression,
  10136. selector
  10137. )
  10138. );
  10139. }
  10140. /// <summary>
  10141. /// Generates an observable sequence of integral numbers within a specified range.
  10142. /// </summary>
  10143. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10144. /// <param name="start">The value of the first integer in the sequence.</param>
  10145. /// <param name="count">The number of sequential integers to generate.</param>
  10146. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10147. /// <exception cref="ArgumentOutOfRangeException">
  10148. /// <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>
  10149. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count)
  10150. {
  10151. if (provider == null)
  10152. throw new ArgumentNullException(nameof(provider));
  10153. return provider.CreateQuery<int>(
  10154. Expression.Call(
  10155. null,
  10156. #if CRIPPLED_REFLECTION
  10157. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int))),
  10158. #else
  10159. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10160. #endif
  10161. Expression.Constant(provider, typeof(IQbservableProvider)),
  10162. Expression.Constant(start, typeof(int)),
  10163. Expression.Constant(count, typeof(int))
  10164. )
  10165. );
  10166. }
  10167. /// <summary>
  10168. /// Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
  10169. /// </summary>
  10170. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10171. /// <param name="start">The value of the first integer in the sequence.</param>
  10172. /// <param name="count">The number of sequential integers to generate.</param>
  10173. /// <param name="scheduler">Scheduler to run the generator loop on.</param>
  10174. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10175. /// <exception cref="ArgumentOutOfRangeException">
  10176. /// <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>
  10177. /// <exception cref="ArgumentNullException">
  10178. /// <paramref name="scheduler" /> is null.</exception>
  10179. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count, IScheduler scheduler)
  10180. {
  10181. if (provider == null)
  10182. throw new ArgumentNullException(nameof(provider));
  10183. if (scheduler == null)
  10184. throw new ArgumentNullException(nameof(scheduler));
  10185. return provider.CreateQuery<int>(
  10186. Expression.Call(
  10187. null,
  10188. #if CRIPPLED_REFLECTION
  10189. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int), default(IScheduler))),
  10190. #else
  10191. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10192. #endif
  10193. Expression.Constant(provider, typeof(IQbservableProvider)),
  10194. Expression.Constant(start, typeof(int)),
  10195. Expression.Constant(count, typeof(int)),
  10196. Expression.Constant(scheduler, typeof(IScheduler))
  10197. )
  10198. );
  10199. }
  10200. /// <summary>
  10201. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10202. /// </summary>
  10203. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10204. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10205. /// <param name="source">Connectable observable sequence.</param>
  10206. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10207. /// <exception cref="ArgumentNullException">
  10208. /// <paramref name="source" /> is null.</exception>
  10209. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source)
  10210. {
  10211. if (provider == null)
  10212. throw new ArgumentNullException(nameof(provider));
  10213. if (source == null)
  10214. throw new ArgumentNullException(nameof(source));
  10215. return provider.CreateQuery<TSource>(
  10216. Expression.Call(
  10217. null,
  10218. #if CRIPPLED_REFLECTION
  10219. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>))),
  10220. #else
  10221. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10222. #endif
  10223. Expression.Constant(provider, typeof(IQbservableProvider)),
  10224. Expression.Constant(source, typeof(IConnectableObservable<TSource>))
  10225. )
  10226. );
  10227. }
  10228. /// <summary>
  10229. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10230. /// </summary>
  10231. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10232. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10233. /// <param name="source">Connectable observable sequence.</param>
  10234. /// <param name="disconnectDelay">The time span that should be waited before possibly unsubscribing from the connectable observable.</param>
  10235. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10236. /// <exception cref="ArgumentNullException">
  10237. /// <paramref name="source" /> is null.</exception>
  10238. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, TimeSpan disconnectDelay)
  10239. {
  10240. if (provider == null)
  10241. throw new ArgumentNullException(nameof(provider));
  10242. if (source == null)
  10243. throw new ArgumentNullException(nameof(source));
  10244. return provider.CreateQuery<TSource>(
  10245. Expression.Call(
  10246. null,
  10247. #if CRIPPLED_REFLECTION
  10248. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(TimeSpan))),
  10249. #else
  10250. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10251. #endif
  10252. Expression.Constant(provider, typeof(IQbservableProvider)),
  10253. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  10254. Expression.Constant(disconnectDelay, typeof(TimeSpan))
  10255. )
  10256. );
  10257. }
  10258. /// <summary>
  10259. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10260. /// </summary>
  10261. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10262. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10263. /// <param name="source">Connectable observable sequence.</param>
  10264. /// <param name="disconnectDelay">The time span that should be waited before possibly unsubscribing from the connectable observable.</param>
  10265. /// <param name="scheduler">The scheduler to use for delayed unsubscription.</param>
  10266. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10267. /// <exception cref="ArgumentNullException">
  10268. /// <paramref name="source" /> is null.</exception>
  10269. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, TimeSpan disconnectDelay, IScheduler scheduler)
  10270. {
  10271. if (provider == null)
  10272. throw new ArgumentNullException(nameof(provider));
  10273. if (source == null)
  10274. throw new ArgumentNullException(nameof(source));
  10275. if (scheduler == null)
  10276. throw new ArgumentNullException(nameof(scheduler));
  10277. return provider.CreateQuery<TSource>(
  10278. Expression.Call(
  10279. null,
  10280. #if CRIPPLED_REFLECTION
  10281. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(TimeSpan), default(IScheduler))),
  10282. #else
  10283. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10284. #endif
  10285. Expression.Constant(provider, typeof(IQbservableProvider)),
  10286. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  10287. Expression.Constant(disconnectDelay, typeof(TimeSpan)),
  10288. Expression.Constant(scheduler, typeof(IScheduler))
  10289. )
  10290. );
  10291. }
  10292. /// <summary>
  10293. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10294. /// </summary>
  10295. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10296. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10297. /// <param name="source">Connectable observable sequence.</param>
  10298. /// <param name="minObservers">The minimum number of observers required to subscribe before establishing the connection to the source.</param>
  10299. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10300. /// <exception cref="ArgumentNullException">
  10301. /// <paramref name="source" /> is null.</exception>
  10302. /// <exception cref="ArgumentOutOfRangeException"><paramref name="minObservers"/> is non-positive.</exception>
  10303. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, int minObservers)
  10304. {
  10305. if (provider == null)
  10306. throw new ArgumentNullException(nameof(provider));
  10307. if (source == null)
  10308. throw new ArgumentNullException(nameof(source));
  10309. if (minObservers <= 0)
  10310. throw new ArgumentOutOfRangeException(nameof(minObservers));
  10311. return provider.CreateQuery<TSource>(
  10312. Expression.Call(
  10313. null,
  10314. #if CRIPPLED_REFLECTION
  10315. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(int))),
  10316. #else
  10317. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10318. #endif
  10319. Expression.Constant(provider, typeof(IQbservableProvider)),
  10320. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  10321. Expression.Constant(minObservers, typeof(int))
  10322. )
  10323. );
  10324. }
  10325. /// <summary>
  10326. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10327. /// </summary>
  10328. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10329. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10330. /// <param name="source">Connectable observable sequence.</param>
  10331. /// <param name="minObservers">The minimum number of observers required to subscribe before establishing the connection to the source.</param>
  10332. /// <param name="disconnectDelay">The time span that should be waited before possibly unsubscribing from the connectable observable.</param>
  10333. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10334. /// <exception cref="ArgumentNullException">
  10335. /// <paramref name="source" /> is null.</exception>
  10336. /// <exception cref="ArgumentOutOfRangeException"><paramref name="minObservers"/> is non-positive.</exception>
  10337. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, int minObservers, TimeSpan disconnectDelay)
  10338. {
  10339. if (provider == null)
  10340. throw new ArgumentNullException(nameof(provider));
  10341. if (source == null)
  10342. throw new ArgumentNullException(nameof(source));
  10343. if (minObservers <= 0)
  10344. throw new ArgumentOutOfRangeException(nameof(minObservers));
  10345. return provider.CreateQuery<TSource>(
  10346. Expression.Call(
  10347. null,
  10348. #if CRIPPLED_REFLECTION
  10349. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(int), default(TimeSpan))),
  10350. #else
  10351. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10352. #endif
  10353. Expression.Constant(provider, typeof(IQbservableProvider)),
  10354. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  10355. Expression.Constant(minObservers, typeof(int)),
  10356. Expression.Constant(disconnectDelay, typeof(TimeSpan))
  10357. )
  10358. );
  10359. }
  10360. /// <summary>
  10361. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10362. /// </summary>
  10363. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10364. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10365. /// <param name="source">Connectable observable sequence.</param>
  10366. /// <param name="minObservers">The minimum number of observers required to subscribe before establishing the connection to the source.</param>
  10367. /// <param name="disconnectDelay">The time span that should be waited before possibly unsubscribing from the connectable observable.</param>
  10368. /// <param name="scheduler">The scheduler to use for delayed unsubscription.</param>
  10369. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10370. /// <exception cref="ArgumentNullException">
  10371. /// <paramref name="source" /> is null.</exception>
  10372. /// <exception cref="ArgumentOutOfRangeException"><paramref name="minObservers"/> is non-positive.</exception>
  10373. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source, int minObservers, TimeSpan disconnectDelay, IScheduler scheduler)
  10374. {
  10375. if (provider == null)
  10376. throw new ArgumentNullException(nameof(provider));
  10377. if (source == null)
  10378. throw new ArgumentNullException(nameof(source));
  10379. if (scheduler == null)
  10380. throw new ArgumentNullException(nameof(scheduler));
  10381. if (minObservers <= 0)
  10382. throw new ArgumentOutOfRangeException(nameof(minObservers));
  10383. return provider.CreateQuery<TSource>(
  10384. Expression.Call(
  10385. null,
  10386. #if CRIPPLED_REFLECTION
  10387. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>), default(int), default(TimeSpan), default(IScheduler))),
  10388. #else
  10389. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10390. #endif
  10391. Expression.Constant(provider, typeof(IQbservableProvider)),
  10392. Expression.Constant(source, typeof(IConnectableObservable<TSource>)),
  10393. Expression.Constant(minObservers, typeof(int)),
  10394. Expression.Constant(disconnectDelay, typeof(TimeSpan)),
  10395. Expression.Constant(scheduler, typeof(IScheduler))
  10396. )
  10397. );
  10398. }
  10399. /// <summary>
  10400. /// Generates an observable sequence that repeats the given element infinitely.
  10401. /// </summary>
  10402. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10403. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10404. /// <param name="value">Element to repeat.</param>
  10405. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10406. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value)
  10407. {
  10408. if (provider == null)
  10409. throw new ArgumentNullException(nameof(provider));
  10410. return provider.CreateQuery<TResult>(
  10411. Expression.Call(
  10412. null,
  10413. #if CRIPPLED_REFLECTION
  10414. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult))),
  10415. #else
  10416. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10417. #endif
  10418. Expression.Constant(provider, typeof(IQbservableProvider)),
  10419. Expression.Constant(value, typeof(TResult))
  10420. )
  10421. );
  10422. }
  10423. /// <summary>
  10424. /// Generates an observable sequence that repeats the given element the specified number of times.
  10425. /// </summary>
  10426. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10427. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10428. /// <param name="value">Element to repeat.</param>
  10429. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10430. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10431. /// <exception cref="ArgumentOutOfRangeException">
  10432. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10433. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount)
  10434. {
  10435. if (provider == null)
  10436. throw new ArgumentNullException(nameof(provider));
  10437. return provider.CreateQuery<TResult>(
  10438. Expression.Call(
  10439. null,
  10440. #if CRIPPLED_REFLECTION
  10441. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int))),
  10442. #else
  10443. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10444. #endif
  10445. Expression.Constant(provider, typeof(IQbservableProvider)),
  10446. Expression.Constant(value, typeof(TResult)),
  10447. Expression.Constant(repeatCount, typeof(int))
  10448. )
  10449. );
  10450. }
  10451. /// <summary>
  10452. /// Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
  10453. /// </summary>
  10454. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10455. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10456. /// <param name="value">Element to repeat.</param>
  10457. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10458. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10459. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10460. /// <exception cref="ArgumentOutOfRangeException">
  10461. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10462. /// <exception cref="ArgumentNullException">
  10463. /// <paramref name="scheduler" /> is null.</exception>
  10464. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount, IScheduler scheduler)
  10465. {
  10466. if (provider == null)
  10467. throw new ArgumentNullException(nameof(provider));
  10468. if (scheduler == null)
  10469. throw new ArgumentNullException(nameof(scheduler));
  10470. return provider.CreateQuery<TResult>(
  10471. Expression.Call(
  10472. null,
  10473. #if CRIPPLED_REFLECTION
  10474. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int), default(IScheduler))),
  10475. #else
  10476. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10477. #endif
  10478. Expression.Constant(provider, typeof(IQbservableProvider)),
  10479. Expression.Constant(value, typeof(TResult)),
  10480. Expression.Constant(repeatCount, typeof(int)),
  10481. Expression.Constant(scheduler, typeof(IScheduler))
  10482. )
  10483. );
  10484. }
  10485. /// <summary>
  10486. /// Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.
  10487. /// </summary>
  10488. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10489. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10490. /// <param name="value">Element to repeat.</param>
  10491. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10492. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10493. /// <exception cref="ArgumentNullException">
  10494. /// <paramref name="scheduler" /> is null.</exception>
  10495. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10496. {
  10497. if (provider == null)
  10498. throw new ArgumentNullException(nameof(provider));
  10499. if (scheduler == null)
  10500. throw new ArgumentNullException(nameof(scheduler));
  10501. return provider.CreateQuery<TResult>(
  10502. Expression.Call(
  10503. null,
  10504. #if CRIPPLED_REFLECTION
  10505. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10506. #else
  10507. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10508. #endif
  10509. Expression.Constant(provider, typeof(IQbservableProvider)),
  10510. Expression.Constant(value, typeof(TResult)),
  10511. Expression.Constant(scheduler, typeof(IScheduler))
  10512. )
  10513. );
  10514. }
  10515. /// <summary>
  10516. /// Repeats the observable sequence indefinitely.
  10517. /// </summary>
  10518. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10519. /// <param name="source">Observable sequence to repeat.</param>
  10520. /// <returns>The observable sequence producing the elements of the given sequence repeatedly and sequentially.</returns>
  10521. /// <exception cref="ArgumentNullException">
  10522. /// <paramref name="source" /> is null.</exception>
  10523. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source)
  10524. {
  10525. if (source == null)
  10526. throw new ArgumentNullException(nameof(source));
  10527. return source.Provider.CreateQuery<TSource>(
  10528. Expression.Call(
  10529. null,
  10530. #if CRIPPLED_REFLECTION
  10531. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>))),
  10532. #else
  10533. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10534. #endif
  10535. source.Expression
  10536. )
  10537. );
  10538. }
  10539. /// <summary>
  10540. /// Repeats the observable sequence a specified number of times.
  10541. /// </summary>
  10542. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10543. /// <param name="source">Observable sequence to repeat.</param>
  10544. /// <param name="repeatCount">Number of times to repeat the sequence.</param>
  10545. /// <returns>The observable sequence producing the elements of the given sequence repeatedly.</returns>
  10546. /// <exception cref="ArgumentNullException">
  10547. /// <paramref name="source" /> is null.</exception>
  10548. /// <exception cref="ArgumentOutOfRangeException">
  10549. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10550. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source, int repeatCount)
  10551. {
  10552. if (source == null)
  10553. throw new ArgumentNullException(nameof(source));
  10554. return source.Provider.CreateQuery<TSource>(
  10555. Expression.Call(
  10556. null,
  10557. #if CRIPPLED_REFLECTION
  10558. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>), default(int))),
  10559. #else
  10560. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10561. #endif
  10562. source.Expression,
  10563. Expression.Constant(repeatCount, typeof(int))
  10564. )
  10565. );
  10566. }
  10567. /// <summary>
  10568. /// Repeatedly resubscribes to the source observable after a normal completion and when the observable
  10569. /// returned by a handler produces an arbitrary item.
  10570. /// </summary>
  10571. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10572. /// <typeparam name="TSignal">The arbitrary element type signaled by the handler observable.</typeparam>
  10573. /// <param name="source">Observable sequence to keep repeating when it successfully terminates.</param>
  10574. /// <param name="handler">The function that is called for each observer and takes an observable sequence objects.
  10575. /// It should return an observable of arbitrary items that should signal that arbitrary item in
  10576. /// response to receiving the completion signal from the source observable. If this observable signals
  10577. /// a terminal event, the sequence is terminated with that signal instead.</param>
  10578. /// <returns>An observable sequence producing the elements of the given sequence repeatedly while each repetition terminates successfully.</returns>
  10579. /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
  10580. /// <exception cref="ArgumentNullException"><paramref name="handler"/> is null.</exception>
  10581. public static IQbservable<TSource> RepeatWhen<TSource, TSignal>(this IQbservable<TSource> source, Expression<Func<IObservable<object>, IObservable<TSignal>>> handler)
  10582. {
  10583. if (source == null)
  10584. throw new ArgumentNullException(nameof(source));
  10585. if (handler == null)
  10586. throw new ArgumentNullException(nameof(handler));
  10587. return source.Provider.CreateQuery<TSource>(
  10588. Expression.Call(
  10589. null,
  10590. #if CRIPPLED_REFLECTION
  10591. InfoOf(() => Qbservable.RepeatWhen<TSource, TSignal>(default(IQbservable<TSource>), default(Expression<Func<IObservable<object>, IObservable<TSignal>>>))),
  10592. #else
  10593. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSignal)),
  10594. #endif
  10595. source.Expression,
  10596. handler
  10597. )
  10598. );
  10599. }
  10600. /// <summary>
  10601. /// 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.
  10602. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10603. /// </summary>
  10604. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10605. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10606. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10607. /// <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>
  10608. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10609. /// <exception cref="ArgumentNullException">
  10610. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10611. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10612. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10613. {
  10614. if (source == null)
  10615. throw new ArgumentNullException(nameof(source));
  10616. if (selector == null)
  10617. throw new ArgumentNullException(nameof(selector));
  10618. return source.Provider.CreateQuery<TResult>(
  10619. Expression.Call(
  10620. null,
  10621. #if CRIPPLED_REFLECTION
  10622. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10623. #else
  10624. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10625. #endif
  10626. source.Expression,
  10627. selector
  10628. )
  10629. );
  10630. }
  10631. /// <summary>
  10632. /// 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.
  10633. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10634. /// </summary>
  10635. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10636. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10637. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10638. /// <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>
  10639. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10640. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10641. /// <exception cref="ArgumentNullException">
  10642. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10643. /// <exception cref="ArgumentOutOfRangeException">
  10644. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10645. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10646. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize)
  10647. {
  10648. if (source == null)
  10649. throw new ArgumentNullException(nameof(source));
  10650. if (selector == null)
  10651. throw new ArgumentNullException(nameof(selector));
  10652. return source.Provider.CreateQuery<TResult>(
  10653. Expression.Call(
  10654. null,
  10655. #if CRIPPLED_REFLECTION
  10656. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int))),
  10657. #else
  10658. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10659. #endif
  10660. source.Expression,
  10661. selector,
  10662. Expression.Constant(bufferSize, typeof(int))
  10663. )
  10664. );
  10665. }
  10666. /// <summary>
  10667. /// 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.
  10668. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10669. /// </summary>
  10670. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10671. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10672. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10673. /// <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>
  10674. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10675. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10676. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10677. /// <exception cref="ArgumentNullException">
  10678. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10679. /// <exception cref="ArgumentOutOfRangeException">
  10680. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10681. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10682. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, IScheduler scheduler)
  10683. {
  10684. if (source == null)
  10685. throw new ArgumentNullException(nameof(source));
  10686. if (selector == null)
  10687. throw new ArgumentNullException(nameof(selector));
  10688. if (scheduler == null)
  10689. throw new ArgumentNullException(nameof(scheduler));
  10690. return source.Provider.CreateQuery<TResult>(
  10691. Expression.Call(
  10692. null,
  10693. #if CRIPPLED_REFLECTION
  10694. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(IScheduler))),
  10695. #else
  10696. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10697. #endif
  10698. source.Expression,
  10699. selector,
  10700. Expression.Constant(bufferSize, typeof(int)),
  10701. Expression.Constant(scheduler, typeof(IScheduler))
  10702. )
  10703. );
  10704. }
  10705. /// <summary>
  10706. /// 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.
  10707. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10708. /// </summary>
  10709. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10710. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10711. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10712. /// <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>
  10713. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10714. /// <param name="window">Maximum time length of the replay buffer.</param>
  10715. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10716. /// <exception cref="ArgumentNullException">
  10717. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10718. /// <exception cref="ArgumentOutOfRangeException">
  10719. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10720. /// <exception cref="ArgumentOutOfRangeException">
  10721. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10722. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10723. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window)
  10724. {
  10725. if (source == null)
  10726. throw new ArgumentNullException(nameof(source));
  10727. if (selector == null)
  10728. throw new ArgumentNullException(nameof(selector));
  10729. return source.Provider.CreateQuery<TResult>(
  10730. Expression.Call(
  10731. null,
  10732. #if CRIPPLED_REFLECTION
  10733. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan))),
  10734. #else
  10735. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10736. #endif
  10737. source.Expression,
  10738. selector,
  10739. Expression.Constant(bufferSize, typeof(int)),
  10740. Expression.Constant(window, typeof(TimeSpan))
  10741. )
  10742. );
  10743. }
  10744. /// <summary>
  10745. /// 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.
  10746. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10747. /// </summary>
  10748. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10749. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10750. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10751. /// <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>
  10752. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10753. /// <param name="window">Maximum time length of the replay buffer.</param>
  10754. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10755. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10756. /// <exception cref="ArgumentNullException">
  10757. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10758. /// <exception cref="ArgumentOutOfRangeException">
  10759. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10760. /// <exception cref="ArgumentOutOfRangeException">
  10761. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10762. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10763. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window, IScheduler scheduler)
  10764. {
  10765. if (source == null)
  10766. throw new ArgumentNullException(nameof(source));
  10767. if (selector == null)
  10768. throw new ArgumentNullException(nameof(selector));
  10769. if (scheduler == null)
  10770. throw new ArgumentNullException(nameof(scheduler));
  10771. return source.Provider.CreateQuery<TResult>(
  10772. Expression.Call(
  10773. null,
  10774. #if CRIPPLED_REFLECTION
  10775. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan), default(IScheduler))),
  10776. #else
  10777. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10778. #endif
  10779. source.Expression,
  10780. selector,
  10781. Expression.Constant(bufferSize, typeof(int)),
  10782. Expression.Constant(window, typeof(TimeSpan)),
  10783. Expression.Constant(scheduler, typeof(IScheduler))
  10784. )
  10785. );
  10786. }
  10787. /// <summary>
  10788. /// 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.
  10789. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10790. /// </summary>
  10791. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10792. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10793. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10794. /// <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>
  10795. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10796. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10797. /// <exception cref="ArgumentNullException">
  10798. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10799. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10800. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, IScheduler scheduler)
  10801. {
  10802. if (source == null)
  10803. throw new ArgumentNullException(nameof(source));
  10804. if (selector == null)
  10805. throw new ArgumentNullException(nameof(selector));
  10806. if (scheduler == null)
  10807. throw new ArgumentNullException(nameof(scheduler));
  10808. return source.Provider.CreateQuery<TResult>(
  10809. Expression.Call(
  10810. null,
  10811. #if CRIPPLED_REFLECTION
  10812. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(IScheduler))),
  10813. #else
  10814. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10815. #endif
  10816. source.Expression,
  10817. selector,
  10818. Expression.Constant(scheduler, typeof(IScheduler))
  10819. )
  10820. );
  10821. }
  10822. /// <summary>
  10823. /// 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.
  10824. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10825. /// </summary>
  10826. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10827. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10828. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10829. /// <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>
  10830. /// <param name="window">Maximum time length of the replay buffer.</param>
  10831. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10832. /// <exception cref="ArgumentNullException">
  10833. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10834. /// <exception cref="ArgumentOutOfRangeException">
  10835. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10836. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10837. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window)
  10838. {
  10839. if (source == null)
  10840. throw new ArgumentNullException(nameof(source));
  10841. if (selector == null)
  10842. throw new ArgumentNullException(nameof(selector));
  10843. return source.Provider.CreateQuery<TResult>(
  10844. Expression.Call(
  10845. null,
  10846. #if CRIPPLED_REFLECTION
  10847. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan))),
  10848. #else
  10849. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10850. #endif
  10851. source.Expression,
  10852. selector,
  10853. Expression.Constant(window, typeof(TimeSpan))
  10854. )
  10855. );
  10856. }
  10857. /// <summary>
  10858. /// 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.
  10859. /// This operator is a specialization of Multicast using a <see cref="T:System.Reactive.Subjects.ReplaySubject`1" />.
  10860. /// </summary>
  10861. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10862. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10863. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10864. /// <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>
  10865. /// <param name="window">Maximum time length of the replay buffer.</param>
  10866. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10867. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10868. /// <exception cref="ArgumentNullException">
  10869. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10870. /// <exception cref="ArgumentOutOfRangeException">
  10871. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10872. /// <seealso cref="T:System.Reactive.Subjects.ReplaySubject`1" />
  10873. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window, IScheduler scheduler)
  10874. {
  10875. if (source == null)
  10876. throw new ArgumentNullException(nameof(source));
  10877. if (selector == null)
  10878. throw new ArgumentNullException(nameof(selector));
  10879. if (scheduler == null)
  10880. throw new ArgumentNullException(nameof(scheduler));
  10881. return source.Provider.CreateQuery<TResult>(
  10882. Expression.Call(
  10883. null,
  10884. #if CRIPPLED_REFLECTION
  10885. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan), default(IScheduler))),
  10886. #else
  10887. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10888. #endif
  10889. source.Expression,
  10890. selector,
  10891. Expression.Constant(window, typeof(TimeSpan)),
  10892. Expression.Constant(scheduler, typeof(IScheduler))
  10893. )
  10894. );
  10895. }
  10896. /// <summary>
  10897. /// Repeats the source observable sequence until it successfully terminates.
  10898. /// </summary>
  10899. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10900. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10901. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10902. /// <exception cref="ArgumentNullException">
  10903. /// <paramref name="source" /> is null.</exception>
  10904. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source)
  10905. {
  10906. if (source == null)
  10907. throw new ArgumentNullException(nameof(source));
  10908. return source.Provider.CreateQuery<TSource>(
  10909. Expression.Call(
  10910. null,
  10911. #if CRIPPLED_REFLECTION
  10912. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>))),
  10913. #else
  10914. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10915. #endif
  10916. source.Expression
  10917. )
  10918. );
  10919. }
  10920. /// <summary>
  10921. /// Repeats the source observable sequence the specified number of times or until it successfully terminates.
  10922. /// </summary>
  10923. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10924. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10925. /// <param name="retryCount">Number of times to repeat the sequence.</param>
  10926. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10927. /// <exception cref="ArgumentNullException">
  10928. /// <paramref name="source" /> is null.</exception>
  10929. /// <exception cref="ArgumentOutOfRangeException">
  10930. /// <paramref name="retryCount" /> is less than zero.</exception>
  10931. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source, int retryCount)
  10932. {
  10933. if (source == null)
  10934. throw new ArgumentNullException(nameof(source));
  10935. return source.Provider.CreateQuery<TSource>(
  10936. Expression.Call(
  10937. null,
  10938. #if CRIPPLED_REFLECTION
  10939. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>), default(int))),
  10940. #else
  10941. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10942. #endif
  10943. source.Expression,
  10944. Expression.Constant(retryCount, typeof(int))
  10945. )
  10946. );
  10947. }
  10948. /// <summary>
  10949. /// Retries (resubscribes to) the source observable after a failure and when the observable
  10950. /// returned by a handler produces an arbitrary item.
  10951. /// </summary>
  10952. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10953. /// <typeparam name="TSignal">The arbitrary element type signaled by the handler observable.</typeparam>
  10954. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10955. /// <param name="handler">The function that is called for each observer and takes an observable sequence of
  10956. /// errors. It should return an observable of arbitrary items that should signal that arbitrary item in
  10957. /// response to receiving the failure Exception from the source observable. If this observable signals
  10958. /// a terminal event, the sequence is terminated with that signal instead.</param>
  10959. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10960. /// <exception cref="ArgumentNullException">
  10961. /// <paramref name="source" /> is null.</exception>
  10962. /// <exception cref="ArgumentNullException">
  10963. /// <paramref name="handler" /> is null.</exception>
  10964. public static IQbservable<TSource> RetryWhen<TSource, TSignal>(this IQbservable<TSource> source, Expression<Func<IObservable<Exception>, IObservable<TSignal>>> handler)
  10965. {
  10966. if (source == null)
  10967. throw new ArgumentNullException(nameof(source));
  10968. if (handler == null)
  10969. throw new ArgumentNullException(nameof(handler));
  10970. return source.Provider.CreateQuery<TSource>(
  10971. Expression.Call(
  10972. null,
  10973. #if CRIPPLED_REFLECTION
  10974. InfoOf(() => Qbservable.RetryWhen<TSource, TSignal>(default(IQbservable<TSource>), default(Expression<Func<IObservable<Exception>, IObservable<TSignal>>>))),
  10975. #else
  10976. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSignal)),
  10977. #endif
  10978. source.Expression,
  10979. handler
  10980. )
  10981. );
  10982. }
  10983. /// <summary>
  10984. /// Returns an observable sequence that contains a single element.
  10985. /// </summary>
  10986. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10987. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  10988. /// <param name="value">Single element in the resulting observable sequence.</param>
  10989. /// <returns>An observable sequence containing the single specified element.</returns>
  10990. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value)
  10991. {
  10992. if (provider == null)
  10993. throw new ArgumentNullException(nameof(provider));
  10994. return provider.CreateQuery<TResult>(
  10995. Expression.Call(
  10996. null,
  10997. #if CRIPPLED_REFLECTION
  10998. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult))),
  10999. #else
  11000. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  11001. #endif
  11002. Expression.Constant(provider, typeof(IQbservableProvider)),
  11003. Expression.Constant(value, typeof(TResult))
  11004. )
  11005. );
  11006. }
  11007. /// <summary>
  11008. /// Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
  11009. /// </summary>
  11010. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  11011. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  11012. /// <param name="value">Single element in the resulting observable sequence.</param>
  11013. /// <param name="scheduler">Scheduler to send the single element on.</param>
  11014. /// <returns>An observable sequence containing the single specified element.</returns>
  11015. /// <exception cref="ArgumentNullException">
  11016. /// <paramref name="scheduler" /> is null.</exception>
  11017. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  11018. {
  11019. if (provider == null)
  11020. throw new ArgumentNullException(nameof(provider));
  11021. if (scheduler == null)
  11022. throw new ArgumentNullException(nameof(scheduler));
  11023. return provider.CreateQuery<TResult>(
  11024. Expression.Call(
  11025. null,
  11026. #if CRIPPLED_REFLECTION
  11027. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  11028. #else
  11029. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  11030. #endif
  11031. Expression.Constant(provider, typeof(IQbservableProvider)),
  11032. Expression.Constant(value, typeof(TResult)),
  11033. Expression.Constant(scheduler, typeof(IScheduler))
  11034. )
  11035. );
  11036. }
  11037. /// <summary>
  11038. /// Samples the observable sequence at each interval.
  11039. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  11040. /// </summary>
  11041. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11042. /// <param name="source">Source sequence to sample.</param>
  11043. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  11044. /// <returns>Sampled observable sequence.</returns>
  11045. /// <exception cref="ArgumentNullException">
  11046. /// <paramref name="source" /> is null.</exception>
  11047. /// <exception cref="ArgumentOutOfRangeException">
  11048. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  11049. /// <remarks>
  11050. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  11051. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  11052. /// </remarks>
  11053. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval)
  11054. {
  11055. if (source == null)
  11056. throw new ArgumentNullException(nameof(source));
  11057. return source.Provider.CreateQuery<TSource>(
  11058. Expression.Call(
  11059. null,
  11060. #if CRIPPLED_REFLECTION
  11061. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  11062. #else
  11063. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11064. #endif
  11065. source.Expression,
  11066. Expression.Constant(interval, typeof(TimeSpan))
  11067. )
  11068. );
  11069. }
  11070. /// <summary>
  11071. /// Samples the observable sequence at each interval, using the specified scheduler to run sampling timers.
  11072. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  11073. /// </summary>
  11074. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11075. /// <param name="source">Source sequence to sample.</param>
  11076. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  11077. /// <param name="scheduler">Scheduler to run the sampling timer on.</param>
  11078. /// <returns>Sampled observable sequence.</returns>
  11079. /// <exception cref="ArgumentNullException">
  11080. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  11081. /// <exception cref="ArgumentOutOfRangeException">
  11082. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  11083. /// <remarks>
  11084. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  11085. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  11086. /// </remarks>
  11087. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval, IScheduler scheduler)
  11088. {
  11089. if (source == null)
  11090. throw new ArgumentNullException(nameof(source));
  11091. if (scheduler == null)
  11092. throw new ArgumentNullException(nameof(scheduler));
  11093. return source.Provider.CreateQuery<TSource>(
  11094. Expression.Call(
  11095. null,
  11096. #if CRIPPLED_REFLECTION
  11097. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  11098. #else
  11099. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11100. #endif
  11101. source.Expression,
  11102. Expression.Constant(interval, typeof(TimeSpan)),
  11103. Expression.Constant(scheduler, typeof(IScheduler))
  11104. )
  11105. );
  11106. }
  11107. /// <summary>
  11108. /// Samples the source observable sequence using a sampler observable sequence producing sampling ticks.
  11109. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  11110. /// </summary>
  11111. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11112. /// <typeparam name="TSample">The type of the elements in the sampling sequence.</typeparam>
  11113. /// <param name="source">Source sequence to sample.</param>
  11114. /// <param name="sampler">Sampling tick sequence.</param>
  11115. /// <returns>Sampled observable sequence.</returns>
  11116. /// <exception cref="ArgumentNullException">
  11117. /// <paramref name="source" /> or <paramref name="sampler" /> is null.</exception>
  11118. public static IQbservable<TSource> Sample<TSource, TSample>(this IQbservable<TSource> source, IObservable<TSample> sampler)
  11119. {
  11120. if (source == null)
  11121. throw new ArgumentNullException(nameof(source));
  11122. if (sampler == null)
  11123. throw new ArgumentNullException(nameof(sampler));
  11124. return source.Provider.CreateQuery<TSource>(
  11125. Expression.Call(
  11126. null,
  11127. #if CRIPPLED_REFLECTION
  11128. InfoOf(() => Qbservable.Sample<TSource, TSample>(default(IQbservable<TSource>), default(IObservable<TSample>))),
  11129. #else
  11130. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSample)),
  11131. #endif
  11132. source.Expression,
  11133. GetSourceExpression(sampler)
  11134. )
  11135. );
  11136. }
  11137. /// <summary>
  11138. /// Applies an accumulator function over an observable sequence and returns each intermediate result.
  11139. /// 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})" />.
  11140. /// </summary>
  11141. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  11142. /// <param name="source">An observable sequence to accumulate over.</param>
  11143. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11144. /// <returns>An observable sequence containing the accumulated values.</returns>
  11145. /// <exception cref="ArgumentNullException">
  11146. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11147. public static IQbservable<TSource> Scan<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  11148. {
  11149. if (source == null)
  11150. throw new ArgumentNullException(nameof(source));
  11151. if (accumulator == null)
  11152. throw new ArgumentNullException(nameof(accumulator));
  11153. return source.Provider.CreateQuery<TSource>(
  11154. Expression.Call(
  11155. null,
  11156. #if CRIPPLED_REFLECTION
  11157. InfoOf(() => Qbservable.Scan<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  11158. #else
  11159. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11160. #endif
  11161. source.Expression,
  11162. accumulator
  11163. )
  11164. );
  11165. }
  11166. /// <summary>
  11167. /// Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
  11168. /// 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})" />.
  11169. /// </summary>
  11170. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11171. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  11172. /// <param name="source">An observable sequence to accumulate over.</param>
  11173. /// <param name="seed">The initial accumulator value.</param>
  11174. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  11175. /// <returns>An observable sequence containing the accumulated values.</returns>
  11176. /// <exception cref="ArgumentNullException">
  11177. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  11178. public static IQbservable<TAccumulate> Scan<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  11179. {
  11180. if (source == null)
  11181. throw new ArgumentNullException(nameof(source));
  11182. if (accumulator == null)
  11183. throw new ArgumentNullException(nameof(accumulator));
  11184. return source.Provider.CreateQuery<TAccumulate>(
  11185. Expression.Call(
  11186. null,
  11187. #if CRIPPLED_REFLECTION
  11188. InfoOf(() => Qbservable.Scan<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  11189. #else
  11190. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  11191. #endif
  11192. source.Expression,
  11193. Expression.Constant(seed, typeof(TAccumulate)),
  11194. accumulator
  11195. )
  11196. );
  11197. }
  11198. /// <summary>
  11199. /// Projects each element of an observable sequence into a new form.
  11200. /// </summary>
  11201. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11202. /// <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>
  11203. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11204. /// <param name="selector">A transform function to apply to each source element.</param>
  11205. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11206. /// <exception cref="ArgumentNullException">
  11207. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11208. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  11209. {
  11210. if (source == null)
  11211. throw new ArgumentNullException(nameof(source));
  11212. if (selector == null)
  11213. throw new ArgumentNullException(nameof(selector));
  11214. return source.Provider.CreateQuery<TResult>(
  11215. Expression.Call(
  11216. null,
  11217. #if CRIPPLED_REFLECTION
  11218. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  11219. #else
  11220. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11221. #endif
  11222. source.Expression,
  11223. selector
  11224. )
  11225. );
  11226. }
  11227. /// <summary>
  11228. /// Projects each element of an observable sequence into a new form by incorporating the element's index.
  11229. /// </summary>
  11230. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11231. /// <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>
  11232. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  11233. /// <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>
  11234. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  11235. /// <exception cref="ArgumentNullException">
  11236. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11237. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, TResult>> selector)
  11238. {
  11239. if (source == null)
  11240. throw new ArgumentNullException(nameof(source));
  11241. if (selector == null)
  11242. throw new ArgumentNullException(nameof(selector));
  11243. return source.Provider.CreateQuery<TResult>(
  11244. Expression.Call(
  11245. null,
  11246. #if CRIPPLED_REFLECTION
  11247. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, TResult>>))),
  11248. #else
  11249. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11250. #endif
  11251. source.Expression,
  11252. selector
  11253. )
  11254. );
  11255. }
  11256. /// <summary>
  11257. /// 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.
  11258. /// </summary>
  11259. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11260. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11261. /// <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>
  11262. /// <param name="source">An observable sequence of elements to project.</param>
  11263. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11264. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11265. /// <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>
  11266. /// <exception cref="ArgumentNullException">
  11267. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11268. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11269. {
  11270. if (source == null)
  11271. throw new ArgumentNullException(nameof(source));
  11272. if (collectionSelector == null)
  11273. throw new ArgumentNullException(nameof(collectionSelector));
  11274. if (resultSelector == null)
  11275. throw new ArgumentNullException(nameof(resultSelector));
  11276. return source.Provider.CreateQuery<TResult>(
  11277. Expression.Call(
  11278. null,
  11279. #if CRIPPLED_REFLECTION
  11280. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11281. #else
  11282. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11283. #endif
  11284. source.Expression,
  11285. collectionSelector,
  11286. resultSelector
  11287. )
  11288. );
  11289. }
  11290. /// <summary>
  11291. /// 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.
  11292. /// </summary>
  11293. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11294. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  11295. /// <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>
  11296. /// <param name="source">An observable sequence of elements to project.</param>
  11297. /// <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>
  11298. /// <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>
  11299. /// <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>
  11300. /// <exception cref="ArgumentNullException">
  11301. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11302. 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)
  11303. {
  11304. if (source == null)
  11305. throw new ArgumentNullException(nameof(source));
  11306. if (collectionSelector == null)
  11307. throw new ArgumentNullException(nameof(collectionSelector));
  11308. if (resultSelector == null)
  11309. throw new ArgumentNullException(nameof(resultSelector));
  11310. return source.Provider.CreateQuery<TResult>(
  11311. Expression.Call(
  11312. null,
  11313. #if CRIPPLED_REFLECTION
  11314. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11315. #else
  11316. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11317. #endif
  11318. source.Expression,
  11319. collectionSelector,
  11320. resultSelector
  11321. )
  11322. );
  11323. }
  11324. /// <summary>
  11325. /// 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.
  11326. /// </summary>
  11327. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11328. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11329. /// <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>
  11330. /// <param name="source">An observable sequence of elements to project.</param>
  11331. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  11332. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11333. /// <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>
  11334. /// <exception cref="ArgumentNullException">
  11335. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11336. /// <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>
  11337. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  11338. {
  11339. if (source == null)
  11340. throw new ArgumentNullException(nameof(source));
  11341. if (collectionSelector == null)
  11342. throw new ArgumentNullException(nameof(collectionSelector));
  11343. if (resultSelector == null)
  11344. throw new ArgumentNullException(nameof(resultSelector));
  11345. return source.Provider.CreateQuery<TResult>(
  11346. Expression.Call(
  11347. null,
  11348. #if CRIPPLED_REFLECTION
  11349. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  11350. #else
  11351. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11352. #endif
  11353. source.Expression,
  11354. collectionSelector,
  11355. resultSelector
  11356. )
  11357. );
  11358. }
  11359. /// <summary>
  11360. /// 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.
  11361. /// </summary>
  11362. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11363. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  11364. /// <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>
  11365. /// <param name="source">An observable sequence of elements to project.</param>
  11366. /// <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>
  11367. /// <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>
  11368. /// <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>
  11369. /// <exception cref="ArgumentNullException">
  11370. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11371. /// <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>
  11372. 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)
  11373. {
  11374. if (source == null)
  11375. throw new ArgumentNullException(nameof(source));
  11376. if (collectionSelector == null)
  11377. throw new ArgumentNullException(nameof(collectionSelector));
  11378. if (resultSelector == null)
  11379. throw new ArgumentNullException(nameof(resultSelector));
  11380. return source.Provider.CreateQuery<TResult>(
  11381. Expression.Call(
  11382. null,
  11383. #if CRIPPLED_REFLECTION
  11384. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  11385. #else
  11386. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  11387. #endif
  11388. source.Expression,
  11389. collectionSelector,
  11390. resultSelector
  11391. )
  11392. );
  11393. }
  11394. /// <summary>
  11395. /// Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  11396. /// </summary>
  11397. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11398. /// <typeparam name="TOther">The type of the elements in the other sequence and the elements in the result sequence.</typeparam>
  11399. /// <param name="source">An observable sequence of elements to project.</param>
  11400. /// <param name="other">An observable sequence to project each element from the source sequence onto.</param>
  11401. /// <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>
  11402. /// <exception cref="ArgumentNullException">
  11403. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  11404. public static IQbservable<TOther> SelectMany<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  11405. {
  11406. if (source == null)
  11407. throw new ArgumentNullException(nameof(source));
  11408. if (other == null)
  11409. throw new ArgumentNullException(nameof(other));
  11410. return source.Provider.CreateQuery<TOther>(
  11411. Expression.Call(
  11412. null,
  11413. #if CRIPPLED_REFLECTION
  11414. InfoOf(() => Qbservable.SelectMany<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  11415. #else
  11416. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  11417. #endif
  11418. source.Expression,
  11419. GetSourceExpression(other)
  11420. )
  11421. );
  11422. }
  11423. /// <summary>
  11424. /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11425. /// </summary>
  11426. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11427. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11428. /// <param name="source">An observable sequence of notifications to project.</param>
  11429. /// <param name="onNext">A transform function to apply to each element.</param>
  11430. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11431. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11432. /// <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>
  11433. /// <exception cref="ArgumentNullException">
  11434. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11435. 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)
  11436. {
  11437. if (source == null)
  11438. throw new ArgumentNullException(nameof(source));
  11439. if (onNext == null)
  11440. throw new ArgumentNullException(nameof(onNext));
  11441. if (onError == null)
  11442. throw new ArgumentNullException(nameof(onError));
  11443. if (onCompleted == null)
  11444. throw new ArgumentNullException(nameof(onCompleted));
  11445. return source.Provider.CreateQuery<TResult>(
  11446. Expression.Call(
  11447. null,
  11448. #if CRIPPLED_REFLECTION
  11449. 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>>>))),
  11450. #else
  11451. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11452. #endif
  11453. source.Expression,
  11454. onNext,
  11455. onError,
  11456. onCompleted
  11457. )
  11458. );
  11459. }
  11460. /// <summary>
  11461. /// 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.
  11462. /// </summary>
  11463. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11464. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11465. /// <param name="source">An observable sequence of notifications to project.</param>
  11466. /// <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>
  11467. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11468. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11469. /// <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>
  11470. /// <exception cref="ArgumentNullException">
  11471. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11472. 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)
  11473. {
  11474. if (source == null)
  11475. throw new ArgumentNullException(nameof(source));
  11476. if (onNext == null)
  11477. throw new ArgumentNullException(nameof(onNext));
  11478. if (onError == null)
  11479. throw new ArgumentNullException(nameof(onError));
  11480. if (onCompleted == null)
  11481. throw new ArgumentNullException(nameof(onCompleted));
  11482. return source.Provider.CreateQuery<TResult>(
  11483. Expression.Call(
  11484. null,
  11485. #if CRIPPLED_REFLECTION
  11486. 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>>>))),
  11487. #else
  11488. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11489. #endif
  11490. source.Expression,
  11491. onNext,
  11492. onError,
  11493. onCompleted
  11494. )
  11495. );
  11496. }
  11497. /// <summary>
  11498. /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11499. /// </summary>
  11500. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11501. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11502. /// <param name="source">An observable sequence of elements to project.</param>
  11503. /// <param name="selector">A transform function to apply to each element.</param>
  11504. /// <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>
  11505. /// <exception cref="ArgumentNullException">
  11506. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11507. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> selector)
  11508. {
  11509. if (source == null)
  11510. throw new ArgumentNullException(nameof(source));
  11511. if (selector == null)
  11512. throw new ArgumentNullException(nameof(selector));
  11513. return source.Provider.CreateQuery<TResult>(
  11514. Expression.Call(
  11515. null,
  11516. #if CRIPPLED_REFLECTION
  11517. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  11518. #else
  11519. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11520. #endif
  11521. source.Expression,
  11522. selector
  11523. )
  11524. );
  11525. }
  11526. /// <summary>
  11527. /// 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.
  11528. /// </summary>
  11529. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11530. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11531. /// <param name="source">An observable sequence of elements to project.</param>
  11532. /// <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>
  11533. /// <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>
  11534. /// <exception cref="ArgumentNullException">
  11535. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11536. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TResult>>> selector)
  11537. {
  11538. if (source == null)
  11539. throw new ArgumentNullException(nameof(source));
  11540. if (selector == null)
  11541. throw new ArgumentNullException(nameof(selector));
  11542. return source.Provider.CreateQuery<TResult>(
  11543. Expression.Call(
  11544. null,
  11545. #if CRIPPLED_REFLECTION
  11546. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>))),
  11547. #else
  11548. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11549. #endif
  11550. source.Expression,
  11551. selector
  11552. )
  11553. );
  11554. }
  11555. /// <summary>
  11556. /// Projects each element of an observable sequence to a task and merges all of the task results into one observable sequence.
  11557. /// </summary>
  11558. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11559. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11560. /// <param name="source">An observable sequence of elements to project.</param>
  11561. /// <param name="selector">A transform function to apply to each element.</param>
  11562. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11563. /// <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>
  11564. /// <exception cref="ArgumentNullException">
  11565. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11566. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TResult>>> selector)
  11567. {
  11568. if (source == null)
  11569. throw new ArgumentNullException(nameof(source));
  11570. if (selector == null)
  11571. throw new ArgumentNullException(nameof(selector));
  11572. return source.Provider.CreateQuery<TResult>(
  11573. Expression.Call(
  11574. null,
  11575. #if CRIPPLED_REFLECTION
  11576. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TResult>>>))),
  11577. #else
  11578. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11579. #endif
  11580. source.Expression,
  11581. selector
  11582. )
  11583. );
  11584. }
  11585. /// <summary>
  11586. /// 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.
  11587. /// </summary>
  11588. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11589. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11590. /// <param name="source">An observable sequence of elements to project.</param>
  11591. /// <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>
  11592. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11593. /// <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>
  11594. /// <exception cref="ArgumentNullException">
  11595. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11596. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, Task<TResult>>> selector)
  11597. {
  11598. if (source == null)
  11599. throw new ArgumentNullException(nameof(source));
  11600. if (selector == null)
  11601. throw new ArgumentNullException(nameof(selector));
  11602. return source.Provider.CreateQuery<TResult>(
  11603. Expression.Call(
  11604. null,
  11605. #if CRIPPLED_REFLECTION
  11606. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TResult>>>))),
  11607. #else
  11608. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11609. #endif
  11610. source.Expression,
  11611. selector
  11612. )
  11613. );
  11614. }
  11615. /// <summary>
  11616. /// Projects each element of an observable sequence to a task with cancellation support and merges all of the task results into one observable sequence.
  11617. /// </summary>
  11618. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11619. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11620. /// <param name="source">An observable sequence of elements to project.</param>
  11621. /// <param name="selector">A transform function to apply to each element.</param>
  11622. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11623. /// <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>
  11624. /// <exception cref="ArgumentNullException">
  11625. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11626. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, CancellationToken, Task<TResult>>> selector)
  11627. {
  11628. if (source == null)
  11629. throw new ArgumentNullException(nameof(source));
  11630. if (selector == null)
  11631. throw new ArgumentNullException(nameof(selector));
  11632. return source.Provider.CreateQuery<TResult>(
  11633. Expression.Call(
  11634. null,
  11635. #if CRIPPLED_REFLECTION
  11636. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TResult>>>))),
  11637. #else
  11638. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11639. #endif
  11640. source.Expression,
  11641. selector
  11642. )
  11643. );
  11644. }
  11645. /// <summary>
  11646. /// 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.
  11647. /// </summary>
  11648. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11649. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11650. /// <param name="source">An observable sequence of elements to project.</param>
  11651. /// <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>
  11652. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11653. /// <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>
  11654. /// <exception cref="ArgumentNullException">
  11655. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11656. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, CancellationToken, Task<TResult>>> selector)
  11657. {
  11658. if (source == null)
  11659. throw new ArgumentNullException(nameof(source));
  11660. if (selector == null)
  11661. throw new ArgumentNullException(nameof(selector));
  11662. return source.Provider.CreateQuery<TResult>(
  11663. Expression.Call(
  11664. null,
  11665. #if CRIPPLED_REFLECTION
  11666. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TResult>>>))),
  11667. #else
  11668. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11669. #endif
  11670. source.Expression,
  11671. selector
  11672. )
  11673. );
  11674. }
  11675. /// <summary>
  11676. /// Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.
  11677. /// </summary>
  11678. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11679. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11680. /// <param name="source">An observable sequence of elements to project.</param>
  11681. /// <param name="selector">A transform function to apply to each element.</param>
  11682. /// <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>
  11683. /// <exception cref="ArgumentNullException">
  11684. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11685. /// <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>
  11686. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector)
  11687. {
  11688. if (source == null)
  11689. throw new ArgumentNullException(nameof(source));
  11690. if (selector == null)
  11691. throw new ArgumentNullException(nameof(selector));
  11692. return source.Provider.CreateQuery<TResult>(
  11693. Expression.Call(
  11694. null,
  11695. #if CRIPPLED_REFLECTION
  11696. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TResult>>>))),
  11697. #else
  11698. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11699. #endif
  11700. source.Expression,
  11701. selector
  11702. )
  11703. );
  11704. }
  11705. /// <summary>
  11706. /// 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.
  11707. /// </summary>
  11708. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11709. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11710. /// <param name="source">An observable sequence of elements to project.</param>
  11711. /// <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>
  11712. /// <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>
  11713. /// <exception cref="ArgumentNullException">
  11714. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11715. /// <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>
  11716. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IEnumerable<TResult>>> selector)
  11717. {
  11718. if (source == null)
  11719. throw new ArgumentNullException(nameof(source));
  11720. if (selector == null)
  11721. throw new ArgumentNullException(nameof(selector));
  11722. return source.Provider.CreateQuery<TResult>(
  11723. Expression.Call(
  11724. null,
  11725. #if CRIPPLED_REFLECTION
  11726. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TResult>>>))),
  11727. #else
  11728. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11729. #endif
  11730. source.Expression,
  11731. selector
  11732. )
  11733. );
  11734. }
  11735. /// <summary>
  11736. /// 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.
  11737. /// </summary>
  11738. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11739. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11740. /// <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>
  11741. /// <param name="source">An observable sequence of elements to project.</param>
  11742. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11743. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11744. /// <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>
  11745. /// <exception cref="ArgumentNullException">
  11746. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11747. /// <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>
  11748. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, TTaskResult, TResult>> resultSelector)
  11749. {
  11750. if (source == null)
  11751. throw new ArgumentNullException(nameof(source));
  11752. if (taskSelector == null)
  11753. throw new ArgumentNullException(nameof(taskSelector));
  11754. if (resultSelector == null)
  11755. throw new ArgumentNullException(nameof(resultSelector));
  11756. return source.Provider.CreateQuery<TResult>(
  11757. Expression.Call(
  11758. null,
  11759. #if CRIPPLED_REFLECTION
  11760. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11761. #else
  11762. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11763. #endif
  11764. source.Expression,
  11765. taskSelector,
  11766. resultSelector
  11767. )
  11768. );
  11769. }
  11770. /// <summary>
  11771. /// 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.
  11772. /// </summary>
  11773. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11774. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11775. /// <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>
  11776. /// <param name="source">An observable sequence of elements to project.</param>
  11777. /// <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>
  11778. /// <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>
  11779. /// <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>
  11780. /// <exception cref="ArgumentNullException">
  11781. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11782. /// <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>
  11783. 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)
  11784. {
  11785. if (source == null)
  11786. throw new ArgumentNullException(nameof(source));
  11787. if (taskSelector == null)
  11788. throw new ArgumentNullException(nameof(taskSelector));
  11789. if (resultSelector == null)
  11790. throw new ArgumentNullException(nameof(resultSelector));
  11791. return source.Provider.CreateQuery<TResult>(
  11792. Expression.Call(
  11793. null,
  11794. #if CRIPPLED_REFLECTION
  11795. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11796. #else
  11797. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11798. #endif
  11799. source.Expression,
  11800. taskSelector,
  11801. resultSelector
  11802. )
  11803. );
  11804. }
  11805. /// <summary>
  11806. /// 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.
  11807. /// </summary>
  11808. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11809. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11810. /// <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>
  11811. /// <param name="source">An observable sequence of elements to project.</param>
  11812. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11813. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11814. /// <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>
  11815. /// <exception cref="ArgumentNullException">
  11816. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11817. /// <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>
  11818. 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)
  11819. {
  11820. if (source == null)
  11821. throw new ArgumentNullException(nameof(source));
  11822. if (taskSelector == null)
  11823. throw new ArgumentNullException(nameof(taskSelector));
  11824. if (resultSelector == null)
  11825. throw new ArgumentNullException(nameof(resultSelector));
  11826. return source.Provider.CreateQuery<TResult>(
  11827. Expression.Call(
  11828. null,
  11829. #if CRIPPLED_REFLECTION
  11830. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11831. #else
  11832. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11833. #endif
  11834. source.Expression,
  11835. taskSelector,
  11836. resultSelector
  11837. )
  11838. );
  11839. }
  11840. /// <summary>
  11841. /// 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.
  11842. /// </summary>
  11843. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11844. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11845. /// <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>
  11846. /// <param name="source">An observable sequence of elements to project.</param>
  11847. /// <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>
  11848. /// <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>
  11849. /// <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>
  11850. /// <exception cref="ArgumentNullException">
  11851. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11852. /// <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>
  11853. 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)
  11854. {
  11855. if (source == null)
  11856. throw new ArgumentNullException(nameof(source));
  11857. if (taskSelector == null)
  11858. throw new ArgumentNullException(nameof(taskSelector));
  11859. if (resultSelector == null)
  11860. throw new ArgumentNullException(nameof(resultSelector));
  11861. return source.Provider.CreateQuery<TResult>(
  11862. Expression.Call(
  11863. null,
  11864. #if CRIPPLED_REFLECTION
  11865. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11866. #else
  11867. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11868. #endif
  11869. source.Expression,
  11870. taskSelector,
  11871. resultSelector
  11872. )
  11873. );
  11874. }
  11875. /// <summary>
  11876. /// Determines whether two sequences are equal by comparing the elements pairwise.
  11877. /// </summary>
  11878. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11879. /// <param name="first">First observable sequence to compare.</param>
  11880. /// <param name="second">Second observable sequence to compare.</param>
  11881. /// <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>
  11882. /// <exception cref="ArgumentNullException">
  11883. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11884. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11885. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  11886. {
  11887. if (first == null)
  11888. throw new ArgumentNullException(nameof(first));
  11889. if (second == null)
  11890. throw new ArgumentNullException(nameof(second));
  11891. return first.Provider.CreateQuery<bool>(
  11892. Expression.Call(
  11893. null,
  11894. #if CRIPPLED_REFLECTION
  11895. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  11896. #else
  11897. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11898. #endif
  11899. first.Expression,
  11900. GetSourceExpression(second)
  11901. )
  11902. );
  11903. }
  11904. /// <summary>
  11905. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise.
  11906. /// </summary>
  11907. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11908. /// <param name="first">First observable sequence to compare.</param>
  11909. /// <param name="second">Second observable sequence to compare.</param>
  11910. /// <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>
  11911. /// <exception cref="ArgumentNullException">
  11912. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11913. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11914. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second)
  11915. {
  11916. if (first == null)
  11917. throw new ArgumentNullException(nameof(first));
  11918. if (second == null)
  11919. throw new ArgumentNullException(nameof(second));
  11920. return first.Provider.CreateQuery<bool>(
  11921. Expression.Call(
  11922. null,
  11923. #if CRIPPLED_REFLECTION
  11924. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  11925. #else
  11926. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11927. #endif
  11928. first.Expression,
  11929. GetSourceExpression(second)
  11930. )
  11931. );
  11932. }
  11933. /// <summary>
  11934. /// Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
  11935. /// </summary>
  11936. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11937. /// <param name="first">First observable sequence to compare.</param>
  11938. /// <param name="second">Second observable sequence to compare.</param>
  11939. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11940. /// <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>
  11941. /// <exception cref="ArgumentNullException">
  11942. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11943. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11944. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IEqualityComparer<TSource> comparer)
  11945. {
  11946. if (first == null)
  11947. throw new ArgumentNullException(nameof(first));
  11948. if (second == null)
  11949. throw new ArgumentNullException(nameof(second));
  11950. if (comparer == null)
  11951. throw new ArgumentNullException(nameof(comparer));
  11952. return first.Provider.CreateQuery<bool>(
  11953. Expression.Call(
  11954. null,
  11955. #if CRIPPLED_REFLECTION
  11956. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IEqualityComparer<TSource>))),
  11957. #else
  11958. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11959. #endif
  11960. first.Expression,
  11961. GetSourceExpression(second),
  11962. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11963. )
  11964. );
  11965. }
  11966. /// <summary>
  11967. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise using a specified equality comparer.
  11968. /// </summary>
  11969. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11970. /// <param name="first">First observable sequence to compare.</param>
  11971. /// <param name="second">Second observable sequence to compare.</param>
  11972. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11973. /// <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>
  11974. /// <exception cref="ArgumentNullException">
  11975. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11976. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11977. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  11978. {
  11979. if (first == null)
  11980. throw new ArgumentNullException(nameof(first));
  11981. if (second == null)
  11982. throw new ArgumentNullException(nameof(second));
  11983. if (comparer == null)
  11984. throw new ArgumentNullException(nameof(comparer));
  11985. return first.Provider.CreateQuery<bool>(
  11986. Expression.Call(
  11987. null,
  11988. #if CRIPPLED_REFLECTION
  11989. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>), default(IEqualityComparer<TSource>))),
  11990. #else
  11991. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11992. #endif
  11993. first.Expression,
  11994. GetSourceExpression(second),
  11995. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11996. )
  11997. );
  11998. }
  11999. /// <summary>
  12000. /// Returns the only element of an observable sequence, and reports an exception if there is not exactly one element in the observable sequence.
  12001. /// </summary>
  12002. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12003. /// <param name="source">Source observable sequence.</param>
  12004. /// <returns>Sequence containing the single element in the observable sequence.</returns>
  12005. /// <exception cref="ArgumentNullException">
  12006. /// <paramref name="source" /> is null.</exception>
  12007. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence contains more than one element. -or- The source sequence is empty.</exception>
  12008. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source)
  12009. {
  12010. if (source == null)
  12011. throw new ArgumentNullException(nameof(source));
  12012. return source.Provider.CreateQuery<TSource>(
  12013. Expression.Call(
  12014. null,
  12015. #if CRIPPLED_REFLECTION
  12016. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>))),
  12017. #else
  12018. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12019. #endif
  12020. source.Expression
  12021. )
  12022. );
  12023. }
  12024. /// <summary>
  12025. /// 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.
  12026. /// </summary>
  12027. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12028. /// <param name="source">Source observable sequence.</param>
  12029. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  12030. /// <returns>Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.</returns>
  12031. /// <exception cref="ArgumentNullException">
  12032. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12033. /// <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>
  12034. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12035. {
  12036. if (source == null)
  12037. throw new ArgumentNullException(nameof(source));
  12038. if (predicate == null)
  12039. throw new ArgumentNullException(nameof(predicate));
  12040. return source.Provider.CreateQuery<TSource>(
  12041. Expression.Call(
  12042. null,
  12043. #if CRIPPLED_REFLECTION
  12044. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12045. #else
  12046. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12047. #endif
  12048. source.Expression,
  12049. predicate
  12050. )
  12051. );
  12052. }
  12053. /// <summary>
  12054. /// 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.
  12055. /// </summary>
  12056. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12057. /// <param name="source">Source observable sequence.</param>
  12058. /// <returns>Sequence containing the single element in the observable sequence, or a default value if no such element exists.</returns>
  12059. /// <exception cref="ArgumentNullException">
  12060. /// <paramref name="source" /> is null.</exception>
  12061. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence contains more than one element.</exception>
  12062. public static IQbservable<TSource?> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  12063. {
  12064. if (source == null)
  12065. throw new ArgumentNullException(nameof(source));
  12066. return source.Provider.CreateQuery<TSource>(
  12067. Expression.Call(
  12068. null,
  12069. #if CRIPPLED_REFLECTION
  12070. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  12071. #else
  12072. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12073. #endif
  12074. source.Expression
  12075. )
  12076. );
  12077. }
  12078. /// <summary>
  12079. /// 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.
  12080. /// </summary>
  12081. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12082. /// <param name="source">Source observable sequence.</param>
  12083. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  12084. /// <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>
  12085. /// <exception cref="ArgumentNullException">
  12086. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12087. /// <exception cref="InvalidOperationException">(Asynchronous) The sequence contains more than one element that satisfies the condition in the predicate.</exception>
  12088. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12089. {
  12090. if (source == null)
  12091. throw new ArgumentNullException(nameof(source));
  12092. if (predicate == null)
  12093. throw new ArgumentNullException(nameof(predicate));
  12094. return source.Provider.CreateQuery<TSource>(
  12095. Expression.Call(
  12096. null,
  12097. #if CRIPPLED_REFLECTION
  12098. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12099. #else
  12100. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12101. #endif
  12102. source.Expression,
  12103. predicate
  12104. )
  12105. );
  12106. }
  12107. /// <summary>
  12108. /// Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
  12109. /// </summary>
  12110. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12111. /// <param name="source">The sequence to take elements from.</param>
  12112. /// <param name="count">The number of elements to skip before returning the remaining elements.</param>
  12113. /// <returns>An observable sequence that contains the elements that occur after the specified index in the input sequence.</returns>
  12114. /// <exception cref="ArgumentNullException">
  12115. /// <paramref name="source" /> is null.</exception>
  12116. /// <exception cref="ArgumentOutOfRangeException">
  12117. /// <paramref name="count" /> is less than zero.</exception>
  12118. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, int count)
  12119. {
  12120. if (source == null)
  12121. throw new ArgumentNullException(nameof(source));
  12122. return source.Provider.CreateQuery<TSource>(
  12123. Expression.Call(
  12124. null,
  12125. #if CRIPPLED_REFLECTION
  12126. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(int))),
  12127. #else
  12128. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12129. #endif
  12130. source.Expression,
  12131. Expression.Constant(count, typeof(int))
  12132. )
  12133. );
  12134. }
  12135. /// <summary>
  12136. /// Skips elements for the specified duration from the start of the observable source sequence.
  12137. /// </summary>
  12138. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12139. /// <param name="source">Source sequence to skip elements for.</param>
  12140. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12141. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12142. /// <exception cref="ArgumentNullException">
  12143. /// <paramref name="source" /> is null.</exception>
  12144. /// <exception cref="ArgumentOutOfRangeException">
  12145. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12146. /// <remarks>
  12147. /// <para>
  12148. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12149. /// 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
  12150. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12151. /// </para>
  12152. /// <para>
  12153. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12154. /// </para>
  12155. /// </remarks>
  12156. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12157. {
  12158. if (source == null)
  12159. throw new ArgumentNullException(nameof(source));
  12160. return source.Provider.CreateQuery<TSource>(
  12161. Expression.Call(
  12162. null,
  12163. #if CRIPPLED_REFLECTION
  12164. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12165. #else
  12166. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12167. #endif
  12168. source.Expression,
  12169. Expression.Constant(duration, typeof(TimeSpan))
  12170. )
  12171. );
  12172. }
  12173. /// <summary>
  12174. /// Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  12175. /// </summary>
  12176. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12177. /// <param name="source">Source sequence to skip elements for.</param>
  12178. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  12179. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12180. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  12181. /// <exception cref="ArgumentNullException">
  12182. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12183. /// <exception cref="ArgumentOutOfRangeException">
  12184. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12185. /// <remarks>
  12186. /// <para>
  12187. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  12188. /// 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
  12189. /// may not execute immediately, despite the TimeSpan.Zero due time.
  12190. /// </para>
  12191. /// <para>
  12192. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  12193. /// </para>
  12194. /// </remarks>
  12195. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  12196. {
  12197. if (source == null)
  12198. throw new ArgumentNullException(nameof(source));
  12199. if (scheduler == null)
  12200. throw new ArgumentNullException(nameof(scheduler));
  12201. return source.Provider.CreateQuery<TSource>(
  12202. Expression.Call(
  12203. null,
  12204. #if CRIPPLED_REFLECTION
  12205. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12206. #else
  12207. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12208. #endif
  12209. source.Expression,
  12210. Expression.Constant(duration, typeof(TimeSpan)),
  12211. Expression.Constant(scheduler, typeof(IScheduler))
  12212. )
  12213. );
  12214. }
  12215. /// <summary>
  12216. /// Bypasses a specified number of elements at the end of an observable sequence.
  12217. /// </summary>
  12218. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12219. /// <param name="source">Source sequence.</param>
  12220. /// <param name="count">Number of elements to bypass at the end of the source sequence.</param>
  12221. /// <returns>An observable sequence containing the source sequence elements except for the bypassed ones at the end.</returns>
  12222. /// <exception cref="ArgumentNullException">
  12223. /// <paramref name="source" /> is null.</exception>
  12224. /// <exception cref="ArgumentOutOfRangeException">
  12225. /// <paramref name="count" /> is less than zero.</exception>
  12226. /// <remarks>
  12227. /// This operator accumulates a queue with a length enough to store the first <paramref name="count" /> elements. As more elements are
  12228. /// received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
  12229. /// </remarks>
  12230. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, int count)
  12231. {
  12232. if (source == null)
  12233. throw new ArgumentNullException(nameof(source));
  12234. return source.Provider.CreateQuery<TSource>(
  12235. Expression.Call(
  12236. null,
  12237. #if CRIPPLED_REFLECTION
  12238. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(int))),
  12239. #else
  12240. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12241. #endif
  12242. source.Expression,
  12243. Expression.Constant(count, typeof(int))
  12244. )
  12245. );
  12246. }
  12247. /// <summary>
  12248. /// Skips elements for the specified duration from the end of the observable source sequence.
  12249. /// </summary>
  12250. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12251. /// <param name="source">Source sequence to skip elements for.</param>
  12252. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12253. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12254. /// <exception cref="ArgumentNullException">
  12255. /// <paramref name="source" /> is null.</exception>
  12256. /// <exception cref="ArgumentOutOfRangeException">
  12257. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12258. /// <remarks>
  12259. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12260. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12261. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12262. /// </remarks>
  12263. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  12264. {
  12265. if (source == null)
  12266. throw new ArgumentNullException(nameof(source));
  12267. return source.Provider.CreateQuery<TSource>(
  12268. Expression.Call(
  12269. null,
  12270. #if CRIPPLED_REFLECTION
  12271. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  12272. #else
  12273. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12274. #endif
  12275. source.Expression,
  12276. Expression.Constant(duration, typeof(TimeSpan))
  12277. )
  12278. );
  12279. }
  12280. /// <summary>
  12281. /// Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  12282. /// </summary>
  12283. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12284. /// <param name="source">Source sequence to skip elements for.</param>
  12285. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  12286. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12287. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  12288. /// <exception cref="ArgumentNullException">
  12289. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12290. /// <exception cref="ArgumentOutOfRangeException">
  12291. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  12292. /// <remarks>
  12293. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  12294. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  12295. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  12296. /// </remarks>
  12297. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  12298. {
  12299. if (source == null)
  12300. throw new ArgumentNullException(nameof(source));
  12301. if (scheduler == null)
  12302. throw new ArgumentNullException(nameof(scheduler));
  12303. return source.Provider.CreateQuery<TSource>(
  12304. Expression.Call(
  12305. null,
  12306. #if CRIPPLED_REFLECTION
  12307. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  12308. #else
  12309. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12310. #endif
  12311. source.Expression,
  12312. Expression.Constant(duration, typeof(TimeSpan)),
  12313. Expression.Constant(scheduler, typeof(IScheduler))
  12314. )
  12315. );
  12316. }
  12317. /// <summary>
  12318. /// Skips elements from the observable source sequence until the specified start time.
  12319. /// </summary>
  12320. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12321. /// <param name="source">Source sequence to skip elements for.</param>
  12322. /// <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>
  12323. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12324. /// <exception cref="ArgumentNullException">
  12325. /// <paramref name="source" /> is null.</exception>
  12326. /// <remarks>
  12327. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12328. /// </remarks>
  12329. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime)
  12330. {
  12331. if (source == null)
  12332. throw new ArgumentNullException(nameof(source));
  12333. return source.Provider.CreateQuery<TSource>(
  12334. Expression.Call(
  12335. null,
  12336. #if CRIPPLED_REFLECTION
  12337. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  12338. #else
  12339. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12340. #endif
  12341. source.Expression,
  12342. Expression.Constant(startTime, typeof(DateTimeOffset))
  12343. )
  12344. );
  12345. }
  12346. /// <summary>
  12347. /// Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  12348. /// </summary>
  12349. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12350. /// <param name="source">Source sequence to skip elements for.</param>
  12351. /// <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>
  12352. /// <param name="scheduler">Scheduler to run the timer on.</param>
  12353. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  12354. /// <exception cref="ArgumentNullException">
  12355. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12356. /// <remarks>
  12357. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  12358. /// </remarks>
  12359. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime, IScheduler scheduler)
  12360. {
  12361. if (source == null)
  12362. throw new ArgumentNullException(nameof(source));
  12363. if (scheduler == null)
  12364. throw new ArgumentNullException(nameof(scheduler));
  12365. return source.Provider.CreateQuery<TSource>(
  12366. Expression.Call(
  12367. null,
  12368. #if CRIPPLED_REFLECTION
  12369. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  12370. #else
  12371. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12372. #endif
  12373. source.Expression,
  12374. Expression.Constant(startTime, typeof(DateTimeOffset)),
  12375. Expression.Constant(scheduler, typeof(IScheduler))
  12376. )
  12377. );
  12378. }
  12379. /// <summary>
  12380. /// Returns the elements from the source observable sequence only after the other observable sequence produces an element.
  12381. /// Starting from Rx.NET 4.0, this will subscribe to <paramref name="other" /> before subscribing to <paramref name="source" />
  12382. /// so in case <paramref name="other" /> emits an element right away, elements from <paramref name="source" /> are not missed.
  12383. /// </summary>
  12384. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12385. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of skip behavior.</typeparam>
  12386. /// <param name="source">Source sequence to propagate elements for.</param>
  12387. /// <param name="other">Observable sequence that triggers propagation of elements of the source sequence.</param>
  12388. /// <returns>An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.</returns>
  12389. /// <exception cref="ArgumentNullException">
  12390. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  12391. public static IQbservable<TSource> SkipUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  12392. {
  12393. if (source == null)
  12394. throw new ArgumentNullException(nameof(source));
  12395. if (other == null)
  12396. throw new ArgumentNullException(nameof(other));
  12397. return source.Provider.CreateQuery<TSource>(
  12398. Expression.Call(
  12399. null,
  12400. #if CRIPPLED_REFLECTION
  12401. InfoOf(() => Qbservable.SkipUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  12402. #else
  12403. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  12404. #endif
  12405. source.Expression,
  12406. GetSourceExpression(other)
  12407. )
  12408. );
  12409. }
  12410. /// <summary>
  12411. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12412. /// </summary>
  12413. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12414. /// <param name="source">An observable sequence to return elements from.</param>
  12415. /// <param name="predicate">A function to test each element for a condition.</param>
  12416. /// <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>
  12417. /// <exception cref="ArgumentNullException">
  12418. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12419. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12420. {
  12421. if (source == null)
  12422. throw new ArgumentNullException(nameof(source));
  12423. if (predicate == null)
  12424. throw new ArgumentNullException(nameof(predicate));
  12425. return source.Provider.CreateQuery<TSource>(
  12426. Expression.Call(
  12427. null,
  12428. #if CRIPPLED_REFLECTION
  12429. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12430. #else
  12431. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12432. #endif
  12433. source.Expression,
  12434. predicate
  12435. )
  12436. );
  12437. }
  12438. /// <summary>
  12439. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12440. /// The element's index is used in the logic of the predicate function.
  12441. /// </summary>
  12442. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12443. /// <param name="source">An observable sequence to return elements from.</param>
  12444. /// <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>
  12445. /// <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>
  12446. /// <exception cref="ArgumentNullException">
  12447. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12448. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  12449. {
  12450. if (source == null)
  12451. throw new ArgumentNullException(nameof(source));
  12452. if (predicate == null)
  12453. throw new ArgumentNullException(nameof(predicate));
  12454. return source.Provider.CreateQuery<TSource>(
  12455. Expression.Call(
  12456. null,
  12457. #if CRIPPLED_REFLECTION
  12458. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  12459. #else
  12460. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12461. #endif
  12462. source.Expression,
  12463. predicate
  12464. )
  12465. );
  12466. }
  12467. /// <summary>
  12468. /// Invokes the action asynchronously, surfacing the result through an observable sequence.
  12469. /// </summary>
  12470. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12471. /// <param name="action">Action to run asynchronously.</param>
  12472. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12473. /// <exception cref="ArgumentNullException">
  12474. /// <paramref name="action" /> is null.</exception>
  12475. /// <remarks>
  12476. /// <list type="bullet">
  12477. /// <item>
  12478. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12479. /// </item>
  12480. /// <item>
  12481. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12482. /// </item>
  12483. /// </list>
  12484. /// </remarks>
  12485. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action)
  12486. {
  12487. if (provider == null)
  12488. throw new ArgumentNullException(nameof(provider));
  12489. if (action == null)
  12490. throw new ArgumentNullException(nameof(action));
  12491. return provider.CreateQuery<Unit>(
  12492. Expression.Call(
  12493. null,
  12494. #if CRIPPLED_REFLECTION
  12495. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>))),
  12496. #else
  12497. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12498. #endif
  12499. Expression.Constant(provider, typeof(IQbservableProvider)),
  12500. action
  12501. )
  12502. );
  12503. }
  12504. /// <summary>
  12505. /// Invokes the action asynchronously on the specified scheduler, surfacing the result through an observable sequence.
  12506. /// </summary>
  12507. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12508. /// <param name="action">Action to run asynchronously.</param>
  12509. /// <param name="scheduler">Scheduler to run the action on.</param>
  12510. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12511. /// <exception cref="ArgumentNullException">
  12512. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  12513. /// <remarks>
  12514. /// <list type="bullet">
  12515. /// <item>
  12516. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12517. /// </item>
  12518. /// <item>
  12519. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12520. /// </item>
  12521. /// </list>
  12522. /// </remarks>
  12523. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  12524. {
  12525. if (provider == null)
  12526. throw new ArgumentNullException(nameof(provider));
  12527. if (action == null)
  12528. throw new ArgumentNullException(nameof(action));
  12529. if (scheduler == null)
  12530. throw new ArgumentNullException(nameof(scheduler));
  12531. return provider.CreateQuery<Unit>(
  12532. Expression.Call(
  12533. null,
  12534. #if CRIPPLED_REFLECTION
  12535. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>), default(IScheduler))),
  12536. #else
  12537. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12538. #endif
  12539. Expression.Constant(provider, typeof(IQbservableProvider)),
  12540. action,
  12541. Expression.Constant(scheduler, typeof(IScheduler))
  12542. )
  12543. );
  12544. }
  12545. /// <summary>
  12546. /// Invokes the specified function asynchronously, surfacing the result through an observable sequence.
  12547. /// </summary>
  12548. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12549. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12550. /// <param name="function">Function to run asynchronously.</param>
  12551. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12552. /// <exception cref="ArgumentNullException">
  12553. /// <paramref name="function" /> is null.</exception>
  12554. /// <remarks>
  12555. /// <list type="bullet">
  12556. /// <item>
  12557. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12558. /// </item>
  12559. /// <item>
  12560. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12561. /// </item>
  12562. /// </list>
  12563. /// </remarks>
  12564. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  12565. {
  12566. if (provider == null)
  12567. throw new ArgumentNullException(nameof(provider));
  12568. if (function == null)
  12569. throw new ArgumentNullException(nameof(function));
  12570. return provider.CreateQuery<TResult>(
  12571. Expression.Call(
  12572. null,
  12573. #if CRIPPLED_REFLECTION
  12574. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>))),
  12575. #else
  12576. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12577. #endif
  12578. Expression.Constant(provider, typeof(IQbservableProvider)),
  12579. function
  12580. )
  12581. );
  12582. }
  12583. /// <summary>
  12584. /// Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence
  12585. /// </summary>
  12586. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12587. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12588. /// <param name="function">Function to run asynchronously.</param>
  12589. /// <param name="scheduler">Scheduler to run the function on.</param>
  12590. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12591. /// <exception cref="ArgumentNullException">
  12592. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  12593. /// <remarks>
  12594. /// <list type="bullet">
  12595. /// <item>
  12596. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12597. /// </item>
  12598. /// <item>
  12599. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12600. /// </item>
  12601. /// </list>
  12602. /// </remarks>
  12603. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  12604. {
  12605. if (provider == null)
  12606. throw new ArgumentNullException(nameof(provider));
  12607. if (function == null)
  12608. throw new ArgumentNullException(nameof(function));
  12609. if (scheduler == null)
  12610. throw new ArgumentNullException(nameof(scheduler));
  12611. return provider.CreateQuery<TResult>(
  12612. Expression.Call(
  12613. null,
  12614. #if CRIPPLED_REFLECTION
  12615. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler))),
  12616. #else
  12617. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12618. #endif
  12619. Expression.Constant(provider, typeof(IQbservableProvider)),
  12620. function,
  12621. Expression.Constant(scheduler, typeof(IScheduler))
  12622. )
  12623. );
  12624. }
  12625. /// <summary>
  12626. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12627. /// </summary>
  12628. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12629. /// <param name="actionAsync">Asynchronous action to run.</param>
  12630. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12631. /// <exception cref="ArgumentNullException">
  12632. /// <paramref name="actionAsync" /> is null.</exception>
  12633. /// <remarks>
  12634. /// <list type="bullet">
  12635. /// <item>
  12636. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12637. /// </item>
  12638. /// <item>
  12639. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12640. /// </item>
  12641. /// </list>
  12642. /// </remarks>
  12643. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  12644. {
  12645. if (provider == null)
  12646. throw new ArgumentNullException(nameof(provider));
  12647. if (actionAsync == null)
  12648. throw new ArgumentNullException(nameof(actionAsync));
  12649. return provider.CreateQuery<Unit>(
  12650. Expression.Call(
  12651. null,
  12652. #if CRIPPLED_REFLECTION
  12653. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  12654. #else
  12655. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12656. #endif
  12657. Expression.Constant(provider, typeof(IQbservableProvider)),
  12658. actionAsync
  12659. )
  12660. );
  12661. }
  12662. /// <summary>
  12663. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12664. /// </summary>
  12665. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12666. /// <param name="actionAsync">Asynchronous action to run.</param>
  12667. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12668. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12669. /// <exception cref="ArgumentNullException">
  12670. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12671. /// <remarks>
  12672. /// <list type="bullet">
  12673. /// <item>
  12674. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12675. /// </item>
  12676. /// <item>
  12677. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12678. /// </item>
  12679. /// </list>
  12680. /// </remarks>
  12681. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync, IScheduler scheduler)
  12682. {
  12683. if (provider == null)
  12684. throw new ArgumentNullException(nameof(provider));
  12685. if (actionAsync == null)
  12686. throw new ArgumentNullException(nameof(actionAsync));
  12687. if (scheduler == null)
  12688. throw new ArgumentNullException(nameof(scheduler));
  12689. return provider.CreateQuery<Unit>(
  12690. Expression.Call(
  12691. null,
  12692. #if CRIPPLED_REFLECTION
  12693. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>), default(IScheduler))),
  12694. #else
  12695. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12696. #endif
  12697. Expression.Constant(provider, typeof(IQbservableProvider)),
  12698. actionAsync,
  12699. Expression.Constant(scheduler, typeof(IScheduler))
  12700. )
  12701. );
  12702. }
  12703. /// <summary>
  12704. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12705. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12706. /// </summary>
  12707. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12708. /// <param name="actionAsync">Asynchronous action to run.</param>
  12709. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12710. /// <exception cref="ArgumentNullException">
  12711. /// <paramref name="actionAsync" /> is null.</exception>
  12712. /// <remarks>
  12713. /// <list type="bullet">
  12714. /// <item>
  12715. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12716. /// </item>
  12717. /// <item>
  12718. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12719. /// </item>
  12720. /// <item>
  12721. /// <description>
  12722. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12723. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12724. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12725. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12726. /// multicast operators.
  12727. /// </description>
  12728. /// </item>
  12729. /// </list>
  12730. /// </remarks>
  12731. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  12732. {
  12733. if (provider == null)
  12734. throw new ArgumentNullException(nameof(provider));
  12735. if (actionAsync == null)
  12736. throw new ArgumentNullException(nameof(actionAsync));
  12737. return provider.CreateQuery<Unit>(
  12738. Expression.Call(
  12739. null,
  12740. #if CRIPPLED_REFLECTION
  12741. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  12742. #else
  12743. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12744. #endif
  12745. Expression.Constant(provider, typeof(IQbservableProvider)),
  12746. actionAsync
  12747. )
  12748. );
  12749. }
  12750. /// <summary>
  12751. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12752. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12753. /// </summary>
  12754. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12755. /// <param name="actionAsync">Asynchronous action to run.</param>
  12756. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12757. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12758. /// <exception cref="ArgumentNullException">
  12759. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12760. /// <remarks>
  12761. /// <list type="bullet">
  12762. /// <item>
  12763. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12764. /// </item>
  12765. /// <item>
  12766. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12767. /// </item>
  12768. /// <item>
  12769. /// <description>
  12770. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12771. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12772. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12773. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12774. /// multicast operators.
  12775. /// </description>
  12776. /// </item>
  12777. /// </list>
  12778. /// </remarks>
  12779. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync, IScheduler scheduler)
  12780. {
  12781. if (provider == null)
  12782. throw new ArgumentNullException(nameof(provider));
  12783. if (actionAsync == null)
  12784. throw new ArgumentNullException(nameof(actionAsync));
  12785. if (scheduler == null)
  12786. throw new ArgumentNullException(nameof(scheduler));
  12787. return provider.CreateQuery<Unit>(
  12788. Expression.Call(
  12789. null,
  12790. #if CRIPPLED_REFLECTION
  12791. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>), default(IScheduler))),
  12792. #else
  12793. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12794. #endif
  12795. Expression.Constant(provider, typeof(IQbservableProvider)),
  12796. actionAsync,
  12797. Expression.Constant(scheduler, typeof(IScheduler))
  12798. )
  12799. );
  12800. }
  12801. /// <summary>
  12802. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12803. /// </summary>
  12804. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12805. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12806. /// <param name="functionAsync">Asynchronous function to run.</param>
  12807. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12808. /// <exception cref="ArgumentNullException">
  12809. /// <paramref name="functionAsync" /> is null.</exception>
  12810. /// <remarks>
  12811. /// <list type="bullet">
  12812. /// <item>
  12813. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12814. /// </item>
  12815. /// <item>
  12816. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12817. /// </item>
  12818. /// </list>
  12819. /// </remarks>
  12820. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  12821. {
  12822. if (provider == null)
  12823. throw new ArgumentNullException(nameof(provider));
  12824. if (functionAsync == null)
  12825. throw new ArgumentNullException(nameof(functionAsync));
  12826. return provider.CreateQuery<TResult>(
  12827. Expression.Call(
  12828. null,
  12829. #if CRIPPLED_REFLECTION
  12830. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  12831. #else
  12832. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12833. #endif
  12834. Expression.Constant(provider, typeof(IQbservableProvider)),
  12835. functionAsync
  12836. )
  12837. );
  12838. }
  12839. /// <summary>
  12840. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12841. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12842. /// </summary>
  12843. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12844. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12845. /// <param name="functionAsync">Asynchronous function to run.</param>
  12846. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12847. /// <exception cref="ArgumentNullException">
  12848. /// <paramref name="functionAsync" /> is null.</exception>
  12849. /// <remarks>
  12850. /// <list type="bullet">
  12851. /// <item>
  12852. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12853. /// </item>
  12854. /// <item>
  12855. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12856. /// </item>
  12857. /// <item>
  12858. /// <description>
  12859. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12860. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12861. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12862. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12863. /// multicast operators.
  12864. /// </description>
  12865. /// </item>
  12866. /// </list>
  12867. /// </remarks>
  12868. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  12869. {
  12870. if (provider == null)
  12871. throw new ArgumentNullException(nameof(provider));
  12872. if (functionAsync == null)
  12873. throw new ArgumentNullException(nameof(functionAsync));
  12874. return provider.CreateQuery<TResult>(
  12875. Expression.Call(
  12876. null,
  12877. #if CRIPPLED_REFLECTION
  12878. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  12879. #else
  12880. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12881. #endif
  12882. Expression.Constant(provider, typeof(IQbservableProvider)),
  12883. functionAsync
  12884. )
  12885. );
  12886. }
  12887. /// <summary>
  12888. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12889. /// </summary>
  12890. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12891. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12892. /// <param name="functionAsync">Asynchronous function to run.</param>
  12893. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12894. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12895. /// <exception cref="ArgumentNullException">
  12896. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12897. /// <remarks>
  12898. /// <list type="bullet">
  12899. /// <item>
  12900. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12901. /// </item>
  12902. /// <item>
  12903. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12904. /// </item>
  12905. /// </list>
  12906. /// </remarks>
  12907. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync, IScheduler scheduler)
  12908. {
  12909. if (provider == null)
  12910. throw new ArgumentNullException(nameof(provider));
  12911. if (functionAsync == null)
  12912. throw new ArgumentNullException(nameof(functionAsync));
  12913. if (scheduler == null)
  12914. throw new ArgumentNullException(nameof(scheduler));
  12915. return provider.CreateQuery<TResult>(
  12916. Expression.Call(
  12917. null,
  12918. #if CRIPPLED_REFLECTION
  12919. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>), default(IScheduler))),
  12920. #else
  12921. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12922. #endif
  12923. Expression.Constant(provider, typeof(IQbservableProvider)),
  12924. functionAsync,
  12925. Expression.Constant(scheduler, typeof(IScheduler))
  12926. )
  12927. );
  12928. }
  12929. /// <summary>
  12930. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12931. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12932. /// </summary>
  12933. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12934. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12935. /// <param name="functionAsync">Asynchronous function to run.</param>
  12936. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12937. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12938. /// <exception cref="ArgumentNullException">
  12939. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12940. /// <remarks>
  12941. /// <list type="bullet">
  12942. /// <item>
  12943. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12944. /// </item>
  12945. /// <item>
  12946. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12947. /// </item>
  12948. /// <item>
  12949. /// <description>
  12950. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12951. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12952. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12953. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12954. /// multicast operators.
  12955. /// </description>
  12956. /// </item>
  12957. /// </list>
  12958. /// </remarks>
  12959. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync, IScheduler scheduler)
  12960. {
  12961. if (provider == null)
  12962. throw new ArgumentNullException(nameof(provider));
  12963. if (functionAsync == null)
  12964. throw new ArgumentNullException(nameof(functionAsync));
  12965. if (scheduler == null)
  12966. throw new ArgumentNullException(nameof(scheduler));
  12967. return provider.CreateQuery<TResult>(
  12968. Expression.Call(
  12969. null,
  12970. #if CRIPPLED_REFLECTION
  12971. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>), default(IScheduler))),
  12972. #else
  12973. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12974. #endif
  12975. Expression.Constant(provider, typeof(IQbservableProvider)),
  12976. functionAsync,
  12977. Expression.Constant(scheduler, typeof(IScheduler))
  12978. )
  12979. );
  12980. }
  12981. /// <summary>
  12982. /// Prepends a sequence of values to an observable sequence.
  12983. /// </summary>
  12984. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12985. /// <param name="source">Source sequence to prepend values to.</param>
  12986. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  12987. /// <param name="values">Values to prepend to the specified sequence.</param>
  12988. /// <returns>The source sequence prepended with the specified values.</returns>
  12989. /// <exception cref="ArgumentNullException">
  12990. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  12991. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, params TSource[] values)
  12992. {
  12993. if (source == null)
  12994. throw new ArgumentNullException(nameof(source));
  12995. if (scheduler == null)
  12996. throw new ArgumentNullException(nameof(scheduler));
  12997. if (values == null)
  12998. throw new ArgumentNullException(nameof(values));
  12999. return source.Provider.CreateQuery<TSource>(
  13000. Expression.Call(
  13001. null,
  13002. #if CRIPPLED_REFLECTION
  13003. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(TSource[]))),
  13004. #else
  13005. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13006. #endif
  13007. source.Expression,
  13008. Expression.Constant(scheduler, typeof(IScheduler)),
  13009. Expression.Constant(values, typeof(TSource[]))
  13010. )
  13011. );
  13012. }
  13013. /// <summary>
  13014. /// Prepends a sequence of values to an observable sequence.
  13015. /// </summary>
  13016. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13017. /// <param name="source">Source sequence to prepend values to.</param>
  13018. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  13019. /// <param name="values">Values to prepend to the specified sequence.</param>
  13020. /// <returns>The source sequence prepended with the specified values.</returns>
  13021. /// <exception cref="ArgumentNullException">
  13022. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  13023. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, IEnumerable<TSource> values)
  13024. {
  13025. if (source == null)
  13026. throw new ArgumentNullException(nameof(source));
  13027. if (scheduler == null)
  13028. throw new ArgumentNullException(nameof(scheduler));
  13029. if (values == null)
  13030. throw new ArgumentNullException(nameof(values));
  13031. return source.Provider.CreateQuery<TSource>(
  13032. Expression.Call(
  13033. null,
  13034. #if CRIPPLED_REFLECTION
  13035. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(IEnumerable<TSource>))),
  13036. #else
  13037. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13038. #endif
  13039. source.Expression,
  13040. Expression.Constant(scheduler, typeof(IScheduler)),
  13041. GetSourceExpression(values)
  13042. )
  13043. );
  13044. }
  13045. /// <summary>
  13046. /// Prepends a sequence of values to an observable sequence.
  13047. /// </summary>
  13048. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13049. /// <param name="source">Source sequence to prepend values to.</param>
  13050. /// <param name="values">Values to prepend to the specified sequence.</param>
  13051. /// <returns>The source sequence prepended with the specified values.</returns>
  13052. /// <exception cref="ArgumentNullException">
  13053. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  13054. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, params TSource[] values)
  13055. {
  13056. if (source == null)
  13057. throw new ArgumentNullException(nameof(source));
  13058. if (values == null)
  13059. throw new ArgumentNullException(nameof(values));
  13060. return source.Provider.CreateQuery<TSource>(
  13061. Expression.Call(
  13062. null,
  13063. #if CRIPPLED_REFLECTION
  13064. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(TSource[]))),
  13065. #else
  13066. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13067. #endif
  13068. source.Expression,
  13069. Expression.Constant(values, typeof(TSource[]))
  13070. )
  13071. );
  13072. }
  13073. /// <summary>
  13074. /// Prepends a sequence of values to an observable sequence.
  13075. /// </summary>
  13076. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13077. /// <param name="source">Source sequence to prepend values to.</param>
  13078. /// <param name="values">Values to prepend to the specified sequence.</param>
  13079. /// <returns>The source sequence prepended with the specified values.</returns>
  13080. /// <exception cref="ArgumentNullException">
  13081. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  13082. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IEnumerable<TSource> values)
  13083. {
  13084. if (source == null)
  13085. throw new ArgumentNullException(nameof(source));
  13086. if (values == null)
  13087. throw new ArgumentNullException(nameof(values));
  13088. return source.Provider.CreateQuery<TSource>(
  13089. Expression.Call(
  13090. null,
  13091. #if CRIPPLED_REFLECTION
  13092. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  13093. #else
  13094. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13095. #endif
  13096. source.Expression,
  13097. GetSourceExpression(values)
  13098. )
  13099. );
  13100. }
  13101. /// <summary>
  13102. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context. This operation is not commonly used;
  13103. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  13104. /// </summary>
  13105. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13106. /// <param name="source">Source sequence.</param>
  13107. /// <param name="context">Synchronization context to perform subscription and unsubscription actions on.</param>
  13108. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified synchronization context.</returns>
  13109. /// <exception cref="ArgumentNullException">
  13110. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  13111. /// <remarks>
  13112. /// This only performs the side-effects of subscription and unsubscription on the specified synchronization context. In order to invoke observer
  13113. /// callbacks on a synchronization context, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Threading.SynchronizationContext)" />.
  13114. /// </remarks>
  13115. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  13116. {
  13117. if (source == null)
  13118. throw new ArgumentNullException(nameof(source));
  13119. if (context == null)
  13120. throw new ArgumentNullException(nameof(context));
  13121. return source.Provider.CreateQuery<TSource>(
  13122. Expression.Call(
  13123. null,
  13124. #if CRIPPLED_REFLECTION
  13125. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  13126. #else
  13127. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13128. #endif
  13129. source.Expression,
  13130. Expression.Constant(context, typeof(SynchronizationContext))
  13131. )
  13132. );
  13133. }
  13134. /// <summary>
  13135. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
  13136. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  13137. /// </summary>
  13138. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13139. /// <param name="source">Source sequence.</param>
  13140. /// <param name="scheduler">Scheduler to perform subscription and unsubscription actions on.</param>
  13141. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.</returns>
  13142. /// <exception cref="ArgumentNullException">
  13143. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13144. /// <remarks>
  13145. /// This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
  13146. /// callbacks on a scheduler, use <see cref="M:System.Reactive.Linq.Observable.ObserveOn``1(System.IObservable{``0},System.Reactive.Concurrency.IScheduler)" />.
  13147. /// </remarks>
  13148. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  13149. {
  13150. if (source == null)
  13151. throw new ArgumentNullException(nameof(source));
  13152. if (scheduler == null)
  13153. throw new ArgumentNullException(nameof(scheduler));
  13154. return source.Provider.CreateQuery<TSource>(
  13155. Expression.Call(
  13156. null,
  13157. #if CRIPPLED_REFLECTION
  13158. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  13159. #else
  13160. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13161. #endif
  13162. source.Expression,
  13163. Expression.Constant(scheduler, typeof(IScheduler))
  13164. )
  13165. );
  13166. }
  13167. /// <summary>
  13168. /// Computes the sum of a sequence of <see cref="Decimal" /> values.
  13169. /// </summary>
  13170. /// <param name="source">A sequence of <see cref="Decimal" /> values to calculate the sum of.</param>
  13171. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13172. /// <exception cref="ArgumentNullException">
  13173. /// <paramref name="source" /> is null.</exception>
  13174. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  13175. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13176. public static IQbservable<decimal> Sum(this IQbservable<decimal> source)
  13177. {
  13178. if (source == null)
  13179. throw new ArgumentNullException(nameof(source));
  13180. return source.Provider.CreateQuery<decimal>(
  13181. Expression.Call(
  13182. null,
  13183. #if CRIPPLED_REFLECTION
  13184. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal>))),
  13185. #else
  13186. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13187. #endif
  13188. source.Expression
  13189. )
  13190. );
  13191. }
  13192. /// <summary>
  13193. /// Computes the sum of a sequence of <see cref="double" /> values.
  13194. /// </summary>
  13195. /// <param name="source">A sequence of <see cref="double" /> values to calculate the sum of.</param>
  13196. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13197. /// <exception cref="ArgumentNullException">
  13198. /// <paramref name="source" /> is null.</exception>
  13199. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13200. public static IQbservable<double> Sum(this IQbservable<double> source)
  13201. {
  13202. if (source == null)
  13203. throw new ArgumentNullException(nameof(source));
  13204. return source.Provider.CreateQuery<double>(
  13205. Expression.Call(
  13206. null,
  13207. #if CRIPPLED_REFLECTION
  13208. InfoOf(() => Qbservable.Sum(default(IQbservable<double>))),
  13209. #else
  13210. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13211. #endif
  13212. source.Expression
  13213. )
  13214. );
  13215. }
  13216. /// <summary>
  13217. /// Computes the sum of a sequence of <see cref="int" /> values.
  13218. /// </summary>
  13219. /// <param name="source">A sequence of <see cref="int" /> values to calculate the sum of.</param>
  13220. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13221. /// <exception cref="ArgumentNullException">
  13222. /// <paramref name="source" /> is null.</exception>
  13223. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
  13224. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13225. public static IQbservable<int> Sum(this IQbservable<int> source)
  13226. {
  13227. if (source == null)
  13228. throw new ArgumentNullException(nameof(source));
  13229. return source.Provider.CreateQuery<int>(
  13230. Expression.Call(
  13231. null,
  13232. #if CRIPPLED_REFLECTION
  13233. InfoOf(() => Qbservable.Sum(default(IQbservable<int>))),
  13234. #else
  13235. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13236. #endif
  13237. source.Expression
  13238. )
  13239. );
  13240. }
  13241. /// <summary>
  13242. /// Computes the sum of a sequence of <see cref="long" /> values.
  13243. /// </summary>
  13244. /// <param name="source">A sequence of <see cref="long" /> values to calculate the sum of.</param>
  13245. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13246. /// <exception cref="ArgumentNullException">
  13247. /// <paramref name="source" /> is null.</exception>
  13248. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  13249. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13250. public static IQbservable<long> Sum(this IQbservable<long> source)
  13251. {
  13252. if (source == null)
  13253. throw new ArgumentNullException(nameof(source));
  13254. return source.Provider.CreateQuery<long>(
  13255. Expression.Call(
  13256. null,
  13257. #if CRIPPLED_REFLECTION
  13258. InfoOf(() => Qbservable.Sum(default(IQbservable<long>))),
  13259. #else
  13260. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13261. #endif
  13262. source.Expression
  13263. )
  13264. );
  13265. }
  13266. /// <summary>
  13267. /// Computes the sum of a sequence of nullable <see cref="Decimal" /> values.
  13268. /// </summary>
  13269. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to calculate the sum of.</param>
  13270. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13271. /// <exception cref="ArgumentNullException">
  13272. /// <paramref name="source" /> is null.</exception>
  13273. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Decimal.MaxValue" />.</exception>
  13274. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13275. public static IQbservable<decimal?> Sum(this IQbservable<decimal?> source)
  13276. {
  13277. if (source == null)
  13278. throw new ArgumentNullException(nameof(source));
  13279. return source.Provider.CreateQuery<decimal?>(
  13280. Expression.Call(
  13281. null,
  13282. #if CRIPPLED_REFLECTION
  13283. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal?>))),
  13284. #else
  13285. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13286. #endif
  13287. source.Expression
  13288. )
  13289. );
  13290. }
  13291. /// <summary>
  13292. /// Computes the sum of a sequence of nullable <see cref="double" /> values.
  13293. /// </summary>
  13294. /// <param name="source">A sequence of nullable <see cref="double" /> values to calculate the sum of.</param>
  13295. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13296. /// <exception cref="ArgumentNullException">
  13297. /// <paramref name="source" /> is null.</exception>
  13298. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13299. public static IQbservable<double?> Sum(this IQbservable<double?> source)
  13300. {
  13301. if (source == null)
  13302. throw new ArgumentNullException(nameof(source));
  13303. return source.Provider.CreateQuery<double?>(
  13304. Expression.Call(
  13305. null,
  13306. #if CRIPPLED_REFLECTION
  13307. InfoOf(() => Qbservable.Sum(default(IQbservable<double?>))),
  13308. #else
  13309. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13310. #endif
  13311. source.Expression
  13312. )
  13313. );
  13314. }
  13315. /// <summary>
  13316. /// Computes the sum of a sequence of nullable <see cref="int" /> values.
  13317. /// </summary>
  13318. /// <param name="source">A sequence of nullable <see cref="int" /> values to calculate the sum of.</param>
  13319. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13320. /// <exception cref="ArgumentNullException">
  13321. /// <paramref name="source" /> is null.</exception>
  13322. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int32.MaxValue" />.</exception>
  13323. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13324. public static IQbservable<int?> Sum(this IQbservable<int?> source)
  13325. {
  13326. if (source == null)
  13327. throw new ArgumentNullException(nameof(source));
  13328. return source.Provider.CreateQuery<int?>(
  13329. Expression.Call(
  13330. null,
  13331. #if CRIPPLED_REFLECTION
  13332. InfoOf(() => Qbservable.Sum(default(IQbservable<int?>))),
  13333. #else
  13334. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13335. #endif
  13336. source.Expression
  13337. )
  13338. );
  13339. }
  13340. /// <summary>
  13341. /// Computes the sum of a sequence of nullable <see cref="long" /> values.
  13342. /// </summary>
  13343. /// <param name="source">A sequence of nullable <see cref="long" /> values to calculate the sum of.</param>
  13344. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13345. /// <exception cref="ArgumentNullException">
  13346. /// <paramref name="source" /> is null.</exception>
  13347. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="F:System.Int64.MaxValue" />.</exception>
  13348. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13349. public static IQbservable<long?> Sum(this IQbservable<long?> source)
  13350. {
  13351. if (source == null)
  13352. throw new ArgumentNullException(nameof(source));
  13353. return source.Provider.CreateQuery<long?>(
  13354. Expression.Call(
  13355. null,
  13356. #if CRIPPLED_REFLECTION
  13357. InfoOf(() => Qbservable.Sum(default(IQbservable<long?>))),
  13358. #else
  13359. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13360. #endif
  13361. source.Expression
  13362. )
  13363. );
  13364. }
  13365. /// <summary>
  13366. /// Computes the sum of a sequence of nullable <see cref="Single" /> values.
  13367. /// </summary>
  13368. /// <param name="source">A sequence of nullable <see cref="Single" /> values to calculate the sum of.</param>
  13369. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13370. /// <exception cref="ArgumentNullException">
  13371. /// <paramref name="source" /> is null.</exception>
  13372. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13373. public static IQbservable<float?> Sum(this IQbservable<float?> source)
  13374. {
  13375. if (source == null)
  13376. throw new ArgumentNullException(nameof(source));
  13377. return source.Provider.CreateQuery<float?>(
  13378. Expression.Call(
  13379. null,
  13380. #if CRIPPLED_REFLECTION
  13381. InfoOf(() => Qbservable.Sum(default(IQbservable<float?>))),
  13382. #else
  13383. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13384. #endif
  13385. source.Expression
  13386. )
  13387. );
  13388. }
  13389. /// <summary>
  13390. /// Computes the sum of a sequence of <see cref="Single" /> values.
  13391. /// </summary>
  13392. /// <param name="source">A sequence of <see cref="Single" /> values to calculate the sum of.</param>
  13393. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13394. /// <exception cref="ArgumentNullException">
  13395. /// <paramref name="source" /> is null.</exception>
  13396. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13397. public static IQbservable<float> Sum(this IQbservable<float> source)
  13398. {
  13399. if (source == null)
  13400. throw new ArgumentNullException(nameof(source));
  13401. return source.Provider.CreateQuery<float>(
  13402. Expression.Call(
  13403. null,
  13404. #if CRIPPLED_REFLECTION
  13405. InfoOf(() => Qbservable.Sum(default(IQbservable<float>))),
  13406. #else
  13407. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13408. #endif
  13409. source.Expression
  13410. )
  13411. );
  13412. }
  13413. /// <summary>
  13414. /// 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.
  13415. /// </summary>
  13416. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13417. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13418. /// <param name="selector">A transform function to apply to each element.</param>
  13419. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13420. /// <exception cref="ArgumentNullException">
  13421. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13422. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13423. public static IQbservable<double> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  13424. {
  13425. if (source == null)
  13426. throw new ArgumentNullException(nameof(source));
  13427. if (selector == null)
  13428. throw new ArgumentNullException(nameof(selector));
  13429. return source.Provider.CreateQuery<double>(
  13430. Expression.Call(
  13431. null,
  13432. #if CRIPPLED_REFLECTION
  13433. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  13434. #else
  13435. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13436. #endif
  13437. source.Expression,
  13438. selector
  13439. )
  13440. );
  13441. }
  13442. /// <summary>
  13443. /// 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.
  13444. /// </summary>
  13445. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13446. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13447. /// <param name="selector">A transform function to apply to each element.</param>
  13448. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13449. /// <exception cref="ArgumentNullException">
  13450. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13451. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13452. public static IQbservable<float> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  13453. {
  13454. if (source == null)
  13455. throw new ArgumentNullException(nameof(source));
  13456. if (selector == null)
  13457. throw new ArgumentNullException(nameof(selector));
  13458. return source.Provider.CreateQuery<float>(
  13459. Expression.Call(
  13460. null,
  13461. #if CRIPPLED_REFLECTION
  13462. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  13463. #else
  13464. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13465. #endif
  13466. source.Expression,
  13467. selector
  13468. )
  13469. );
  13470. }
  13471. /// <summary>
  13472. /// 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.
  13473. /// </summary>
  13474. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13475. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13476. /// <param name="selector">A transform function to apply to each element.</param>
  13477. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13478. /// <exception cref="ArgumentNullException">
  13479. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13480. /// <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>
  13481. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13482. public static IQbservable<decimal> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  13483. {
  13484. if (source == null)
  13485. throw new ArgumentNullException(nameof(source));
  13486. if (selector == null)
  13487. throw new ArgumentNullException(nameof(selector));
  13488. return source.Provider.CreateQuery<decimal>(
  13489. Expression.Call(
  13490. null,
  13491. #if CRIPPLED_REFLECTION
  13492. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  13493. #else
  13494. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13495. #endif
  13496. source.Expression,
  13497. selector
  13498. )
  13499. );
  13500. }
  13501. /// <summary>
  13502. /// 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.
  13503. /// </summary>
  13504. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13505. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13506. /// <param name="selector">A transform function to apply to each element.</param>
  13507. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13508. /// <exception cref="ArgumentNullException">
  13509. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13510. /// <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>
  13511. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13512. public static IQbservable<int> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  13513. {
  13514. if (source == null)
  13515. throw new ArgumentNullException(nameof(source));
  13516. if (selector == null)
  13517. throw new ArgumentNullException(nameof(selector));
  13518. return source.Provider.CreateQuery<int>(
  13519. Expression.Call(
  13520. null,
  13521. #if CRIPPLED_REFLECTION
  13522. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  13523. #else
  13524. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13525. #endif
  13526. source.Expression,
  13527. selector
  13528. )
  13529. );
  13530. }
  13531. /// <summary>
  13532. /// 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.
  13533. /// </summary>
  13534. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13535. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13536. /// <param name="selector">A transform function to apply to each element.</param>
  13537. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13538. /// <exception cref="ArgumentNullException">
  13539. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13540. /// <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>
  13541. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13542. public static IQbservable<long> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  13543. {
  13544. if (source == null)
  13545. throw new ArgumentNullException(nameof(source));
  13546. if (selector == null)
  13547. throw new ArgumentNullException(nameof(selector));
  13548. return source.Provider.CreateQuery<long>(
  13549. Expression.Call(
  13550. null,
  13551. #if CRIPPLED_REFLECTION
  13552. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  13553. #else
  13554. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13555. #endif
  13556. source.Expression,
  13557. selector
  13558. )
  13559. );
  13560. }
  13561. /// <summary>
  13562. /// 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.
  13563. /// </summary>
  13564. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13565. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13566. /// <param name="selector">A transform function to apply to each element.</param>
  13567. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13568. /// <exception cref="ArgumentNullException">
  13569. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13570. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13571. public static IQbservable<double?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  13572. {
  13573. if (source == null)
  13574. throw new ArgumentNullException(nameof(source));
  13575. if (selector == null)
  13576. throw new ArgumentNullException(nameof(selector));
  13577. return source.Provider.CreateQuery<double?>(
  13578. Expression.Call(
  13579. null,
  13580. #if CRIPPLED_REFLECTION
  13581. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  13582. #else
  13583. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13584. #endif
  13585. source.Expression,
  13586. selector
  13587. )
  13588. );
  13589. }
  13590. /// <summary>
  13591. /// 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.
  13592. /// </summary>
  13593. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13594. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13595. /// <param name="selector">A transform function to apply to each element.</param>
  13596. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13597. /// <exception cref="ArgumentNullException">
  13598. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13599. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13600. public static IQbservable<float?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  13601. {
  13602. if (source == null)
  13603. throw new ArgumentNullException(nameof(source));
  13604. if (selector == null)
  13605. throw new ArgumentNullException(nameof(selector));
  13606. return source.Provider.CreateQuery<float?>(
  13607. Expression.Call(
  13608. null,
  13609. #if CRIPPLED_REFLECTION
  13610. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  13611. #else
  13612. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13613. #endif
  13614. source.Expression,
  13615. selector
  13616. )
  13617. );
  13618. }
  13619. /// <summary>
  13620. /// 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.
  13621. /// </summary>
  13622. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13623. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13624. /// <param name="selector">A transform function to apply to each element.</param>
  13625. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13626. /// <exception cref="ArgumentNullException">
  13627. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13628. /// <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>
  13629. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13630. public static IQbservable<decimal?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  13631. {
  13632. if (source == null)
  13633. throw new ArgumentNullException(nameof(source));
  13634. if (selector == null)
  13635. throw new ArgumentNullException(nameof(selector));
  13636. return source.Provider.CreateQuery<decimal?>(
  13637. Expression.Call(
  13638. null,
  13639. #if CRIPPLED_REFLECTION
  13640. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  13641. #else
  13642. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13643. #endif
  13644. source.Expression,
  13645. selector
  13646. )
  13647. );
  13648. }
  13649. /// <summary>
  13650. /// 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.
  13651. /// </summary>
  13652. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13653. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13654. /// <param name="selector">A transform function to apply to each element.</param>
  13655. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13656. /// <exception cref="ArgumentNullException">
  13657. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13658. /// <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>
  13659. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13660. public static IQbservable<int?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  13661. {
  13662. if (source == null)
  13663. throw new ArgumentNullException(nameof(source));
  13664. if (selector == null)
  13665. throw new ArgumentNullException(nameof(selector));
  13666. return source.Provider.CreateQuery<int?>(
  13667. Expression.Call(
  13668. null,
  13669. #if CRIPPLED_REFLECTION
  13670. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  13671. #else
  13672. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13673. #endif
  13674. source.Expression,
  13675. selector
  13676. )
  13677. );
  13678. }
  13679. /// <summary>
  13680. /// 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.
  13681. /// </summary>
  13682. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13683. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13684. /// <param name="selector">A transform function to apply to each element.</param>
  13685. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13686. /// <exception cref="ArgumentNullException">
  13687. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13688. /// <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>
  13689. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13690. public static IQbservable<long?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  13691. {
  13692. if (source == null)
  13693. throw new ArgumentNullException(nameof(source));
  13694. if (selector == null)
  13695. throw new ArgumentNullException(nameof(selector));
  13696. return source.Provider.CreateQuery<long?>(
  13697. Expression.Call(
  13698. null,
  13699. #if CRIPPLED_REFLECTION
  13700. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  13701. #else
  13702. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13703. #endif
  13704. source.Expression,
  13705. selector
  13706. )
  13707. );
  13708. }
  13709. /// <summary>
  13710. /// Transforms an observable sequence of observable sequences into an observable sequence
  13711. /// producing values only from the most recent observable sequence.
  13712. /// Each time a new inner observable sequence is received, unsubscribe from the
  13713. /// previous inner observable sequence.
  13714. /// </summary>
  13715. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  13716. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  13717. /// <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>
  13718. /// <exception cref="ArgumentNullException">
  13719. /// <paramref name="sources" /> is null.</exception>
  13720. public static IQbservable<TSource> Switch<TSource>(this IQbservable<IObservable<TSource>> sources)
  13721. {
  13722. if (sources == null)
  13723. throw new ArgumentNullException(nameof(sources));
  13724. return sources.Provider.CreateQuery<TSource>(
  13725. Expression.Call(
  13726. null,
  13727. #if CRIPPLED_REFLECTION
  13728. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<IObservable<TSource>>))),
  13729. #else
  13730. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13731. #endif
  13732. sources.Expression
  13733. )
  13734. );
  13735. }
  13736. /// <summary>
  13737. /// Transforms an observable sequence of tasks into an observable sequence
  13738. /// producing values only from the most recent observable sequence.
  13739. /// Each time a new task is received, the previous task's result is ignored.
  13740. /// </summary>
  13741. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  13742. /// <param name="sources">Observable sequence of tasks.</param>
  13743. /// <returns>The observable sequence that at any point in time produces the result of the most recent task that has been received.</returns>
  13744. /// <exception cref="ArgumentNullException">
  13745. /// <paramref name="sources" /> is null.</exception>
  13746. /// <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>
  13747. public static IQbservable<TSource> Switch<TSource>(this IQbservable<Task<TSource>> sources)
  13748. {
  13749. if (sources == null)
  13750. throw new ArgumentNullException(nameof(sources));
  13751. return sources.Provider.CreateQuery<TSource>(
  13752. Expression.Call(
  13753. null,
  13754. #if CRIPPLED_REFLECTION
  13755. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<Task<TSource>>))),
  13756. #else
  13757. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13758. #endif
  13759. sources.Expression
  13760. )
  13761. );
  13762. }
  13763. /// <summary>
  13764. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently.
  13765. /// This overload is useful to "fix" an observable sequence that exhibits concurrent callbacks on individual observers, which is invalid behavior for the query processor.
  13766. /// </summary>
  13767. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13768. /// <param name="source">Source sequence.</param>
  13769. /// <returns>The source sequence whose outgoing calls to observers are synchronized.</returns>
  13770. /// <exception cref="ArgumentNullException">
  13771. /// <paramref name="source" /> is null.</exception>
  13772. /// <remarks>
  13773. /// It's invalid behavior - according to the observer grammar - for a sequence to exhibit concurrent callbacks on a given observer.
  13774. /// This operator can be used to "fix" a source that doesn't conform to this rule.
  13775. /// </remarks>
  13776. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source)
  13777. {
  13778. if (source == null)
  13779. throw new ArgumentNullException(nameof(source));
  13780. return source.Provider.CreateQuery<TSource>(
  13781. Expression.Call(
  13782. null,
  13783. #if CRIPPLED_REFLECTION
  13784. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>))),
  13785. #else
  13786. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13787. #endif
  13788. source.Expression
  13789. )
  13790. );
  13791. }
  13792. /// <summary>
  13793. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently, using the specified gate object.
  13794. /// 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.
  13795. /// </summary>
  13796. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13797. /// <param name="source">Source sequence.</param>
  13798. /// <param name="gate">Gate object to synchronize each observer call on.</param>
  13799. /// <returns>The source sequence whose outgoing calls to observers are synchronized on the given gate object.</returns>
  13800. /// <exception cref="ArgumentNullException">
  13801. /// <paramref name="source" /> or <paramref name="gate" /> is null.</exception>
  13802. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source, object gate)
  13803. {
  13804. if (source == null)
  13805. throw new ArgumentNullException(nameof(source));
  13806. if (gate == null)
  13807. throw new ArgumentNullException(nameof(gate));
  13808. return source.Provider.CreateQuery<TSource>(
  13809. Expression.Call(
  13810. null,
  13811. #if CRIPPLED_REFLECTION
  13812. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>), default(object))),
  13813. #else
  13814. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13815. #endif
  13816. source.Expression,
  13817. Expression.Constant(gate, typeof(object))
  13818. )
  13819. );
  13820. }
  13821. /// <summary>
  13822. /// Returns a specified number of contiguous elements from the start of an observable sequence.
  13823. /// </summary>
  13824. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13825. /// <param name="source">The sequence to take elements from.</param>
  13826. /// <param name="count">The number of elements to return.</param>
  13827. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13828. /// <exception cref="ArgumentNullException">
  13829. /// <paramref name="source" /> is null.</exception>
  13830. /// <exception cref="ArgumentOutOfRangeException">
  13831. /// <paramref name="count" /> is less than zero.</exception>
  13832. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count)
  13833. {
  13834. if (source == null)
  13835. throw new ArgumentNullException(nameof(source));
  13836. return source.Provider.CreateQuery<TSource>(
  13837. Expression.Call(
  13838. null,
  13839. #if CRIPPLED_REFLECTION
  13840. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int))),
  13841. #else
  13842. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13843. #endif
  13844. source.Expression,
  13845. Expression.Constant(count, typeof(int))
  13846. )
  13847. );
  13848. }
  13849. /// <summary>
  13850. /// 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).
  13851. /// </summary>
  13852. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13853. /// <param name="source">The sequence to take elements from.</param>
  13854. /// <param name="count">The number of elements to return.</param>
  13855. /// <param name="scheduler">Scheduler used to produce an OnCompleted message in case <paramref name="count">count</paramref> is set to 0.</param>
  13856. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13857. /// <exception cref="ArgumentNullException">
  13858. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13859. /// <exception cref="ArgumentOutOfRangeException">
  13860. /// <paramref name="count" /> is less than zero.</exception>
  13861. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13862. {
  13863. if (source == null)
  13864. throw new ArgumentNullException(nameof(source));
  13865. if (scheduler == null)
  13866. throw new ArgumentNullException(nameof(scheduler));
  13867. return source.Provider.CreateQuery<TSource>(
  13868. Expression.Call(
  13869. null,
  13870. #if CRIPPLED_REFLECTION
  13871. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13872. #else
  13873. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13874. #endif
  13875. source.Expression,
  13876. Expression.Constant(count, typeof(int)),
  13877. Expression.Constant(scheduler, typeof(IScheduler))
  13878. )
  13879. );
  13880. }
  13881. /// <summary>
  13882. /// Takes elements for the specified duration from the start of the observable source sequence.
  13883. /// </summary>
  13884. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13885. /// <param name="source">Source sequence to take elements from.</param>
  13886. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13887. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13888. /// <exception cref="ArgumentNullException">
  13889. /// <paramref name="source" /> is null.</exception>
  13890. /// <exception cref="ArgumentOutOfRangeException">
  13891. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13892. /// <remarks>
  13893. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13894. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13895. /// immediately, despite the TimeSpan.Zero due time.
  13896. /// </remarks>
  13897. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13898. {
  13899. if (source == null)
  13900. throw new ArgumentNullException(nameof(source));
  13901. return source.Provider.CreateQuery<TSource>(
  13902. Expression.Call(
  13903. null,
  13904. #if CRIPPLED_REFLECTION
  13905. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13906. #else
  13907. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13908. #endif
  13909. source.Expression,
  13910. Expression.Constant(duration, typeof(TimeSpan))
  13911. )
  13912. );
  13913. }
  13914. /// <summary>
  13915. /// Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  13916. /// </summary>
  13917. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13918. /// <param name="source">Source sequence to take elements from.</param>
  13919. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13920. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13921. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13922. /// <exception cref="ArgumentNullException">
  13923. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13924. /// <exception cref="ArgumentOutOfRangeException">
  13925. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13926. /// <remarks>
  13927. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13928. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13929. /// immediately, despite the TimeSpan.Zero due time.
  13930. /// </remarks>
  13931. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13932. {
  13933. if (source == null)
  13934. throw new ArgumentNullException(nameof(source));
  13935. if (scheduler == null)
  13936. throw new ArgumentNullException(nameof(scheduler));
  13937. return source.Provider.CreateQuery<TSource>(
  13938. Expression.Call(
  13939. null,
  13940. #if CRIPPLED_REFLECTION
  13941. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13942. #else
  13943. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13944. #endif
  13945. source.Expression,
  13946. Expression.Constant(duration, typeof(TimeSpan)),
  13947. Expression.Constant(scheduler, typeof(IScheduler))
  13948. )
  13949. );
  13950. }
  13951. /// <summary>
  13952. /// Returns a specified number of contiguous elements from the end of an observable sequence.
  13953. /// </summary>
  13954. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13955. /// <param name="source">Source sequence.</param>
  13956. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13957. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13958. /// <exception cref="ArgumentNullException">
  13959. /// <paramref name="source" /> is null.</exception>
  13960. /// <exception cref="ArgumentOutOfRangeException">
  13961. /// <paramref name="count" /> is less than zero.</exception>
  13962. /// <remarks>
  13963. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13964. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13965. /// </remarks>
  13966. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count)
  13967. {
  13968. if (source == null)
  13969. throw new ArgumentNullException(nameof(source));
  13970. return source.Provider.CreateQuery<TSource>(
  13971. Expression.Call(
  13972. null,
  13973. #if CRIPPLED_REFLECTION
  13974. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int))),
  13975. #else
  13976. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13977. #endif
  13978. source.Expression,
  13979. Expression.Constant(count, typeof(int))
  13980. )
  13981. );
  13982. }
  13983. /// <summary>
  13984. /// Returns a specified number of contiguous elements from the end of an observable sequence, using the specified scheduler to drain the queue.
  13985. /// </summary>
  13986. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13987. /// <param name="source">Source sequence.</param>
  13988. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13989. /// <param name="scheduler">Scheduler used to drain the queue upon completion of the source sequence.</param>
  13990. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13991. /// <exception cref="ArgumentNullException">
  13992. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13993. /// <exception cref="ArgumentOutOfRangeException">
  13994. /// <paramref name="count" /> is less than zero.</exception>
  13995. /// <remarks>
  13996. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13997. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13998. /// </remarks>
  13999. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  14000. {
  14001. if (source == null)
  14002. throw new ArgumentNullException(nameof(source));
  14003. if (scheduler == null)
  14004. throw new ArgumentNullException(nameof(scheduler));
  14005. return source.Provider.CreateQuery<TSource>(
  14006. Expression.Call(
  14007. null,
  14008. #if CRIPPLED_REFLECTION
  14009. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  14010. #else
  14011. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14012. #endif
  14013. source.Expression,
  14014. Expression.Constant(count, typeof(int)),
  14015. Expression.Constant(scheduler, typeof(IScheduler))
  14016. )
  14017. );
  14018. }
  14019. /// <summary>
  14020. /// Returns elements within the specified duration from the end of the observable source sequence.
  14021. /// </summary>
  14022. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14023. /// <param name="source">Source sequence to take elements from.</param>
  14024. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14025. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  14026. /// <exception cref="ArgumentNullException">
  14027. /// <paramref name="source" /> is null.</exception>
  14028. /// <exception cref="ArgumentOutOfRangeException">
  14029. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14030. /// <remarks>
  14031. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14032. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  14033. /// to be delayed with <paramref name="duration" />.
  14034. /// </remarks>
  14035. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  14036. {
  14037. if (source == null)
  14038. throw new ArgumentNullException(nameof(source));
  14039. return source.Provider.CreateQuery<TSource>(
  14040. Expression.Call(
  14041. null,
  14042. #if CRIPPLED_REFLECTION
  14043. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14044. #else
  14045. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14046. #endif
  14047. source.Expression,
  14048. Expression.Constant(duration, typeof(TimeSpan))
  14049. )
  14050. );
  14051. }
  14052. /// <summary>
  14053. /// Returns elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  14054. /// </summary>
  14055. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14056. /// <param name="source">Source sequence to take elements from.</param>
  14057. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14058. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14059. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  14060. /// <exception cref="ArgumentNullException">
  14061. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14062. /// <exception cref="ArgumentOutOfRangeException">
  14063. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14064. /// <remarks>
  14065. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14066. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  14067. /// to be delayed with <paramref name="duration" />.
  14068. /// </remarks>
  14069. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  14070. {
  14071. if (source == null)
  14072. throw new ArgumentNullException(nameof(source));
  14073. if (scheduler == null)
  14074. throw new ArgumentNullException(nameof(scheduler));
  14075. return source.Provider.CreateQuery<TSource>(
  14076. Expression.Call(
  14077. null,
  14078. #if CRIPPLED_REFLECTION
  14079. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14080. #else
  14081. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14082. #endif
  14083. source.Expression,
  14084. Expression.Constant(duration, typeof(TimeSpan)),
  14085. Expression.Constant(scheduler, typeof(IScheduler))
  14086. )
  14087. );
  14088. }
  14089. /// <summary>
  14090. /// 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.
  14091. /// </summary>
  14092. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14093. /// <param name="source">Source sequence to take elements from.</param>
  14094. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14095. /// <param name="timerScheduler">Scheduler to run the timer on.</param>
  14096. /// <param name="loopScheduler">Scheduler to drain the collected elements.</param>
  14097. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  14098. /// <exception cref="ArgumentNullException">
  14099. /// <paramref name="source" /> or <paramref name="timerScheduler" /> or <paramref name="loopScheduler" /> is null.</exception>
  14100. /// <exception cref="ArgumentOutOfRangeException">
  14101. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14102. /// <remarks>
  14103. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14104. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  14105. /// to be delayed with <paramref name="duration" />.
  14106. /// </remarks>
  14107. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler timerScheduler, IScheduler loopScheduler)
  14108. {
  14109. if (source == null)
  14110. throw new ArgumentNullException(nameof(source));
  14111. if (timerScheduler == null)
  14112. throw new ArgumentNullException(nameof(timerScheduler));
  14113. if (loopScheduler == null)
  14114. throw new ArgumentNullException(nameof(loopScheduler));
  14115. return source.Provider.CreateQuery<TSource>(
  14116. Expression.Call(
  14117. null,
  14118. #if CRIPPLED_REFLECTION
  14119. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler), default(IScheduler))),
  14120. #else
  14121. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14122. #endif
  14123. source.Expression,
  14124. Expression.Constant(duration, typeof(TimeSpan)),
  14125. Expression.Constant(timerScheduler, typeof(IScheduler)),
  14126. Expression.Constant(loopScheduler, typeof(IScheduler))
  14127. )
  14128. );
  14129. }
  14130. /// <summary>
  14131. /// Returns a list with the specified number of contiguous elements from the end of an observable sequence.
  14132. /// </summary>
  14133. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14134. /// <param name="source">Source sequence.</param>
  14135. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  14136. /// <returns>An observable sequence containing a single list with the specified number of elements from the end of the source sequence.</returns>
  14137. /// <exception cref="ArgumentNullException">
  14138. /// <paramref name="source" /> is null.</exception>
  14139. /// <exception cref="ArgumentOutOfRangeException">
  14140. /// <paramref name="count" /> is less than zero.</exception>
  14141. /// <remarks>
  14142. /// This operator accumulates a buffer with a length enough to store <paramref name="count" /> elements. Upon completion of the
  14143. /// source sequence, this buffer is produced on the result sequence.
  14144. /// </remarks>
  14145. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, int count)
  14146. {
  14147. if (source == null)
  14148. throw new ArgumentNullException(nameof(source));
  14149. return source.Provider.CreateQuery<IList<TSource>>(
  14150. Expression.Call(
  14151. null,
  14152. #if CRIPPLED_REFLECTION
  14153. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(int))),
  14154. #else
  14155. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14156. #endif
  14157. source.Expression,
  14158. Expression.Constant(count, typeof(int))
  14159. )
  14160. );
  14161. }
  14162. /// <summary>
  14163. /// Returns a list with the elements within the specified duration from the end of the observable source sequence.
  14164. /// </summary>
  14165. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14166. /// <param name="source">Source sequence to take elements from.</param>
  14167. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14168. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  14169. /// <exception cref="ArgumentNullException">
  14170. /// <paramref name="source" /> is null.</exception>
  14171. /// <exception cref="ArgumentOutOfRangeException">
  14172. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14173. /// <remarks>
  14174. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14175. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  14176. /// </remarks>
  14177. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  14178. {
  14179. if (source == null)
  14180. throw new ArgumentNullException(nameof(source));
  14181. return source.Provider.CreateQuery<IList<TSource>>(
  14182. Expression.Call(
  14183. null,
  14184. #if CRIPPLED_REFLECTION
  14185. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14186. #else
  14187. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14188. #endif
  14189. source.Expression,
  14190. Expression.Constant(duration, typeof(TimeSpan))
  14191. )
  14192. );
  14193. }
  14194. /// <summary>
  14195. /// 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.
  14196. /// </summary>
  14197. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14198. /// <param name="source">Source sequence to take elements from.</param>
  14199. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  14200. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14201. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  14202. /// <exception cref="ArgumentNullException">
  14203. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14204. /// <exception cref="ArgumentOutOfRangeException">
  14205. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  14206. /// <remarks>
  14207. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  14208. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  14209. /// </remarks>
  14210. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  14211. {
  14212. if (source == null)
  14213. throw new ArgumentNullException(nameof(source));
  14214. if (scheduler == null)
  14215. throw new ArgumentNullException(nameof(scheduler));
  14216. return source.Provider.CreateQuery<IList<TSource>>(
  14217. Expression.Call(
  14218. null,
  14219. #if CRIPPLED_REFLECTION
  14220. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14221. #else
  14222. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14223. #endif
  14224. source.Expression,
  14225. Expression.Constant(duration, typeof(TimeSpan)),
  14226. Expression.Constant(scheduler, typeof(IScheduler))
  14227. )
  14228. );
  14229. }
  14230. /// <summary>
  14231. /// Takes elements for the specified duration until the specified end time.
  14232. /// </summary>
  14233. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14234. /// <param name="source">Source sequence to take elements from.</param>
  14235. /// <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>
  14236. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  14237. /// <exception cref="ArgumentNullException">
  14238. /// <paramref name="source" /> is null.</exception>
  14239. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime)
  14240. {
  14241. if (source == null)
  14242. throw new ArgumentNullException(nameof(source));
  14243. return source.Provider.CreateQuery<TSource>(
  14244. Expression.Call(
  14245. null,
  14246. #if CRIPPLED_REFLECTION
  14247. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14248. #else
  14249. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14250. #endif
  14251. source.Expression,
  14252. Expression.Constant(endTime, typeof(DateTimeOffset))
  14253. )
  14254. );
  14255. }
  14256. /// <summary>
  14257. /// Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  14258. /// </summary>
  14259. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14260. /// <param name="source">Source sequence to take elements from.</param>
  14261. /// <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>
  14262. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14263. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  14264. /// <exception cref="ArgumentNullException">
  14265. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14266. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime, IScheduler scheduler)
  14267. {
  14268. if (source == null)
  14269. throw new ArgumentNullException(nameof(source));
  14270. if (scheduler == null)
  14271. throw new ArgumentNullException(nameof(scheduler));
  14272. return source.Provider.CreateQuery<TSource>(
  14273. Expression.Call(
  14274. null,
  14275. #if CRIPPLED_REFLECTION
  14276. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14277. #else
  14278. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14279. #endif
  14280. source.Expression,
  14281. Expression.Constant(endTime, typeof(DateTimeOffset)),
  14282. Expression.Constant(scheduler, typeof(IScheduler))
  14283. )
  14284. );
  14285. }
  14286. /// <summary>
  14287. /// Returns the elements from the source observable sequence until the other observable sequence produces an element.
  14288. /// </summary>
  14289. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14290. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of take behavior.</typeparam>
  14291. /// <param name="source">Source sequence to propagate elements for.</param>
  14292. /// <param name="other">Observable sequence that terminates propagation of elements of the source sequence.</param>
  14293. /// <returns>An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.</returns>
  14294. /// <exception cref="ArgumentNullException">
  14295. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14296. public static IQbservable<TSource> TakeUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  14297. {
  14298. if (source == null)
  14299. throw new ArgumentNullException(nameof(source));
  14300. if (other == null)
  14301. throw new ArgumentNullException(nameof(other));
  14302. return source.Provider.CreateQuery<TSource>(
  14303. Expression.Call(
  14304. null,
  14305. #if CRIPPLED_REFLECTION
  14306. InfoOf(() => Qbservable.TakeUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  14307. #else
  14308. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  14309. #endif
  14310. source.Expression,
  14311. GetSourceExpression(other)
  14312. )
  14313. );
  14314. }
  14315. /// <summary>
  14316. /// Relays elements from the source observable sequence and calls the predicate after an
  14317. /// emission to check if the sequence should stop after that specific item.
  14318. /// </summary>
  14319. /// <typeparam name="TSource">The type of the elements in the source and result sequences.</typeparam>
  14320. /// <param name="source">The source sequence to relay elements of.</param>
  14321. /// <param name="stopPredicate">Called after each upstream item has been emitted with
  14322. /// that upstream item and should return <code>true</code> to indicate the sequence should
  14323. /// complete.</param>
  14324. /// <returns>The observable sequence with the source elements until the stop predicate returns true.</returns>
  14325. /// <example>
  14326. /// The following sequence will stop after the value 5 has been encountered:
  14327. /// <code>
  14328. /// Observable.Range(1, 10)
  14329. /// .TakeUntil(item =&gt; item == 5)
  14330. /// .Subscribe(Console.WriteLine);
  14331. /// </code>
  14332. /// </example>
  14333. /// <exception cref="ArgumentException">If <typeparamref name="TSource"/> or <paramref name="stopPredicate"/> is <code>null</code>.</exception>
  14334. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> stopPredicate)
  14335. {
  14336. if (source == null)
  14337. throw new ArgumentNullException(nameof(source));
  14338. if (stopPredicate == null)
  14339. throw new ArgumentNullException(nameof(stopPredicate));
  14340. return source.Provider.CreateQuery<TSource>(
  14341. Expression.Call(
  14342. null,
  14343. #if CRIPPLED_REFLECTION
  14344. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  14345. #else
  14346. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14347. #endif
  14348. source.Expression,
  14349. stopPredicate
  14350. )
  14351. );
  14352. }
  14353. /// <summary>
  14354. /// Returns elements from an observable sequence as long as a specified condition is true.
  14355. /// </summary>
  14356. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14357. /// <param name="source">A sequence to return elements from.</param>
  14358. /// <param name="predicate">A function to test each element for a condition.</param>
  14359. /// <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>
  14360. /// <exception cref="ArgumentNullException">
  14361. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14362. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  14363. {
  14364. if (source == null)
  14365. throw new ArgumentNullException(nameof(source));
  14366. if (predicate == null)
  14367. throw new ArgumentNullException(nameof(predicate));
  14368. return source.Provider.CreateQuery<TSource>(
  14369. Expression.Call(
  14370. null,
  14371. #if CRIPPLED_REFLECTION
  14372. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  14373. #else
  14374. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14375. #endif
  14376. source.Expression,
  14377. predicate
  14378. )
  14379. );
  14380. }
  14381. /// <summary>
  14382. /// Returns elements from an observable sequence as long as a specified condition is true.
  14383. /// The element's index is used in the logic of the predicate function.
  14384. /// </summary>
  14385. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14386. /// <param name="source">A sequence to return elements from.</param>
  14387. /// <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>
  14388. /// <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>
  14389. /// <exception cref="ArgumentNullException">
  14390. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  14391. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  14392. {
  14393. if (source == null)
  14394. throw new ArgumentNullException(nameof(source));
  14395. if (predicate == null)
  14396. throw new ArgumentNullException(nameof(predicate));
  14397. return source.Provider.CreateQuery<TSource>(
  14398. Expression.Call(
  14399. null,
  14400. #if CRIPPLED_REFLECTION
  14401. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  14402. #else
  14403. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14404. #endif
  14405. source.Expression,
  14406. predicate
  14407. )
  14408. );
  14409. }
  14410. /// <summary>
  14411. /// Ignores elements from an observable sequence which are followed by another element within a specified relative time duration.
  14412. /// </summary>
  14413. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14414. /// <param name="source">Source sequence to throttle.</param>
  14415. /// <param name="dueTime">Throttling duration for each element.</param>
  14416. /// <returns>The throttled sequence.</returns>
  14417. /// <exception cref="ArgumentNullException">
  14418. /// <paramref name="source" /> is null.</exception>
  14419. /// <exception cref="ArgumentOutOfRangeException">
  14420. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14421. /// <remarks>
  14422. /// <para>
  14423. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14424. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14425. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14426. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14427. /// Observable.Sample set of operators.
  14428. /// </para>
  14429. /// <para>
  14430. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14431. /// 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
  14432. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14433. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14434. /// </para>
  14435. /// </remarks>
  14436. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14437. {
  14438. if (source == null)
  14439. throw new ArgumentNullException(nameof(source));
  14440. return source.Provider.CreateQuery<TSource>(
  14441. Expression.Call(
  14442. null,
  14443. #if CRIPPLED_REFLECTION
  14444. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14445. #else
  14446. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14447. #endif
  14448. source.Expression,
  14449. Expression.Constant(dueTime, typeof(TimeSpan))
  14450. )
  14451. );
  14452. }
  14453. /// <summary>
  14454. /// 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.
  14455. /// </summary>
  14456. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14457. /// <param name="source">Source sequence to throttle.</param>
  14458. /// <param name="dueTime">Throttling duration for each element.</param>
  14459. /// <param name="scheduler">Scheduler to run the throttle timers on.</param>
  14460. /// <returns>The throttled sequence.</returns>
  14461. /// <exception cref="ArgumentNullException">
  14462. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14463. /// <exception cref="ArgumentOutOfRangeException">
  14464. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14465. /// <remarks>
  14466. /// <para>
  14467. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14468. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14469. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14470. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14471. /// Observable.Sample set of operators.
  14472. /// </para>
  14473. /// <para>
  14474. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14475. /// 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
  14476. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14477. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14478. /// </para>
  14479. /// </remarks>
  14480. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14481. {
  14482. if (source == null)
  14483. throw new ArgumentNullException(nameof(source));
  14484. if (scheduler == null)
  14485. throw new ArgumentNullException(nameof(scheduler));
  14486. return source.Provider.CreateQuery<TSource>(
  14487. Expression.Call(
  14488. null,
  14489. #if CRIPPLED_REFLECTION
  14490. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14491. #else
  14492. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14493. #endif
  14494. source.Expression,
  14495. Expression.Constant(dueTime, typeof(TimeSpan)),
  14496. Expression.Constant(scheduler, typeof(IScheduler))
  14497. )
  14498. );
  14499. }
  14500. /// <summary>
  14501. /// Ignores elements from an observable sequence which are followed by another value within a computed throttle duration.
  14502. /// </summary>
  14503. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14504. /// <typeparam name="TThrottle">The type of the elements in the throttle sequences selected for each element in the source sequence.</typeparam>
  14505. /// <param name="source">Source sequence to throttle.</param>
  14506. /// <param name="throttleDurationSelector">Selector function to retrieve a sequence indicating the throttle duration for each given element.</param>
  14507. /// <returns>The throttled sequence.</returns>
  14508. /// <exception cref="ArgumentNullException">
  14509. /// <paramref name="source" /> or <paramref name="throttleDurationSelector" /> is null.</exception>
  14510. /// <remarks>
  14511. /// This operator throttles the source sequence by holding on to each element for the duration denoted by <paramref name="throttleDurationSelector" />.
  14512. /// 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
  14513. /// whole process. For streams where the duration computed by applying the <paramref name="throttleDurationSelector" /> to each element overlaps with
  14514. /// the occurrence of the successor element, the resulting stream won't produce any elements. In order to reduce the volume of a stream whilst
  14515. /// guaranteeing the periodic production of elements, consider using the Observable.Sample set of operators.
  14516. /// </remarks>
  14517. public static IQbservable<TSource> Throttle<TSource, TThrottle>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TThrottle>>> throttleDurationSelector)
  14518. {
  14519. if (source == null)
  14520. throw new ArgumentNullException(nameof(source));
  14521. if (throttleDurationSelector == null)
  14522. throw new ArgumentNullException(nameof(throttleDurationSelector));
  14523. return source.Provider.CreateQuery<TSource>(
  14524. Expression.Call(
  14525. null,
  14526. #if CRIPPLED_REFLECTION
  14527. InfoOf(() => Qbservable.Throttle<TSource, TThrottle>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TThrottle>>>))),
  14528. #else
  14529. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TThrottle)),
  14530. #endif
  14531. source.Expression,
  14532. throttleDurationSelector
  14533. )
  14534. );
  14535. }
  14536. /// <summary>
  14537. /// Returns an observable sequence that terminates with an exception.
  14538. /// </summary>
  14539. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14540. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14541. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14542. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14543. /// <exception cref="ArgumentNullException">
  14544. /// <paramref name="exception" /> is null.</exception>
  14545. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception)
  14546. {
  14547. if (provider == null)
  14548. throw new ArgumentNullException(nameof(provider));
  14549. if (exception == null)
  14550. throw new ArgumentNullException(nameof(exception));
  14551. return provider.CreateQuery<TResult>(
  14552. Expression.Call(
  14553. null,
  14554. #if CRIPPLED_REFLECTION
  14555. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception))),
  14556. #else
  14557. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14558. #endif
  14559. Expression.Constant(provider, typeof(IQbservableProvider)),
  14560. Expression.Constant(exception, typeof(Exception))
  14561. )
  14562. );
  14563. }
  14564. /// <summary>
  14565. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14566. /// </summary>
  14567. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14568. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14569. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14570. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14571. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14572. /// <exception cref="ArgumentNullException">
  14573. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14574. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler)
  14575. {
  14576. if (provider == null)
  14577. throw new ArgumentNullException(nameof(provider));
  14578. if (exception == null)
  14579. throw new ArgumentNullException(nameof(exception));
  14580. if (scheduler == null)
  14581. throw new ArgumentNullException(nameof(scheduler));
  14582. return provider.CreateQuery<TResult>(
  14583. Expression.Call(
  14584. null,
  14585. #if CRIPPLED_REFLECTION
  14586. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler))),
  14587. #else
  14588. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14589. #endif
  14590. Expression.Constant(provider, typeof(IQbservableProvider)),
  14591. Expression.Constant(exception, typeof(Exception)),
  14592. Expression.Constant(scheduler, typeof(IScheduler))
  14593. )
  14594. );
  14595. }
  14596. /// <summary>
  14597. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14598. /// </summary>
  14599. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14600. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14601. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14602. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14603. /// <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>
  14604. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14605. /// <exception cref="ArgumentNullException">
  14606. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14607. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler, TResult witness)
  14608. {
  14609. if (provider == null)
  14610. throw new ArgumentNullException(nameof(provider));
  14611. if (exception == null)
  14612. throw new ArgumentNullException(nameof(exception));
  14613. if (scheduler == null)
  14614. throw new ArgumentNullException(nameof(scheduler));
  14615. return provider.CreateQuery<TResult>(
  14616. Expression.Call(
  14617. null,
  14618. #if CRIPPLED_REFLECTION
  14619. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler), default(TResult))),
  14620. #else
  14621. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14622. #endif
  14623. Expression.Constant(provider, typeof(IQbservableProvider)),
  14624. Expression.Constant(exception, typeof(Exception)),
  14625. Expression.Constant(scheduler, typeof(IScheduler)),
  14626. Expression.Constant(witness, typeof(TResult))
  14627. )
  14628. );
  14629. }
  14630. /// <summary>
  14631. /// Returns an observable sequence that terminates with an exception.
  14632. /// </summary>
  14633. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14634. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}" /> type parameter of the resulting sequence.</typeparam>
  14635. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14636. /// <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>
  14637. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14638. /// <exception cref="ArgumentNullException">
  14639. /// <paramref name="exception" /> is null.</exception>
  14640. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, TResult witness)
  14641. {
  14642. if (provider == null)
  14643. throw new ArgumentNullException(nameof(provider));
  14644. if (exception == null)
  14645. throw new ArgumentNullException(nameof(exception));
  14646. return provider.CreateQuery<TResult>(
  14647. Expression.Call(
  14648. null,
  14649. #if CRIPPLED_REFLECTION
  14650. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(TResult))),
  14651. #else
  14652. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14653. #endif
  14654. Expression.Constant(provider, typeof(IQbservableProvider)),
  14655. Expression.Constant(exception, typeof(Exception)),
  14656. Expression.Constant(witness, typeof(TResult))
  14657. )
  14658. );
  14659. }
  14660. /// <summary>
  14661. /// Records the time interval between consecutive elements in an observable sequence.
  14662. /// </summary>
  14663. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14664. /// <param name="source">Source sequence to record time intervals for.</param>
  14665. /// <returns>An observable sequence with time interval information on elements.</returns>
  14666. /// <exception cref="ArgumentNullException">
  14667. /// <paramref name="source" /> is null.</exception>
  14668. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source)
  14669. {
  14670. if (source == null)
  14671. throw new ArgumentNullException(nameof(source));
  14672. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14673. Expression.Call(
  14674. null,
  14675. #if CRIPPLED_REFLECTION
  14676. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>))),
  14677. #else
  14678. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14679. #endif
  14680. source.Expression
  14681. )
  14682. );
  14683. }
  14684. /// <summary>
  14685. /// Records the time interval between consecutive elements in an observable sequence, using the specified scheduler to compute time intervals.
  14686. /// </summary>
  14687. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14688. /// <param name="source">Source sequence to record time intervals for.</param>
  14689. /// <param name="scheduler">Scheduler used to compute time intervals.</param>
  14690. /// <returns>An observable sequence with time interval information on elements.</returns>
  14691. /// <exception cref="ArgumentNullException">
  14692. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14693. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  14694. {
  14695. if (source == null)
  14696. throw new ArgumentNullException(nameof(source));
  14697. if (scheduler == null)
  14698. throw new ArgumentNullException(nameof(scheduler));
  14699. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14700. Expression.Call(
  14701. null,
  14702. #if CRIPPLED_REFLECTION
  14703. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  14704. #else
  14705. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14706. #endif
  14707. source.Expression,
  14708. Expression.Constant(scheduler, typeof(IScheduler))
  14709. )
  14710. );
  14711. }
  14712. /// <summary>
  14713. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14714. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14715. /// </summary>
  14716. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14717. /// <param name="source">Source sequence to perform a timeout for.</param>
  14718. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14719. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14720. /// <exception cref="ArgumentNullException">
  14721. /// <paramref name="source" /> is null.</exception>
  14722. /// <exception cref="TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14723. /// <remarks>
  14724. /// 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})" />
  14725. /// 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
  14726. /// 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.
  14727. /// </remarks>
  14728. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  14729. {
  14730. if (source == null)
  14731. throw new ArgumentNullException(nameof(source));
  14732. return source.Provider.CreateQuery<TSource>(
  14733. Expression.Call(
  14734. null,
  14735. #if CRIPPLED_REFLECTION
  14736. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14737. #else
  14738. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14739. #endif
  14740. source.Expression,
  14741. Expression.Constant(dueTime, typeof(DateTimeOffset))
  14742. )
  14743. );
  14744. }
  14745. /// <summary>
  14746. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14747. /// 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.
  14748. /// </summary>
  14749. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14750. /// <param name="source">Source sequence to perform a timeout for.</param>
  14751. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14752. /// <param name="other">Sequence to return in case of a timeout.</param>
  14753. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14754. /// <exception cref="ArgumentNullException">
  14755. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14756. /// <remarks>
  14757. /// 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})" />
  14758. /// 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
  14759. /// 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.
  14760. /// </remarks>
  14761. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other)
  14762. {
  14763. if (source == null)
  14764. throw new ArgumentNullException(nameof(source));
  14765. if (other == null)
  14766. throw new ArgumentNullException(nameof(other));
  14767. return source.Provider.CreateQuery<TSource>(
  14768. Expression.Call(
  14769. null,
  14770. #if CRIPPLED_REFLECTION
  14771. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>))),
  14772. #else
  14773. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14774. #endif
  14775. source.Expression,
  14776. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14777. GetSourceExpression(other)
  14778. )
  14779. );
  14780. }
  14781. /// <summary>
  14782. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14783. /// 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.
  14784. /// </summary>
  14785. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14786. /// <param name="source">Source sequence to perform a timeout for.</param>
  14787. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14788. /// <param name="other">Sequence to return in case of a timeout.</param>
  14789. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14790. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14791. /// <exception cref="ArgumentNullException">
  14792. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14793. /// <remarks>
  14794. /// 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})" />
  14795. /// 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
  14796. /// 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.
  14797. /// </remarks>
  14798. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other, IScheduler scheduler)
  14799. {
  14800. if (source == null)
  14801. throw new ArgumentNullException(nameof(source));
  14802. if (other == null)
  14803. throw new ArgumentNullException(nameof(other));
  14804. if (scheduler == null)
  14805. throw new ArgumentNullException(nameof(scheduler));
  14806. return source.Provider.CreateQuery<TSource>(
  14807. Expression.Call(
  14808. null,
  14809. #if CRIPPLED_REFLECTION
  14810. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>), default(IScheduler))),
  14811. #else
  14812. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14813. #endif
  14814. source.Expression,
  14815. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14816. GetSourceExpression(other),
  14817. Expression.Constant(scheduler, typeof(IScheduler))
  14818. )
  14819. );
  14820. }
  14821. /// <summary>
  14822. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14823. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14824. /// </summary>
  14825. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14826. /// <param name="source">Source sequence to perform a timeout for.</param>
  14827. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14828. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14829. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14830. /// <exception cref="ArgumentNullException">
  14831. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14832. /// <exception cref="TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14833. /// <remarks>
  14834. /// In case you only want to timeout on the first element, consider using the <see cref="M:System.Reactive.Linq.Observable.Amb``1(System.IObservable{``0},System.IObservable{``0})" />
  14835. /// operator applied to the source sequence and a delayed <see cref="M:System.Reactive.Linq.Observable.Throw``1(System.Exception)" /> sequence. Alternatively, the general-purpose overload
  14836. /// of Timeout, <see cref="M:System.Reactive.Linq.Observable.Timeout``2(System.IObservable{``0},System.IObservable{``1},System.Func{``0,System.IObservable{``1}})" /> can be used.
  14837. /// </remarks>
  14838. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  14839. {
  14840. if (source == null)
  14841. throw new ArgumentNullException(nameof(source));
  14842. if (scheduler == null)
  14843. throw new ArgumentNullException(nameof(scheduler));
  14844. return source.Provider.CreateQuery<TSource>(
  14845. Expression.Call(
  14846. null,
  14847. #if CRIPPLED_REFLECTION
  14848. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14849. #else
  14850. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14851. #endif
  14852. source.Expression,
  14853. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14854. Expression.Constant(scheduler, typeof(IScheduler))
  14855. )
  14856. );
  14857. }
  14858. /// <summary>
  14859. /// Applies a timeout policy for each element in the observable sequence.
  14860. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14861. /// </summary>
  14862. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14863. /// <param name="source">Source sequence to perform a timeout for.</param>
  14864. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14865. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14866. /// <exception cref="ArgumentNullException">
  14867. /// <paramref name="source" /> is null.</exception>
  14868. /// <exception cref="ArgumentOutOfRangeException">
  14869. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14870. /// <exception cref="TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14871. /// <remarks>
  14872. /// <para>
  14873. /// 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})" />
  14874. /// 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
  14875. /// 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.
  14876. /// </para>
  14877. /// <para>
  14878. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14879. /// 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
  14880. /// 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
  14881. /// arrive before the scheduler gets a chance to run the timeout action.
  14882. /// </para>
  14883. /// </remarks>
  14884. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14885. {
  14886. if (source == null)
  14887. throw new ArgumentNullException(nameof(source));
  14888. return source.Provider.CreateQuery<TSource>(
  14889. Expression.Call(
  14890. null,
  14891. #if CRIPPLED_REFLECTION
  14892. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14893. #else
  14894. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14895. #endif
  14896. source.Expression,
  14897. Expression.Constant(dueTime, typeof(TimeSpan))
  14898. )
  14899. );
  14900. }
  14901. /// <summary>
  14902. /// Applies a timeout policy for each element in the observable sequence.
  14903. /// 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.
  14904. /// </summary>
  14905. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14906. /// <param name="source">Source sequence to perform a timeout for.</param>
  14907. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14908. /// <param name="other">Sequence to return in case of a timeout.</param>
  14909. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14910. /// <exception cref="ArgumentNullException">
  14911. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14912. /// <exception cref="ArgumentOutOfRangeException">
  14913. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14914. /// <remarks>
  14915. /// <para>
  14916. /// 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})" />
  14917. /// 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
  14918. /// 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.
  14919. /// </para>
  14920. /// <para>
  14921. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14922. /// 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
  14923. /// 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
  14924. /// arrive before the scheduler gets a chance to run the timeout action.
  14925. /// </para>
  14926. /// </remarks>
  14927. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other)
  14928. {
  14929. if (source == null)
  14930. throw new ArgumentNullException(nameof(source));
  14931. if (other == null)
  14932. throw new ArgumentNullException(nameof(other));
  14933. return source.Provider.CreateQuery<TSource>(
  14934. Expression.Call(
  14935. null,
  14936. #if CRIPPLED_REFLECTION
  14937. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>))),
  14938. #else
  14939. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14940. #endif
  14941. source.Expression,
  14942. Expression.Constant(dueTime, typeof(TimeSpan)),
  14943. GetSourceExpression(other)
  14944. )
  14945. );
  14946. }
  14947. /// <summary>
  14948. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14949. /// 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.
  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. /// <param name="source">Source sequence to perform a timeout for.</param>
  14953. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14954. /// <param name="other">Sequence to return in case of a timeout.</param>
  14955. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14956. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14957. /// <exception cref="ArgumentNullException">
  14958. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14959. /// <exception cref="ArgumentOutOfRangeException">
  14960. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14961. /// <remarks>
  14962. /// <para>
  14963. /// 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})" />
  14964. /// 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
  14965. /// 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.
  14966. /// </para>
  14967. /// <para>
  14968. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14969. /// 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
  14970. /// 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
  14971. /// arrive before the scheduler gets a chance to run the timeout action.
  14972. /// </para>
  14973. /// </remarks>
  14974. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other, IScheduler scheduler)
  14975. {
  14976. if (source == null)
  14977. throw new ArgumentNullException(nameof(source));
  14978. if (other == null)
  14979. throw new ArgumentNullException(nameof(other));
  14980. if (scheduler == null)
  14981. throw new ArgumentNullException(nameof(scheduler));
  14982. return source.Provider.CreateQuery<TSource>(
  14983. Expression.Call(
  14984. null,
  14985. #if CRIPPLED_REFLECTION
  14986. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>), default(IScheduler))),
  14987. #else
  14988. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14989. #endif
  14990. source.Expression,
  14991. Expression.Constant(dueTime, typeof(TimeSpan)),
  14992. GetSourceExpression(other),
  14993. Expression.Constant(scheduler, typeof(IScheduler))
  14994. )
  14995. );
  14996. }
  14997. /// <summary>
  14998. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14999. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  15000. /// </summary>
  15001. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15002. /// <param name="source">Source sequence to perform a timeout for.</param>
  15003. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  15004. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  15005. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  15006. /// <exception cref="ArgumentNullException">
  15007. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15008. /// <exception cref="ArgumentOutOfRangeException">
  15009. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  15010. /// <exception cref="TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  15011. /// <remarks>
  15012. /// <para>
  15013. /// 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})" />
  15014. /// 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
  15015. /// 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.
  15016. /// </para>
  15017. /// <para>
  15018. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  15019. /// 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
  15020. /// 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
  15021. /// arrive before the scheduler gets a chance to run the timeout action.
  15022. /// </para>
  15023. /// </remarks>
  15024. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  15025. {
  15026. if (source == null)
  15027. throw new ArgumentNullException(nameof(source));
  15028. if (scheduler == null)
  15029. throw new ArgumentNullException(nameof(scheduler));
  15030. return source.Provider.CreateQuery<TSource>(
  15031. Expression.Call(
  15032. null,
  15033. #if CRIPPLED_REFLECTION
  15034. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  15035. #else
  15036. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15037. #endif
  15038. source.Expression,
  15039. Expression.Constant(dueTime, typeof(TimeSpan)),
  15040. Expression.Constant(scheduler, typeof(IScheduler))
  15041. )
  15042. );
  15043. }
  15044. /// <summary>
  15045. /// 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.
  15046. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  15047. /// </summary>
  15048. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15049. /// <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>
  15050. /// <param name="source">Source sequence to perform a timeout for.</param>
  15051. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  15052. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15053. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  15054. /// <exception cref="ArgumentNullException">
  15055. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  15056. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  15057. {
  15058. if (source == null)
  15059. throw new ArgumentNullException(nameof(source));
  15060. if (firstTimeout == null)
  15061. throw new ArgumentNullException(nameof(firstTimeout));
  15062. if (timeoutDurationSelector == null)
  15063. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  15064. return source.Provider.CreateQuery<TSource>(
  15065. Expression.Call(
  15066. null,
  15067. #if CRIPPLED_REFLECTION
  15068. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  15069. #else
  15070. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15071. #endif
  15072. source.Expression,
  15073. GetSourceExpression(firstTimeout),
  15074. timeoutDurationSelector
  15075. )
  15076. );
  15077. }
  15078. /// <summary>
  15079. /// 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.
  15080. /// 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.
  15081. /// </summary>
  15082. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  15083. /// <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>
  15084. /// <param name="source">Source sequence to perform a timeout for.</param>
  15085. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  15086. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15087. /// <param name="other">Sequence to return in case of a timeout.</param>
  15088. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15089. /// <exception cref="ArgumentNullException">
  15090. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  15091. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  15092. {
  15093. if (source == null)
  15094. throw new ArgumentNullException(nameof(source));
  15095. if (firstTimeout == null)
  15096. throw new ArgumentNullException(nameof(firstTimeout));
  15097. if (timeoutDurationSelector == null)
  15098. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  15099. if (other == null)
  15100. throw new ArgumentNullException(nameof(other));
  15101. return source.Provider.CreateQuery<TSource>(
  15102. Expression.Call(
  15103. null,
  15104. #if CRIPPLED_REFLECTION
  15105. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  15106. #else
  15107. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15108. #endif
  15109. source.Expression,
  15110. GetSourceExpression(firstTimeout),
  15111. timeoutDurationSelector,
  15112. GetSourceExpression(other)
  15113. )
  15114. );
  15115. }
  15116. /// <summary>
  15117. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  15118. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  15119. /// </summary>
  15120. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15121. /// <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>
  15122. /// <param name="source">Source sequence to perform a timeout for.</param>
  15123. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15124. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  15125. /// <exception cref="ArgumentNullException">
  15126. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  15127. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  15128. {
  15129. if (source == null)
  15130. throw new ArgumentNullException(nameof(source));
  15131. if (timeoutDurationSelector == null)
  15132. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  15133. return source.Provider.CreateQuery<TSource>(
  15134. Expression.Call(
  15135. null,
  15136. #if CRIPPLED_REFLECTION
  15137. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  15138. #else
  15139. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15140. #endif
  15141. source.Expression,
  15142. timeoutDurationSelector
  15143. )
  15144. );
  15145. }
  15146. /// <summary>
  15147. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  15148. /// 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.
  15149. /// </summary>
  15150. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  15151. /// <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>
  15152. /// <param name="source">Source sequence to perform a timeout for.</param>
  15153. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  15154. /// <param name="other">Sequence to return in case of a timeout.</param>
  15155. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  15156. /// <exception cref="ArgumentNullException">
  15157. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  15158. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  15159. {
  15160. if (source == null)
  15161. throw new ArgumentNullException(nameof(source));
  15162. if (timeoutDurationSelector == null)
  15163. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  15164. if (other == null)
  15165. throw new ArgumentNullException(nameof(other));
  15166. return source.Provider.CreateQuery<TSource>(
  15167. Expression.Call(
  15168. null,
  15169. #if CRIPPLED_REFLECTION
  15170. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  15171. #else
  15172. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  15173. #endif
  15174. source.Expression,
  15175. timeoutDurationSelector,
  15176. GetSourceExpression(other)
  15177. )
  15178. );
  15179. }
  15180. /// <summary>
  15181. /// Returns an observable sequence that produces a single value at the specified absolute due time.
  15182. /// </summary>
  15183. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15184. /// <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>
  15185. /// <returns>An observable sequence that produces a value at due time.</returns>
  15186. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime)
  15187. {
  15188. if (provider == null)
  15189. throw new ArgumentNullException(nameof(provider));
  15190. return provider.CreateQuery<long>(
  15191. Expression.Call(
  15192. null,
  15193. #if CRIPPLED_REFLECTION
  15194. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset))),
  15195. #else
  15196. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15197. #endif
  15198. Expression.Constant(provider, typeof(IQbservableProvider)),
  15199. Expression.Constant(dueTime, typeof(DateTimeOffset))
  15200. )
  15201. );
  15202. }
  15203. /// <summary>
  15204. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time.
  15205. /// </summary>
  15206. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15207. /// <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>
  15208. /// <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>
  15209. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  15210. /// <exception cref="ArgumentOutOfRangeException">
  15211. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15212. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period)
  15213. {
  15214. if (provider == null)
  15215. throw new ArgumentNullException(nameof(provider));
  15216. return provider.CreateQuery<long>(
  15217. Expression.Call(
  15218. null,
  15219. #if CRIPPLED_REFLECTION
  15220. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan))),
  15221. #else
  15222. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15223. #endif
  15224. Expression.Constant(provider, typeof(IQbservableProvider)),
  15225. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15226. Expression.Constant(period, typeof(TimeSpan))
  15227. )
  15228. );
  15229. }
  15230. /// <summary>
  15231. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time, using the specified scheduler to run timers.
  15232. /// </summary>
  15233. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15234. /// <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>
  15235. /// <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>
  15236. /// <param name="scheduler">Scheduler to run timers on.</param>
  15237. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  15238. /// <exception cref="ArgumentOutOfRangeException">
  15239. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15240. /// <exception cref="ArgumentNullException">
  15241. /// <paramref name="scheduler" /> is null.</exception>
  15242. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period, IScheduler scheduler)
  15243. {
  15244. if (provider == null)
  15245. throw new ArgumentNullException(nameof(provider));
  15246. if (scheduler == null)
  15247. throw new ArgumentNullException(nameof(scheduler));
  15248. return provider.CreateQuery<long>(
  15249. Expression.Call(
  15250. null,
  15251. #if CRIPPLED_REFLECTION
  15252. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan), default(IScheduler))),
  15253. #else
  15254. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15255. #endif
  15256. Expression.Constant(provider, typeof(IQbservableProvider)),
  15257. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15258. Expression.Constant(period, typeof(TimeSpan)),
  15259. Expression.Constant(scheduler, typeof(IScheduler))
  15260. )
  15261. );
  15262. }
  15263. /// <summary>
  15264. /// Returns an observable sequence that produces a single value at the specified absolute due time, using the specified scheduler to run the timer.
  15265. /// </summary>
  15266. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15267. /// <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>
  15268. /// <param name="scheduler">Scheduler to run the timer on.</param>
  15269. /// <returns>An observable sequence that produces a value at due time.</returns>
  15270. /// <exception cref="ArgumentNullException">
  15271. /// <paramref name="scheduler" /> is null.</exception>
  15272. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, IScheduler scheduler)
  15273. {
  15274. if (provider == null)
  15275. throw new ArgumentNullException(nameof(provider));
  15276. if (scheduler == null)
  15277. throw new ArgumentNullException(nameof(scheduler));
  15278. return provider.CreateQuery<long>(
  15279. Expression.Call(
  15280. null,
  15281. #if CRIPPLED_REFLECTION
  15282. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(IScheduler))),
  15283. #else
  15284. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15285. #endif
  15286. Expression.Constant(provider, typeof(IQbservableProvider)),
  15287. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  15288. Expression.Constant(scheduler, typeof(IScheduler))
  15289. )
  15290. );
  15291. }
  15292. /// <summary>
  15293. /// Returns an observable sequence that produces a single value after the specified relative due time has elapsed.
  15294. /// </summary>
  15295. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15296. /// <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>
  15297. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15298. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime)
  15299. {
  15300. if (provider == null)
  15301. throw new ArgumentNullException(nameof(provider));
  15302. return provider.CreateQuery<long>(
  15303. Expression.Call(
  15304. null,
  15305. #if CRIPPLED_REFLECTION
  15306. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan))),
  15307. #else
  15308. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15309. #endif
  15310. Expression.Constant(provider, typeof(IQbservableProvider)),
  15311. Expression.Constant(dueTime, typeof(TimeSpan))
  15312. )
  15313. );
  15314. }
  15315. /// <summary>
  15316. /// Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed.
  15317. /// </summary>
  15318. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15319. /// <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>
  15320. /// <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>
  15321. /// <returns>An observable sequence that produces a value after due time has elapsed and then after each period.</returns>
  15322. /// <exception cref="ArgumentOutOfRangeException">
  15323. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15324. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period)
  15325. {
  15326. if (provider == null)
  15327. throw new ArgumentNullException(nameof(provider));
  15328. return provider.CreateQuery<long>(
  15329. Expression.Call(
  15330. null,
  15331. #if CRIPPLED_REFLECTION
  15332. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan))),
  15333. #else
  15334. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15335. #endif
  15336. Expression.Constant(provider, typeof(IQbservableProvider)),
  15337. Expression.Constant(dueTime, typeof(TimeSpan)),
  15338. Expression.Constant(period, typeof(TimeSpan))
  15339. )
  15340. );
  15341. }
  15342. /// <summary>
  15343. /// 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.
  15344. /// </summary>
  15345. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15346. /// <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>
  15347. /// <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>
  15348. /// <param name="scheduler">Scheduler to run timers on.</param>
  15349. /// <returns>An observable sequence that produces a value after due time has elapsed and then each period.</returns>
  15350. /// <exception cref="ArgumentOutOfRangeException">
  15351. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  15352. /// <exception cref="ArgumentNullException">
  15353. /// <paramref name="scheduler" /> is null.</exception>
  15354. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period, IScheduler scheduler)
  15355. {
  15356. if (provider == null)
  15357. throw new ArgumentNullException(nameof(provider));
  15358. if (scheduler == null)
  15359. throw new ArgumentNullException(nameof(scheduler));
  15360. return provider.CreateQuery<long>(
  15361. Expression.Call(
  15362. null,
  15363. #if CRIPPLED_REFLECTION
  15364. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  15365. #else
  15366. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15367. #endif
  15368. Expression.Constant(provider, typeof(IQbservableProvider)),
  15369. Expression.Constant(dueTime, typeof(TimeSpan)),
  15370. Expression.Constant(period, typeof(TimeSpan)),
  15371. Expression.Constant(scheduler, typeof(IScheduler))
  15372. )
  15373. );
  15374. }
  15375. /// <summary>
  15376. /// 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.
  15377. /// </summary>
  15378. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15379. /// <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>
  15380. /// <param name="scheduler">Scheduler to run the timer on.</param>
  15381. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  15382. /// <exception cref="ArgumentNullException">
  15383. /// <paramref name="scheduler" /> is null.</exception>
  15384. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, IScheduler scheduler)
  15385. {
  15386. if (provider == null)
  15387. throw new ArgumentNullException(nameof(provider));
  15388. if (scheduler == null)
  15389. throw new ArgumentNullException(nameof(scheduler));
  15390. return provider.CreateQuery<long>(
  15391. Expression.Call(
  15392. null,
  15393. #if CRIPPLED_REFLECTION
  15394. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  15395. #else
  15396. (MethodInfo)MethodInfo.GetCurrentMethod(),
  15397. #endif
  15398. Expression.Constant(provider, typeof(IQbservableProvider)),
  15399. Expression.Constant(dueTime, typeof(TimeSpan)),
  15400. Expression.Constant(scheduler, typeof(IScheduler))
  15401. )
  15402. );
  15403. }
  15404. /// <summary>
  15405. /// Timestamps each element in an observable sequence using the local system clock.
  15406. /// </summary>
  15407. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15408. /// <param name="source">Source sequence to timestamp elements for.</param>
  15409. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15410. /// <exception cref="ArgumentNullException">
  15411. /// <paramref name="source" /> is null.</exception>
  15412. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source)
  15413. {
  15414. if (source == null)
  15415. throw new ArgumentNullException(nameof(source));
  15416. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15417. Expression.Call(
  15418. null,
  15419. #if CRIPPLED_REFLECTION
  15420. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>))),
  15421. #else
  15422. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15423. #endif
  15424. source.Expression
  15425. )
  15426. );
  15427. }
  15428. /// <summary>
  15429. /// Timestamp each element in an observable sequence using the clock of the specified scheduler.
  15430. /// </summary>
  15431. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15432. /// <param name="source">Source sequence to timestamp elements for.</param>
  15433. /// <param name="scheduler">Scheduler used to compute timestamps.</param>
  15434. /// <returns>An observable sequence with timestamp information on elements.</returns>
  15435. /// <exception cref="ArgumentNullException">
  15436. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15437. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  15438. {
  15439. if (source == null)
  15440. throw new ArgumentNullException(nameof(source));
  15441. if (scheduler == null)
  15442. throw new ArgumentNullException(nameof(scheduler));
  15443. return source.Provider.CreateQuery<Timestamped<TSource>>(
  15444. Expression.Call(
  15445. null,
  15446. #if CRIPPLED_REFLECTION
  15447. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  15448. #else
  15449. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15450. #endif
  15451. source.Expression,
  15452. Expression.Constant(scheduler, typeof(IScheduler))
  15453. )
  15454. );
  15455. }
  15456. /// <summary>
  15457. /// Creates an array from an observable sequence.
  15458. /// </summary>
  15459. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15460. /// <param name="source">The source observable sequence to get an array of elements for.</param>
  15461. /// <returns>An observable sequence containing a single element with an array containing all the elements of the source sequence.</returns>
  15462. /// <exception cref="ArgumentNullException">
  15463. /// <paramref name="source" /> is null.</exception>
  15464. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15465. public static IQbservable<TSource[]> ToArray<TSource>(this IQbservable<TSource> source)
  15466. {
  15467. if (source == null)
  15468. throw new ArgumentNullException(nameof(source));
  15469. return source.Provider.CreateQuery<TSource[]>(
  15470. Expression.Call(
  15471. null,
  15472. #if CRIPPLED_REFLECTION
  15473. InfoOf(() => Qbservable.ToArray<TSource>(default(IQbservable<TSource>))),
  15474. #else
  15475. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15476. #endif
  15477. source.Expression
  15478. )
  15479. );
  15480. }
  15481. /// <summary>
  15482. /// Creates a dictionary from an observable sequence according to a specified key selector function.
  15483. /// </summary>
  15484. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15485. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15486. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15487. /// <param name="keySelector">A function to extract a key from each element.</param>
  15488. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15489. /// <exception cref="ArgumentNullException">
  15490. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15491. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15492. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15493. where TKey : notnull
  15494. {
  15495. if (source == null)
  15496. throw new ArgumentNullException(nameof(source));
  15497. if (keySelector == null)
  15498. throw new ArgumentNullException(nameof(keySelector));
  15499. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15500. Expression.Call(
  15501. null,
  15502. #if CRIPPLED_REFLECTION
  15503. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15504. #else
  15505. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15506. #endif
  15507. source.Expression,
  15508. keySelector
  15509. )
  15510. );
  15511. }
  15512. /// <summary>
  15513. /// Creates a dictionary from an observable sequence according to a specified key selector function, and a comparer.
  15514. /// </summary>
  15515. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15516. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15517. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15518. /// <param name="keySelector">A function to extract a key from each element.</param>
  15519. /// <param name="comparer">An equality comparer to compare keys.</param>
  15520. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15521. /// <exception cref="ArgumentNullException">
  15522. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15523. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15524. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15525. where TKey : notnull
  15526. {
  15527. if (source == null)
  15528. throw new ArgumentNullException(nameof(source));
  15529. if (keySelector == null)
  15530. throw new ArgumentNullException(nameof(keySelector));
  15531. if (comparer == null)
  15532. throw new ArgumentNullException(nameof(comparer));
  15533. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15534. Expression.Call(
  15535. null,
  15536. #if CRIPPLED_REFLECTION
  15537. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15538. #else
  15539. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15540. #endif
  15541. source.Expression,
  15542. keySelector,
  15543. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15544. )
  15545. );
  15546. }
  15547. /// <summary>
  15548. /// Creates a dictionary from an observable sequence according to a specified key selector function, and an element selector function.
  15549. /// </summary>
  15550. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15551. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15552. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15553. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15554. /// <param name="keySelector">A function to extract a key from each element.</param>
  15555. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15556. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15557. /// <exception cref="ArgumentNullException">
  15558. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15559. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15560. public static IQbservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15561. where TKey : notnull
  15562. {
  15563. if (source == null)
  15564. throw new ArgumentNullException(nameof(source));
  15565. if (keySelector == null)
  15566. throw new ArgumentNullException(nameof(keySelector));
  15567. if (elementSelector == null)
  15568. throw new ArgumentNullException(nameof(elementSelector));
  15569. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15570. Expression.Call(
  15571. null,
  15572. #if CRIPPLED_REFLECTION
  15573. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15574. #else
  15575. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15576. #endif
  15577. source.Expression,
  15578. keySelector,
  15579. elementSelector
  15580. )
  15581. );
  15582. }
  15583. /// <summary>
  15584. /// Creates a dictionary from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15585. /// </summary>
  15586. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15587. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15588. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15589. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15590. /// <param name="keySelector">A function to extract a key from each element.</param>
  15591. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15592. /// <param name="comparer">An equality comparer to compare keys.</param>
  15593. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15594. /// <exception cref="ArgumentNullException">
  15595. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15596. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15597. 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)
  15598. where TKey : notnull
  15599. {
  15600. if (source == null)
  15601. throw new ArgumentNullException(nameof(source));
  15602. if (keySelector == null)
  15603. throw new ArgumentNullException(nameof(keySelector));
  15604. if (elementSelector == null)
  15605. throw new ArgumentNullException(nameof(elementSelector));
  15606. if (comparer == null)
  15607. throw new ArgumentNullException(nameof(comparer));
  15608. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15609. Expression.Call(
  15610. null,
  15611. #if CRIPPLED_REFLECTION
  15612. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15613. #else
  15614. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15615. #endif
  15616. source.Expression,
  15617. keySelector,
  15618. elementSelector,
  15619. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15620. )
  15621. );
  15622. }
  15623. /// <summary>
  15624. /// Converts an observable sequence to an enumerable sequence.
  15625. /// </summary>
  15626. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15627. /// <param name="source">An observable sequence to convert to an enumerable sequence.</param>
  15628. /// <returns>The enumerable sequence containing the elements in the observable sequence.</returns>
  15629. /// <exception cref="ArgumentNullException">
  15630. /// <paramref name="source" /> is null.</exception>
  15631. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  15632. public static IQueryable<TSource> ToQueryable<TSource>(this IQbservable<TSource> source)
  15633. {
  15634. if (source == null)
  15635. throw new ArgumentNullException(nameof(source));
  15636. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  15637. Expression.Call(
  15638. null,
  15639. #if CRIPPLED_REFLECTION
  15640. InfoOf(() => Qbservable.ToQueryable<TSource>(default(IQbservable<TSource>))),
  15641. #else
  15642. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15643. #endif
  15644. source.Expression
  15645. )
  15646. );
  15647. }
  15648. /// <summary>
  15649. /// Creates a list from an observable sequence.
  15650. /// </summary>
  15651. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15652. /// <param name="source">The source observable sequence to get a list of elements for.</param>
  15653. /// <returns>An observable sequence containing a single element with a list containing all the elements of the source sequence.</returns>
  15654. /// <exception cref="ArgumentNullException">
  15655. /// <paramref name="source" /> is null.</exception>
  15656. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15657. public static IQbservable<IList<TSource>> ToList<TSource>(this IQbservable<TSource> source)
  15658. {
  15659. if (source == null)
  15660. throw new ArgumentNullException(nameof(source));
  15661. return source.Provider.CreateQuery<IList<TSource>>(
  15662. Expression.Call(
  15663. null,
  15664. #if CRIPPLED_REFLECTION
  15665. InfoOf(() => Qbservable.ToList<TSource>(default(IQbservable<TSource>))),
  15666. #else
  15667. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15668. #endif
  15669. source.Expression
  15670. )
  15671. );
  15672. }
  15673. /// <summary>
  15674. /// Creates a lookup from an observable sequence according to a specified key selector function.
  15675. /// </summary>
  15676. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15677. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15678. /// <param name="source">An observable sequence to create a lookup for.</param>
  15679. /// <param name="keySelector">A function to extract a key from each element.</param>
  15680. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15681. /// <exception cref="ArgumentNullException">
  15682. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15683. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15684. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15685. {
  15686. if (source == null)
  15687. throw new ArgumentNullException(nameof(source));
  15688. if (keySelector == null)
  15689. throw new ArgumentNullException(nameof(keySelector));
  15690. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15691. Expression.Call(
  15692. null,
  15693. #if CRIPPLED_REFLECTION
  15694. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15695. #else
  15696. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15697. #endif
  15698. source.Expression,
  15699. keySelector
  15700. )
  15701. );
  15702. }
  15703. /// <summary>
  15704. /// Creates a lookup from an observable sequence according to a specified key selector function, and a comparer.
  15705. /// </summary>
  15706. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15707. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15708. /// <param name="source">An observable sequence to create a lookup for.</param>
  15709. /// <param name="keySelector">A function to extract a key from each element.</param>
  15710. /// <param name="comparer">An equality comparer to compare keys.</param>
  15711. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15712. /// <exception cref="ArgumentNullException">
  15713. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15714. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15715. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15716. {
  15717. if (source == null)
  15718. throw new ArgumentNullException(nameof(source));
  15719. if (keySelector == null)
  15720. throw new ArgumentNullException(nameof(keySelector));
  15721. if (comparer == null)
  15722. throw new ArgumentNullException(nameof(comparer));
  15723. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15724. Expression.Call(
  15725. null,
  15726. #if CRIPPLED_REFLECTION
  15727. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15728. #else
  15729. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15730. #endif
  15731. source.Expression,
  15732. keySelector,
  15733. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15734. )
  15735. );
  15736. }
  15737. /// <summary>
  15738. /// Creates a lookup from an observable sequence according to a specified key selector function, and an element selector function.
  15739. /// </summary>
  15740. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15741. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15742. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15743. /// <param name="source">An observable sequence to create a lookup for.</param>
  15744. /// <param name="keySelector">A function to extract a key from each element.</param>
  15745. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15746. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15747. /// <exception cref="ArgumentNullException">
  15748. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15749. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15750. public static IQbservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15751. {
  15752. if (source == null)
  15753. throw new ArgumentNullException(nameof(source));
  15754. if (keySelector == null)
  15755. throw new ArgumentNullException(nameof(keySelector));
  15756. if (elementSelector == null)
  15757. throw new ArgumentNullException(nameof(elementSelector));
  15758. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15759. Expression.Call(
  15760. null,
  15761. #if CRIPPLED_REFLECTION
  15762. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15763. #else
  15764. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15765. #endif
  15766. source.Expression,
  15767. keySelector,
  15768. elementSelector
  15769. )
  15770. );
  15771. }
  15772. /// <summary>
  15773. /// Creates a lookup from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15774. /// </summary>
  15775. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15776. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15777. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15778. /// <param name="source">An observable sequence to create a lookup for.</param>
  15779. /// <param name="keySelector">A function to extract a key from each element.</param>
  15780. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15781. /// <param name="comparer">An equality comparer to compare keys.</param>
  15782. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15783. /// <exception cref="ArgumentNullException">
  15784. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15785. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15786. 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)
  15787. {
  15788. if (source == null)
  15789. throw new ArgumentNullException(nameof(source));
  15790. if (keySelector == null)
  15791. throw new ArgumentNullException(nameof(keySelector));
  15792. if (elementSelector == null)
  15793. throw new ArgumentNullException(nameof(elementSelector));
  15794. if (comparer == null)
  15795. throw new ArgumentNullException(nameof(comparer));
  15796. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15797. Expression.Call(
  15798. null,
  15799. #if CRIPPLED_REFLECTION
  15800. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15801. #else
  15802. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15803. #endif
  15804. source.Expression,
  15805. keySelector,
  15806. elementSelector,
  15807. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15808. )
  15809. );
  15810. }
  15811. /// <summary>
  15812. /// Converts an enumerable sequence to an observable sequence.
  15813. /// </summary>
  15814. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15815. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15816. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15817. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15818. /// <exception cref="ArgumentNullException">
  15819. /// <paramref name="source" /> is null.</exception>
  15820. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source)
  15821. {
  15822. if (provider == null)
  15823. throw new ArgumentNullException(nameof(provider));
  15824. if (source == null)
  15825. throw new ArgumentNullException(nameof(source));
  15826. return provider.CreateQuery<TSource>(
  15827. Expression.Call(
  15828. null,
  15829. #if CRIPPLED_REFLECTION
  15830. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>))),
  15831. #else
  15832. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15833. #endif
  15834. Expression.Constant(provider, typeof(IQbservableProvider)),
  15835. GetSourceExpression(source)
  15836. )
  15837. );
  15838. }
  15839. /// <summary>
  15840. /// Converts an enumerable sequence to an observable sequence, using the specified scheduler to run the enumeration loop.
  15841. /// </summary>
  15842. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15843. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15844. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15845. /// <param name="scheduler">Scheduler to run the enumeration of the input sequence on.</param>
  15846. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15847. /// <exception cref="ArgumentNullException">
  15848. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15849. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source, IScheduler scheduler)
  15850. {
  15851. if (provider == null)
  15852. throw new ArgumentNullException(nameof(provider));
  15853. if (source == null)
  15854. throw new ArgumentNullException(nameof(source));
  15855. if (scheduler == null)
  15856. throw new ArgumentNullException(nameof(scheduler));
  15857. return provider.CreateQuery<TSource>(
  15858. Expression.Call(
  15859. null,
  15860. #if CRIPPLED_REFLECTION
  15861. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>), default(IScheduler))),
  15862. #else
  15863. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15864. #endif
  15865. Expression.Constant(provider, typeof(IQbservableProvider)),
  15866. GetSourceExpression(source),
  15867. Expression.Constant(scheduler, typeof(IScheduler))
  15868. )
  15869. );
  15870. }
  15871. /// <summary>
  15872. /// Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
  15873. /// </summary>
  15874. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15875. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15876. /// <typeparam name="TResource">The type of the resource used during the generation of the resulting sequence. Needs to implement <see cref="IDisposable" />.</typeparam>
  15877. /// <param name="resourceFactory">Factory function to obtain a resource object.</param>
  15878. /// <param name="observableFactory">Factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15879. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15880. /// <exception cref="ArgumentNullException">
  15881. /// <paramref name="resourceFactory" /> or <paramref name="observableFactory" /> is null.</exception>
  15882. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<TResource>> resourceFactory, Expression<Func<TResource, IObservable<TResult>>> observableFactory)
  15883. where TResource : IDisposable
  15884. {
  15885. if (provider == null)
  15886. throw new ArgumentNullException(nameof(provider));
  15887. if (resourceFactory == null)
  15888. throw new ArgumentNullException(nameof(resourceFactory));
  15889. if (observableFactory == null)
  15890. throw new ArgumentNullException(nameof(observableFactory));
  15891. return provider.CreateQuery<TResult>(
  15892. Expression.Call(
  15893. null,
  15894. #if CRIPPLED_REFLECTION
  15895. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<TResource>>), default(Expression<Func<TResource, IObservable<TResult>>>))),
  15896. #else
  15897. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15898. #endif
  15899. Expression.Constant(provider, typeof(IQbservableProvider)),
  15900. resourceFactory,
  15901. observableFactory
  15902. )
  15903. );
  15904. }
  15905. /// <summary>
  15906. /// 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.
  15907. /// 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.
  15908. /// </summary>
  15909. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15910. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15911. /// <typeparam name="TResource">The type of the resource used during the generation of the resulting sequence. Needs to implement <see cref="IDisposable" />.</typeparam>
  15912. /// <param name="resourceFactoryAsync">Asynchronous factory function to obtain a resource object.</param>
  15913. /// <param name="observableFactoryAsync">Asynchronous factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15914. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15915. /// <exception cref="ArgumentNullException">
  15916. /// <paramref name="resourceFactoryAsync" /> or <paramref name="observableFactoryAsync" /> is null.</exception>
  15917. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  15918. /// <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>
  15919. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResource>>> resourceFactoryAsync, Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  15920. where TResource : IDisposable
  15921. {
  15922. if (provider == null)
  15923. throw new ArgumentNullException(nameof(provider));
  15924. if (resourceFactoryAsync == null)
  15925. throw new ArgumentNullException(nameof(resourceFactoryAsync));
  15926. if (observableFactoryAsync == null)
  15927. throw new ArgumentNullException(nameof(observableFactoryAsync));
  15928. return provider.CreateQuery<TResult>(
  15929. Expression.Call(
  15930. null,
  15931. #if CRIPPLED_REFLECTION
  15932. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResource>>>), default(Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>>))),
  15933. #else
  15934. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15935. #endif
  15936. Expression.Constant(provider, typeof(IQbservableProvider)),
  15937. resourceFactoryAsync,
  15938. observableFactoryAsync
  15939. )
  15940. );
  15941. }
  15942. /// <summary>
  15943. /// Filters the elements of an observable sequence based on a predicate.
  15944. /// </summary>
  15945. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15946. /// <param name="source">An observable sequence whose elements to filter.</param>
  15947. /// <param name="predicate">A function to test each source element for a condition.</param>
  15948. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15949. /// <exception cref="ArgumentNullException">
  15950. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15951. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  15952. {
  15953. if (source == null)
  15954. throw new ArgumentNullException(nameof(source));
  15955. if (predicate == null)
  15956. throw new ArgumentNullException(nameof(predicate));
  15957. return source.Provider.CreateQuery<TSource>(
  15958. Expression.Call(
  15959. null,
  15960. #if CRIPPLED_REFLECTION
  15961. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  15962. #else
  15963. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15964. #endif
  15965. source.Expression,
  15966. predicate
  15967. )
  15968. );
  15969. }
  15970. /// <summary>
  15971. /// Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
  15972. /// </summary>
  15973. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15974. /// <param name="source">An observable sequence whose elements to filter.</param>
  15975. /// <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>
  15976. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15977. /// <exception cref="ArgumentNullException">
  15978. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15979. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  15980. {
  15981. if (source == null)
  15982. throw new ArgumentNullException(nameof(source));
  15983. if (predicate == null)
  15984. throw new ArgumentNullException(nameof(predicate));
  15985. return source.Provider.CreateQuery<TSource>(
  15986. Expression.Call(
  15987. null,
  15988. #if CRIPPLED_REFLECTION
  15989. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  15990. #else
  15991. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15992. #endif
  15993. source.Expression,
  15994. predicate
  15995. )
  15996. );
  15997. }
  15998. /// <summary>
  15999. /// 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.
  16000. /// </summary>
  16001. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16002. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  16003. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  16004. /// <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>
  16005. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  16006. /// <exception cref="ArgumentNullException">
  16007. /// <paramref name="condition" /> or <paramref name="source" /> is null.</exception>
  16008. public static IQbservable<TSource> While<TSource>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TSource> source)
  16009. {
  16010. if (provider == null)
  16011. throw new ArgumentNullException(nameof(provider));
  16012. if (condition == null)
  16013. throw new ArgumentNullException(nameof(condition));
  16014. if (source == null)
  16015. throw new ArgumentNullException(nameof(source));
  16016. return provider.CreateQuery<TSource>(
  16017. Expression.Call(
  16018. null,
  16019. #if CRIPPLED_REFLECTION
  16020. InfoOf(() => Qbservable.While<TSource>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TSource>))),
  16021. #else
  16022. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16023. #endif
  16024. Expression.Constant(provider, typeof(IQbservableProvider)),
  16025. condition,
  16026. GetSourceExpression(source)
  16027. )
  16028. );
  16029. }
  16030. /// <summary>
  16031. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on element count information.
  16032. /// </summary>
  16033. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16034. /// <param name="source">Source sequence to produce windows over.</param>
  16035. /// <param name="count">Length of each window.</param>
  16036. /// <returns>An observable sequence of windows.</returns>
  16037. /// <exception cref="ArgumentNullException">
  16038. /// <paramref name="source" /> is null.</exception>
  16039. /// <exception cref="ArgumentOutOfRangeException">
  16040. /// <paramref name="count" /> is less than or equal to zero.</exception>
  16041. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count)
  16042. {
  16043. if (source == null)
  16044. throw new ArgumentNullException(nameof(source));
  16045. return source.Provider.CreateQuery<IObservable<TSource>>(
  16046. Expression.Call(
  16047. null,
  16048. #if CRIPPLED_REFLECTION
  16049. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int))),
  16050. #else
  16051. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16052. #endif
  16053. source.Expression,
  16054. Expression.Constant(count, typeof(int))
  16055. )
  16056. );
  16057. }
  16058. /// <summary>
  16059. /// Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
  16060. /// </summary>
  16061. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16062. /// <param name="source">Source sequence to produce windows over.</param>
  16063. /// <param name="count">Length of each window.</param>
  16064. /// <param name="skip">Number of elements to skip between creation of consecutive windows.</param>
  16065. /// <returns>An observable sequence of windows.</returns>
  16066. /// <exception cref="ArgumentNullException">
  16067. /// <paramref name="source" /> is null.</exception>
  16068. /// <exception cref="ArgumentOutOfRangeException">
  16069. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  16070. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count, int skip)
  16071. {
  16072. if (source == null)
  16073. throw new ArgumentNullException(nameof(source));
  16074. return source.Provider.CreateQuery<IObservable<TSource>>(
  16075. Expression.Call(
  16076. null,
  16077. #if CRIPPLED_REFLECTION
  16078. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  16079. #else
  16080. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16081. #endif
  16082. source.Expression,
  16083. Expression.Constant(count, typeof(int)),
  16084. Expression.Constant(skip, typeof(int))
  16085. )
  16086. );
  16087. }
  16088. /// <summary>
  16089. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information.
  16090. /// </summary>
  16091. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16092. /// <param name="source">Source sequence to produce windows over.</param>
  16093. /// <param name="timeSpan">Length of each window.</param>
  16094. /// <returns>The sequence of windows.</returns>
  16095. /// <exception cref="ArgumentNullException">
  16096. /// <paramref name="source" /> is null.</exception>
  16097. /// <exception cref="ArgumentOutOfRangeException">
  16098. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16099. /// <remarks>
  16100. /// 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.
  16101. /// 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
  16102. /// 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.
  16103. /// </remarks>
  16104. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  16105. {
  16106. if (source == null)
  16107. throw new ArgumentNullException(nameof(source));
  16108. return source.Provider.CreateQuery<IObservable<TSource>>(
  16109. Expression.Call(
  16110. null,
  16111. #if CRIPPLED_REFLECTION
  16112. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  16113. #else
  16114. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16115. #endif
  16116. source.Expression,
  16117. Expression.Constant(timeSpan, typeof(TimeSpan))
  16118. )
  16119. );
  16120. }
  16121. /// <summary>
  16122. /// 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.
  16123. /// 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.
  16124. /// </summary>
  16125. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16126. /// <param name="source">Source sequence to produce windows over.</param>
  16127. /// <param name="timeSpan">Maximum time length of a window.</param>
  16128. /// <param name="count">Maximum element count of a window.</param>
  16129. /// <returns>An observable sequence of windows.</returns>
  16130. /// <exception cref="ArgumentNullException">
  16131. /// <paramref name="source" /> is null.</exception>
  16132. /// <exception cref="ArgumentOutOfRangeException">
  16133. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  16134. /// <remarks>
  16135. /// 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.
  16136. /// 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
  16137. /// 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.
  16138. /// </remarks>
  16139. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  16140. {
  16141. if (source == null)
  16142. throw new ArgumentNullException(nameof(source));
  16143. return source.Provider.CreateQuery<IObservable<TSource>>(
  16144. Expression.Call(
  16145. null,
  16146. #if CRIPPLED_REFLECTION
  16147. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  16148. #else
  16149. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16150. #endif
  16151. source.Expression,
  16152. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16153. Expression.Constant(count, typeof(int))
  16154. )
  16155. );
  16156. }
  16157. /// <summary>
  16158. /// 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.
  16159. /// 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.
  16160. /// </summary>
  16161. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16162. /// <param name="source">Source sequence to produce windows over.</param>
  16163. /// <param name="timeSpan">Maximum time length of a window.</param>
  16164. /// <param name="count">Maximum element count of a window.</param>
  16165. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16166. /// <returns>An observable sequence of windows.</returns>
  16167. /// <exception cref="ArgumentNullException">
  16168. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16169. /// <exception cref="ArgumentOutOfRangeException">
  16170. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  16171. /// <remarks>
  16172. /// 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.
  16173. /// 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
  16174. /// 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.
  16175. /// </remarks>
  16176. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  16177. {
  16178. if (source == null)
  16179. throw new ArgumentNullException(nameof(source));
  16180. if (scheduler == null)
  16181. throw new ArgumentNullException(nameof(scheduler));
  16182. return source.Provider.CreateQuery<IObservable<TSource>>(
  16183. Expression.Call(
  16184. null,
  16185. #if CRIPPLED_REFLECTION
  16186. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  16187. #else
  16188. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16189. #endif
  16190. source.Expression,
  16191. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16192. Expression.Constant(count, typeof(int)),
  16193. Expression.Constant(scheduler, typeof(IScheduler))
  16194. )
  16195. );
  16196. }
  16197. /// <summary>
  16198. /// 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.
  16199. /// </summary>
  16200. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16201. /// <param name="source">Source sequence to produce windows over.</param>
  16202. /// <param name="timeSpan">Length of each window.</param>
  16203. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16204. /// <returns>An observable sequence of windows.</returns>
  16205. /// <exception cref="ArgumentNullException">
  16206. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16207. /// <exception cref="ArgumentOutOfRangeException">
  16208. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16209. /// <remarks>
  16210. /// 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.
  16211. /// 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
  16212. /// 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.
  16213. /// </remarks>
  16214. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  16215. {
  16216. if (source == null)
  16217. throw new ArgumentNullException(nameof(source));
  16218. if (scheduler == null)
  16219. throw new ArgumentNullException(nameof(scheduler));
  16220. return source.Provider.CreateQuery<IObservable<TSource>>(
  16221. Expression.Call(
  16222. null,
  16223. #if CRIPPLED_REFLECTION
  16224. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  16225. #else
  16226. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16227. #endif
  16228. source.Expression,
  16229. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16230. Expression.Constant(scheduler, typeof(IScheduler))
  16231. )
  16232. );
  16233. }
  16234. /// <summary>
  16235. /// Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  16236. /// </summary>
  16237. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16238. /// <param name="source">Source sequence to produce windows over.</param>
  16239. /// <param name="timeSpan">Length of each window.</param>
  16240. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  16241. /// <returns>An observable sequence of windows.</returns>
  16242. /// <exception cref="ArgumentNullException">
  16243. /// <paramref name="source" /> is null.</exception>
  16244. /// <exception cref="ArgumentOutOfRangeException">
  16245. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16246. /// <remarks>
  16247. /// <para>
  16248. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  16249. /// 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
  16250. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  16251. /// </para>
  16252. /// <para>
  16253. /// 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.
  16254. /// 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,
  16255. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16256. /// </para>
  16257. /// </remarks>
  16258. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  16259. {
  16260. if (source == null)
  16261. throw new ArgumentNullException(nameof(source));
  16262. return source.Provider.CreateQuery<IObservable<TSource>>(
  16263. Expression.Call(
  16264. null,
  16265. #if CRIPPLED_REFLECTION
  16266. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  16267. #else
  16268. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16269. #endif
  16270. source.Expression,
  16271. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16272. Expression.Constant(timeShift, typeof(TimeSpan))
  16273. )
  16274. );
  16275. }
  16276. /// <summary>
  16277. /// 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.
  16278. /// </summary>
  16279. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16280. /// <param name="source">Source sequence to produce windows over.</param>
  16281. /// <param name="timeSpan">Length of each window.</param>
  16282. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  16283. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  16284. /// <returns>An observable sequence of windows.</returns>
  16285. /// <exception cref="ArgumentNullException">
  16286. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  16287. /// <exception cref="ArgumentOutOfRangeException">
  16288. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  16289. /// <remarks>
  16290. /// <para>
  16291. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  16292. /// 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
  16293. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  16294. /// </para>
  16295. /// <para>
  16296. /// 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.
  16297. /// 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,
  16298. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  16299. /// </para>
  16300. /// </remarks>
  16301. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  16302. {
  16303. if (source == null)
  16304. throw new ArgumentNullException(nameof(source));
  16305. if (scheduler == null)
  16306. throw new ArgumentNullException(nameof(scheduler));
  16307. return source.Provider.CreateQuery<IObservable<TSource>>(
  16308. Expression.Call(
  16309. null,
  16310. #if CRIPPLED_REFLECTION
  16311. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  16312. #else
  16313. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16314. #endif
  16315. source.Expression,
  16316. Expression.Constant(timeSpan, typeof(TimeSpan)),
  16317. Expression.Constant(timeShift, typeof(TimeSpan)),
  16318. Expression.Constant(scheduler, typeof(IScheduler))
  16319. )
  16320. );
  16321. }
  16322. /// <summary>
  16323. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16324. /// </summary>
  16325. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16326. /// <typeparam name="TWindowBoundary">The type of the elements in the sequences indicating window boundary events.</typeparam>
  16327. /// <param name="source">Source sequence to produce windows over.</param>
  16328. /// <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>
  16329. /// <returns>An observable sequence of windows.</returns>
  16330. /// <exception cref="ArgumentNullException">
  16331. /// <paramref name="source" /> or <paramref name="windowBoundaries" /> is null.</exception>
  16332. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowBoundary>(this IQbservable<TSource> source, IObservable<TWindowBoundary> windowBoundaries)
  16333. {
  16334. if (source == null)
  16335. throw new ArgumentNullException(nameof(source));
  16336. if (windowBoundaries == null)
  16337. throw new ArgumentNullException(nameof(windowBoundaries));
  16338. return source.Provider.CreateQuery<IObservable<TSource>>(
  16339. Expression.Call(
  16340. null,
  16341. #if CRIPPLED_REFLECTION
  16342. InfoOf(() => Qbservable.Window<TSource, TWindowBoundary>(default(IQbservable<TSource>), default(IObservable<TWindowBoundary>))),
  16343. #else
  16344. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowBoundary)),
  16345. #endif
  16346. source.Expression,
  16347. GetSourceExpression(windowBoundaries)
  16348. )
  16349. );
  16350. }
  16351. /// <summary>
  16352. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  16353. /// </summary>
  16354. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16355. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16356. /// <param name="source">Source sequence to produce windows over.</param>
  16357. /// <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>
  16358. /// <returns>An observable sequence of windows.</returns>
  16359. /// <exception cref="ArgumentNullException">
  16360. /// <paramref name="source" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16361. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TWindowClosing>>> windowClosingSelector)
  16362. {
  16363. if (source == null)
  16364. throw new ArgumentNullException(nameof(source));
  16365. if (windowClosingSelector == null)
  16366. throw new ArgumentNullException(nameof(windowClosingSelector));
  16367. return source.Provider.CreateQuery<IObservable<TSource>>(
  16368. Expression.Call(
  16369. null,
  16370. #if CRIPPLED_REFLECTION
  16371. InfoOf(() => Qbservable.Window<TSource, TWindowClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TWindowClosing>>>))),
  16372. #else
  16373. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowClosing)),
  16374. #endif
  16375. source.Expression,
  16376. windowClosingSelector
  16377. )
  16378. );
  16379. }
  16380. /// <summary>
  16381. /// Projects each element of an observable sequence into zero or more windows.
  16382. /// </summary>
  16383. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  16384. /// <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>
  16385. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  16386. /// <param name="source">Source sequence to produce windows over.</param>
  16387. /// <param name="windowOpenings">Observable sequence whose elements denote the creation of new windows.</param>
  16388. /// <param name="windowClosingSelector">A function invoked to define the closing of each produced window.</param>
  16389. /// <returns>An observable sequence of windows.</returns>
  16390. /// <exception cref="ArgumentNullException">
  16391. /// <paramref name="source" /> or <paramref name="windowOpenings" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  16392. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowOpening, TWindowClosing>(this IQbservable<TSource> source, IObservable<TWindowOpening> windowOpenings, Expression<Func<TWindowOpening, IObservable<TWindowClosing>>> windowClosingSelector)
  16393. {
  16394. if (source == null)
  16395. throw new ArgumentNullException(nameof(source));
  16396. if (windowOpenings == null)
  16397. throw new ArgumentNullException(nameof(windowOpenings));
  16398. if (windowClosingSelector == null)
  16399. throw new ArgumentNullException(nameof(windowClosingSelector));
  16400. return source.Provider.CreateQuery<IObservable<TSource>>(
  16401. Expression.Call(
  16402. null,
  16403. #if CRIPPLED_REFLECTION
  16404. InfoOf(() => Qbservable.Window<TSource, TWindowOpening, TWindowClosing>(default(IQbservable<TSource>), default(IObservable<TWindowOpening>), default(Expression<Func<TWindowOpening, IObservable<TWindowClosing>>>))),
  16405. #else
  16406. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowOpening), typeof(TWindowClosing)),
  16407. #endif
  16408. source.Expression,
  16409. GetSourceExpression(windowOpenings),
  16410. windowClosingSelector
  16411. )
  16412. );
  16413. }
  16414. /// <summary>
  16415. /// 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.
  16416. /// 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
  16417. /// in case <paramref name="first" /> emits an element right away.
  16418. /// </summary>
  16419. /// <typeparam name="TFirst">The type of the elements in the first source sequence.</typeparam>
  16420. /// <typeparam name="TSecond">The type of the elements in the second source sequence.</typeparam>
  16421. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16422. /// <param name="first">First observable source.</param>
  16423. /// <param name="second">Second observable source.</param>
  16424. /// <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>
  16425. /// <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>
  16426. /// <exception cref="ArgumentNullException">
  16427. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16428. public static IQbservable<TResult> WithLatestFrom<TFirst, TSecond, TResult>(this IQbservable<TFirst> first, IObservable<TSecond> second, Expression<Func<TFirst, TSecond, TResult>> resultSelector)
  16429. {
  16430. if (first == null)
  16431. throw new ArgumentNullException(nameof(first));
  16432. if (second == null)
  16433. throw new ArgumentNullException(nameof(second));
  16434. if (resultSelector == null)
  16435. throw new ArgumentNullException(nameof(resultSelector));
  16436. return first.Provider.CreateQuery<TResult>(
  16437. Expression.Call(
  16438. null,
  16439. #if CRIPPLED_REFLECTION
  16440. InfoOf(() => Qbservable.WithLatestFrom<TFirst, TSecond, TResult>(default(IQbservable<TFirst>), default(IObservable<TSecond>), default(Expression<Func<TFirst, TSecond, TResult>>))),
  16441. #else
  16442. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)),
  16443. #endif
  16444. first.Expression,
  16445. GetSourceExpression(second),
  16446. resultSelector
  16447. )
  16448. );
  16449. }
  16450. /// <summary>
  16451. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16452. /// </summary>
  16453. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16454. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16455. /// <param name="sources">Observable sources.</param>
  16456. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16457. /// <exception cref="ArgumentNullException">
  16458. /// <paramref name="sources" /> is null.</exception>
  16459. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  16460. {
  16461. if (provider == null)
  16462. throw new ArgumentNullException(nameof(provider));
  16463. if (sources == null)
  16464. throw new ArgumentNullException(nameof(sources));
  16465. return provider.CreateQuery<IList<TSource>>(
  16466. Expression.Call(
  16467. null,
  16468. #if CRIPPLED_REFLECTION
  16469. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  16470. #else
  16471. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16472. #endif
  16473. Expression.Constant(provider, typeof(IQbservableProvider)),
  16474. GetSourceExpression(sources)
  16475. )
  16476. );
  16477. }
  16478. /// <summary>
  16479. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16480. /// </summary>
  16481. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16482. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16483. /// <param name="sources">Observable sources.</param>
  16484. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16485. /// <exception cref="ArgumentNullException">
  16486. /// <paramref name="sources" /> is null.</exception>
  16487. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  16488. {
  16489. if (provider == null)
  16490. throw new ArgumentNullException(nameof(provider));
  16491. if (sources == null)
  16492. throw new ArgumentNullException(nameof(sources));
  16493. return provider.CreateQuery<IList<TSource>>(
  16494. Expression.Call(
  16495. null,
  16496. #if CRIPPLED_REFLECTION
  16497. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  16498. #else
  16499. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16500. #endif
  16501. Expression.Constant(provider, typeof(IQbservableProvider)),
  16502. GetSourceExpression(sources)
  16503. )
  16504. );
  16505. }
  16506. /// <summary>
  16507. /// 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.
  16508. /// </summary>
  16509. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16510. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  16511. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16512. /// <param name="sources">Observable sources.</param>
  16513. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16514. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16515. /// <exception cref="ArgumentNullException">
  16516. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  16517. public static IQbservable<TResult> Zip<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  16518. {
  16519. if (provider == null)
  16520. throw new ArgumentNullException(nameof(provider));
  16521. if (sources == null)
  16522. throw new ArgumentNullException(nameof(sources));
  16523. if (resultSelector == null)
  16524. throw new ArgumentNullException(nameof(resultSelector));
  16525. return provider.CreateQuery<TResult>(
  16526. Expression.Call(
  16527. null,
  16528. #if CRIPPLED_REFLECTION
  16529. InfoOf(() => Qbservable.Zip<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  16530. #else
  16531. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  16532. #endif
  16533. Expression.Constant(provider, typeof(IQbservableProvider)),
  16534. GetSourceExpression(sources),
  16535. resultSelector
  16536. )
  16537. );
  16538. }
  16539. /// <summary>
  16540. /// Merges two observable sequences into one observable sequence by combining their elements in a pairwise fashion.
  16541. /// </summary>
  16542. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16543. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16544. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16545. /// <param name="first">First observable source.</param>
  16546. /// <param name="second">Second observable source.</param>
  16547. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16548. /// <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>
  16549. /// <exception cref="ArgumentNullException">
  16550. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16551. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16552. {
  16553. if (first == null)
  16554. throw new ArgumentNullException(nameof(first));
  16555. if (second == null)
  16556. throw new ArgumentNullException(nameof(second));
  16557. if (resultSelector == null)
  16558. throw new ArgumentNullException(nameof(resultSelector));
  16559. return first.Provider.CreateQuery<TResult>(
  16560. Expression.Call(
  16561. null,
  16562. #if CRIPPLED_REFLECTION
  16563. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16564. #else
  16565. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16566. #endif
  16567. first.Expression,
  16568. GetSourceExpression(second),
  16569. resultSelector
  16570. )
  16571. );
  16572. }
  16573. /// <summary>
  16574. /// Merges an observable sequence and an enumerable sequence into one observable sequence by using the selector function.
  16575. /// </summary>
  16576. /// <typeparam name="TSource1">The type of the elements in the first observable source sequence.</typeparam>
  16577. /// <typeparam name="TSource2">The type of the elements in the second enumerable source sequence.</typeparam>
  16578. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16579. /// <param name="first">First observable source.</param>
  16580. /// <param name="second">Second enumerable source.</param>
  16581. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16582. /// <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>
  16583. /// <exception cref="ArgumentNullException">
  16584. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16585. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IEnumerable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16586. {
  16587. if (first == null)
  16588. throw new ArgumentNullException(nameof(first));
  16589. if (second == null)
  16590. throw new ArgumentNullException(nameof(second));
  16591. if (resultSelector == null)
  16592. throw new ArgumentNullException(nameof(resultSelector));
  16593. return first.Provider.CreateQuery<TResult>(
  16594. Expression.Call(
  16595. null,
  16596. #if CRIPPLED_REFLECTION
  16597. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IEnumerable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16598. #else
  16599. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16600. #endif
  16601. first.Expression,
  16602. GetSourceExpression(second),
  16603. resultSelector
  16604. )
  16605. );
  16606. }
  16607. /// <summary>
  16608. /// 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.
  16609. /// </summary>
  16610. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16611. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16612. /// <typeparam name="TSource3">The type of the elements in the third 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="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16618. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16619. /// <exception cref="ArgumentNullException">
  16620. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  16621. 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)
  16622. {
  16623. if (source1 == null)
  16624. throw new ArgumentNullException(nameof(source1));
  16625. if (source2 == null)
  16626. throw new ArgumentNullException(nameof(source2));
  16627. if (source3 == null)
  16628. throw new ArgumentNullException(nameof(source3));
  16629. if (resultSelector == null)
  16630. throw new ArgumentNullException(nameof(resultSelector));
  16631. return source1.Provider.CreateQuery<TResult>(
  16632. Expression.Call(
  16633. null,
  16634. #if CRIPPLED_REFLECTION
  16635. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  16636. #else
  16637. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  16638. #endif
  16639. source1.Expression,
  16640. GetSourceExpression(source2),
  16641. GetSourceExpression(source3),
  16642. resultSelector
  16643. )
  16644. );
  16645. }
  16646. /// <summary>
  16647. /// 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.
  16648. /// </summary>
  16649. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16650. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16651. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16652. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16653. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16654. /// <param name="source1">First observable source.</param>
  16655. /// <param name="source2">Second observable source.</param>
  16656. /// <param name="source3">Third observable source.</param>
  16657. /// <param name="source4">Fourth observable source.</param>
  16658. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16659. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16660. /// <exception cref="ArgumentNullException">
  16661. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  16662. 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)
  16663. {
  16664. if (source1 == null)
  16665. throw new ArgumentNullException(nameof(source1));
  16666. if (source2 == null)
  16667. throw new ArgumentNullException(nameof(source2));
  16668. if (source3 == null)
  16669. throw new ArgumentNullException(nameof(source3));
  16670. if (source4 == null)
  16671. throw new ArgumentNullException(nameof(source4));
  16672. if (resultSelector == null)
  16673. throw new ArgumentNullException(nameof(resultSelector));
  16674. return source1.Provider.CreateQuery<TResult>(
  16675. Expression.Call(
  16676. null,
  16677. #if CRIPPLED_REFLECTION
  16678. 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>>))),
  16679. #else
  16680. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  16681. #endif
  16682. source1.Expression,
  16683. GetSourceExpression(source2),
  16684. GetSourceExpression(source3),
  16685. GetSourceExpression(source4),
  16686. resultSelector
  16687. )
  16688. );
  16689. }
  16690. /// <summary>
  16691. /// 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.
  16692. /// </summary>
  16693. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16694. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16695. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16696. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16697. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16698. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16699. /// <param name="source1">First observable source.</param>
  16700. /// <param name="source2">Second observable source.</param>
  16701. /// <param name="source3">Third observable source.</param>
  16702. /// <param name="source4">Fourth observable source.</param>
  16703. /// <param name="source5">Fifth observable source.</param>
  16704. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16705. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16706. /// <exception cref="ArgumentNullException">
  16707. /// <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>
  16708. 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)
  16709. {
  16710. if (source1 == null)
  16711. throw new ArgumentNullException(nameof(source1));
  16712. if (source2 == null)
  16713. throw new ArgumentNullException(nameof(source2));
  16714. if (source3 == null)
  16715. throw new ArgumentNullException(nameof(source3));
  16716. if (source4 == null)
  16717. throw new ArgumentNullException(nameof(source4));
  16718. if (source5 == null)
  16719. throw new ArgumentNullException(nameof(source5));
  16720. if (resultSelector == null)
  16721. throw new ArgumentNullException(nameof(resultSelector));
  16722. return source1.Provider.CreateQuery<TResult>(
  16723. Expression.Call(
  16724. null,
  16725. #if CRIPPLED_REFLECTION
  16726. 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>>))),
  16727. #else
  16728. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  16729. #endif
  16730. source1.Expression,
  16731. GetSourceExpression(source2),
  16732. GetSourceExpression(source3),
  16733. GetSourceExpression(source4),
  16734. GetSourceExpression(source5),
  16735. resultSelector
  16736. )
  16737. );
  16738. }
  16739. /// <summary>
  16740. /// 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.
  16741. /// </summary>
  16742. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16743. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16744. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16745. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16746. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16747. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16748. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16749. /// <param name="source1">First observable source.</param>
  16750. /// <param name="source2">Second observable source.</param>
  16751. /// <param name="source3">Third observable source.</param>
  16752. /// <param name="source4">Fourth observable source.</param>
  16753. /// <param name="source5">Fifth observable source.</param>
  16754. /// <param name="source6">Sixth observable source.</param>
  16755. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16756. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16757. /// <exception cref="ArgumentNullException">
  16758. /// <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>
  16759. 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)
  16760. {
  16761. if (source1 == null)
  16762. throw new ArgumentNullException(nameof(source1));
  16763. if (source2 == null)
  16764. throw new ArgumentNullException(nameof(source2));
  16765. if (source3 == null)
  16766. throw new ArgumentNullException(nameof(source3));
  16767. if (source4 == null)
  16768. throw new ArgumentNullException(nameof(source4));
  16769. if (source5 == null)
  16770. throw new ArgumentNullException(nameof(source5));
  16771. if (source6 == null)
  16772. throw new ArgumentNullException(nameof(source6));
  16773. if (resultSelector == null)
  16774. throw new ArgumentNullException(nameof(resultSelector));
  16775. return source1.Provider.CreateQuery<TResult>(
  16776. Expression.Call(
  16777. null,
  16778. #if CRIPPLED_REFLECTION
  16779. 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>>))),
  16780. #else
  16781. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  16782. #endif
  16783. source1.Expression,
  16784. GetSourceExpression(source2),
  16785. GetSourceExpression(source3),
  16786. GetSourceExpression(source4),
  16787. GetSourceExpression(source5),
  16788. GetSourceExpression(source6),
  16789. resultSelector
  16790. )
  16791. );
  16792. }
  16793. /// <summary>
  16794. /// 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.
  16795. /// </summary>
  16796. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16797. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16798. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16799. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16800. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16801. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16802. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16803. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16804. /// <param name="source1">First observable source.</param>
  16805. /// <param name="source2">Second observable source.</param>
  16806. /// <param name="source3">Third observable source.</param>
  16807. /// <param name="source4">Fourth observable source.</param>
  16808. /// <param name="source5">Fifth observable source.</param>
  16809. /// <param name="source6">Sixth observable source.</param>
  16810. /// <param name="source7">Seventh observable source.</param>
  16811. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16812. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16813. /// <exception cref="ArgumentNullException">
  16814. /// <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>
  16815. 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)
  16816. {
  16817. if (source1 == null)
  16818. throw new ArgumentNullException(nameof(source1));
  16819. if (source2 == null)
  16820. throw new ArgumentNullException(nameof(source2));
  16821. if (source3 == null)
  16822. throw new ArgumentNullException(nameof(source3));
  16823. if (source4 == null)
  16824. throw new ArgumentNullException(nameof(source4));
  16825. if (source5 == null)
  16826. throw new ArgumentNullException(nameof(source5));
  16827. if (source6 == null)
  16828. throw new ArgumentNullException(nameof(source6));
  16829. if (source7 == null)
  16830. throw new ArgumentNullException(nameof(source7));
  16831. if (resultSelector == null)
  16832. throw new ArgumentNullException(nameof(resultSelector));
  16833. return source1.Provider.CreateQuery<TResult>(
  16834. Expression.Call(
  16835. null,
  16836. #if CRIPPLED_REFLECTION
  16837. 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>>))),
  16838. #else
  16839. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  16840. #endif
  16841. source1.Expression,
  16842. GetSourceExpression(source2),
  16843. GetSourceExpression(source3),
  16844. GetSourceExpression(source4),
  16845. GetSourceExpression(source5),
  16846. GetSourceExpression(source6),
  16847. GetSourceExpression(source7),
  16848. resultSelector
  16849. )
  16850. );
  16851. }
  16852. /// <summary>
  16853. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index.
  16854. /// </summary>
  16855. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16856. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16857. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16858. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16859. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16860. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16861. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16862. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16863. /// <typeparam name="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="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16873. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16874. /// <exception cref="ArgumentNullException">
  16875. /// <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>
  16876. 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)
  16877. {
  16878. if (source1 == null)
  16879. throw new ArgumentNullException(nameof(source1));
  16880. if (source2 == null)
  16881. throw new ArgumentNullException(nameof(source2));
  16882. if (source3 == null)
  16883. throw new ArgumentNullException(nameof(source3));
  16884. if (source4 == null)
  16885. throw new ArgumentNullException(nameof(source4));
  16886. if (source5 == null)
  16887. throw new ArgumentNullException(nameof(source5));
  16888. if (source6 == null)
  16889. throw new ArgumentNullException(nameof(source6));
  16890. if (source7 == null)
  16891. throw new ArgumentNullException(nameof(source7));
  16892. if (source8 == null)
  16893. throw new ArgumentNullException(nameof(source8));
  16894. if (resultSelector == null)
  16895. throw new ArgumentNullException(nameof(resultSelector));
  16896. return source1.Provider.CreateQuery<TResult>(
  16897. Expression.Call(
  16898. null,
  16899. #if CRIPPLED_REFLECTION
  16900. 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>>))),
  16901. #else
  16902. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  16903. #endif
  16904. source1.Expression,
  16905. GetSourceExpression(source2),
  16906. GetSourceExpression(source3),
  16907. GetSourceExpression(source4),
  16908. GetSourceExpression(source5),
  16909. GetSourceExpression(source6),
  16910. GetSourceExpression(source7),
  16911. GetSourceExpression(source8),
  16912. resultSelector
  16913. )
  16914. );
  16915. }
  16916. /// <summary>
  16917. /// 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.
  16918. /// </summary>
  16919. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16920. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16921. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16922. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16923. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16924. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16925. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16926. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16927. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16928. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16929. /// <param name="source1">First observable source.</param>
  16930. /// <param name="source2">Second observable source.</param>
  16931. /// <param name="source3">Third observable source.</param>
  16932. /// <param name="source4">Fourth observable source.</param>
  16933. /// <param name="source5">Fifth observable source.</param>
  16934. /// <param name="source6">Sixth observable source.</param>
  16935. /// <param name="source7">Seventh observable source.</param>
  16936. /// <param name="source8">Eighth observable source.</param>
  16937. /// <param name="source9">Ninth observable source.</param>
  16938. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16939. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16940. /// <exception cref="ArgumentNullException">
  16941. /// <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>
  16942. 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)
  16943. {
  16944. if (source1 == null)
  16945. throw new ArgumentNullException(nameof(source1));
  16946. if (source2 == null)
  16947. throw new ArgumentNullException(nameof(source2));
  16948. if (source3 == null)
  16949. throw new ArgumentNullException(nameof(source3));
  16950. if (source4 == null)
  16951. throw new ArgumentNullException(nameof(source4));
  16952. if (source5 == null)
  16953. throw new ArgumentNullException(nameof(source5));
  16954. if (source6 == null)
  16955. throw new ArgumentNullException(nameof(source6));
  16956. if (source7 == null)
  16957. throw new ArgumentNullException(nameof(source7));
  16958. if (source8 == null)
  16959. throw new ArgumentNullException(nameof(source8));
  16960. if (source9 == null)
  16961. throw new ArgumentNullException(nameof(source9));
  16962. if (resultSelector == null)
  16963. throw new ArgumentNullException(nameof(resultSelector));
  16964. return source1.Provider.CreateQuery<TResult>(
  16965. Expression.Call(
  16966. null,
  16967. #if CRIPPLED_REFLECTION
  16968. 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>>))),
  16969. #else
  16970. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  16971. #endif
  16972. source1.Expression,
  16973. GetSourceExpression(source2),
  16974. GetSourceExpression(source3),
  16975. GetSourceExpression(source4),
  16976. GetSourceExpression(source5),
  16977. GetSourceExpression(source6),
  16978. GetSourceExpression(source7),
  16979. GetSourceExpression(source8),
  16980. GetSourceExpression(source9),
  16981. resultSelector
  16982. )
  16983. );
  16984. }
  16985. /// <summary>
  16986. /// 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.
  16987. /// </summary>
  16988. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16989. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16990. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16991. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16992. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16993. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16994. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16995. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16996. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16997. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16998. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16999. /// <param name="source1">First observable source.</param>
  17000. /// <param name="source2">Second observable source.</param>
  17001. /// <param name="source3">Third observable source.</param>
  17002. /// <param name="source4">Fourth observable source.</param>
  17003. /// <param name="source5">Fifth observable source.</param>
  17004. /// <param name="source6">Sixth observable source.</param>
  17005. /// <param name="source7">Seventh observable source.</param>
  17006. /// <param name="source8">Eighth observable source.</param>
  17007. /// <param name="source9">Ninth observable source.</param>
  17008. /// <param name="source10">Tenth observable source.</param>
  17009. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17010. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17011. /// <exception cref="ArgumentNullException">
  17012. /// <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>
  17013. 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)
  17014. {
  17015. if (source1 == null)
  17016. throw new ArgumentNullException(nameof(source1));
  17017. if (source2 == null)
  17018. throw new ArgumentNullException(nameof(source2));
  17019. if (source3 == null)
  17020. throw new ArgumentNullException(nameof(source3));
  17021. if (source4 == null)
  17022. throw new ArgumentNullException(nameof(source4));
  17023. if (source5 == null)
  17024. throw new ArgumentNullException(nameof(source5));
  17025. if (source6 == null)
  17026. throw new ArgumentNullException(nameof(source6));
  17027. if (source7 == null)
  17028. throw new ArgumentNullException(nameof(source7));
  17029. if (source8 == null)
  17030. throw new ArgumentNullException(nameof(source8));
  17031. if (source9 == null)
  17032. throw new ArgumentNullException(nameof(source9));
  17033. if (source10 == null)
  17034. throw new ArgumentNullException(nameof(source10));
  17035. if (resultSelector == null)
  17036. throw new ArgumentNullException(nameof(resultSelector));
  17037. return source1.Provider.CreateQuery<TResult>(
  17038. Expression.Call(
  17039. null,
  17040. #if CRIPPLED_REFLECTION
  17041. 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>>))),
  17042. #else
  17043. ((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)),
  17044. #endif
  17045. source1.Expression,
  17046. GetSourceExpression(source2),
  17047. GetSourceExpression(source3),
  17048. GetSourceExpression(source4),
  17049. GetSourceExpression(source5),
  17050. GetSourceExpression(source6),
  17051. GetSourceExpression(source7),
  17052. GetSourceExpression(source8),
  17053. GetSourceExpression(source9),
  17054. GetSourceExpression(source10),
  17055. resultSelector
  17056. )
  17057. );
  17058. }
  17059. /// <summary>
  17060. /// 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.
  17061. /// </summary>
  17062. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17063. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17064. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17065. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17066. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17067. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17068. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17069. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17070. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17071. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17072. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17073. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17074. /// <param name="source1">First observable source.</param>
  17075. /// <param name="source2">Second observable source.</param>
  17076. /// <param name="source3">Third observable source.</param>
  17077. /// <param name="source4">Fourth observable source.</param>
  17078. /// <param name="source5">Fifth observable source.</param>
  17079. /// <param name="source6">Sixth observable source.</param>
  17080. /// <param name="source7">Seventh observable source.</param>
  17081. /// <param name="source8">Eighth observable source.</param>
  17082. /// <param name="source9">Ninth observable source.</param>
  17083. /// <param name="source10">Tenth observable source.</param>
  17084. /// <param name="source11">Eleventh observable source.</param>
  17085. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17086. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17087. /// <exception cref="ArgumentNullException">
  17088. /// <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>
  17089. 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)
  17090. {
  17091. if (source1 == null)
  17092. throw new ArgumentNullException(nameof(source1));
  17093. if (source2 == null)
  17094. throw new ArgumentNullException(nameof(source2));
  17095. if (source3 == null)
  17096. throw new ArgumentNullException(nameof(source3));
  17097. if (source4 == null)
  17098. throw new ArgumentNullException(nameof(source4));
  17099. if (source5 == null)
  17100. throw new ArgumentNullException(nameof(source5));
  17101. if (source6 == null)
  17102. throw new ArgumentNullException(nameof(source6));
  17103. if (source7 == null)
  17104. throw new ArgumentNullException(nameof(source7));
  17105. if (source8 == null)
  17106. throw new ArgumentNullException(nameof(source8));
  17107. if (source9 == null)
  17108. throw new ArgumentNullException(nameof(source9));
  17109. if (source10 == null)
  17110. throw new ArgumentNullException(nameof(source10));
  17111. if (source11 == null)
  17112. throw new ArgumentNullException(nameof(source11));
  17113. if (resultSelector == null)
  17114. throw new ArgumentNullException(nameof(resultSelector));
  17115. return source1.Provider.CreateQuery<TResult>(
  17116. Expression.Call(
  17117. null,
  17118. #if CRIPPLED_REFLECTION
  17119. 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>>))),
  17120. #else
  17121. ((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)),
  17122. #endif
  17123. source1.Expression,
  17124. GetSourceExpression(source2),
  17125. GetSourceExpression(source3),
  17126. GetSourceExpression(source4),
  17127. GetSourceExpression(source5),
  17128. GetSourceExpression(source6),
  17129. GetSourceExpression(source7),
  17130. GetSourceExpression(source8),
  17131. GetSourceExpression(source9),
  17132. GetSourceExpression(source10),
  17133. GetSourceExpression(source11),
  17134. resultSelector
  17135. )
  17136. );
  17137. }
  17138. /// <summary>
  17139. /// 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.
  17140. /// </summary>
  17141. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17142. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17143. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17144. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17145. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17146. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17147. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17148. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17149. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17150. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17151. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17152. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17153. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17154. /// <param name="source1">First observable source.</param>
  17155. /// <param name="source2">Second observable source.</param>
  17156. /// <param name="source3">Third observable source.</param>
  17157. /// <param name="source4">Fourth observable source.</param>
  17158. /// <param name="source5">Fifth observable source.</param>
  17159. /// <param name="source6">Sixth observable source.</param>
  17160. /// <param name="source7">Seventh observable source.</param>
  17161. /// <param name="source8">Eighth observable source.</param>
  17162. /// <param name="source9">Ninth observable source.</param>
  17163. /// <param name="source10">Tenth observable source.</param>
  17164. /// <param name="source11">Eleventh observable source.</param>
  17165. /// <param name="source12">Twelfth observable source.</param>
  17166. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17167. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17168. /// <exception cref="ArgumentNullException">
  17169. /// <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>
  17170. 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)
  17171. {
  17172. if (source1 == null)
  17173. throw new ArgumentNullException(nameof(source1));
  17174. if (source2 == null)
  17175. throw new ArgumentNullException(nameof(source2));
  17176. if (source3 == null)
  17177. throw new ArgumentNullException(nameof(source3));
  17178. if (source4 == null)
  17179. throw new ArgumentNullException(nameof(source4));
  17180. if (source5 == null)
  17181. throw new ArgumentNullException(nameof(source5));
  17182. if (source6 == null)
  17183. throw new ArgumentNullException(nameof(source6));
  17184. if (source7 == null)
  17185. throw new ArgumentNullException(nameof(source7));
  17186. if (source8 == null)
  17187. throw new ArgumentNullException(nameof(source8));
  17188. if (source9 == null)
  17189. throw new ArgumentNullException(nameof(source9));
  17190. if (source10 == null)
  17191. throw new ArgumentNullException(nameof(source10));
  17192. if (source11 == null)
  17193. throw new ArgumentNullException(nameof(source11));
  17194. if (source12 == null)
  17195. throw new ArgumentNullException(nameof(source12));
  17196. if (resultSelector == null)
  17197. throw new ArgumentNullException(nameof(resultSelector));
  17198. return source1.Provider.CreateQuery<TResult>(
  17199. Expression.Call(
  17200. null,
  17201. #if CRIPPLED_REFLECTION
  17202. 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>>))),
  17203. #else
  17204. ((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)),
  17205. #endif
  17206. source1.Expression,
  17207. GetSourceExpression(source2),
  17208. GetSourceExpression(source3),
  17209. GetSourceExpression(source4),
  17210. GetSourceExpression(source5),
  17211. GetSourceExpression(source6),
  17212. GetSourceExpression(source7),
  17213. GetSourceExpression(source8),
  17214. GetSourceExpression(source9),
  17215. GetSourceExpression(source10),
  17216. GetSourceExpression(source11),
  17217. GetSourceExpression(source12),
  17218. resultSelector
  17219. )
  17220. );
  17221. }
  17222. /// <summary>
  17223. /// 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.
  17224. /// </summary>
  17225. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17226. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17227. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17228. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17229. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17230. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17231. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17232. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17233. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17234. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17235. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17236. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17237. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17238. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17239. /// <param name="source1">First observable source.</param>
  17240. /// <param name="source2">Second observable source.</param>
  17241. /// <param name="source3">Third observable source.</param>
  17242. /// <param name="source4">Fourth observable source.</param>
  17243. /// <param name="source5">Fifth observable source.</param>
  17244. /// <param name="source6">Sixth observable source.</param>
  17245. /// <param name="source7">Seventh observable source.</param>
  17246. /// <param name="source8">Eighth observable source.</param>
  17247. /// <param name="source9">Ninth observable source.</param>
  17248. /// <param name="source10">Tenth observable source.</param>
  17249. /// <param name="source11">Eleventh observable source.</param>
  17250. /// <param name="source12">Twelfth observable source.</param>
  17251. /// <param name="source13">Thirteenth observable source.</param>
  17252. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17253. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17254. /// <exception cref="ArgumentNullException">
  17255. /// <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>
  17256. 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)
  17257. {
  17258. if (source1 == null)
  17259. throw new ArgumentNullException(nameof(source1));
  17260. if (source2 == null)
  17261. throw new ArgumentNullException(nameof(source2));
  17262. if (source3 == null)
  17263. throw new ArgumentNullException(nameof(source3));
  17264. if (source4 == null)
  17265. throw new ArgumentNullException(nameof(source4));
  17266. if (source5 == null)
  17267. throw new ArgumentNullException(nameof(source5));
  17268. if (source6 == null)
  17269. throw new ArgumentNullException(nameof(source6));
  17270. if (source7 == null)
  17271. throw new ArgumentNullException(nameof(source7));
  17272. if (source8 == null)
  17273. throw new ArgumentNullException(nameof(source8));
  17274. if (source9 == null)
  17275. throw new ArgumentNullException(nameof(source9));
  17276. if (source10 == null)
  17277. throw new ArgumentNullException(nameof(source10));
  17278. if (source11 == null)
  17279. throw new ArgumentNullException(nameof(source11));
  17280. if (source12 == null)
  17281. throw new ArgumentNullException(nameof(source12));
  17282. if (source13 == null)
  17283. throw new ArgumentNullException(nameof(source13));
  17284. if (resultSelector == null)
  17285. throw new ArgumentNullException(nameof(resultSelector));
  17286. return source1.Provider.CreateQuery<TResult>(
  17287. Expression.Call(
  17288. null,
  17289. #if CRIPPLED_REFLECTION
  17290. 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>>))),
  17291. #else
  17292. ((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)),
  17293. #endif
  17294. source1.Expression,
  17295. GetSourceExpression(source2),
  17296. GetSourceExpression(source3),
  17297. GetSourceExpression(source4),
  17298. GetSourceExpression(source5),
  17299. GetSourceExpression(source6),
  17300. GetSourceExpression(source7),
  17301. GetSourceExpression(source8),
  17302. GetSourceExpression(source9),
  17303. GetSourceExpression(source10),
  17304. GetSourceExpression(source11),
  17305. GetSourceExpression(source12),
  17306. GetSourceExpression(source13),
  17307. resultSelector
  17308. )
  17309. );
  17310. }
  17311. /// <summary>
  17312. /// 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.
  17313. /// </summary>
  17314. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17315. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17316. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17317. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17318. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17319. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17320. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17321. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17322. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17323. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17324. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17325. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17326. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17327. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17328. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17329. /// <param name="source1">First observable source.</param>
  17330. /// <param name="source2">Second observable source.</param>
  17331. /// <param name="source3">Third observable source.</param>
  17332. /// <param name="source4">Fourth observable source.</param>
  17333. /// <param name="source5">Fifth observable source.</param>
  17334. /// <param name="source6">Sixth observable source.</param>
  17335. /// <param name="source7">Seventh observable source.</param>
  17336. /// <param name="source8">Eighth observable source.</param>
  17337. /// <param name="source9">Ninth observable source.</param>
  17338. /// <param name="source10">Tenth observable source.</param>
  17339. /// <param name="source11">Eleventh observable source.</param>
  17340. /// <param name="source12">Twelfth observable source.</param>
  17341. /// <param name="source13">Thirteenth observable source.</param>
  17342. /// <param name="source14">Fourteenth observable source.</param>
  17343. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17344. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17345. /// <exception cref="ArgumentNullException">
  17346. /// <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>
  17347. 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)
  17348. {
  17349. if (source1 == null)
  17350. throw new ArgumentNullException(nameof(source1));
  17351. if (source2 == null)
  17352. throw new ArgumentNullException(nameof(source2));
  17353. if (source3 == null)
  17354. throw new ArgumentNullException(nameof(source3));
  17355. if (source4 == null)
  17356. throw new ArgumentNullException(nameof(source4));
  17357. if (source5 == null)
  17358. throw new ArgumentNullException(nameof(source5));
  17359. if (source6 == null)
  17360. throw new ArgumentNullException(nameof(source6));
  17361. if (source7 == null)
  17362. throw new ArgumentNullException(nameof(source7));
  17363. if (source8 == null)
  17364. throw new ArgumentNullException(nameof(source8));
  17365. if (source9 == null)
  17366. throw new ArgumentNullException(nameof(source9));
  17367. if (source10 == null)
  17368. throw new ArgumentNullException(nameof(source10));
  17369. if (source11 == null)
  17370. throw new ArgumentNullException(nameof(source11));
  17371. if (source12 == null)
  17372. throw new ArgumentNullException(nameof(source12));
  17373. if (source13 == null)
  17374. throw new ArgumentNullException(nameof(source13));
  17375. if (source14 == null)
  17376. throw new ArgumentNullException(nameof(source14));
  17377. if (resultSelector == null)
  17378. throw new ArgumentNullException(nameof(resultSelector));
  17379. return source1.Provider.CreateQuery<TResult>(
  17380. Expression.Call(
  17381. null,
  17382. #if CRIPPLED_REFLECTION
  17383. 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>>))),
  17384. #else
  17385. ((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)),
  17386. #endif
  17387. source1.Expression,
  17388. GetSourceExpression(source2),
  17389. GetSourceExpression(source3),
  17390. GetSourceExpression(source4),
  17391. GetSourceExpression(source5),
  17392. GetSourceExpression(source6),
  17393. GetSourceExpression(source7),
  17394. GetSourceExpression(source8),
  17395. GetSourceExpression(source9),
  17396. GetSourceExpression(source10),
  17397. GetSourceExpression(source11),
  17398. GetSourceExpression(source12),
  17399. GetSourceExpression(source13),
  17400. GetSourceExpression(source14),
  17401. resultSelector
  17402. )
  17403. );
  17404. }
  17405. /// <summary>
  17406. /// 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.
  17407. /// </summary>
  17408. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17409. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17410. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17411. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17412. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17413. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17414. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17415. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17416. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17417. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17418. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17419. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17420. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17421. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17422. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17423. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17424. /// <param name="source1">First observable source.</param>
  17425. /// <param name="source2">Second observable source.</param>
  17426. /// <param name="source3">Third observable source.</param>
  17427. /// <param name="source4">Fourth observable source.</param>
  17428. /// <param name="source5">Fifth observable source.</param>
  17429. /// <param name="source6">Sixth observable source.</param>
  17430. /// <param name="source7">Seventh observable source.</param>
  17431. /// <param name="source8">Eighth observable source.</param>
  17432. /// <param name="source9">Ninth observable source.</param>
  17433. /// <param name="source10">Tenth observable source.</param>
  17434. /// <param name="source11">Eleventh observable source.</param>
  17435. /// <param name="source12">Twelfth observable source.</param>
  17436. /// <param name="source13">Thirteenth observable source.</param>
  17437. /// <param name="source14">Fourteenth observable source.</param>
  17438. /// <param name="source15">Fifteenth observable source.</param>
  17439. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17440. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17441. /// <exception cref="ArgumentNullException">
  17442. /// <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>
  17443. 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)
  17444. {
  17445. if (source1 == null)
  17446. throw new ArgumentNullException(nameof(source1));
  17447. if (source2 == null)
  17448. throw new ArgumentNullException(nameof(source2));
  17449. if (source3 == null)
  17450. throw new ArgumentNullException(nameof(source3));
  17451. if (source4 == null)
  17452. throw new ArgumentNullException(nameof(source4));
  17453. if (source5 == null)
  17454. throw new ArgumentNullException(nameof(source5));
  17455. if (source6 == null)
  17456. throw new ArgumentNullException(nameof(source6));
  17457. if (source7 == null)
  17458. throw new ArgumentNullException(nameof(source7));
  17459. if (source8 == null)
  17460. throw new ArgumentNullException(nameof(source8));
  17461. if (source9 == null)
  17462. throw new ArgumentNullException(nameof(source9));
  17463. if (source10 == null)
  17464. throw new ArgumentNullException(nameof(source10));
  17465. if (source11 == null)
  17466. throw new ArgumentNullException(nameof(source11));
  17467. if (source12 == null)
  17468. throw new ArgumentNullException(nameof(source12));
  17469. if (source13 == null)
  17470. throw new ArgumentNullException(nameof(source13));
  17471. if (source14 == null)
  17472. throw new ArgumentNullException(nameof(source14));
  17473. if (source15 == null)
  17474. throw new ArgumentNullException(nameof(source15));
  17475. if (resultSelector == null)
  17476. throw new ArgumentNullException(nameof(resultSelector));
  17477. return source1.Provider.CreateQuery<TResult>(
  17478. Expression.Call(
  17479. null,
  17480. #if CRIPPLED_REFLECTION
  17481. 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>>))),
  17482. #else
  17483. ((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)),
  17484. #endif
  17485. source1.Expression,
  17486. GetSourceExpression(source2),
  17487. GetSourceExpression(source3),
  17488. GetSourceExpression(source4),
  17489. GetSourceExpression(source5),
  17490. GetSourceExpression(source6),
  17491. GetSourceExpression(source7),
  17492. GetSourceExpression(source8),
  17493. GetSourceExpression(source9),
  17494. GetSourceExpression(source10),
  17495. GetSourceExpression(source11),
  17496. GetSourceExpression(source12),
  17497. GetSourceExpression(source13),
  17498. GetSourceExpression(source14),
  17499. GetSourceExpression(source15),
  17500. resultSelector
  17501. )
  17502. );
  17503. }
  17504. /// <summary>
  17505. /// 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.
  17506. /// </summary>
  17507. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17508. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17509. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17510. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17511. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17512. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17513. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17514. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17515. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17516. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17517. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17518. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17519. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17520. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17521. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17522. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  17523. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17524. /// <param name="source1">First observable source.</param>
  17525. /// <param name="source2">Second observable source.</param>
  17526. /// <param name="source3">Third observable source.</param>
  17527. /// <param name="source4">Fourth observable source.</param>
  17528. /// <param name="source5">Fifth observable source.</param>
  17529. /// <param name="source6">Sixth observable source.</param>
  17530. /// <param name="source7">Seventh observable source.</param>
  17531. /// <param name="source8">Eighth observable source.</param>
  17532. /// <param name="source9">Ninth observable source.</param>
  17533. /// <param name="source10">Tenth observable source.</param>
  17534. /// <param name="source11">Eleventh observable source.</param>
  17535. /// <param name="source12">Twelfth observable source.</param>
  17536. /// <param name="source13">Thirteenth observable source.</param>
  17537. /// <param name="source14">Fourteenth observable source.</param>
  17538. /// <param name="source15">Fifteenth observable source.</param>
  17539. /// <param name="source16">Sixteenth observable source.</param>
  17540. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17541. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17542. /// <exception cref="ArgumentNullException">
  17543. /// <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>
  17544. 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)
  17545. {
  17546. if (source1 == null)
  17547. throw new ArgumentNullException(nameof(source1));
  17548. if (source2 == null)
  17549. throw new ArgumentNullException(nameof(source2));
  17550. if (source3 == null)
  17551. throw new ArgumentNullException(nameof(source3));
  17552. if (source4 == null)
  17553. throw new ArgumentNullException(nameof(source4));
  17554. if (source5 == null)
  17555. throw new ArgumentNullException(nameof(source5));
  17556. if (source6 == null)
  17557. throw new ArgumentNullException(nameof(source6));
  17558. if (source7 == null)
  17559. throw new ArgumentNullException(nameof(source7));
  17560. if (source8 == null)
  17561. throw new ArgumentNullException(nameof(source8));
  17562. if (source9 == null)
  17563. throw new ArgumentNullException(nameof(source9));
  17564. if (source10 == null)
  17565. throw new ArgumentNullException(nameof(source10));
  17566. if (source11 == null)
  17567. throw new ArgumentNullException(nameof(source11));
  17568. if (source12 == null)
  17569. throw new ArgumentNullException(nameof(source12));
  17570. if (source13 == null)
  17571. throw new ArgumentNullException(nameof(source13));
  17572. if (source14 == null)
  17573. throw new ArgumentNullException(nameof(source14));
  17574. if (source15 == null)
  17575. throw new ArgumentNullException(nameof(source15));
  17576. if (source16 == null)
  17577. throw new ArgumentNullException(nameof(source16));
  17578. if (resultSelector == null)
  17579. throw new ArgumentNullException(nameof(resultSelector));
  17580. return source1.Provider.CreateQuery<TResult>(
  17581. Expression.Call(
  17582. null,
  17583. #if CRIPPLED_REFLECTION
  17584. 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>>))),
  17585. #else
  17586. ((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)),
  17587. #endif
  17588. source1.Expression,
  17589. GetSourceExpression(source2),
  17590. GetSourceExpression(source3),
  17591. GetSourceExpression(source4),
  17592. GetSourceExpression(source5),
  17593. GetSourceExpression(source6),
  17594. GetSourceExpression(source7),
  17595. GetSourceExpression(source8),
  17596. GetSourceExpression(source9),
  17597. GetSourceExpression(source10),
  17598. GetSourceExpression(source11),
  17599. GetSourceExpression(source12),
  17600. GetSourceExpression(source13),
  17601. GetSourceExpression(source14),
  17602. GetSourceExpression(source15),
  17603. GetSourceExpression(source16),
  17604. resultSelector
  17605. )
  17606. );
  17607. }
  17608. /// <summary>
  17609. /// 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.
  17610. /// </summary>
  17611. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17612. /// <param name="action">Action to convert to an asynchronous action.</param>
  17613. /// <returns>Asynchronous action.</returns>
  17614. /// <exception cref="ArgumentNullException">
  17615. /// <paramref name="action" /> is null.</exception>
  17616. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action)
  17617. {
  17618. if (provider == null)
  17619. throw new ArgumentNullException(nameof(provider));
  17620. if (action == null)
  17621. throw new ArgumentNullException(nameof(action));
  17622. #if CRIPPLED_REFLECTION
  17623. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>)));
  17624. #else
  17625. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17626. #endif
  17627. return () => provider.CreateQuery<Unit>(
  17628. Expression.Invoke(
  17629. Expression.Call(
  17630. null,
  17631. m,
  17632. Expression.Constant(provider, typeof(IQbservableProvider)),
  17633. action
  17634. )
  17635. )
  17636. );
  17637. }
  17638. /// <summary>
  17639. /// 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.
  17640. /// </summary>
  17641. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17642. /// <param name="action">Action to convert to an asynchronous action.</param>
  17643. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17644. /// <returns>Asynchronous action.</returns>
  17645. /// <exception cref="ArgumentNullException">
  17646. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17647. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  17648. {
  17649. if (provider == null)
  17650. throw new ArgumentNullException(nameof(provider));
  17651. if (action == null)
  17652. throw new ArgumentNullException(nameof(action));
  17653. if (scheduler == null)
  17654. throw new ArgumentNullException(nameof(scheduler));
  17655. #if CRIPPLED_REFLECTION
  17656. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>), default(IScheduler)));
  17657. #else
  17658. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17659. #endif
  17660. return () => provider.CreateQuery<Unit>(
  17661. Expression.Invoke(
  17662. Expression.Call(
  17663. null,
  17664. m,
  17665. Expression.Constant(provider, typeof(IQbservableProvider)),
  17666. action,
  17667. Expression.Constant(scheduler, typeof(IScheduler))
  17668. )
  17669. )
  17670. );
  17671. }
  17672. /// <summary>
  17673. /// 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.
  17674. /// </summary>
  17675. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17676. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17677. /// <param name="action">Action to convert to an asynchronous action.</param>
  17678. /// <returns>Asynchronous action.</returns>
  17679. /// <exception cref="ArgumentNullException">
  17680. /// <paramref name="action" /> is null.</exception>
  17681. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action)
  17682. {
  17683. if (provider == null)
  17684. throw new ArgumentNullException(nameof(provider));
  17685. if (action == null)
  17686. throw new ArgumentNullException(nameof(action));
  17687. #if CRIPPLED_REFLECTION
  17688. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>)));
  17689. #else
  17690. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17691. #endif
  17692. return (t1) => provider.CreateQuery<Unit>(
  17693. Expression.Invoke(
  17694. Expression.Call(
  17695. null,
  17696. m,
  17697. Expression.Constant(provider, typeof(IQbservableProvider)),
  17698. action
  17699. ),
  17700. Expression.Constant(t1, typeof(TArg1))
  17701. )
  17702. );
  17703. }
  17704. /// <summary>
  17705. /// 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.
  17706. /// </summary>
  17707. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17708. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17709. /// <param name="action">Action to convert to an asynchronous action.</param>
  17710. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17711. /// <returns>Asynchronous action.</returns>
  17712. /// <exception cref="ArgumentNullException">
  17713. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17714. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action, IScheduler scheduler)
  17715. {
  17716. if (provider == null)
  17717. throw new ArgumentNullException(nameof(provider));
  17718. if (action == null)
  17719. throw new ArgumentNullException(nameof(action));
  17720. if (scheduler == null)
  17721. throw new ArgumentNullException(nameof(scheduler));
  17722. #if CRIPPLED_REFLECTION
  17723. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>), default(IScheduler)));
  17724. #else
  17725. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17726. #endif
  17727. return (t1) => provider.CreateQuery<Unit>(
  17728. Expression.Invoke(
  17729. Expression.Call(
  17730. null,
  17731. m,
  17732. Expression.Constant(provider, typeof(IQbservableProvider)),
  17733. action,
  17734. Expression.Constant(scheduler, typeof(IScheduler))
  17735. ),
  17736. Expression.Constant(t1, typeof(TArg1))
  17737. )
  17738. );
  17739. }
  17740. /// <summary>
  17741. /// 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.
  17742. /// </summary>
  17743. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17744. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17745. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17746. /// <param name="action">Action to convert to an asynchronous action.</param>
  17747. /// <returns>Asynchronous action.</returns>
  17748. /// <exception cref="ArgumentNullException">
  17749. /// <paramref name="action" /> is null.</exception>
  17750. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action)
  17751. {
  17752. if (provider == null)
  17753. throw new ArgumentNullException(nameof(provider));
  17754. if (action == null)
  17755. throw new ArgumentNullException(nameof(action));
  17756. #if CRIPPLED_REFLECTION
  17757. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>)));
  17758. #else
  17759. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17760. #endif
  17761. return (t1, t2) => provider.CreateQuery<Unit>(
  17762. Expression.Invoke(
  17763. Expression.Call(
  17764. null,
  17765. m,
  17766. Expression.Constant(provider, typeof(IQbservableProvider)),
  17767. action
  17768. ),
  17769. Expression.Constant(t1, typeof(TArg1)),
  17770. Expression.Constant(t2, typeof(TArg2))
  17771. )
  17772. );
  17773. }
  17774. /// <summary>
  17775. /// 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.
  17776. /// </summary>
  17777. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17778. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17779. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17780. /// <param name="action">Action to convert to an asynchronous action.</param>
  17781. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17782. /// <returns>Asynchronous action.</returns>
  17783. /// <exception cref="ArgumentNullException">
  17784. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17785. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action, IScheduler scheduler)
  17786. {
  17787. if (provider == null)
  17788. throw new ArgumentNullException(nameof(provider));
  17789. if (action == null)
  17790. throw new ArgumentNullException(nameof(action));
  17791. if (scheduler == null)
  17792. throw new ArgumentNullException(nameof(scheduler));
  17793. #if CRIPPLED_REFLECTION
  17794. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>), default(IScheduler)));
  17795. #else
  17796. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17797. #endif
  17798. return (t1, t2) => provider.CreateQuery<Unit>(
  17799. Expression.Invoke(
  17800. Expression.Call(
  17801. null,
  17802. m,
  17803. Expression.Constant(provider, typeof(IQbservableProvider)),
  17804. action,
  17805. Expression.Constant(scheduler, typeof(IScheduler))
  17806. ),
  17807. Expression.Constant(t1, typeof(TArg1)),
  17808. Expression.Constant(t2, typeof(TArg2))
  17809. )
  17810. );
  17811. }
  17812. /// <summary>
  17813. /// 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.
  17814. /// </summary>
  17815. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17816. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17817. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17818. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17819. /// <param name="action">Action to convert to an asynchronous action.</param>
  17820. /// <returns>Asynchronous action.</returns>
  17821. /// <exception cref="ArgumentNullException">
  17822. /// <paramref name="action" /> is null.</exception>
  17823. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action)
  17824. {
  17825. if (provider == null)
  17826. throw new ArgumentNullException(nameof(provider));
  17827. if (action == null)
  17828. throw new ArgumentNullException(nameof(action));
  17829. #if CRIPPLED_REFLECTION
  17830. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>)));
  17831. #else
  17832. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17833. #endif
  17834. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17835. Expression.Invoke(
  17836. Expression.Call(
  17837. null,
  17838. m,
  17839. Expression.Constant(provider, typeof(IQbservableProvider)),
  17840. action
  17841. ),
  17842. Expression.Constant(t1, typeof(TArg1)),
  17843. Expression.Constant(t2, typeof(TArg2)),
  17844. Expression.Constant(t3, typeof(TArg3))
  17845. )
  17846. );
  17847. }
  17848. /// <summary>
  17849. /// 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.
  17850. /// </summary>
  17851. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17852. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17853. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17854. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17855. /// <param name="action">Action to convert to an asynchronous action.</param>
  17856. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17857. /// <returns>Asynchronous action.</returns>
  17858. /// <exception cref="ArgumentNullException">
  17859. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17860. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action, IScheduler scheduler)
  17861. {
  17862. if (provider == null)
  17863. throw new ArgumentNullException(nameof(provider));
  17864. if (action == null)
  17865. throw new ArgumentNullException(nameof(action));
  17866. if (scheduler == null)
  17867. throw new ArgumentNullException(nameof(scheduler));
  17868. #if CRIPPLED_REFLECTION
  17869. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>), default(IScheduler)));
  17870. #else
  17871. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17872. #endif
  17873. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17874. Expression.Invoke(
  17875. Expression.Call(
  17876. null,
  17877. m,
  17878. Expression.Constant(provider, typeof(IQbservableProvider)),
  17879. action,
  17880. Expression.Constant(scheduler, typeof(IScheduler))
  17881. ),
  17882. Expression.Constant(t1, typeof(TArg1)),
  17883. Expression.Constant(t2, typeof(TArg2)),
  17884. Expression.Constant(t3, typeof(TArg3))
  17885. )
  17886. );
  17887. }
  17888. /// <summary>
  17889. /// 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.
  17890. /// </summary>
  17891. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17892. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17893. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17894. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17895. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17896. /// <param name="action">Action to convert to an asynchronous action.</param>
  17897. /// <returns>Asynchronous action.</returns>
  17898. /// <exception cref="ArgumentNullException">
  17899. /// <paramref name="action" /> is null.</exception>
  17900. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4>> action)
  17901. {
  17902. if (provider == null)
  17903. throw new ArgumentNullException(nameof(provider));
  17904. if (action == null)
  17905. throw new ArgumentNullException(nameof(action));
  17906. #if CRIPPLED_REFLECTION
  17907. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>)));
  17908. #else
  17909. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17910. #endif
  17911. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17912. Expression.Invoke(
  17913. Expression.Call(
  17914. null,
  17915. m,
  17916. Expression.Constant(provider, typeof(IQbservableProvider)),
  17917. action
  17918. ),
  17919. Expression.Constant(t1, typeof(TArg1)),
  17920. Expression.Constant(t2, typeof(TArg2)),
  17921. Expression.Constant(t3, typeof(TArg3)),
  17922. Expression.Constant(t4, typeof(TArg4))
  17923. )
  17924. );
  17925. }
  17926. /// <summary>
  17927. /// 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.
  17928. /// </summary>
  17929. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17930. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17931. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17932. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17933. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17934. /// <param name="action">Action to convert to an asynchronous action.</param>
  17935. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17936. /// <returns>Asynchronous action.</returns>
  17937. /// <exception cref="ArgumentNullException">
  17938. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17939. 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)
  17940. {
  17941. if (provider == null)
  17942. throw new ArgumentNullException(nameof(provider));
  17943. if (action == null)
  17944. throw new ArgumentNullException(nameof(action));
  17945. if (scheduler == null)
  17946. throw new ArgumentNullException(nameof(scheduler));
  17947. #if CRIPPLED_REFLECTION
  17948. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>), default(IScheduler)));
  17949. #else
  17950. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17951. #endif
  17952. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17953. Expression.Invoke(
  17954. Expression.Call(
  17955. null,
  17956. m,
  17957. Expression.Constant(provider, typeof(IQbservableProvider)),
  17958. action,
  17959. Expression.Constant(scheduler, typeof(IScheduler))
  17960. ),
  17961. Expression.Constant(t1, typeof(TArg1)),
  17962. Expression.Constant(t2, typeof(TArg2)),
  17963. Expression.Constant(t3, typeof(TArg3)),
  17964. Expression.Constant(t4, typeof(TArg4))
  17965. )
  17966. );
  17967. }
  17968. /// <summary>
  17969. /// 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.
  17970. /// </summary>
  17971. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17972. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17973. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17974. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17975. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17976. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17977. /// <param name="action">Action to convert to an asynchronous action.</param>
  17978. /// <returns>Asynchronous action.</returns>
  17979. /// <exception cref="ArgumentNullException">
  17980. /// <paramref name="action" /> is null.</exception>
  17981. 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)
  17982. {
  17983. if (provider == null)
  17984. throw new ArgumentNullException(nameof(provider));
  17985. if (action == null)
  17986. throw new ArgumentNullException(nameof(action));
  17987. #if CRIPPLED_REFLECTION
  17988. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>)));
  17989. #else
  17990. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  17991. #endif
  17992. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  17993. Expression.Invoke(
  17994. Expression.Call(
  17995. null,
  17996. m,
  17997. Expression.Constant(provider, typeof(IQbservableProvider)),
  17998. action
  17999. ),
  18000. Expression.Constant(t1, typeof(TArg1)),
  18001. Expression.Constant(t2, typeof(TArg2)),
  18002. Expression.Constant(t3, typeof(TArg3)),
  18003. Expression.Constant(t4, typeof(TArg4)),
  18004. Expression.Constant(t5, typeof(TArg5))
  18005. )
  18006. );
  18007. }
  18008. /// <summary>
  18009. /// 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.
  18010. /// </summary>
  18011. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18012. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18013. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18014. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18015. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18016. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18017. /// <param name="action">Action to convert to an asynchronous action.</param>
  18018. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18019. /// <returns>Asynchronous action.</returns>
  18020. /// <exception cref="ArgumentNullException">
  18021. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18022. 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)
  18023. {
  18024. if (provider == null)
  18025. throw new ArgumentNullException(nameof(provider));
  18026. if (action == null)
  18027. throw new ArgumentNullException(nameof(action));
  18028. if (scheduler == null)
  18029. throw new ArgumentNullException(nameof(scheduler));
  18030. #if CRIPPLED_REFLECTION
  18031. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>), default(IScheduler)));
  18032. #else
  18033. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  18034. #endif
  18035. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  18036. Expression.Invoke(
  18037. Expression.Call(
  18038. null,
  18039. m,
  18040. Expression.Constant(provider, typeof(IQbservableProvider)),
  18041. action,
  18042. Expression.Constant(scheduler, typeof(IScheduler))
  18043. ),
  18044. Expression.Constant(t1, typeof(TArg1)),
  18045. Expression.Constant(t2, typeof(TArg2)),
  18046. Expression.Constant(t3, typeof(TArg3)),
  18047. Expression.Constant(t4, typeof(TArg4)),
  18048. Expression.Constant(t5, typeof(TArg5))
  18049. )
  18050. );
  18051. }
  18052. /// <summary>
  18053. /// 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.
  18054. /// </summary>
  18055. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18056. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18057. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18058. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18059. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18060. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18061. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18062. /// <param name="action">Action to convert to an asynchronous action.</param>
  18063. /// <returns>Asynchronous action.</returns>
  18064. /// <exception cref="ArgumentNullException">
  18065. /// <paramref name="action" /> is null.</exception>
  18066. 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)
  18067. {
  18068. if (provider == null)
  18069. throw new ArgumentNullException(nameof(provider));
  18070. if (action == null)
  18071. throw new ArgumentNullException(nameof(action));
  18072. #if CRIPPLED_REFLECTION
  18073. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>)));
  18074. #else
  18075. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  18076. #endif
  18077. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  18078. Expression.Invoke(
  18079. Expression.Call(
  18080. null,
  18081. m,
  18082. Expression.Constant(provider, typeof(IQbservableProvider)),
  18083. action
  18084. ),
  18085. Expression.Constant(t1, typeof(TArg1)),
  18086. Expression.Constant(t2, typeof(TArg2)),
  18087. Expression.Constant(t3, typeof(TArg3)),
  18088. Expression.Constant(t4, typeof(TArg4)),
  18089. Expression.Constant(t5, typeof(TArg5)),
  18090. Expression.Constant(t6, typeof(TArg6))
  18091. )
  18092. );
  18093. }
  18094. /// <summary>
  18095. /// 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.
  18096. /// </summary>
  18097. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18098. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18099. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18100. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18101. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18102. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18103. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18104. /// <param name="action">Action to convert to an asynchronous action.</param>
  18105. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18106. /// <returns>Asynchronous action.</returns>
  18107. /// <exception cref="ArgumentNullException">
  18108. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18109. 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)
  18110. {
  18111. if (provider == null)
  18112. throw new ArgumentNullException(nameof(provider));
  18113. if (action == null)
  18114. throw new ArgumentNullException(nameof(action));
  18115. if (scheduler == null)
  18116. throw new ArgumentNullException(nameof(scheduler));
  18117. #if CRIPPLED_REFLECTION
  18118. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>), default(IScheduler)));
  18119. #else
  18120. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  18121. #endif
  18122. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  18123. Expression.Invoke(
  18124. Expression.Call(
  18125. null,
  18126. m,
  18127. Expression.Constant(provider, typeof(IQbservableProvider)),
  18128. action,
  18129. Expression.Constant(scheduler, typeof(IScheduler))
  18130. ),
  18131. Expression.Constant(t1, typeof(TArg1)),
  18132. Expression.Constant(t2, typeof(TArg2)),
  18133. Expression.Constant(t3, typeof(TArg3)),
  18134. Expression.Constant(t4, typeof(TArg4)),
  18135. Expression.Constant(t5, typeof(TArg5)),
  18136. Expression.Constant(t6, typeof(TArg6))
  18137. )
  18138. );
  18139. }
  18140. /// <summary>
  18141. /// 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.
  18142. /// </summary>
  18143. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18144. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18145. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18146. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18147. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18148. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18149. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18150. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18151. /// <param name="action">Action to convert to an asynchronous action.</param>
  18152. /// <returns>Asynchronous action.</returns>
  18153. /// <exception cref="ArgumentNullException">
  18154. /// <paramref name="action" /> is null.</exception>
  18155. 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)
  18156. {
  18157. if (provider == null)
  18158. throw new ArgumentNullException(nameof(provider));
  18159. if (action == null)
  18160. throw new ArgumentNullException(nameof(action));
  18161. #if CRIPPLED_REFLECTION
  18162. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>>)));
  18163. #else
  18164. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  18165. #endif
  18166. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  18167. Expression.Invoke(
  18168. Expression.Call(
  18169. null,
  18170. m,
  18171. Expression.Constant(provider, typeof(IQbservableProvider)),
  18172. action
  18173. ),
  18174. Expression.Constant(t1, typeof(TArg1)),
  18175. Expression.Constant(t2, typeof(TArg2)),
  18176. Expression.Constant(t3, typeof(TArg3)),
  18177. Expression.Constant(t4, typeof(TArg4)),
  18178. Expression.Constant(t5, typeof(TArg5)),
  18179. Expression.Constant(t6, typeof(TArg6)),
  18180. Expression.Constant(t7, typeof(TArg7))
  18181. )
  18182. );
  18183. }
  18184. /// <summary>
  18185. /// 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.
  18186. /// </summary>
  18187. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18188. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18189. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18190. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18191. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18192. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18193. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18194. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18195. /// <param name="action">Action to convert to an asynchronous action.</param>
  18196. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18197. /// <returns>Asynchronous action.</returns>
  18198. /// <exception cref="ArgumentNullException">
  18199. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18200. 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)
  18201. {
  18202. if (provider == null)
  18203. throw new ArgumentNullException(nameof(provider));
  18204. if (action == null)
  18205. throw new ArgumentNullException(nameof(action));
  18206. if (scheduler == null)
  18207. throw new ArgumentNullException(nameof(scheduler));
  18208. #if CRIPPLED_REFLECTION
  18209. 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)));
  18210. #else
  18211. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  18212. #endif
  18213. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  18214. Expression.Invoke(
  18215. Expression.Call(
  18216. null,
  18217. m,
  18218. Expression.Constant(provider, typeof(IQbservableProvider)),
  18219. action,
  18220. Expression.Constant(scheduler, typeof(IScheduler))
  18221. ),
  18222. Expression.Constant(t1, typeof(TArg1)),
  18223. Expression.Constant(t2, typeof(TArg2)),
  18224. Expression.Constant(t3, typeof(TArg3)),
  18225. Expression.Constant(t4, typeof(TArg4)),
  18226. Expression.Constant(t5, typeof(TArg5)),
  18227. Expression.Constant(t6, typeof(TArg6)),
  18228. Expression.Constant(t7, typeof(TArg7))
  18229. )
  18230. );
  18231. }
  18232. /// <summary>
  18233. /// 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.
  18234. /// </summary>
  18235. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18236. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18237. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18238. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18239. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18240. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18241. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18242. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18243. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18244. /// <param name="action">Action to convert to an asynchronous action.</param>
  18245. /// <returns>Asynchronous action.</returns>
  18246. /// <exception cref="ArgumentNullException">
  18247. /// <paramref name="action" /> is null.</exception>
  18248. 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)
  18249. {
  18250. if (provider == null)
  18251. throw new ArgumentNullException(nameof(provider));
  18252. if (action == null)
  18253. throw new ArgumentNullException(nameof(action));
  18254. #if CRIPPLED_REFLECTION
  18255. 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>>)));
  18256. #else
  18257. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  18258. #endif
  18259. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  18260. Expression.Invoke(
  18261. Expression.Call(
  18262. null,
  18263. m,
  18264. Expression.Constant(provider, typeof(IQbservableProvider)),
  18265. action
  18266. ),
  18267. Expression.Constant(t1, typeof(TArg1)),
  18268. Expression.Constant(t2, typeof(TArg2)),
  18269. Expression.Constant(t3, typeof(TArg3)),
  18270. Expression.Constant(t4, typeof(TArg4)),
  18271. Expression.Constant(t5, typeof(TArg5)),
  18272. Expression.Constant(t6, typeof(TArg6)),
  18273. Expression.Constant(t7, typeof(TArg7)),
  18274. Expression.Constant(t8, typeof(TArg8))
  18275. )
  18276. );
  18277. }
  18278. /// <summary>
  18279. /// 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.
  18280. /// </summary>
  18281. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18282. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18283. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18284. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18285. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18286. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18287. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18288. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18289. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18290. /// <param name="action">Action to convert to an asynchronous action.</param>
  18291. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18292. /// <returns>Asynchronous action.</returns>
  18293. /// <exception cref="ArgumentNullException">
  18294. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18295. 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)
  18296. {
  18297. if (provider == null)
  18298. throw new ArgumentNullException(nameof(provider));
  18299. if (action == null)
  18300. throw new ArgumentNullException(nameof(action));
  18301. if (scheduler == null)
  18302. throw new ArgumentNullException(nameof(scheduler));
  18303. #if CRIPPLED_REFLECTION
  18304. 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)));
  18305. #else
  18306. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  18307. #endif
  18308. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  18309. Expression.Invoke(
  18310. Expression.Call(
  18311. null,
  18312. m,
  18313. Expression.Constant(provider, typeof(IQbservableProvider)),
  18314. action,
  18315. Expression.Constant(scheduler, typeof(IScheduler))
  18316. ),
  18317. Expression.Constant(t1, typeof(TArg1)),
  18318. Expression.Constant(t2, typeof(TArg2)),
  18319. Expression.Constant(t3, typeof(TArg3)),
  18320. Expression.Constant(t4, typeof(TArg4)),
  18321. Expression.Constant(t5, typeof(TArg5)),
  18322. Expression.Constant(t6, typeof(TArg6)),
  18323. Expression.Constant(t7, typeof(TArg7)),
  18324. Expression.Constant(t8, typeof(TArg8))
  18325. )
  18326. );
  18327. }
  18328. /// <summary>
  18329. /// 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.
  18330. /// </summary>
  18331. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18332. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18333. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18334. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18335. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18336. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18337. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18338. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18339. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18340. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18341. /// <param name="action">Action to convert to an asynchronous action.</param>
  18342. /// <returns>Asynchronous action.</returns>
  18343. /// <exception cref="ArgumentNullException">
  18344. /// <paramref name="action" /> is null.</exception>
  18345. 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)
  18346. {
  18347. if (provider == null)
  18348. throw new ArgumentNullException(nameof(provider));
  18349. if (action == null)
  18350. throw new ArgumentNullException(nameof(action));
  18351. #if CRIPPLED_REFLECTION
  18352. 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>>)));
  18353. #else
  18354. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18355. #endif
  18356. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18357. Expression.Invoke(
  18358. Expression.Call(
  18359. null,
  18360. m,
  18361. Expression.Constant(provider, typeof(IQbservableProvider)),
  18362. action
  18363. ),
  18364. Expression.Constant(t1, typeof(TArg1)),
  18365. Expression.Constant(t2, typeof(TArg2)),
  18366. Expression.Constant(t3, typeof(TArg3)),
  18367. Expression.Constant(t4, typeof(TArg4)),
  18368. Expression.Constant(t5, typeof(TArg5)),
  18369. Expression.Constant(t6, typeof(TArg6)),
  18370. Expression.Constant(t7, typeof(TArg7)),
  18371. Expression.Constant(t8, typeof(TArg8)),
  18372. Expression.Constant(t9, typeof(TArg9))
  18373. )
  18374. );
  18375. }
  18376. /// <summary>
  18377. /// 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.
  18378. /// </summary>
  18379. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18380. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18381. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18382. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18383. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18384. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18385. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18386. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18387. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18388. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18389. /// <param name="action">Action to convert to an asynchronous action.</param>
  18390. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18391. /// <returns>Asynchronous action.</returns>
  18392. /// <exception cref="ArgumentNullException">
  18393. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18394. 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)
  18395. {
  18396. if (provider == null)
  18397. throw new ArgumentNullException(nameof(provider));
  18398. if (action == null)
  18399. throw new ArgumentNullException(nameof(action));
  18400. if (scheduler == null)
  18401. throw new ArgumentNullException(nameof(scheduler));
  18402. #if CRIPPLED_REFLECTION
  18403. 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)));
  18404. #else
  18405. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  18406. #endif
  18407. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  18408. Expression.Invoke(
  18409. Expression.Call(
  18410. null,
  18411. m,
  18412. Expression.Constant(provider, typeof(IQbservableProvider)),
  18413. action,
  18414. Expression.Constant(scheduler, typeof(IScheduler))
  18415. ),
  18416. Expression.Constant(t1, typeof(TArg1)),
  18417. Expression.Constant(t2, typeof(TArg2)),
  18418. Expression.Constant(t3, typeof(TArg3)),
  18419. Expression.Constant(t4, typeof(TArg4)),
  18420. Expression.Constant(t5, typeof(TArg5)),
  18421. Expression.Constant(t6, typeof(TArg6)),
  18422. Expression.Constant(t7, typeof(TArg7)),
  18423. Expression.Constant(t8, typeof(TArg8)),
  18424. Expression.Constant(t9, typeof(TArg9))
  18425. )
  18426. );
  18427. }
  18428. /// <summary>
  18429. /// 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.
  18430. /// </summary>
  18431. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18432. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18433. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18434. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18435. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18436. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18437. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18438. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18439. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18440. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18441. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18442. /// <param name="action">Action to convert to an asynchronous action.</param>
  18443. /// <returns>Asynchronous action.</returns>
  18444. /// <exception cref="ArgumentNullException">
  18445. /// <paramref name="action" /> is null.</exception>
  18446. 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)
  18447. {
  18448. if (provider == null)
  18449. throw new ArgumentNullException(nameof(provider));
  18450. if (action == null)
  18451. throw new ArgumentNullException(nameof(action));
  18452. #if CRIPPLED_REFLECTION
  18453. 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>>)));
  18454. #else
  18455. 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));
  18456. #endif
  18457. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18458. Expression.Invoke(
  18459. Expression.Call(
  18460. null,
  18461. m,
  18462. Expression.Constant(provider, typeof(IQbservableProvider)),
  18463. action
  18464. ),
  18465. Expression.Constant(t1, typeof(TArg1)),
  18466. Expression.Constant(t2, typeof(TArg2)),
  18467. Expression.Constant(t3, typeof(TArg3)),
  18468. Expression.Constant(t4, typeof(TArg4)),
  18469. Expression.Constant(t5, typeof(TArg5)),
  18470. Expression.Constant(t6, typeof(TArg6)),
  18471. Expression.Constant(t7, typeof(TArg7)),
  18472. Expression.Constant(t8, typeof(TArg8)),
  18473. Expression.Constant(t9, typeof(TArg9)),
  18474. Expression.Constant(t10, typeof(TArg10))
  18475. )
  18476. );
  18477. }
  18478. /// <summary>
  18479. /// 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.
  18480. /// </summary>
  18481. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18482. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18483. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18484. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18485. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18486. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18487. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18488. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18489. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18490. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18491. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18492. /// <param name="action">Action to convert to an asynchronous action.</param>
  18493. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18494. /// <returns>Asynchronous action.</returns>
  18495. /// <exception cref="ArgumentNullException">
  18496. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18497. 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)
  18498. {
  18499. if (provider == null)
  18500. throw new ArgumentNullException(nameof(provider));
  18501. if (action == null)
  18502. throw new ArgumentNullException(nameof(action));
  18503. if (scheduler == null)
  18504. throw new ArgumentNullException(nameof(scheduler));
  18505. #if CRIPPLED_REFLECTION
  18506. 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)));
  18507. #else
  18508. 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));
  18509. #endif
  18510. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18511. Expression.Invoke(
  18512. Expression.Call(
  18513. null,
  18514. m,
  18515. Expression.Constant(provider, typeof(IQbservableProvider)),
  18516. action,
  18517. Expression.Constant(scheduler, typeof(IScheduler))
  18518. ),
  18519. Expression.Constant(t1, typeof(TArg1)),
  18520. Expression.Constant(t2, typeof(TArg2)),
  18521. Expression.Constant(t3, typeof(TArg3)),
  18522. Expression.Constant(t4, typeof(TArg4)),
  18523. Expression.Constant(t5, typeof(TArg5)),
  18524. Expression.Constant(t6, typeof(TArg6)),
  18525. Expression.Constant(t7, typeof(TArg7)),
  18526. Expression.Constant(t8, typeof(TArg8)),
  18527. Expression.Constant(t9, typeof(TArg9)),
  18528. Expression.Constant(t10, typeof(TArg10))
  18529. )
  18530. );
  18531. }
  18532. /// <summary>
  18533. /// 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.
  18534. /// </summary>
  18535. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18536. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18537. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18538. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18539. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18540. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18541. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18542. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18543. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18544. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18545. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18546. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18547. /// <param name="action">Action to convert to an asynchronous action.</param>
  18548. /// <returns>Asynchronous action.</returns>
  18549. /// <exception cref="ArgumentNullException">
  18550. /// <paramref name="action" /> is null.</exception>
  18551. 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)
  18552. {
  18553. if (provider == null)
  18554. throw new ArgumentNullException(nameof(provider));
  18555. if (action == null)
  18556. throw new ArgumentNullException(nameof(action));
  18557. #if CRIPPLED_REFLECTION
  18558. 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>>)));
  18559. #else
  18560. 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));
  18561. #endif
  18562. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18563. Expression.Invoke(
  18564. Expression.Call(
  18565. null,
  18566. m,
  18567. Expression.Constant(provider, typeof(IQbservableProvider)),
  18568. action
  18569. ),
  18570. Expression.Constant(t1, typeof(TArg1)),
  18571. Expression.Constant(t2, typeof(TArg2)),
  18572. Expression.Constant(t3, typeof(TArg3)),
  18573. Expression.Constant(t4, typeof(TArg4)),
  18574. Expression.Constant(t5, typeof(TArg5)),
  18575. Expression.Constant(t6, typeof(TArg6)),
  18576. Expression.Constant(t7, typeof(TArg7)),
  18577. Expression.Constant(t8, typeof(TArg8)),
  18578. Expression.Constant(t9, typeof(TArg9)),
  18579. Expression.Constant(t10, typeof(TArg10)),
  18580. Expression.Constant(t11, typeof(TArg11))
  18581. )
  18582. );
  18583. }
  18584. /// <summary>
  18585. /// 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.
  18586. /// </summary>
  18587. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18588. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18589. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18590. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18591. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18592. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18593. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18594. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18595. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18596. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18597. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18598. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18599. /// <param name="action">Action to convert to an asynchronous action.</param>
  18600. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18601. /// <returns>Asynchronous action.</returns>
  18602. /// <exception cref="ArgumentNullException">
  18603. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18604. 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)
  18605. {
  18606. if (provider == null)
  18607. throw new ArgumentNullException(nameof(provider));
  18608. if (action == null)
  18609. throw new ArgumentNullException(nameof(action));
  18610. if (scheduler == null)
  18611. throw new ArgumentNullException(nameof(scheduler));
  18612. #if CRIPPLED_REFLECTION
  18613. 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)));
  18614. #else
  18615. 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));
  18616. #endif
  18617. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18618. Expression.Invoke(
  18619. Expression.Call(
  18620. null,
  18621. m,
  18622. Expression.Constant(provider, typeof(IQbservableProvider)),
  18623. action,
  18624. Expression.Constant(scheduler, typeof(IScheduler))
  18625. ),
  18626. Expression.Constant(t1, typeof(TArg1)),
  18627. Expression.Constant(t2, typeof(TArg2)),
  18628. Expression.Constant(t3, typeof(TArg3)),
  18629. Expression.Constant(t4, typeof(TArg4)),
  18630. Expression.Constant(t5, typeof(TArg5)),
  18631. Expression.Constant(t6, typeof(TArg6)),
  18632. Expression.Constant(t7, typeof(TArg7)),
  18633. Expression.Constant(t8, typeof(TArg8)),
  18634. Expression.Constant(t9, typeof(TArg9)),
  18635. Expression.Constant(t10, typeof(TArg10)),
  18636. Expression.Constant(t11, typeof(TArg11))
  18637. )
  18638. );
  18639. }
  18640. /// <summary>
  18641. /// 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.
  18642. /// </summary>
  18643. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18644. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18645. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18646. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18647. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18648. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18649. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18650. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18651. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18652. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18653. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18654. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18655. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18656. /// <param name="action">Action to convert to an asynchronous action.</param>
  18657. /// <returns>Asynchronous action.</returns>
  18658. /// <exception cref="ArgumentNullException">
  18659. /// <paramref name="action" /> is null.</exception>
  18660. 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)
  18661. {
  18662. if (provider == null)
  18663. throw new ArgumentNullException(nameof(provider));
  18664. if (action == null)
  18665. throw new ArgumentNullException(nameof(action));
  18666. #if CRIPPLED_REFLECTION
  18667. 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>>)));
  18668. #else
  18669. 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));
  18670. #endif
  18671. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18672. Expression.Invoke(
  18673. Expression.Call(
  18674. null,
  18675. m,
  18676. Expression.Constant(provider, typeof(IQbservableProvider)),
  18677. action
  18678. ),
  18679. Expression.Constant(t1, typeof(TArg1)),
  18680. Expression.Constant(t2, typeof(TArg2)),
  18681. Expression.Constant(t3, typeof(TArg3)),
  18682. Expression.Constant(t4, typeof(TArg4)),
  18683. Expression.Constant(t5, typeof(TArg5)),
  18684. Expression.Constant(t6, typeof(TArg6)),
  18685. Expression.Constant(t7, typeof(TArg7)),
  18686. Expression.Constant(t8, typeof(TArg8)),
  18687. Expression.Constant(t9, typeof(TArg9)),
  18688. Expression.Constant(t10, typeof(TArg10)),
  18689. Expression.Constant(t11, typeof(TArg11)),
  18690. Expression.Constant(t12, typeof(TArg12))
  18691. )
  18692. );
  18693. }
  18694. /// <summary>
  18695. /// 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.
  18696. /// </summary>
  18697. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18698. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18699. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18700. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18701. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18702. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18703. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18704. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18705. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18706. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18707. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18708. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18709. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18710. /// <param name="action">Action to convert to an asynchronous action.</param>
  18711. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18712. /// <returns>Asynchronous action.</returns>
  18713. /// <exception cref="ArgumentNullException">
  18714. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18715. 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)
  18716. {
  18717. if (provider == null)
  18718. throw new ArgumentNullException(nameof(provider));
  18719. if (action == null)
  18720. throw new ArgumentNullException(nameof(action));
  18721. if (scheduler == null)
  18722. throw new ArgumentNullException(nameof(scheduler));
  18723. #if CRIPPLED_REFLECTION
  18724. 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)));
  18725. #else
  18726. 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));
  18727. #endif
  18728. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18729. Expression.Invoke(
  18730. Expression.Call(
  18731. null,
  18732. m,
  18733. Expression.Constant(provider, typeof(IQbservableProvider)),
  18734. action,
  18735. Expression.Constant(scheduler, typeof(IScheduler))
  18736. ),
  18737. Expression.Constant(t1, typeof(TArg1)),
  18738. Expression.Constant(t2, typeof(TArg2)),
  18739. Expression.Constant(t3, typeof(TArg3)),
  18740. Expression.Constant(t4, typeof(TArg4)),
  18741. Expression.Constant(t5, typeof(TArg5)),
  18742. Expression.Constant(t6, typeof(TArg6)),
  18743. Expression.Constant(t7, typeof(TArg7)),
  18744. Expression.Constant(t8, typeof(TArg8)),
  18745. Expression.Constant(t9, typeof(TArg9)),
  18746. Expression.Constant(t10, typeof(TArg10)),
  18747. Expression.Constant(t11, typeof(TArg11)),
  18748. Expression.Constant(t12, typeof(TArg12))
  18749. )
  18750. );
  18751. }
  18752. /// <summary>
  18753. /// 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.
  18754. /// </summary>
  18755. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18756. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18757. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18758. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18759. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18760. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18761. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18762. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18763. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18764. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18765. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18766. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18767. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18768. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18769. /// <param name="action">Action to convert to an asynchronous action.</param>
  18770. /// <returns>Asynchronous action.</returns>
  18771. /// <exception cref="ArgumentNullException">
  18772. /// <paramref name="action" /> is null.</exception>
  18773. 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)
  18774. {
  18775. if (provider == null)
  18776. throw new ArgumentNullException(nameof(provider));
  18777. if (action == null)
  18778. throw new ArgumentNullException(nameof(action));
  18779. #if CRIPPLED_REFLECTION
  18780. 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>>)));
  18781. #else
  18782. 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));
  18783. #endif
  18784. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18785. Expression.Invoke(
  18786. Expression.Call(
  18787. null,
  18788. m,
  18789. Expression.Constant(provider, typeof(IQbservableProvider)),
  18790. action
  18791. ),
  18792. Expression.Constant(t1, typeof(TArg1)),
  18793. Expression.Constant(t2, typeof(TArg2)),
  18794. Expression.Constant(t3, typeof(TArg3)),
  18795. Expression.Constant(t4, typeof(TArg4)),
  18796. Expression.Constant(t5, typeof(TArg5)),
  18797. Expression.Constant(t6, typeof(TArg6)),
  18798. Expression.Constant(t7, typeof(TArg7)),
  18799. Expression.Constant(t8, typeof(TArg8)),
  18800. Expression.Constant(t9, typeof(TArg9)),
  18801. Expression.Constant(t10, typeof(TArg10)),
  18802. Expression.Constant(t11, typeof(TArg11)),
  18803. Expression.Constant(t12, typeof(TArg12)),
  18804. Expression.Constant(t13, typeof(TArg13))
  18805. )
  18806. );
  18807. }
  18808. /// <summary>
  18809. /// 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.
  18810. /// </summary>
  18811. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18812. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18813. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18814. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18815. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18816. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18817. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18818. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18819. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18820. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18821. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18822. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18823. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18824. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18825. /// <param name="action">Action to convert to an asynchronous action.</param>
  18826. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18827. /// <returns>Asynchronous action.</returns>
  18828. /// <exception cref="ArgumentNullException">
  18829. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18830. 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)
  18831. {
  18832. if (provider == null)
  18833. throw new ArgumentNullException(nameof(provider));
  18834. if (action == null)
  18835. throw new ArgumentNullException(nameof(action));
  18836. if (scheduler == null)
  18837. throw new ArgumentNullException(nameof(scheduler));
  18838. #if CRIPPLED_REFLECTION
  18839. 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)));
  18840. #else
  18841. 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));
  18842. #endif
  18843. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18844. Expression.Invoke(
  18845. Expression.Call(
  18846. null,
  18847. m,
  18848. Expression.Constant(provider, typeof(IQbservableProvider)),
  18849. action,
  18850. Expression.Constant(scheduler, typeof(IScheduler))
  18851. ),
  18852. Expression.Constant(t1, typeof(TArg1)),
  18853. Expression.Constant(t2, typeof(TArg2)),
  18854. Expression.Constant(t3, typeof(TArg3)),
  18855. Expression.Constant(t4, typeof(TArg4)),
  18856. Expression.Constant(t5, typeof(TArg5)),
  18857. Expression.Constant(t6, typeof(TArg6)),
  18858. Expression.Constant(t7, typeof(TArg7)),
  18859. Expression.Constant(t8, typeof(TArg8)),
  18860. Expression.Constant(t9, typeof(TArg9)),
  18861. Expression.Constant(t10, typeof(TArg10)),
  18862. Expression.Constant(t11, typeof(TArg11)),
  18863. Expression.Constant(t12, typeof(TArg12)),
  18864. Expression.Constant(t13, typeof(TArg13))
  18865. )
  18866. );
  18867. }
  18868. /// <summary>
  18869. /// 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.
  18870. /// </summary>
  18871. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18872. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18873. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18874. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18875. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18876. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18877. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18878. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18879. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18880. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18881. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18882. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18883. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18884. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18885. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18886. /// <param name="action">Action to convert to an asynchronous action.</param>
  18887. /// <returns>Asynchronous action.</returns>
  18888. /// <exception cref="ArgumentNullException">
  18889. /// <paramref name="action" /> is null.</exception>
  18890. 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)
  18891. {
  18892. if (provider == null)
  18893. throw new ArgumentNullException(nameof(provider));
  18894. if (action == null)
  18895. throw new ArgumentNullException(nameof(action));
  18896. #if CRIPPLED_REFLECTION
  18897. 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>>)));
  18898. #else
  18899. 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));
  18900. #endif
  18901. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18902. Expression.Invoke(
  18903. Expression.Call(
  18904. null,
  18905. m,
  18906. Expression.Constant(provider, typeof(IQbservableProvider)),
  18907. action
  18908. ),
  18909. Expression.Constant(t1, typeof(TArg1)),
  18910. Expression.Constant(t2, typeof(TArg2)),
  18911. Expression.Constant(t3, typeof(TArg3)),
  18912. Expression.Constant(t4, typeof(TArg4)),
  18913. Expression.Constant(t5, typeof(TArg5)),
  18914. Expression.Constant(t6, typeof(TArg6)),
  18915. Expression.Constant(t7, typeof(TArg7)),
  18916. Expression.Constant(t8, typeof(TArg8)),
  18917. Expression.Constant(t9, typeof(TArg9)),
  18918. Expression.Constant(t10, typeof(TArg10)),
  18919. Expression.Constant(t11, typeof(TArg11)),
  18920. Expression.Constant(t12, typeof(TArg12)),
  18921. Expression.Constant(t13, typeof(TArg13)),
  18922. Expression.Constant(t14, typeof(TArg14))
  18923. )
  18924. );
  18925. }
  18926. /// <summary>
  18927. /// 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.
  18928. /// </summary>
  18929. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18930. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18931. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18932. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18933. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18934. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18935. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18936. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18937. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18938. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18939. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18940. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18941. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18942. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18943. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18944. /// <param name="action">Action to convert to an asynchronous action.</param>
  18945. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18946. /// <returns>Asynchronous action.</returns>
  18947. /// <exception cref="ArgumentNullException">
  18948. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18949. 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)
  18950. {
  18951. if (provider == null)
  18952. throw new ArgumentNullException(nameof(provider));
  18953. if (action == null)
  18954. throw new ArgumentNullException(nameof(action));
  18955. if (scheduler == null)
  18956. throw new ArgumentNullException(nameof(scheduler));
  18957. #if CRIPPLED_REFLECTION
  18958. 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)));
  18959. #else
  18960. 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));
  18961. #endif
  18962. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18963. Expression.Invoke(
  18964. Expression.Call(
  18965. null,
  18966. m,
  18967. Expression.Constant(provider, typeof(IQbservableProvider)),
  18968. action,
  18969. Expression.Constant(scheduler, typeof(IScheduler))
  18970. ),
  18971. Expression.Constant(t1, typeof(TArg1)),
  18972. Expression.Constant(t2, typeof(TArg2)),
  18973. Expression.Constant(t3, typeof(TArg3)),
  18974. Expression.Constant(t4, typeof(TArg4)),
  18975. Expression.Constant(t5, typeof(TArg5)),
  18976. Expression.Constant(t6, typeof(TArg6)),
  18977. Expression.Constant(t7, typeof(TArg7)),
  18978. Expression.Constant(t8, typeof(TArg8)),
  18979. Expression.Constant(t9, typeof(TArg9)),
  18980. Expression.Constant(t10, typeof(TArg10)),
  18981. Expression.Constant(t11, typeof(TArg11)),
  18982. Expression.Constant(t12, typeof(TArg12)),
  18983. Expression.Constant(t13, typeof(TArg13)),
  18984. Expression.Constant(t14, typeof(TArg14))
  18985. )
  18986. );
  18987. }
  18988. /// <summary>
  18989. /// 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.
  18990. /// </summary>
  18991. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18992. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18993. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18994. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18995. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18996. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18997. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18998. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18999. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19000. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19001. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19002. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19003. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19004. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19005. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19006. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19007. /// <param name="action">Action to convert to an asynchronous action.</param>
  19008. /// <returns>Asynchronous action.</returns>
  19009. /// <exception cref="ArgumentNullException">
  19010. /// <paramref name="action" /> is null.</exception>
  19011. 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)
  19012. {
  19013. if (provider == null)
  19014. throw new ArgumentNullException(nameof(provider));
  19015. if (action == null)
  19016. throw new ArgumentNullException(nameof(action));
  19017. #if CRIPPLED_REFLECTION
  19018. 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>>)));
  19019. #else
  19020. 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));
  19021. #endif
  19022. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  19023. Expression.Invoke(
  19024. Expression.Call(
  19025. null,
  19026. m,
  19027. Expression.Constant(provider, typeof(IQbservableProvider)),
  19028. action
  19029. ),
  19030. Expression.Constant(t1, typeof(TArg1)),
  19031. Expression.Constant(t2, typeof(TArg2)),
  19032. Expression.Constant(t3, typeof(TArg3)),
  19033. Expression.Constant(t4, typeof(TArg4)),
  19034. Expression.Constant(t5, typeof(TArg5)),
  19035. Expression.Constant(t6, typeof(TArg6)),
  19036. Expression.Constant(t7, typeof(TArg7)),
  19037. Expression.Constant(t8, typeof(TArg8)),
  19038. Expression.Constant(t9, typeof(TArg9)),
  19039. Expression.Constant(t10, typeof(TArg10)),
  19040. Expression.Constant(t11, typeof(TArg11)),
  19041. Expression.Constant(t12, typeof(TArg12)),
  19042. Expression.Constant(t13, typeof(TArg13)),
  19043. Expression.Constant(t14, typeof(TArg14)),
  19044. Expression.Constant(t15, typeof(TArg15))
  19045. )
  19046. );
  19047. }
  19048. /// <summary>
  19049. /// 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.
  19050. /// </summary>
  19051. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19052. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19053. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19054. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19055. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19056. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19057. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19058. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19059. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19060. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19061. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19062. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19063. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19064. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19065. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19066. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19067. /// <param name="action">Action to convert to an asynchronous action.</param>
  19068. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  19069. /// <returns>Asynchronous action.</returns>
  19070. /// <exception cref="ArgumentNullException">
  19071. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  19072. 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)
  19073. {
  19074. if (provider == null)
  19075. throw new ArgumentNullException(nameof(provider));
  19076. if (action == null)
  19077. throw new ArgumentNullException(nameof(action));
  19078. if (scheduler == null)
  19079. throw new ArgumentNullException(nameof(scheduler));
  19080. #if CRIPPLED_REFLECTION
  19081. 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)));
  19082. #else
  19083. 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));
  19084. #endif
  19085. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  19086. Expression.Invoke(
  19087. Expression.Call(
  19088. null,
  19089. m,
  19090. Expression.Constant(provider, typeof(IQbservableProvider)),
  19091. action,
  19092. Expression.Constant(scheduler, typeof(IScheduler))
  19093. ),
  19094. Expression.Constant(t1, typeof(TArg1)),
  19095. Expression.Constant(t2, typeof(TArg2)),
  19096. Expression.Constant(t3, typeof(TArg3)),
  19097. Expression.Constant(t4, typeof(TArg4)),
  19098. Expression.Constant(t5, typeof(TArg5)),
  19099. Expression.Constant(t6, typeof(TArg6)),
  19100. Expression.Constant(t7, typeof(TArg7)),
  19101. Expression.Constant(t8, typeof(TArg8)),
  19102. Expression.Constant(t9, typeof(TArg9)),
  19103. Expression.Constant(t10, typeof(TArg10)),
  19104. Expression.Constant(t11, typeof(TArg11)),
  19105. Expression.Constant(t12, typeof(TArg12)),
  19106. Expression.Constant(t13, typeof(TArg13)),
  19107. Expression.Constant(t14, typeof(TArg14)),
  19108. Expression.Constant(t15, typeof(TArg15))
  19109. )
  19110. );
  19111. }
  19112. /// <summary>
  19113. /// 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.
  19114. /// </summary>
  19115. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19116. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19117. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19118. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19119. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19120. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19121. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19122. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19123. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19124. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19125. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19126. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19127. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19128. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19129. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19130. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19131. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  19132. /// <param name="action">Action to convert to an asynchronous action.</param>
  19133. /// <returns>Asynchronous action.</returns>
  19134. /// <exception cref="ArgumentNullException">
  19135. /// <paramref name="action" /> is null.</exception>
  19136. 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)
  19137. {
  19138. if (provider == null)
  19139. throw new ArgumentNullException(nameof(provider));
  19140. if (action == null)
  19141. throw new ArgumentNullException(nameof(action));
  19142. #if CRIPPLED_REFLECTION
  19143. 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>>)));
  19144. #else
  19145. 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));
  19146. #endif
  19147. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  19148. Expression.Invoke(
  19149. Expression.Call(
  19150. null,
  19151. m,
  19152. Expression.Constant(provider, typeof(IQbservableProvider)),
  19153. action
  19154. ),
  19155. Expression.Constant(t1, typeof(TArg1)),
  19156. Expression.Constant(t2, typeof(TArg2)),
  19157. Expression.Constant(t3, typeof(TArg3)),
  19158. Expression.Constant(t4, typeof(TArg4)),
  19159. Expression.Constant(t5, typeof(TArg5)),
  19160. Expression.Constant(t6, typeof(TArg6)),
  19161. Expression.Constant(t7, typeof(TArg7)),
  19162. Expression.Constant(t8, typeof(TArg8)),
  19163. Expression.Constant(t9, typeof(TArg9)),
  19164. Expression.Constant(t10, typeof(TArg10)),
  19165. Expression.Constant(t11, typeof(TArg11)),
  19166. Expression.Constant(t12, typeof(TArg12)),
  19167. Expression.Constant(t13, typeof(TArg13)),
  19168. Expression.Constant(t14, typeof(TArg14)),
  19169. Expression.Constant(t15, typeof(TArg15)),
  19170. Expression.Constant(t16, typeof(TArg16))
  19171. )
  19172. );
  19173. }
  19174. /// <summary>
  19175. /// 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.
  19176. /// </summary>
  19177. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19178. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  19179. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  19180. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  19181. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  19182. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  19183. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  19184. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  19185. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  19186. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  19187. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  19188. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  19189. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  19190. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  19191. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  19192. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  19193. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  19194. /// <param name="action">Action to convert to an asynchronous action.</param>
  19195. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  19196. /// <returns>Asynchronous action.</returns>
  19197. /// <exception cref="ArgumentNullException">
  19198. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  19199. 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)
  19200. {
  19201. if (provider == null)
  19202. throw new ArgumentNullException(nameof(provider));
  19203. if (action == null)
  19204. throw new ArgumentNullException(nameof(action));
  19205. if (scheduler == null)
  19206. throw new ArgumentNullException(nameof(scheduler));
  19207. #if CRIPPLED_REFLECTION
  19208. 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)));
  19209. #else
  19210. 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));
  19211. #endif
  19212. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  19213. Expression.Invoke(
  19214. Expression.Call(
  19215. null,
  19216. m,
  19217. Expression.Constant(provider, typeof(IQbservableProvider)),
  19218. action,
  19219. Expression.Constant(scheduler, typeof(IScheduler))
  19220. ),
  19221. Expression.Constant(t1, typeof(TArg1)),
  19222. Expression.Constant(t2, typeof(TArg2)),
  19223. Expression.Constant(t3, typeof(TArg3)),
  19224. Expression.Constant(t4, typeof(TArg4)),
  19225. Expression.Constant(t5, typeof(TArg5)),
  19226. Expression.Constant(t6, typeof(TArg6)),
  19227. Expression.Constant(t7, typeof(TArg7)),
  19228. Expression.Constant(t8, typeof(TArg8)),
  19229. Expression.Constant(t9, typeof(TArg9)),
  19230. Expression.Constant(t10, typeof(TArg10)),
  19231. Expression.Constant(t11, typeof(TArg11)),
  19232. Expression.Constant(t12, typeof(TArg12)),
  19233. Expression.Constant(t13, typeof(TArg13)),
  19234. Expression.Constant(t14, typeof(TArg14)),
  19235. Expression.Constant(t15, typeof(TArg15)),
  19236. Expression.Constant(t16, typeof(TArg16))
  19237. )
  19238. );
  19239. }
  19240. /// <summary>
  19241. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19242. /// </summary>
  19243. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19244. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19245. /// <param name="function">Function to convert to an asynchronous function.</param>
  19246. /// <returns>Asynchronous function.</returns>
  19247. /// <exception cref="ArgumentNullException">
  19248. /// <paramref name="function" /> is null.</exception>
  19249. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  19250. {
  19251. if (provider == null)
  19252. throw new ArgumentNullException(nameof(provider));
  19253. if (function == null)
  19254. throw new ArgumentNullException(nameof(function));
  19255. #if CRIPPLED_REFLECTION
  19256. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>)));
  19257. #else
  19258. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  19259. #endif
  19260. return () => provider.CreateQuery<TResult>(
  19261. Expression.Invoke(
  19262. Expression.Call(
  19263. null,
  19264. m,
  19265. Expression.Constant(provider, typeof(IQbservableProvider)),
  19266. function
  19267. )
  19268. )
  19269. );
  19270. }
  19271. /// <summary>
  19272. /// 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.
  19273. /// </summary>
  19274. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19275. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19276. /// <param name="function">Function to convert to an asynchronous function.</param>
  19277. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19278. /// <returns>Asynchronous function.</returns>
  19279. /// <exception cref="ArgumentNullException">
  19280. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19281. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  19282. {
  19283. if (provider == null)
  19284. throw new ArgumentNullException(nameof(provider));
  19285. if (function == null)
  19286. throw new ArgumentNullException(nameof(function));
  19287. if (scheduler == null)
  19288. throw new ArgumentNullException(nameof(scheduler));
  19289. #if CRIPPLED_REFLECTION
  19290. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler)));
  19291. #else
  19292. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  19293. #endif
  19294. return () => provider.CreateQuery<TResult>(
  19295. Expression.Invoke(
  19296. Expression.Call(
  19297. null,
  19298. m,
  19299. Expression.Constant(provider, typeof(IQbservableProvider)),
  19300. function,
  19301. Expression.Constant(scheduler, typeof(IScheduler))
  19302. )
  19303. )
  19304. );
  19305. }
  19306. /// <summary>
  19307. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19308. /// </summary>
  19309. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19310. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19311. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19312. /// <param name="function">Function to convert to an asynchronous function.</param>
  19313. /// <returns>Asynchronous function.</returns>
  19314. /// <exception cref="ArgumentNullException">
  19315. /// <paramref name="function" /> is null.</exception>
  19316. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function)
  19317. {
  19318. if (provider == null)
  19319. throw new ArgumentNullException(nameof(provider));
  19320. if (function == null)
  19321. throw new ArgumentNullException(nameof(function));
  19322. #if CRIPPLED_REFLECTION
  19323. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>)));
  19324. #else
  19325. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19326. #endif
  19327. return (t1) => provider.CreateQuery<TResult>(
  19328. Expression.Invoke(
  19329. Expression.Call(
  19330. null,
  19331. m,
  19332. Expression.Constant(provider, typeof(IQbservableProvider)),
  19333. function
  19334. ),
  19335. Expression.Constant(t1, typeof(TArg1))
  19336. )
  19337. );
  19338. }
  19339. /// <summary>
  19340. /// 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.
  19341. /// </summary>
  19342. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19343. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19344. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19345. /// <param name="function">Function to convert to an asynchronous function.</param>
  19346. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19347. /// <returns>Asynchronous function.</returns>
  19348. /// <exception cref="ArgumentNullException">
  19349. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19350. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function, IScheduler scheduler)
  19351. {
  19352. if (provider == null)
  19353. throw new ArgumentNullException(nameof(provider));
  19354. if (function == null)
  19355. throw new ArgumentNullException(nameof(function));
  19356. if (scheduler == null)
  19357. throw new ArgumentNullException(nameof(scheduler));
  19358. #if CRIPPLED_REFLECTION
  19359. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>), default(IScheduler)));
  19360. #else
  19361. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  19362. #endif
  19363. return (t1) => provider.CreateQuery<TResult>(
  19364. Expression.Invoke(
  19365. Expression.Call(
  19366. null,
  19367. m,
  19368. Expression.Constant(provider, typeof(IQbservableProvider)),
  19369. function,
  19370. Expression.Constant(scheduler, typeof(IScheduler))
  19371. ),
  19372. Expression.Constant(t1, typeof(TArg1))
  19373. )
  19374. );
  19375. }
  19376. /// <summary>
  19377. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19378. /// </summary>
  19379. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19380. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19381. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19382. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19383. /// <param name="function">Function to convert to an asynchronous function.</param>
  19384. /// <returns>Asynchronous function.</returns>
  19385. /// <exception cref="ArgumentNullException">
  19386. /// <paramref name="function" /> is null.</exception>
  19387. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function)
  19388. {
  19389. if (provider == null)
  19390. throw new ArgumentNullException(nameof(provider));
  19391. if (function == null)
  19392. throw new ArgumentNullException(nameof(function));
  19393. #if CRIPPLED_REFLECTION
  19394. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>)));
  19395. #else
  19396. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19397. #endif
  19398. return (t1, t2) => provider.CreateQuery<TResult>(
  19399. Expression.Invoke(
  19400. Expression.Call(
  19401. null,
  19402. m,
  19403. Expression.Constant(provider, typeof(IQbservableProvider)),
  19404. function
  19405. ),
  19406. Expression.Constant(t1, typeof(TArg1)),
  19407. Expression.Constant(t2, typeof(TArg2))
  19408. )
  19409. );
  19410. }
  19411. /// <summary>
  19412. /// 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.
  19413. /// </summary>
  19414. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19415. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19416. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19417. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19418. /// <param name="function">Function to convert to an asynchronous function.</param>
  19419. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19420. /// <returns>Asynchronous function.</returns>
  19421. /// <exception cref="ArgumentNullException">
  19422. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19423. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function, IScheduler scheduler)
  19424. {
  19425. if (provider == null)
  19426. throw new ArgumentNullException(nameof(provider));
  19427. if (function == null)
  19428. throw new ArgumentNullException(nameof(function));
  19429. if (scheduler == null)
  19430. throw new ArgumentNullException(nameof(scheduler));
  19431. #if CRIPPLED_REFLECTION
  19432. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>), default(IScheduler)));
  19433. #else
  19434. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  19435. #endif
  19436. return (t1, t2) => provider.CreateQuery<TResult>(
  19437. Expression.Invoke(
  19438. Expression.Call(
  19439. null,
  19440. m,
  19441. Expression.Constant(provider, typeof(IQbservableProvider)),
  19442. function,
  19443. Expression.Constant(scheduler, typeof(IScheduler))
  19444. ),
  19445. Expression.Constant(t1, typeof(TArg1)),
  19446. Expression.Constant(t2, typeof(TArg2))
  19447. )
  19448. );
  19449. }
  19450. /// <summary>
  19451. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19452. /// </summary>
  19453. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19454. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19455. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19456. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19457. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19458. /// <param name="function">Function to convert to an asynchronous function.</param>
  19459. /// <returns>Asynchronous function.</returns>
  19460. /// <exception cref="ArgumentNullException">
  19461. /// <paramref name="function" /> is null.</exception>
  19462. public static Func<TArg1, TArg2, TArg3, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TResult>> function)
  19463. {
  19464. if (provider == null)
  19465. throw new ArgumentNullException(nameof(provider));
  19466. if (function == null)
  19467. throw new ArgumentNullException(nameof(function));
  19468. #if CRIPPLED_REFLECTION
  19469. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>)));
  19470. #else
  19471. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19472. #endif
  19473. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19474. Expression.Invoke(
  19475. Expression.Call(
  19476. null,
  19477. m,
  19478. Expression.Constant(provider, typeof(IQbservableProvider)),
  19479. function
  19480. ),
  19481. Expression.Constant(t1, typeof(TArg1)),
  19482. Expression.Constant(t2, typeof(TArg2)),
  19483. Expression.Constant(t3, typeof(TArg3))
  19484. )
  19485. );
  19486. }
  19487. /// <summary>
  19488. /// 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.
  19489. /// </summary>
  19490. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19491. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19492. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19493. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19494. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19495. /// <param name="function">Function to convert to an asynchronous function.</param>
  19496. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19497. /// <returns>Asynchronous function.</returns>
  19498. /// <exception cref="ArgumentNullException">
  19499. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19500. 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)
  19501. {
  19502. if (provider == null)
  19503. throw new ArgumentNullException(nameof(provider));
  19504. if (function == null)
  19505. throw new ArgumentNullException(nameof(function));
  19506. if (scheduler == null)
  19507. throw new ArgumentNullException(nameof(scheduler));
  19508. #if CRIPPLED_REFLECTION
  19509. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>), default(IScheduler)));
  19510. #else
  19511. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19512. #endif
  19513. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19514. Expression.Invoke(
  19515. Expression.Call(
  19516. null,
  19517. m,
  19518. Expression.Constant(provider, typeof(IQbservableProvider)),
  19519. function,
  19520. Expression.Constant(scheduler, typeof(IScheduler))
  19521. ),
  19522. Expression.Constant(t1, typeof(TArg1)),
  19523. Expression.Constant(t2, typeof(TArg2)),
  19524. Expression.Constant(t3, typeof(TArg3))
  19525. )
  19526. );
  19527. }
  19528. /// <summary>
  19529. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19530. /// </summary>
  19531. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19532. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19533. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19534. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19535. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19536. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19537. /// <param name="function">Function to convert to an asynchronous function.</param>
  19538. /// <returns>Asynchronous function.</returns>
  19539. /// <exception cref="ArgumentNullException">
  19540. /// <paramref name="function" /> is null.</exception>
  19541. 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)
  19542. {
  19543. if (provider == null)
  19544. throw new ArgumentNullException(nameof(provider));
  19545. if (function == null)
  19546. throw new ArgumentNullException(nameof(function));
  19547. #if CRIPPLED_REFLECTION
  19548. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>)));
  19549. #else
  19550. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19551. #endif
  19552. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19553. Expression.Invoke(
  19554. Expression.Call(
  19555. null,
  19556. m,
  19557. Expression.Constant(provider, typeof(IQbservableProvider)),
  19558. function
  19559. ),
  19560. Expression.Constant(t1, typeof(TArg1)),
  19561. Expression.Constant(t2, typeof(TArg2)),
  19562. Expression.Constant(t3, typeof(TArg3)),
  19563. Expression.Constant(t4, typeof(TArg4))
  19564. )
  19565. );
  19566. }
  19567. /// <summary>
  19568. /// 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.
  19569. /// </summary>
  19570. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19571. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19572. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19573. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19574. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19575. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19576. /// <param name="function">Function to convert to an asynchronous function.</param>
  19577. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19578. /// <returns>Asynchronous function.</returns>
  19579. /// <exception cref="ArgumentNullException">
  19580. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19581. 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)
  19582. {
  19583. if (provider == null)
  19584. throw new ArgumentNullException(nameof(provider));
  19585. if (function == null)
  19586. throw new ArgumentNullException(nameof(function));
  19587. if (scheduler == null)
  19588. throw new ArgumentNullException(nameof(scheduler));
  19589. #if CRIPPLED_REFLECTION
  19590. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>), default(IScheduler)));
  19591. #else
  19592. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19593. #endif
  19594. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19595. Expression.Invoke(
  19596. Expression.Call(
  19597. null,
  19598. m,
  19599. Expression.Constant(provider, typeof(IQbservableProvider)),
  19600. function,
  19601. Expression.Constant(scheduler, typeof(IScheduler))
  19602. ),
  19603. Expression.Constant(t1, typeof(TArg1)),
  19604. Expression.Constant(t2, typeof(TArg2)),
  19605. Expression.Constant(t3, typeof(TArg3)),
  19606. Expression.Constant(t4, typeof(TArg4))
  19607. )
  19608. );
  19609. }
  19610. /// <summary>
  19611. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19612. /// </summary>
  19613. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19614. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19615. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19616. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19617. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19618. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19619. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19620. /// <param name="function">Function to convert to an asynchronous function.</param>
  19621. /// <returns>Asynchronous function.</returns>
  19622. /// <exception cref="ArgumentNullException">
  19623. /// <paramref name="function" /> is null.</exception>
  19624. 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)
  19625. {
  19626. if (provider == null)
  19627. throw new ArgumentNullException(nameof(provider));
  19628. if (function == null)
  19629. throw new ArgumentNullException(nameof(function));
  19630. #if CRIPPLED_REFLECTION
  19631. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>)));
  19632. #else
  19633. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19634. #endif
  19635. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19636. Expression.Invoke(
  19637. Expression.Call(
  19638. null,
  19639. m,
  19640. Expression.Constant(provider, typeof(IQbservableProvider)),
  19641. function
  19642. ),
  19643. Expression.Constant(t1, typeof(TArg1)),
  19644. Expression.Constant(t2, typeof(TArg2)),
  19645. Expression.Constant(t3, typeof(TArg3)),
  19646. Expression.Constant(t4, typeof(TArg4)),
  19647. Expression.Constant(t5, typeof(TArg5))
  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 on the specified scheduler.
  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="TResult">The type of the result returned by the function.</typeparam>
  19661. /// <param name="function">Function to convert to an asynchronous function.</param>
  19662. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19663. /// <returns>Asynchronous function.</returns>
  19664. /// <exception cref="ArgumentNullException">
  19665. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19666. 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)
  19667. {
  19668. if (provider == null)
  19669. throw new ArgumentNullException(nameof(provider));
  19670. if (function == null)
  19671. throw new ArgumentNullException(nameof(function));
  19672. if (scheduler == null)
  19673. throw new ArgumentNullException(nameof(scheduler));
  19674. #if CRIPPLED_REFLECTION
  19675. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>), default(IScheduler)));
  19676. #else
  19677. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19678. #endif
  19679. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19680. Expression.Invoke(
  19681. Expression.Call(
  19682. null,
  19683. m,
  19684. Expression.Constant(provider, typeof(IQbservableProvider)),
  19685. function,
  19686. Expression.Constant(scheduler, typeof(IScheduler))
  19687. ),
  19688. Expression.Constant(t1, typeof(TArg1)),
  19689. Expression.Constant(t2, typeof(TArg2)),
  19690. Expression.Constant(t3, typeof(TArg3)),
  19691. Expression.Constant(t4, typeof(TArg4)),
  19692. Expression.Constant(t5, typeof(TArg5))
  19693. )
  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.
  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="TResult">The type of the result returned by the function.</typeparam>
  19707. /// <param name="function">Function to convert to an asynchronous function.</param>
  19708. /// <returns>Asynchronous function.</returns>
  19709. /// <exception cref="ArgumentNullException">
  19710. /// <paramref name="function" /> is null.</exception>
  19711. 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)
  19712. {
  19713. if (provider == null)
  19714. throw new ArgumentNullException(nameof(provider));
  19715. if (function == null)
  19716. throw new ArgumentNullException(nameof(function));
  19717. #if CRIPPLED_REFLECTION
  19718. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>>)));
  19719. #else
  19720. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19721. #endif
  19722. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19723. Expression.Invoke(
  19724. Expression.Call(
  19725. null,
  19726. m,
  19727. Expression.Constant(provider, typeof(IQbservableProvider)),
  19728. function
  19729. ),
  19730. Expression.Constant(t1, typeof(TArg1)),
  19731. Expression.Constant(t2, typeof(TArg2)),
  19732. Expression.Constant(t3, typeof(TArg3)),
  19733. Expression.Constant(t4, typeof(TArg4)),
  19734. Expression.Constant(t5, typeof(TArg5)),
  19735. Expression.Constant(t6, typeof(TArg6))
  19736. )
  19737. );
  19738. }
  19739. /// <summary>
  19740. /// 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.
  19741. /// </summary>
  19742. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19743. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19744. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19745. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19746. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19747. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19748. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19749. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19750. /// <param name="function">Function to convert to an asynchronous function.</param>
  19751. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19752. /// <returns>Asynchronous function.</returns>
  19753. /// <exception cref="ArgumentNullException">
  19754. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19755. 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)
  19756. {
  19757. if (provider == null)
  19758. throw new ArgumentNullException(nameof(provider));
  19759. if (function == null)
  19760. throw new ArgumentNullException(nameof(function));
  19761. if (scheduler == null)
  19762. throw new ArgumentNullException(nameof(scheduler));
  19763. #if CRIPPLED_REFLECTION
  19764. 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)));
  19765. #else
  19766. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19767. #endif
  19768. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19769. Expression.Invoke(
  19770. Expression.Call(
  19771. null,
  19772. m,
  19773. Expression.Constant(provider, typeof(IQbservableProvider)),
  19774. function,
  19775. Expression.Constant(scheduler, typeof(IScheduler))
  19776. ),
  19777. Expression.Constant(t1, typeof(TArg1)),
  19778. Expression.Constant(t2, typeof(TArg2)),
  19779. Expression.Constant(t3, typeof(TArg3)),
  19780. Expression.Constant(t4, typeof(TArg4)),
  19781. Expression.Constant(t5, typeof(TArg5)),
  19782. Expression.Constant(t6, typeof(TArg6))
  19783. )
  19784. );
  19785. }
  19786. /// <summary>
  19787. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19788. /// </summary>
  19789. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19790. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19791. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19792. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19793. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19794. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19795. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19796. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19797. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19798. /// <param name="function">Function to convert to an asynchronous function.</param>
  19799. /// <returns>Asynchronous function.</returns>
  19800. /// <exception cref="ArgumentNullException">
  19801. /// <paramref name="function" /> is null.</exception>
  19802. 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)
  19803. {
  19804. if (provider == null)
  19805. throw new ArgumentNullException(nameof(provider));
  19806. if (function == null)
  19807. throw new ArgumentNullException(nameof(function));
  19808. #if CRIPPLED_REFLECTION
  19809. 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>>)));
  19810. #else
  19811. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19812. #endif
  19813. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19814. Expression.Invoke(
  19815. Expression.Call(
  19816. null,
  19817. m,
  19818. Expression.Constant(provider, typeof(IQbservableProvider)),
  19819. function
  19820. ),
  19821. Expression.Constant(t1, typeof(TArg1)),
  19822. Expression.Constant(t2, typeof(TArg2)),
  19823. Expression.Constant(t3, typeof(TArg3)),
  19824. Expression.Constant(t4, typeof(TArg4)),
  19825. Expression.Constant(t5, typeof(TArg5)),
  19826. Expression.Constant(t6, typeof(TArg6)),
  19827. Expression.Constant(t7, typeof(TArg7))
  19828. )
  19829. );
  19830. }
  19831. /// <summary>
  19832. /// 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.
  19833. /// </summary>
  19834. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19835. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19836. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19837. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19838. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19839. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19840. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19841. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19842. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19843. /// <param name="function">Function to convert to an asynchronous function.</param>
  19844. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19845. /// <returns>Asynchronous function.</returns>
  19846. /// <exception cref="ArgumentNullException">
  19847. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19848. 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)
  19849. {
  19850. if (provider == null)
  19851. throw new ArgumentNullException(nameof(provider));
  19852. if (function == null)
  19853. throw new ArgumentNullException(nameof(function));
  19854. if (scheduler == null)
  19855. throw new ArgumentNullException(nameof(scheduler));
  19856. #if CRIPPLED_REFLECTION
  19857. 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)));
  19858. #else
  19859. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19860. #endif
  19861. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19862. Expression.Invoke(
  19863. Expression.Call(
  19864. null,
  19865. m,
  19866. Expression.Constant(provider, typeof(IQbservableProvider)),
  19867. function,
  19868. Expression.Constant(scheduler, typeof(IScheduler))
  19869. ),
  19870. Expression.Constant(t1, typeof(TArg1)),
  19871. Expression.Constant(t2, typeof(TArg2)),
  19872. Expression.Constant(t3, typeof(TArg3)),
  19873. Expression.Constant(t4, typeof(TArg4)),
  19874. Expression.Constant(t5, typeof(TArg5)),
  19875. Expression.Constant(t6, typeof(TArg6)),
  19876. Expression.Constant(t7, typeof(TArg7))
  19877. )
  19878. );
  19879. }
  19880. /// <summary>
  19881. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19882. /// </summary>
  19883. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19884. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19885. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19886. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19887. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19888. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19889. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19890. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19891. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19892. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19893. /// <param name="function">Function to convert to an asynchronous function.</param>
  19894. /// <returns>Asynchronous function.</returns>
  19895. /// <exception cref="ArgumentNullException">
  19896. /// <paramref name="function" /> is null.</exception>
  19897. 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)
  19898. {
  19899. if (provider == null)
  19900. throw new ArgumentNullException(nameof(provider));
  19901. if (function == null)
  19902. throw new ArgumentNullException(nameof(function));
  19903. #if CRIPPLED_REFLECTION
  19904. 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>>)));
  19905. #else
  19906. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19907. #endif
  19908. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19909. Expression.Invoke(
  19910. Expression.Call(
  19911. null,
  19912. m,
  19913. Expression.Constant(provider, typeof(IQbservableProvider)),
  19914. function
  19915. ),
  19916. Expression.Constant(t1, typeof(TArg1)),
  19917. Expression.Constant(t2, typeof(TArg2)),
  19918. Expression.Constant(t3, typeof(TArg3)),
  19919. Expression.Constant(t4, typeof(TArg4)),
  19920. Expression.Constant(t5, typeof(TArg5)),
  19921. Expression.Constant(t6, typeof(TArg6)),
  19922. Expression.Constant(t7, typeof(TArg7)),
  19923. Expression.Constant(t8, typeof(TArg8))
  19924. )
  19925. );
  19926. }
  19927. /// <summary>
  19928. /// 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.
  19929. /// </summary>
  19930. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19931. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19932. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19933. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19934. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19935. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19936. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19937. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19938. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19939. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19940. /// <param name="function">Function to convert to an asynchronous function.</param>
  19941. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19942. /// <returns>Asynchronous function.</returns>
  19943. /// <exception cref="ArgumentNullException">
  19944. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19945. 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)
  19946. {
  19947. if (provider == null)
  19948. throw new ArgumentNullException(nameof(provider));
  19949. if (function == null)
  19950. throw new ArgumentNullException(nameof(function));
  19951. if (scheduler == null)
  19952. throw new ArgumentNullException(nameof(scheduler));
  19953. #if CRIPPLED_REFLECTION
  19954. 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)));
  19955. #else
  19956. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19957. #endif
  19958. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19959. Expression.Invoke(
  19960. Expression.Call(
  19961. null,
  19962. m,
  19963. Expression.Constant(provider, typeof(IQbservableProvider)),
  19964. function,
  19965. Expression.Constant(scheduler, typeof(IScheduler))
  19966. ),
  19967. Expression.Constant(t1, typeof(TArg1)),
  19968. Expression.Constant(t2, typeof(TArg2)),
  19969. Expression.Constant(t3, typeof(TArg3)),
  19970. Expression.Constant(t4, typeof(TArg4)),
  19971. Expression.Constant(t5, typeof(TArg5)),
  19972. Expression.Constant(t6, typeof(TArg6)),
  19973. Expression.Constant(t7, typeof(TArg7)),
  19974. Expression.Constant(t8, typeof(TArg8))
  19975. )
  19976. );
  19977. }
  19978. /// <summary>
  19979. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19980. /// </summary>
  19981. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19982. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19983. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19984. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19985. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19986. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19987. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19988. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19989. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19990. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19991. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19992. /// <param name="function">Function to convert to an asynchronous function.</param>
  19993. /// <returns>Asynchronous function.</returns>
  19994. /// <exception cref="ArgumentNullException">
  19995. /// <paramref name="function" /> is null.</exception>
  19996. 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)
  19997. {
  19998. if (provider == null)
  19999. throw new ArgumentNullException(nameof(provider));
  20000. if (function == null)
  20001. throw new ArgumentNullException(nameof(function));
  20002. #if CRIPPLED_REFLECTION
  20003. 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>>)));
  20004. #else
  20005. 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));
  20006. #endif
  20007. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  20008. Expression.Invoke(
  20009. Expression.Call(
  20010. null,
  20011. m,
  20012. Expression.Constant(provider, typeof(IQbservableProvider)),
  20013. function
  20014. ),
  20015. Expression.Constant(t1, typeof(TArg1)),
  20016. Expression.Constant(t2, typeof(TArg2)),
  20017. Expression.Constant(t3, typeof(TArg3)),
  20018. Expression.Constant(t4, typeof(TArg4)),
  20019. Expression.Constant(t5, typeof(TArg5)),
  20020. Expression.Constant(t6, typeof(TArg6)),
  20021. Expression.Constant(t7, typeof(TArg7)),
  20022. Expression.Constant(t8, typeof(TArg8)),
  20023. Expression.Constant(t9, typeof(TArg9))
  20024. )
  20025. );
  20026. }
  20027. /// <summary>
  20028. /// 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.
  20029. /// </summary>
  20030. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20031. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20032. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20033. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20034. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20035. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20036. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20037. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20038. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20039. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20040. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20041. /// <param name="function">Function to convert to an asynchronous function.</param>
  20042. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20043. /// <returns>Asynchronous function.</returns>
  20044. /// <exception cref="ArgumentNullException">
  20045. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20046. 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)
  20047. {
  20048. if (provider == null)
  20049. throw new ArgumentNullException(nameof(provider));
  20050. if (function == null)
  20051. throw new ArgumentNullException(nameof(function));
  20052. if (scheduler == null)
  20053. throw new ArgumentNullException(nameof(scheduler));
  20054. #if CRIPPLED_REFLECTION
  20055. 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)));
  20056. #else
  20057. 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));
  20058. #endif
  20059. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  20060. Expression.Invoke(
  20061. Expression.Call(
  20062. null,
  20063. m,
  20064. Expression.Constant(provider, typeof(IQbservableProvider)),
  20065. function,
  20066. Expression.Constant(scheduler, typeof(IScheduler))
  20067. ),
  20068. Expression.Constant(t1, typeof(TArg1)),
  20069. Expression.Constant(t2, typeof(TArg2)),
  20070. Expression.Constant(t3, typeof(TArg3)),
  20071. Expression.Constant(t4, typeof(TArg4)),
  20072. Expression.Constant(t5, typeof(TArg5)),
  20073. Expression.Constant(t6, typeof(TArg6)),
  20074. Expression.Constant(t7, typeof(TArg7)),
  20075. Expression.Constant(t8, typeof(TArg8)),
  20076. Expression.Constant(t9, typeof(TArg9))
  20077. )
  20078. );
  20079. }
  20080. /// <summary>
  20081. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20082. /// </summary>
  20083. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20084. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20085. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20086. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20087. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20088. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20089. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20090. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20091. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20092. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20093. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20094. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20095. /// <param name="function">Function to convert to an asynchronous function.</param>
  20096. /// <returns>Asynchronous function.</returns>
  20097. /// <exception cref="ArgumentNullException">
  20098. /// <paramref name="function" /> is null.</exception>
  20099. 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)
  20100. {
  20101. if (provider == null)
  20102. throw new ArgumentNullException(nameof(provider));
  20103. if (function == null)
  20104. throw new ArgumentNullException(nameof(function));
  20105. #if CRIPPLED_REFLECTION
  20106. 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>>)));
  20107. #else
  20108. 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));
  20109. #endif
  20110. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  20111. Expression.Invoke(
  20112. Expression.Call(
  20113. null,
  20114. m,
  20115. Expression.Constant(provider, typeof(IQbservableProvider)),
  20116. function
  20117. ),
  20118. Expression.Constant(t1, typeof(TArg1)),
  20119. Expression.Constant(t2, typeof(TArg2)),
  20120. Expression.Constant(t3, typeof(TArg3)),
  20121. Expression.Constant(t4, typeof(TArg4)),
  20122. Expression.Constant(t5, typeof(TArg5)),
  20123. Expression.Constant(t6, typeof(TArg6)),
  20124. Expression.Constant(t7, typeof(TArg7)),
  20125. Expression.Constant(t8, typeof(TArg8)),
  20126. Expression.Constant(t9, typeof(TArg9)),
  20127. Expression.Constant(t10, typeof(TArg10))
  20128. )
  20129. );
  20130. }
  20131. /// <summary>
  20132. /// 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.
  20133. /// </summary>
  20134. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20135. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20136. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20137. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20138. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20139. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20140. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20141. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20142. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20143. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20144. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20145. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20146. /// <param name="function">Function to convert to an asynchronous function.</param>
  20147. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20148. /// <returns>Asynchronous function.</returns>
  20149. /// <exception cref="ArgumentNullException">
  20150. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20151. 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)
  20152. {
  20153. if (provider == null)
  20154. throw new ArgumentNullException(nameof(provider));
  20155. if (function == null)
  20156. throw new ArgumentNullException(nameof(function));
  20157. if (scheduler == null)
  20158. throw new ArgumentNullException(nameof(scheduler));
  20159. #if CRIPPLED_REFLECTION
  20160. 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)));
  20161. #else
  20162. 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));
  20163. #endif
  20164. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  20165. Expression.Invoke(
  20166. Expression.Call(
  20167. null,
  20168. m,
  20169. Expression.Constant(provider, typeof(IQbservableProvider)),
  20170. function,
  20171. Expression.Constant(scheduler, typeof(IScheduler))
  20172. ),
  20173. Expression.Constant(t1, typeof(TArg1)),
  20174. Expression.Constant(t2, typeof(TArg2)),
  20175. Expression.Constant(t3, typeof(TArg3)),
  20176. Expression.Constant(t4, typeof(TArg4)),
  20177. Expression.Constant(t5, typeof(TArg5)),
  20178. Expression.Constant(t6, typeof(TArg6)),
  20179. Expression.Constant(t7, typeof(TArg7)),
  20180. Expression.Constant(t8, typeof(TArg8)),
  20181. Expression.Constant(t9, typeof(TArg9)),
  20182. Expression.Constant(t10, typeof(TArg10))
  20183. )
  20184. );
  20185. }
  20186. /// <summary>
  20187. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20188. /// </summary>
  20189. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20190. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20191. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20192. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20193. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20194. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20195. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20196. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20197. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20198. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20199. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20200. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20201. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20202. /// <param name="function">Function to convert to an asynchronous function.</param>
  20203. /// <returns>Asynchronous function.</returns>
  20204. /// <exception cref="ArgumentNullException">
  20205. /// <paramref name="function" /> is null.</exception>
  20206. 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)
  20207. {
  20208. if (provider == null)
  20209. throw new ArgumentNullException(nameof(provider));
  20210. if (function == null)
  20211. throw new ArgumentNullException(nameof(function));
  20212. #if CRIPPLED_REFLECTION
  20213. 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>>)));
  20214. #else
  20215. 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));
  20216. #endif
  20217. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  20218. Expression.Invoke(
  20219. Expression.Call(
  20220. null,
  20221. m,
  20222. Expression.Constant(provider, typeof(IQbservableProvider)),
  20223. function
  20224. ),
  20225. Expression.Constant(t1, typeof(TArg1)),
  20226. Expression.Constant(t2, typeof(TArg2)),
  20227. Expression.Constant(t3, typeof(TArg3)),
  20228. Expression.Constant(t4, typeof(TArg4)),
  20229. Expression.Constant(t5, typeof(TArg5)),
  20230. Expression.Constant(t6, typeof(TArg6)),
  20231. Expression.Constant(t7, typeof(TArg7)),
  20232. Expression.Constant(t8, typeof(TArg8)),
  20233. Expression.Constant(t9, typeof(TArg9)),
  20234. Expression.Constant(t10, typeof(TArg10)),
  20235. Expression.Constant(t11, typeof(TArg11))
  20236. )
  20237. );
  20238. }
  20239. /// <summary>
  20240. /// 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.
  20241. /// </summary>
  20242. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20243. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20244. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20245. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20246. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20247. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20248. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20249. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20250. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20251. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20252. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20253. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20254. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20255. /// <param name="function">Function to convert to an asynchronous function.</param>
  20256. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20257. /// <returns>Asynchronous function.</returns>
  20258. /// <exception cref="ArgumentNullException">
  20259. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20260. 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)
  20261. {
  20262. if (provider == null)
  20263. throw new ArgumentNullException(nameof(provider));
  20264. if (function == null)
  20265. throw new ArgumentNullException(nameof(function));
  20266. if (scheduler == null)
  20267. throw new ArgumentNullException(nameof(scheduler));
  20268. #if CRIPPLED_REFLECTION
  20269. 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)));
  20270. #else
  20271. 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));
  20272. #endif
  20273. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  20274. Expression.Invoke(
  20275. Expression.Call(
  20276. null,
  20277. m,
  20278. Expression.Constant(provider, typeof(IQbservableProvider)),
  20279. function,
  20280. Expression.Constant(scheduler, typeof(IScheduler))
  20281. ),
  20282. Expression.Constant(t1, typeof(TArg1)),
  20283. Expression.Constant(t2, typeof(TArg2)),
  20284. Expression.Constant(t3, typeof(TArg3)),
  20285. Expression.Constant(t4, typeof(TArg4)),
  20286. Expression.Constant(t5, typeof(TArg5)),
  20287. Expression.Constant(t6, typeof(TArg6)),
  20288. Expression.Constant(t7, typeof(TArg7)),
  20289. Expression.Constant(t8, typeof(TArg8)),
  20290. Expression.Constant(t9, typeof(TArg9)),
  20291. Expression.Constant(t10, typeof(TArg10)),
  20292. Expression.Constant(t11, typeof(TArg11))
  20293. )
  20294. );
  20295. }
  20296. /// <summary>
  20297. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20298. /// </summary>
  20299. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20300. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20301. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20302. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20303. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20304. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20305. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20306. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20307. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20308. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20309. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20310. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20311. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20312. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20313. /// <param name="function">Function to convert to an asynchronous function.</param>
  20314. /// <returns>Asynchronous function.</returns>
  20315. /// <exception cref="ArgumentNullException">
  20316. /// <paramref name="function" /> is null.</exception>
  20317. 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)
  20318. {
  20319. if (provider == null)
  20320. throw new ArgumentNullException(nameof(provider));
  20321. if (function == null)
  20322. throw new ArgumentNullException(nameof(function));
  20323. #if CRIPPLED_REFLECTION
  20324. 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>>)));
  20325. #else
  20326. 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));
  20327. #endif
  20328. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20329. Expression.Invoke(
  20330. Expression.Call(
  20331. null,
  20332. m,
  20333. Expression.Constant(provider, typeof(IQbservableProvider)),
  20334. function
  20335. ),
  20336. Expression.Constant(t1, typeof(TArg1)),
  20337. Expression.Constant(t2, typeof(TArg2)),
  20338. Expression.Constant(t3, typeof(TArg3)),
  20339. Expression.Constant(t4, typeof(TArg4)),
  20340. Expression.Constant(t5, typeof(TArg5)),
  20341. Expression.Constant(t6, typeof(TArg6)),
  20342. Expression.Constant(t7, typeof(TArg7)),
  20343. Expression.Constant(t8, typeof(TArg8)),
  20344. Expression.Constant(t9, typeof(TArg9)),
  20345. Expression.Constant(t10, typeof(TArg10)),
  20346. Expression.Constant(t11, typeof(TArg11)),
  20347. Expression.Constant(t12, typeof(TArg12))
  20348. )
  20349. );
  20350. }
  20351. /// <summary>
  20352. /// 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.
  20353. /// </summary>
  20354. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20355. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20356. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20357. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20358. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20359. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20360. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20361. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20362. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20363. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20364. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20365. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20366. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20367. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20368. /// <param name="function">Function to convert to an asynchronous function.</param>
  20369. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20370. /// <returns>Asynchronous function.</returns>
  20371. /// <exception cref="ArgumentNullException">
  20372. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20373. 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)
  20374. {
  20375. if (provider == null)
  20376. throw new ArgumentNullException(nameof(provider));
  20377. if (function == null)
  20378. throw new ArgumentNullException(nameof(function));
  20379. if (scheduler == null)
  20380. throw new ArgumentNullException(nameof(scheduler));
  20381. #if CRIPPLED_REFLECTION
  20382. 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)));
  20383. #else
  20384. 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));
  20385. #endif
  20386. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  20387. Expression.Invoke(
  20388. Expression.Call(
  20389. null,
  20390. m,
  20391. Expression.Constant(provider, typeof(IQbservableProvider)),
  20392. function,
  20393. Expression.Constant(scheduler, typeof(IScheduler))
  20394. ),
  20395. Expression.Constant(t1, typeof(TArg1)),
  20396. Expression.Constant(t2, typeof(TArg2)),
  20397. Expression.Constant(t3, typeof(TArg3)),
  20398. Expression.Constant(t4, typeof(TArg4)),
  20399. Expression.Constant(t5, typeof(TArg5)),
  20400. Expression.Constant(t6, typeof(TArg6)),
  20401. Expression.Constant(t7, typeof(TArg7)),
  20402. Expression.Constant(t8, typeof(TArg8)),
  20403. Expression.Constant(t9, typeof(TArg9)),
  20404. Expression.Constant(t10, typeof(TArg10)),
  20405. Expression.Constant(t11, typeof(TArg11)),
  20406. Expression.Constant(t12, typeof(TArg12))
  20407. )
  20408. );
  20409. }
  20410. /// <summary>
  20411. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20412. /// </summary>
  20413. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20414. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20415. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20416. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20417. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20418. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20419. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20420. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20421. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20422. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20423. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20424. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20425. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20426. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20427. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20428. /// <param name="function">Function to convert to an asynchronous function.</param>
  20429. /// <returns>Asynchronous function.</returns>
  20430. /// <exception cref="ArgumentNullException">
  20431. /// <paramref name="function" /> is null.</exception>
  20432. 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)
  20433. {
  20434. if (provider == null)
  20435. throw new ArgumentNullException(nameof(provider));
  20436. if (function == null)
  20437. throw new ArgumentNullException(nameof(function));
  20438. #if CRIPPLED_REFLECTION
  20439. 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>>)));
  20440. #else
  20441. 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));
  20442. #endif
  20443. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20444. Expression.Invoke(
  20445. Expression.Call(
  20446. null,
  20447. m,
  20448. Expression.Constant(provider, typeof(IQbservableProvider)),
  20449. function
  20450. ),
  20451. Expression.Constant(t1, typeof(TArg1)),
  20452. Expression.Constant(t2, typeof(TArg2)),
  20453. Expression.Constant(t3, typeof(TArg3)),
  20454. Expression.Constant(t4, typeof(TArg4)),
  20455. Expression.Constant(t5, typeof(TArg5)),
  20456. Expression.Constant(t6, typeof(TArg6)),
  20457. Expression.Constant(t7, typeof(TArg7)),
  20458. Expression.Constant(t8, typeof(TArg8)),
  20459. Expression.Constant(t9, typeof(TArg9)),
  20460. Expression.Constant(t10, typeof(TArg10)),
  20461. Expression.Constant(t11, typeof(TArg11)),
  20462. Expression.Constant(t12, typeof(TArg12)),
  20463. Expression.Constant(t13, typeof(TArg13))
  20464. )
  20465. );
  20466. }
  20467. /// <summary>
  20468. /// 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.
  20469. /// </summary>
  20470. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20471. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20472. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20473. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20474. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20475. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20476. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20477. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20478. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20479. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20480. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20481. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20482. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20483. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20484. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20485. /// <param name="function">Function to convert to an asynchronous function.</param>
  20486. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20487. /// <returns>Asynchronous function.</returns>
  20488. /// <exception cref="ArgumentNullException">
  20489. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20490. 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)
  20491. {
  20492. if (provider == null)
  20493. throw new ArgumentNullException(nameof(provider));
  20494. if (function == null)
  20495. throw new ArgumentNullException(nameof(function));
  20496. if (scheduler == null)
  20497. throw new ArgumentNullException(nameof(scheduler));
  20498. #if CRIPPLED_REFLECTION
  20499. 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)));
  20500. #else
  20501. 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));
  20502. #endif
  20503. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20504. Expression.Invoke(
  20505. Expression.Call(
  20506. null,
  20507. m,
  20508. Expression.Constant(provider, typeof(IQbservableProvider)),
  20509. function,
  20510. Expression.Constant(scheduler, typeof(IScheduler))
  20511. ),
  20512. Expression.Constant(t1, typeof(TArg1)),
  20513. Expression.Constant(t2, typeof(TArg2)),
  20514. Expression.Constant(t3, typeof(TArg3)),
  20515. Expression.Constant(t4, typeof(TArg4)),
  20516. Expression.Constant(t5, typeof(TArg5)),
  20517. Expression.Constant(t6, typeof(TArg6)),
  20518. Expression.Constant(t7, typeof(TArg7)),
  20519. Expression.Constant(t8, typeof(TArg8)),
  20520. Expression.Constant(t9, typeof(TArg9)),
  20521. Expression.Constant(t10, typeof(TArg10)),
  20522. Expression.Constant(t11, typeof(TArg11)),
  20523. Expression.Constant(t12, typeof(TArg12)),
  20524. Expression.Constant(t13, typeof(TArg13))
  20525. )
  20526. );
  20527. }
  20528. /// <summary>
  20529. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20530. /// </summary>
  20531. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20532. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20533. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20534. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20535. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20536. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20537. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20538. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20539. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20540. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20541. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20542. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20543. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20544. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20545. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20546. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20547. /// <param name="function">Function to convert to an asynchronous function.</param>
  20548. /// <returns>Asynchronous function.</returns>
  20549. /// <exception cref="ArgumentNullException">
  20550. /// <paramref name="function" /> is null.</exception>
  20551. 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)
  20552. {
  20553. if (provider == null)
  20554. throw new ArgumentNullException(nameof(provider));
  20555. if (function == null)
  20556. throw new ArgumentNullException(nameof(function));
  20557. #if CRIPPLED_REFLECTION
  20558. 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>>)));
  20559. #else
  20560. 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));
  20561. #endif
  20562. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20563. Expression.Invoke(
  20564. Expression.Call(
  20565. null,
  20566. m,
  20567. Expression.Constant(provider, typeof(IQbservableProvider)),
  20568. function
  20569. ),
  20570. Expression.Constant(t1, typeof(TArg1)),
  20571. Expression.Constant(t2, typeof(TArg2)),
  20572. Expression.Constant(t3, typeof(TArg3)),
  20573. Expression.Constant(t4, typeof(TArg4)),
  20574. Expression.Constant(t5, typeof(TArg5)),
  20575. Expression.Constant(t6, typeof(TArg6)),
  20576. Expression.Constant(t7, typeof(TArg7)),
  20577. Expression.Constant(t8, typeof(TArg8)),
  20578. Expression.Constant(t9, typeof(TArg9)),
  20579. Expression.Constant(t10, typeof(TArg10)),
  20580. Expression.Constant(t11, typeof(TArg11)),
  20581. Expression.Constant(t12, typeof(TArg12)),
  20582. Expression.Constant(t13, typeof(TArg13)),
  20583. Expression.Constant(t14, typeof(TArg14))
  20584. )
  20585. );
  20586. }
  20587. /// <summary>
  20588. /// 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.
  20589. /// </summary>
  20590. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20591. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20592. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20593. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20594. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20595. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20596. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20597. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20598. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20599. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20600. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20601. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20602. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20603. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20604. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20605. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20606. /// <param name="function">Function to convert to an asynchronous function.</param>
  20607. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20608. /// <returns>Asynchronous function.</returns>
  20609. /// <exception cref="ArgumentNullException">
  20610. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20611. 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)
  20612. {
  20613. if (provider == null)
  20614. throw new ArgumentNullException(nameof(provider));
  20615. if (function == null)
  20616. throw new ArgumentNullException(nameof(function));
  20617. if (scheduler == null)
  20618. throw new ArgumentNullException(nameof(scheduler));
  20619. #if CRIPPLED_REFLECTION
  20620. 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)));
  20621. #else
  20622. 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));
  20623. #endif
  20624. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20625. Expression.Invoke(
  20626. Expression.Call(
  20627. null,
  20628. m,
  20629. Expression.Constant(provider, typeof(IQbservableProvider)),
  20630. function,
  20631. Expression.Constant(scheduler, typeof(IScheduler))
  20632. ),
  20633. Expression.Constant(t1, typeof(TArg1)),
  20634. Expression.Constant(t2, typeof(TArg2)),
  20635. Expression.Constant(t3, typeof(TArg3)),
  20636. Expression.Constant(t4, typeof(TArg4)),
  20637. Expression.Constant(t5, typeof(TArg5)),
  20638. Expression.Constant(t6, typeof(TArg6)),
  20639. Expression.Constant(t7, typeof(TArg7)),
  20640. Expression.Constant(t8, typeof(TArg8)),
  20641. Expression.Constant(t9, typeof(TArg9)),
  20642. Expression.Constant(t10, typeof(TArg10)),
  20643. Expression.Constant(t11, typeof(TArg11)),
  20644. Expression.Constant(t12, typeof(TArg12)),
  20645. Expression.Constant(t13, typeof(TArg13)),
  20646. Expression.Constant(t14, typeof(TArg14))
  20647. )
  20648. );
  20649. }
  20650. /// <summary>
  20651. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20652. /// </summary>
  20653. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20654. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20655. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20656. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20657. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20658. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20659. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20660. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20661. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20662. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20663. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20664. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20665. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20666. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20667. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20668. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20669. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20670. /// <param name="function">Function to convert to an asynchronous function.</param>
  20671. /// <returns>Asynchronous function.</returns>
  20672. /// <exception cref="ArgumentNullException">
  20673. /// <paramref name="function" /> is null.</exception>
  20674. 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)
  20675. {
  20676. if (provider == null)
  20677. throw new ArgumentNullException(nameof(provider));
  20678. if (function == null)
  20679. throw new ArgumentNullException(nameof(function));
  20680. #if CRIPPLED_REFLECTION
  20681. 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>>)));
  20682. #else
  20683. 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));
  20684. #endif
  20685. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20686. Expression.Invoke(
  20687. Expression.Call(
  20688. null,
  20689. m,
  20690. Expression.Constant(provider, typeof(IQbservableProvider)),
  20691. function
  20692. ),
  20693. Expression.Constant(t1, typeof(TArg1)),
  20694. Expression.Constant(t2, typeof(TArg2)),
  20695. Expression.Constant(t3, typeof(TArg3)),
  20696. Expression.Constant(t4, typeof(TArg4)),
  20697. Expression.Constant(t5, typeof(TArg5)),
  20698. Expression.Constant(t6, typeof(TArg6)),
  20699. Expression.Constant(t7, typeof(TArg7)),
  20700. Expression.Constant(t8, typeof(TArg8)),
  20701. Expression.Constant(t9, typeof(TArg9)),
  20702. Expression.Constant(t10, typeof(TArg10)),
  20703. Expression.Constant(t11, typeof(TArg11)),
  20704. Expression.Constant(t12, typeof(TArg12)),
  20705. Expression.Constant(t13, typeof(TArg13)),
  20706. Expression.Constant(t14, typeof(TArg14)),
  20707. Expression.Constant(t15, typeof(TArg15))
  20708. )
  20709. );
  20710. }
  20711. /// <summary>
  20712. /// 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.
  20713. /// </summary>
  20714. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20715. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20716. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20717. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20718. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20719. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20720. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20721. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20722. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20723. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20724. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20725. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20726. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20727. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20728. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20729. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20730. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20731. /// <param name="function">Function to convert to an asynchronous function.</param>
  20732. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20733. /// <returns>Asynchronous function.</returns>
  20734. /// <exception cref="ArgumentNullException">
  20735. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20736. 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)
  20737. {
  20738. if (provider == null)
  20739. throw new ArgumentNullException(nameof(provider));
  20740. if (function == null)
  20741. throw new ArgumentNullException(nameof(function));
  20742. if (scheduler == null)
  20743. throw new ArgumentNullException(nameof(scheduler));
  20744. #if CRIPPLED_REFLECTION
  20745. 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)));
  20746. #else
  20747. 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));
  20748. #endif
  20749. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20750. Expression.Invoke(
  20751. Expression.Call(
  20752. null,
  20753. m,
  20754. Expression.Constant(provider, typeof(IQbservableProvider)),
  20755. function,
  20756. Expression.Constant(scheduler, typeof(IScheduler))
  20757. ),
  20758. Expression.Constant(t1, typeof(TArg1)),
  20759. Expression.Constant(t2, typeof(TArg2)),
  20760. Expression.Constant(t3, typeof(TArg3)),
  20761. Expression.Constant(t4, typeof(TArg4)),
  20762. Expression.Constant(t5, typeof(TArg5)),
  20763. Expression.Constant(t6, typeof(TArg6)),
  20764. Expression.Constant(t7, typeof(TArg7)),
  20765. Expression.Constant(t8, typeof(TArg8)),
  20766. Expression.Constant(t9, typeof(TArg9)),
  20767. Expression.Constant(t10, typeof(TArg10)),
  20768. Expression.Constant(t11, typeof(TArg11)),
  20769. Expression.Constant(t12, typeof(TArg12)),
  20770. Expression.Constant(t13, typeof(TArg13)),
  20771. Expression.Constant(t14, typeof(TArg14)),
  20772. Expression.Constant(t15, typeof(TArg15))
  20773. )
  20774. );
  20775. }
  20776. /// <summary>
  20777. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20778. /// </summary>
  20779. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20780. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20781. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20782. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20783. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20784. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20785. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20786. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20787. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20788. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20789. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20790. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20791. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20792. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20793. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20794. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20795. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20796. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20797. /// <param name="function">Function to convert to an asynchronous function.</param>
  20798. /// <returns>Asynchronous function.</returns>
  20799. /// <exception cref="ArgumentNullException">
  20800. /// <paramref name="function" /> is null.</exception>
  20801. 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)
  20802. {
  20803. if (provider == null)
  20804. throw new ArgumentNullException(nameof(provider));
  20805. if (function == null)
  20806. throw new ArgumentNullException(nameof(function));
  20807. #if CRIPPLED_REFLECTION
  20808. 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>>)));
  20809. #else
  20810. 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));
  20811. #endif
  20812. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20813. Expression.Invoke(
  20814. Expression.Call(
  20815. null,
  20816. m,
  20817. Expression.Constant(provider, typeof(IQbservableProvider)),
  20818. function
  20819. ),
  20820. Expression.Constant(t1, typeof(TArg1)),
  20821. Expression.Constant(t2, typeof(TArg2)),
  20822. Expression.Constant(t3, typeof(TArg3)),
  20823. Expression.Constant(t4, typeof(TArg4)),
  20824. Expression.Constant(t5, typeof(TArg5)),
  20825. Expression.Constant(t6, typeof(TArg6)),
  20826. Expression.Constant(t7, typeof(TArg7)),
  20827. Expression.Constant(t8, typeof(TArg8)),
  20828. Expression.Constant(t9, typeof(TArg9)),
  20829. Expression.Constant(t10, typeof(TArg10)),
  20830. Expression.Constant(t11, typeof(TArg11)),
  20831. Expression.Constant(t12, typeof(TArg12)),
  20832. Expression.Constant(t13, typeof(TArg13)),
  20833. Expression.Constant(t14, typeof(TArg14)),
  20834. Expression.Constant(t15, typeof(TArg15)),
  20835. Expression.Constant(t16, typeof(TArg16))
  20836. )
  20837. );
  20838. }
  20839. /// <summary>
  20840. /// 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.
  20841. /// </summary>
  20842. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20843. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20844. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20845. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20846. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20847. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20848. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20849. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20850. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20851. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20852. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20853. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20854. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20855. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20856. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20857. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20858. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20859. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20860. /// <param name="function">Function to convert to an asynchronous function.</param>
  20861. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20862. /// <returns>Asynchronous function.</returns>
  20863. /// <exception cref="ArgumentNullException">
  20864. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20865. 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)
  20866. {
  20867. if (provider == null)
  20868. throw new ArgumentNullException(nameof(provider));
  20869. if (function == null)
  20870. throw new ArgumentNullException(nameof(function));
  20871. if (scheduler == null)
  20872. throw new ArgumentNullException(nameof(scheduler));
  20873. #if CRIPPLED_REFLECTION
  20874. 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)));
  20875. #else
  20876. 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));
  20877. #endif
  20878. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20879. Expression.Invoke(
  20880. Expression.Call(
  20881. null,
  20882. m,
  20883. Expression.Constant(provider, typeof(IQbservableProvider)),
  20884. function,
  20885. Expression.Constant(scheduler, typeof(IScheduler))
  20886. ),
  20887. Expression.Constant(t1, typeof(TArg1)),
  20888. Expression.Constant(t2, typeof(TArg2)),
  20889. Expression.Constant(t3, typeof(TArg3)),
  20890. Expression.Constant(t4, typeof(TArg4)),
  20891. Expression.Constant(t5, typeof(TArg5)),
  20892. Expression.Constant(t6, typeof(TArg6)),
  20893. Expression.Constant(t7, typeof(TArg7)),
  20894. Expression.Constant(t8, typeof(TArg8)),
  20895. Expression.Constant(t9, typeof(TArg9)),
  20896. Expression.Constant(t10, typeof(TArg10)),
  20897. Expression.Constant(t11, typeof(TArg11)),
  20898. Expression.Constant(t12, typeof(TArg12)),
  20899. Expression.Constant(t13, typeof(TArg13)),
  20900. Expression.Constant(t14, typeof(TArg14)),
  20901. Expression.Constant(t15, typeof(TArg15)),
  20902. Expression.Constant(t16, typeof(TArg16))
  20903. )
  20904. );
  20905. }
  20906. /// <summary>
  20907. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20908. /// </summary>
  20909. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20910. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20911. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20912. /// <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>
  20913. /// <exception cref="ArgumentNullException">
  20914. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20915. /// <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>
  20916. #if PREFERASYNC
  20917. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20918. #endif
  20919. public static Func<IQbservable<Unit>> FromAsyncPattern(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  20920. {
  20921. if (provider == null)
  20922. throw new ArgumentNullException(nameof(provider));
  20923. if (begin == null)
  20924. throw new ArgumentNullException(nameof(begin));
  20925. if (end == null)
  20926. throw new ArgumentNullException(nameof(end));
  20927. #if CRIPPLED_REFLECTION
  20928. var m = InfoOf(() => Qbservable.FromAsyncPattern(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20929. #else
  20930. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  20931. #endif
  20932. return () => provider.CreateQuery<Unit>(
  20933. Expression.Invoke(
  20934. Expression.Call(
  20935. null,
  20936. m,
  20937. Expression.Constant(provider, typeof(IQbservableProvider)),
  20938. begin,
  20939. end
  20940. )
  20941. )
  20942. );
  20943. }
  20944. /// <summary>
  20945. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20946. /// </summary>
  20947. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20948. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20949. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20950. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20951. /// <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>
  20952. /// <exception cref="ArgumentNullException">
  20953. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20954. /// <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>
  20955. #if PREFERASYNC
  20956. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20957. #endif
  20958. public static Func<TArg1, IQbservable<Unit>> FromAsyncPattern<TArg1>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>> end)
  20959. {
  20960. if (provider == null)
  20961. throw new ArgumentNullException(nameof(provider));
  20962. if (begin == null)
  20963. throw new ArgumentNullException(nameof(begin));
  20964. if (end == null)
  20965. throw new ArgumentNullException(nameof(end));
  20966. #if CRIPPLED_REFLECTION
  20967. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20968. #else
  20969. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  20970. #endif
  20971. return (t1) => provider.CreateQuery<Unit>(
  20972. Expression.Invoke(
  20973. Expression.Call(
  20974. null,
  20975. m,
  20976. Expression.Constant(provider, typeof(IQbservableProvider)),
  20977. begin,
  20978. end
  20979. ),
  20980. Expression.Constant(t1, typeof(TArg1))
  20981. )
  20982. );
  20983. }
  20984. /// <summary>
  20985. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20986. /// </summary>
  20987. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20988. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20989. /// <typeparam name="TArg2">The type of the second 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, IQbservable<Unit>> FromAsyncPattern<TArg1, TArg2>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, 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>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21009. #else
  21010. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  21011. #endif
  21012. return (t1, t2) => 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. )
  21024. );
  21025. }
  21026. /// <summary>
  21027. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21028. /// </summary>
  21029. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21030. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21031. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21032. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21033. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21034. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21035. /// <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>
  21036. /// <exception cref="ArgumentNullException">
  21037. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21038. /// <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>
  21039. #if PREFERASYNC
  21040. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21041. #endif
  21042. 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)
  21043. {
  21044. if (provider == null)
  21045. throw new ArgumentNullException(nameof(provider));
  21046. if (begin == null)
  21047. throw new ArgumentNullException(nameof(begin));
  21048. if (end == null)
  21049. throw new ArgumentNullException(nameof(end));
  21050. #if CRIPPLED_REFLECTION
  21051. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  21052. #else
  21053. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  21054. #endif
  21055. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  21056. Expression.Invoke(
  21057. Expression.Call(
  21058. null,
  21059. m,
  21060. Expression.Constant(provider, typeof(IQbservableProvider)),
  21061. begin,
  21062. end
  21063. ),
  21064. Expression.Constant(t1, typeof(TArg1)),
  21065. Expression.Constant(t2, typeof(TArg2)),
  21066. Expression.Constant(t3, typeof(TArg3))
  21067. )
  21068. );
  21069. }
  21070. /// <summary>
  21071. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21072. /// </summary>
  21073. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21074. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21075. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21076. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21077. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21078. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21079. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21080. /// <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>
  21081. /// <exception cref="ArgumentNullException">
  21082. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21083. /// <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>
  21084. #if PREFERASYNC
  21085. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21086. #endif
  21087. 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)
  21088. {
  21089. if (provider == null)
  21090. throw new ArgumentNullException(nameof(provider));
  21091. if (begin == null)
  21092. throw new ArgumentNullException(nameof(begin));
  21093. if (end == null)
  21094. throw new ArgumentNullException(nameof(end));
  21095. #if CRIPPLED_REFLECTION
  21096. 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>>)));
  21097. #else
  21098. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  21099. #endif
  21100. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  21101. Expression.Invoke(
  21102. Expression.Call(
  21103. null,
  21104. m,
  21105. Expression.Constant(provider, typeof(IQbservableProvider)),
  21106. begin,
  21107. end
  21108. ),
  21109. Expression.Constant(t1, typeof(TArg1)),
  21110. Expression.Constant(t2, typeof(TArg2)),
  21111. Expression.Constant(t3, typeof(TArg3)),
  21112. Expression.Constant(t4, typeof(TArg4))
  21113. )
  21114. );
  21115. }
  21116. /// <summary>
  21117. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21118. /// </summary>
  21119. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21120. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21121. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21122. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21123. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21124. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21125. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21126. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21127. /// <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>
  21128. /// <exception cref="ArgumentNullException">
  21129. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21130. /// <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>
  21131. #if PREFERASYNC
  21132. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21133. #endif
  21134. 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)
  21135. {
  21136. if (provider == null)
  21137. throw new ArgumentNullException(nameof(provider));
  21138. if (begin == null)
  21139. throw new ArgumentNullException(nameof(begin));
  21140. if (end == null)
  21141. throw new ArgumentNullException(nameof(end));
  21142. #if CRIPPLED_REFLECTION
  21143. 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>>)));
  21144. #else
  21145. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  21146. #endif
  21147. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  21148. Expression.Invoke(
  21149. Expression.Call(
  21150. null,
  21151. m,
  21152. Expression.Constant(provider, typeof(IQbservableProvider)),
  21153. begin,
  21154. end
  21155. ),
  21156. Expression.Constant(t1, typeof(TArg1)),
  21157. Expression.Constant(t2, typeof(TArg2)),
  21158. Expression.Constant(t3, typeof(TArg3)),
  21159. Expression.Constant(t4, typeof(TArg4)),
  21160. Expression.Constant(t5, typeof(TArg5))
  21161. )
  21162. );
  21163. }
  21164. /// <summary>
  21165. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21166. /// </summary>
  21167. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21168. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21169. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21170. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21171. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21172. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21173. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21174. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21175. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21176. /// <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>
  21177. /// <exception cref="ArgumentNullException">
  21178. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21179. /// <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>
  21180. #if PREFERASYNC
  21181. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21182. #endif
  21183. 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)
  21184. {
  21185. if (provider == null)
  21186. throw new ArgumentNullException(nameof(provider));
  21187. if (begin == null)
  21188. throw new ArgumentNullException(nameof(begin));
  21189. if (end == null)
  21190. throw new ArgumentNullException(nameof(end));
  21191. #if CRIPPLED_REFLECTION
  21192. 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>>)));
  21193. #else
  21194. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  21195. #endif
  21196. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  21197. Expression.Invoke(
  21198. Expression.Call(
  21199. null,
  21200. m,
  21201. Expression.Constant(provider, typeof(IQbservableProvider)),
  21202. begin,
  21203. end
  21204. ),
  21205. Expression.Constant(t1, typeof(TArg1)),
  21206. Expression.Constant(t2, typeof(TArg2)),
  21207. Expression.Constant(t3, typeof(TArg3)),
  21208. Expression.Constant(t4, typeof(TArg4)),
  21209. Expression.Constant(t5, typeof(TArg5)),
  21210. Expression.Constant(t6, typeof(TArg6))
  21211. )
  21212. );
  21213. }
  21214. /// <summary>
  21215. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21216. /// </summary>
  21217. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21218. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21219. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21220. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21221. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21222. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21223. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21224. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21225. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21226. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21227. /// <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>
  21228. /// <exception cref="ArgumentNullException">
  21229. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21230. /// <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>
  21231. #if PREFERASYNC
  21232. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21233. #endif
  21234. 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)
  21235. {
  21236. if (provider == null)
  21237. throw new ArgumentNullException(nameof(provider));
  21238. if (begin == null)
  21239. throw new ArgumentNullException(nameof(begin));
  21240. if (end == null)
  21241. throw new ArgumentNullException(nameof(end));
  21242. #if CRIPPLED_REFLECTION
  21243. 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>>)));
  21244. #else
  21245. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  21246. #endif
  21247. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  21248. Expression.Invoke(
  21249. Expression.Call(
  21250. null,
  21251. m,
  21252. Expression.Constant(provider, typeof(IQbservableProvider)),
  21253. begin,
  21254. end
  21255. ),
  21256. Expression.Constant(t1, typeof(TArg1)),
  21257. Expression.Constant(t2, typeof(TArg2)),
  21258. Expression.Constant(t3, typeof(TArg3)),
  21259. Expression.Constant(t4, typeof(TArg4)),
  21260. Expression.Constant(t5, typeof(TArg5)),
  21261. Expression.Constant(t6, typeof(TArg6)),
  21262. Expression.Constant(t7, typeof(TArg7))
  21263. )
  21264. );
  21265. }
  21266. /// <summary>
  21267. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21268. /// </summary>
  21269. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21270. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21271. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21272. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21273. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21274. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21275. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21276. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21277. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21278. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21279. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21280. /// <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>
  21281. /// <exception cref="ArgumentNullException">
  21282. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21283. /// <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>
  21284. #if PREFERASYNC
  21285. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21286. #endif
  21287. 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)
  21288. {
  21289. if (provider == null)
  21290. throw new ArgumentNullException(nameof(provider));
  21291. if (begin == null)
  21292. throw new ArgumentNullException(nameof(begin));
  21293. if (end == null)
  21294. throw new ArgumentNullException(nameof(end));
  21295. #if CRIPPLED_REFLECTION
  21296. 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>>)));
  21297. #else
  21298. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  21299. #endif
  21300. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  21301. Expression.Invoke(
  21302. Expression.Call(
  21303. null,
  21304. m,
  21305. Expression.Constant(provider, typeof(IQbservableProvider)),
  21306. begin,
  21307. end
  21308. ),
  21309. Expression.Constant(t1, typeof(TArg1)),
  21310. Expression.Constant(t2, typeof(TArg2)),
  21311. Expression.Constant(t3, typeof(TArg3)),
  21312. Expression.Constant(t4, typeof(TArg4)),
  21313. Expression.Constant(t5, typeof(TArg5)),
  21314. Expression.Constant(t6, typeof(TArg6)),
  21315. Expression.Constant(t7, typeof(TArg7)),
  21316. Expression.Constant(t8, typeof(TArg8))
  21317. )
  21318. );
  21319. }
  21320. /// <summary>
  21321. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21322. /// </summary>
  21323. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21324. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21325. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21326. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21327. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21328. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21329. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21330. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21331. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21332. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21333. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21334. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21335. /// <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>
  21336. /// <exception cref="ArgumentNullException">
  21337. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21338. /// <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>
  21339. #if PREFERASYNC
  21340. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21341. #endif
  21342. 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)
  21343. {
  21344. if (provider == null)
  21345. throw new ArgumentNullException(nameof(provider));
  21346. if (begin == null)
  21347. throw new ArgumentNullException(nameof(begin));
  21348. if (end == null)
  21349. throw new ArgumentNullException(nameof(end));
  21350. #if CRIPPLED_REFLECTION
  21351. 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>>)));
  21352. #else
  21353. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  21354. #endif
  21355. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  21356. Expression.Invoke(
  21357. Expression.Call(
  21358. null,
  21359. m,
  21360. Expression.Constant(provider, typeof(IQbservableProvider)),
  21361. begin,
  21362. end
  21363. ),
  21364. Expression.Constant(t1, typeof(TArg1)),
  21365. Expression.Constant(t2, typeof(TArg2)),
  21366. Expression.Constant(t3, typeof(TArg3)),
  21367. Expression.Constant(t4, typeof(TArg4)),
  21368. Expression.Constant(t5, typeof(TArg5)),
  21369. Expression.Constant(t6, typeof(TArg6)),
  21370. Expression.Constant(t7, typeof(TArg7)),
  21371. Expression.Constant(t8, typeof(TArg8)),
  21372. Expression.Constant(t9, typeof(TArg9))
  21373. )
  21374. );
  21375. }
  21376. /// <summary>
  21377. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21378. /// </summary>
  21379. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21380. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21381. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21382. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21383. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21384. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21385. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21386. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21387. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21388. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21389. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21390. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21391. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21392. /// <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>
  21393. /// <exception cref="ArgumentNullException">
  21394. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21395. /// <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>
  21396. #if PREFERASYNC
  21397. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21398. #endif
  21399. 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)
  21400. {
  21401. if (provider == null)
  21402. throw new ArgumentNullException(nameof(provider));
  21403. if (begin == null)
  21404. throw new ArgumentNullException(nameof(begin));
  21405. if (end == null)
  21406. throw new ArgumentNullException(nameof(end));
  21407. #if CRIPPLED_REFLECTION
  21408. 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>>)));
  21409. #else
  21410. 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));
  21411. #endif
  21412. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  21413. Expression.Invoke(
  21414. Expression.Call(
  21415. null,
  21416. m,
  21417. Expression.Constant(provider, typeof(IQbservableProvider)),
  21418. begin,
  21419. end
  21420. ),
  21421. Expression.Constant(t1, typeof(TArg1)),
  21422. Expression.Constant(t2, typeof(TArg2)),
  21423. Expression.Constant(t3, typeof(TArg3)),
  21424. Expression.Constant(t4, typeof(TArg4)),
  21425. Expression.Constant(t5, typeof(TArg5)),
  21426. Expression.Constant(t6, typeof(TArg6)),
  21427. Expression.Constant(t7, typeof(TArg7)),
  21428. Expression.Constant(t8, typeof(TArg8)),
  21429. Expression.Constant(t9, typeof(TArg9)),
  21430. Expression.Constant(t10, typeof(TArg10))
  21431. )
  21432. );
  21433. }
  21434. /// <summary>
  21435. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21436. /// </summary>
  21437. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21438. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21439. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21440. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21441. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21442. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21443. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21444. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21445. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21446. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21447. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21448. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21449. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21450. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21451. /// <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>
  21452. /// <exception cref="ArgumentNullException">
  21453. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21454. /// <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>
  21455. #if PREFERASYNC
  21456. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21457. #endif
  21458. 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)
  21459. {
  21460. if (provider == null)
  21461. throw new ArgumentNullException(nameof(provider));
  21462. if (begin == null)
  21463. throw new ArgumentNullException(nameof(begin));
  21464. if (end == null)
  21465. throw new ArgumentNullException(nameof(end));
  21466. #if CRIPPLED_REFLECTION
  21467. 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>>)));
  21468. #else
  21469. 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));
  21470. #endif
  21471. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  21472. Expression.Invoke(
  21473. Expression.Call(
  21474. null,
  21475. m,
  21476. Expression.Constant(provider, typeof(IQbservableProvider)),
  21477. begin,
  21478. end
  21479. ),
  21480. Expression.Constant(t1, typeof(TArg1)),
  21481. Expression.Constant(t2, typeof(TArg2)),
  21482. Expression.Constant(t3, typeof(TArg3)),
  21483. Expression.Constant(t4, typeof(TArg4)),
  21484. Expression.Constant(t5, typeof(TArg5)),
  21485. Expression.Constant(t6, typeof(TArg6)),
  21486. Expression.Constant(t7, typeof(TArg7)),
  21487. Expression.Constant(t8, typeof(TArg8)),
  21488. Expression.Constant(t9, typeof(TArg9)),
  21489. Expression.Constant(t10, typeof(TArg10)),
  21490. Expression.Constant(t11, typeof(TArg11))
  21491. )
  21492. );
  21493. }
  21494. /// <summary>
  21495. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21496. /// </summary>
  21497. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21498. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21499. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21500. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21501. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21502. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21503. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21504. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21505. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21506. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21507. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21508. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21509. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21510. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21511. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21512. /// <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>
  21513. /// <exception cref="ArgumentNullException">
  21514. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21515. /// <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>
  21516. #if PREFERASYNC
  21517. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21518. #endif
  21519. 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)
  21520. {
  21521. if (provider == null)
  21522. throw new ArgumentNullException(nameof(provider));
  21523. if (begin == null)
  21524. throw new ArgumentNullException(nameof(begin));
  21525. if (end == null)
  21526. throw new ArgumentNullException(nameof(end));
  21527. #if CRIPPLED_REFLECTION
  21528. 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>>)));
  21529. #else
  21530. 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));
  21531. #endif
  21532. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  21533. Expression.Invoke(
  21534. Expression.Call(
  21535. null,
  21536. m,
  21537. Expression.Constant(provider, typeof(IQbservableProvider)),
  21538. begin,
  21539. end
  21540. ),
  21541. Expression.Constant(t1, typeof(TArg1)),
  21542. Expression.Constant(t2, typeof(TArg2)),
  21543. Expression.Constant(t3, typeof(TArg3)),
  21544. Expression.Constant(t4, typeof(TArg4)),
  21545. Expression.Constant(t5, typeof(TArg5)),
  21546. Expression.Constant(t6, typeof(TArg6)),
  21547. Expression.Constant(t7, typeof(TArg7)),
  21548. Expression.Constant(t8, typeof(TArg8)),
  21549. Expression.Constant(t9, typeof(TArg9)),
  21550. Expression.Constant(t10, typeof(TArg10)),
  21551. Expression.Constant(t11, typeof(TArg11)),
  21552. Expression.Constant(t12, typeof(TArg12))
  21553. )
  21554. );
  21555. }
  21556. /// <summary>
  21557. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21558. /// </summary>
  21559. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21560. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21561. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21562. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21563. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21564. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21565. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21566. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21567. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21568. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21569. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21570. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21571. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21572. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21573. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21574. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21575. /// <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>
  21576. /// <exception cref="ArgumentNullException">
  21577. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21578. /// <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>
  21579. #if PREFERASYNC
  21580. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21581. #endif
  21582. 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)
  21583. {
  21584. if (provider == null)
  21585. throw new ArgumentNullException(nameof(provider));
  21586. if (begin == null)
  21587. throw new ArgumentNullException(nameof(begin));
  21588. if (end == null)
  21589. throw new ArgumentNullException(nameof(end));
  21590. #if CRIPPLED_REFLECTION
  21591. 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>>)));
  21592. #else
  21593. 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));
  21594. #endif
  21595. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  21596. Expression.Invoke(
  21597. Expression.Call(
  21598. null,
  21599. m,
  21600. Expression.Constant(provider, typeof(IQbservableProvider)),
  21601. begin,
  21602. end
  21603. ),
  21604. Expression.Constant(t1, typeof(TArg1)),
  21605. Expression.Constant(t2, typeof(TArg2)),
  21606. Expression.Constant(t3, typeof(TArg3)),
  21607. Expression.Constant(t4, typeof(TArg4)),
  21608. Expression.Constant(t5, typeof(TArg5)),
  21609. Expression.Constant(t6, typeof(TArg6)),
  21610. Expression.Constant(t7, typeof(TArg7)),
  21611. Expression.Constant(t8, typeof(TArg8)),
  21612. Expression.Constant(t9, typeof(TArg9)),
  21613. Expression.Constant(t10, typeof(TArg10)),
  21614. Expression.Constant(t11, typeof(TArg11)),
  21615. Expression.Constant(t12, typeof(TArg12)),
  21616. Expression.Constant(t13, typeof(TArg13))
  21617. )
  21618. );
  21619. }
  21620. /// <summary>
  21621. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21622. /// </summary>
  21623. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21624. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21625. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21626. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21627. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21628. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21629. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21630. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21631. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21632. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21633. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21634. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21635. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21636. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21637. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin 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 (represented as a Unit value) 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, 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)
  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, 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>>)));
  21657. #else
  21658. 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));
  21659. #endif
  21660. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  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. Expression.Constant(t3, typeof(TArg3)),
  21672. Expression.Constant(t4, typeof(TArg4)),
  21673. Expression.Constant(t5, typeof(TArg5)),
  21674. Expression.Constant(t6, typeof(TArg6)),
  21675. Expression.Constant(t7, typeof(TArg7)),
  21676. Expression.Constant(t8, typeof(TArg8)),
  21677. Expression.Constant(t9, typeof(TArg9)),
  21678. Expression.Constant(t10, typeof(TArg10)),
  21679. Expression.Constant(t11, typeof(TArg11)),
  21680. Expression.Constant(t12, typeof(TArg12)),
  21681. Expression.Constant(t13, typeof(TArg13)),
  21682. Expression.Constant(t14, typeof(TArg14))
  21683. )
  21684. );
  21685. }
  21686. /// <summary>
  21687. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21688. /// </summary>
  21689. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21690. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21691. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21692. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21693. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21694. /// <exception cref="ArgumentNullException">
  21695. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21696. /// <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>
  21697. #if PREFERASYNC
  21698. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21699. #endif
  21700. public static Func<IQbservable<TResult>> FromAsyncPattern<TResult>(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  21701. {
  21702. if (provider == null)
  21703. throw new ArgumentNullException(nameof(provider));
  21704. if (begin == null)
  21705. throw new ArgumentNullException(nameof(begin));
  21706. if (end == null)
  21707. throw new ArgumentNullException(nameof(end));
  21708. #if CRIPPLED_REFLECTION
  21709. var m = InfoOf(() => Qbservable.FromAsyncPattern<TResult>(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21710. #else
  21711. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  21712. #endif
  21713. return () => provider.CreateQuery<TResult>(
  21714. Expression.Invoke(
  21715. Expression.Call(
  21716. null,
  21717. m,
  21718. Expression.Constant(provider, typeof(IQbservableProvider)),
  21719. begin,
  21720. end
  21721. )
  21722. )
  21723. );
  21724. }
  21725. /// <summary>
  21726. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21727. /// </summary>
  21728. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21729. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21730. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21731. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21732. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21733. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21734. /// <exception cref="ArgumentNullException">
  21735. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21736. /// <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>
  21737. #if PREFERASYNC
  21738. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21739. #endif
  21740. public static Func<TArg1, IQbservable<TResult>> FromAsyncPattern<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>> end)
  21741. {
  21742. if (provider == null)
  21743. throw new ArgumentNullException(nameof(provider));
  21744. if (begin == null)
  21745. throw new ArgumentNullException(nameof(begin));
  21746. if (end == null)
  21747. throw new ArgumentNullException(nameof(end));
  21748. #if CRIPPLED_REFLECTION
  21749. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21750. #else
  21751. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  21752. #endif
  21753. return (t1) => provider.CreateQuery<TResult>(
  21754. Expression.Invoke(
  21755. Expression.Call(
  21756. null,
  21757. m,
  21758. Expression.Constant(provider, typeof(IQbservableProvider)),
  21759. begin,
  21760. end
  21761. ),
  21762. Expression.Constant(t1, typeof(TArg1))
  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="TResult">The type of the result returned by the end delegate.</typeparam>
  21773. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21774. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21775. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21776. /// <exception cref="ArgumentNullException">
  21777. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21778. /// <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>
  21779. #if PREFERASYNC
  21780. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21781. #endif
  21782. 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)
  21783. {
  21784. if (provider == null)
  21785. throw new ArgumentNullException(nameof(provider));
  21786. if (begin == null)
  21787. throw new ArgumentNullException(nameof(begin));
  21788. if (end == null)
  21789. throw new ArgumentNullException(nameof(end));
  21790. #if CRIPPLED_REFLECTION
  21791. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21792. #else
  21793. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  21794. #endif
  21795. return (t1, t2) => provider.CreateQuery<TResult>(
  21796. Expression.Invoke(
  21797. Expression.Call(
  21798. null,
  21799. m,
  21800. Expression.Constant(provider, typeof(IQbservableProvider)),
  21801. begin,
  21802. end
  21803. ),
  21804. Expression.Constant(t1, typeof(TArg1)),
  21805. Expression.Constant(t2, typeof(TArg2))
  21806. )
  21807. );
  21808. }
  21809. /// <summary>
  21810. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21811. /// </summary>
  21812. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21813. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21814. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21815. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21816. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21817. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21818. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21819. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21820. /// <exception cref="ArgumentNullException">
  21821. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21822. /// <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>
  21823. #if PREFERASYNC
  21824. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21825. #endif
  21826. 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)
  21827. {
  21828. if (provider == null)
  21829. throw new ArgumentNullException(nameof(provider));
  21830. if (begin == null)
  21831. throw new ArgumentNullException(nameof(begin));
  21832. if (end == null)
  21833. throw new ArgumentNullException(nameof(end));
  21834. #if CRIPPLED_REFLECTION
  21835. 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>>)));
  21836. #else
  21837. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  21838. #endif
  21839. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  21840. Expression.Invoke(
  21841. Expression.Call(
  21842. null,
  21843. m,
  21844. Expression.Constant(provider, typeof(IQbservableProvider)),
  21845. begin,
  21846. end
  21847. ),
  21848. Expression.Constant(t1, typeof(TArg1)),
  21849. Expression.Constant(t2, typeof(TArg2)),
  21850. Expression.Constant(t3, typeof(TArg3))
  21851. )
  21852. );
  21853. }
  21854. /// <summary>
  21855. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21856. /// </summary>
  21857. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21858. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21859. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21860. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21861. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21862. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21863. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21864. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21865. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21866. /// <exception cref="ArgumentNullException">
  21867. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21868. /// <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>
  21869. #if PREFERASYNC
  21870. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21871. #endif
  21872. 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)
  21873. {
  21874. if (provider == null)
  21875. throw new ArgumentNullException(nameof(provider));
  21876. if (begin == null)
  21877. throw new ArgumentNullException(nameof(begin));
  21878. if (end == null)
  21879. throw new ArgumentNullException(nameof(end));
  21880. #if CRIPPLED_REFLECTION
  21881. 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>>)));
  21882. #else
  21883. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  21884. #endif
  21885. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  21886. Expression.Invoke(
  21887. Expression.Call(
  21888. null,
  21889. m,
  21890. Expression.Constant(provider, typeof(IQbservableProvider)),
  21891. begin,
  21892. end
  21893. ),
  21894. Expression.Constant(t1, typeof(TArg1)),
  21895. Expression.Constant(t2, typeof(TArg2)),
  21896. Expression.Constant(t3, typeof(TArg3)),
  21897. Expression.Constant(t4, typeof(TArg4))
  21898. )
  21899. );
  21900. }
  21901. /// <summary>
  21902. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21903. /// </summary>
  21904. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21905. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21906. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21907. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21908. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21909. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21910. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21911. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21912. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21913. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21914. /// <exception cref="ArgumentNullException">
  21915. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21916. /// <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>
  21917. #if PREFERASYNC
  21918. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21919. #endif
  21920. 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)
  21921. {
  21922. if (provider == null)
  21923. throw new ArgumentNullException(nameof(provider));
  21924. if (begin == null)
  21925. throw new ArgumentNullException(nameof(begin));
  21926. if (end == null)
  21927. throw new ArgumentNullException(nameof(end));
  21928. #if CRIPPLED_REFLECTION
  21929. 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>>)));
  21930. #else
  21931. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  21932. #endif
  21933. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  21934. Expression.Invoke(
  21935. Expression.Call(
  21936. null,
  21937. m,
  21938. Expression.Constant(provider, typeof(IQbservableProvider)),
  21939. begin,
  21940. end
  21941. ),
  21942. Expression.Constant(t1, typeof(TArg1)),
  21943. Expression.Constant(t2, typeof(TArg2)),
  21944. Expression.Constant(t3, typeof(TArg3)),
  21945. Expression.Constant(t4, typeof(TArg4)),
  21946. Expression.Constant(t5, typeof(TArg5))
  21947. )
  21948. );
  21949. }
  21950. /// <summary>
  21951. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21952. /// </summary>
  21953. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21954. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21955. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21956. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21957. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21958. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21959. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21960. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21961. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21962. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21963. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21964. /// <exception cref="ArgumentNullException">
  21965. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21966. /// <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>
  21967. #if PREFERASYNC
  21968. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21969. #endif
  21970. 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)
  21971. {
  21972. if (provider == null)
  21973. throw new ArgumentNullException(nameof(provider));
  21974. if (begin == null)
  21975. throw new ArgumentNullException(nameof(begin));
  21976. if (end == null)
  21977. throw new ArgumentNullException(nameof(end));
  21978. #if CRIPPLED_REFLECTION
  21979. 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>>)));
  21980. #else
  21981. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  21982. #endif
  21983. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  21984. Expression.Invoke(
  21985. Expression.Call(
  21986. null,
  21987. m,
  21988. Expression.Constant(provider, typeof(IQbservableProvider)),
  21989. begin,
  21990. end
  21991. ),
  21992. Expression.Constant(t1, typeof(TArg1)),
  21993. Expression.Constant(t2, typeof(TArg2)),
  21994. Expression.Constant(t3, typeof(TArg3)),
  21995. Expression.Constant(t4, typeof(TArg4)),
  21996. Expression.Constant(t5, typeof(TArg5)),
  21997. Expression.Constant(t6, typeof(TArg6))
  21998. )
  21999. );
  22000. }
  22001. /// <summary>
  22002. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22003. /// </summary>
  22004. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22005. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22006. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22007. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22008. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22009. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22010. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22011. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22012. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22013. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22014. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22015. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22016. /// <exception cref="ArgumentNullException">
  22017. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22018. /// <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>
  22019. #if PREFERASYNC
  22020. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22021. #endif
  22022. 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)
  22023. {
  22024. if (provider == null)
  22025. throw new ArgumentNullException(nameof(provider));
  22026. if (begin == null)
  22027. throw new ArgumentNullException(nameof(begin));
  22028. if (end == null)
  22029. throw new ArgumentNullException(nameof(end));
  22030. #if CRIPPLED_REFLECTION
  22031. 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>>)));
  22032. #else
  22033. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  22034. #endif
  22035. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  22036. Expression.Invoke(
  22037. Expression.Call(
  22038. null,
  22039. m,
  22040. Expression.Constant(provider, typeof(IQbservableProvider)),
  22041. begin,
  22042. end
  22043. ),
  22044. Expression.Constant(t1, typeof(TArg1)),
  22045. Expression.Constant(t2, typeof(TArg2)),
  22046. Expression.Constant(t3, typeof(TArg3)),
  22047. Expression.Constant(t4, typeof(TArg4)),
  22048. Expression.Constant(t5, typeof(TArg5)),
  22049. Expression.Constant(t6, typeof(TArg6)),
  22050. Expression.Constant(t7, typeof(TArg7))
  22051. )
  22052. );
  22053. }
  22054. /// <summary>
  22055. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22056. /// </summary>
  22057. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22058. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22059. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22060. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22061. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22062. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22063. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22064. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22065. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22066. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22067. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22068. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22069. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22070. /// <exception cref="ArgumentNullException">
  22071. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22072. /// <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>
  22073. #if PREFERASYNC
  22074. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22075. #endif
  22076. 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)
  22077. {
  22078. if (provider == null)
  22079. throw new ArgumentNullException(nameof(provider));
  22080. if (begin == null)
  22081. throw new ArgumentNullException(nameof(begin));
  22082. if (end == null)
  22083. throw new ArgumentNullException(nameof(end));
  22084. #if CRIPPLED_REFLECTION
  22085. 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>>)));
  22086. #else
  22087. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  22088. #endif
  22089. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  22090. Expression.Invoke(
  22091. Expression.Call(
  22092. null,
  22093. m,
  22094. Expression.Constant(provider, typeof(IQbservableProvider)),
  22095. begin,
  22096. end
  22097. ),
  22098. Expression.Constant(t1, typeof(TArg1)),
  22099. Expression.Constant(t2, typeof(TArg2)),
  22100. Expression.Constant(t3, typeof(TArg3)),
  22101. Expression.Constant(t4, typeof(TArg4)),
  22102. Expression.Constant(t5, typeof(TArg5)),
  22103. Expression.Constant(t6, typeof(TArg6)),
  22104. Expression.Constant(t7, typeof(TArg7)),
  22105. Expression.Constant(t8, typeof(TArg8))
  22106. )
  22107. );
  22108. }
  22109. /// <summary>
  22110. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22111. /// </summary>
  22112. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22113. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22114. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22115. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22116. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22117. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22118. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22119. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22120. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22121. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22122. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22123. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22124. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22125. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22126. /// <exception cref="ArgumentNullException">
  22127. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22128. /// <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>
  22129. #if PREFERASYNC
  22130. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22131. #endif
  22132. 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)
  22133. {
  22134. if (provider == null)
  22135. throw new ArgumentNullException(nameof(provider));
  22136. if (begin == null)
  22137. throw new ArgumentNullException(nameof(begin));
  22138. if (end == null)
  22139. throw new ArgumentNullException(nameof(end));
  22140. #if CRIPPLED_REFLECTION
  22141. 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>>)));
  22142. #else
  22143. 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));
  22144. #endif
  22145. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  22146. Expression.Invoke(
  22147. Expression.Call(
  22148. null,
  22149. m,
  22150. Expression.Constant(provider, typeof(IQbservableProvider)),
  22151. begin,
  22152. end
  22153. ),
  22154. Expression.Constant(t1, typeof(TArg1)),
  22155. Expression.Constant(t2, typeof(TArg2)),
  22156. Expression.Constant(t3, typeof(TArg3)),
  22157. Expression.Constant(t4, typeof(TArg4)),
  22158. Expression.Constant(t5, typeof(TArg5)),
  22159. Expression.Constant(t6, typeof(TArg6)),
  22160. Expression.Constant(t7, typeof(TArg7)),
  22161. Expression.Constant(t8, typeof(TArg8)),
  22162. Expression.Constant(t9, typeof(TArg9))
  22163. )
  22164. );
  22165. }
  22166. /// <summary>
  22167. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22168. /// </summary>
  22169. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22170. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22171. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22172. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22173. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22174. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22175. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22176. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22177. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22178. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22179. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22180. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22181. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22182. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22183. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22184. /// <exception cref="ArgumentNullException">
  22185. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22186. /// <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>
  22187. #if PREFERASYNC
  22188. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22189. #endif
  22190. 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)
  22191. {
  22192. if (provider == null)
  22193. throw new ArgumentNullException(nameof(provider));
  22194. if (begin == null)
  22195. throw new ArgumentNullException(nameof(begin));
  22196. if (end == null)
  22197. throw new ArgumentNullException(nameof(end));
  22198. #if CRIPPLED_REFLECTION
  22199. 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>>)));
  22200. #else
  22201. 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));
  22202. #endif
  22203. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  22204. Expression.Invoke(
  22205. Expression.Call(
  22206. null,
  22207. m,
  22208. Expression.Constant(provider, typeof(IQbservableProvider)),
  22209. begin,
  22210. end
  22211. ),
  22212. Expression.Constant(t1, typeof(TArg1)),
  22213. Expression.Constant(t2, typeof(TArg2)),
  22214. Expression.Constant(t3, typeof(TArg3)),
  22215. Expression.Constant(t4, typeof(TArg4)),
  22216. Expression.Constant(t5, typeof(TArg5)),
  22217. Expression.Constant(t6, typeof(TArg6)),
  22218. Expression.Constant(t7, typeof(TArg7)),
  22219. Expression.Constant(t8, typeof(TArg8)),
  22220. Expression.Constant(t9, typeof(TArg9)),
  22221. Expression.Constant(t10, typeof(TArg10))
  22222. )
  22223. );
  22224. }
  22225. /// <summary>
  22226. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22227. /// </summary>
  22228. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22229. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22230. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22231. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22232. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22233. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22234. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22235. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22236. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22237. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22238. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22239. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22240. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22241. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22242. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22243. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22244. /// <exception cref="ArgumentNullException">
  22245. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22246. /// <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>
  22247. #if PREFERASYNC
  22248. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22249. #endif
  22250. 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)
  22251. {
  22252. if (provider == null)
  22253. throw new ArgumentNullException(nameof(provider));
  22254. if (begin == null)
  22255. throw new ArgumentNullException(nameof(begin));
  22256. if (end == null)
  22257. throw new ArgumentNullException(nameof(end));
  22258. #if CRIPPLED_REFLECTION
  22259. 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>>)));
  22260. #else
  22261. 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));
  22262. #endif
  22263. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  22264. Expression.Invoke(
  22265. Expression.Call(
  22266. null,
  22267. m,
  22268. Expression.Constant(provider, typeof(IQbservableProvider)),
  22269. begin,
  22270. end
  22271. ),
  22272. Expression.Constant(t1, typeof(TArg1)),
  22273. Expression.Constant(t2, typeof(TArg2)),
  22274. Expression.Constant(t3, typeof(TArg3)),
  22275. Expression.Constant(t4, typeof(TArg4)),
  22276. Expression.Constant(t5, typeof(TArg5)),
  22277. Expression.Constant(t6, typeof(TArg6)),
  22278. Expression.Constant(t7, typeof(TArg7)),
  22279. Expression.Constant(t8, typeof(TArg8)),
  22280. Expression.Constant(t9, typeof(TArg9)),
  22281. Expression.Constant(t10, typeof(TArg10)),
  22282. Expression.Constant(t11, typeof(TArg11))
  22283. )
  22284. );
  22285. }
  22286. /// <summary>
  22287. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22288. /// </summary>
  22289. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22290. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22291. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22292. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22293. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22294. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22295. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22296. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22297. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22298. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22299. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22300. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22301. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22302. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22303. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22304. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22305. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22306. /// <exception cref="ArgumentNullException">
  22307. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22308. /// <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>
  22309. #if PREFERASYNC
  22310. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22311. #endif
  22312. 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)
  22313. {
  22314. if (provider == null)
  22315. throw new ArgumentNullException(nameof(provider));
  22316. if (begin == null)
  22317. throw new ArgumentNullException(nameof(begin));
  22318. if (end == null)
  22319. throw new ArgumentNullException(nameof(end));
  22320. #if CRIPPLED_REFLECTION
  22321. 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>>)));
  22322. #else
  22323. 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));
  22324. #endif
  22325. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  22326. Expression.Invoke(
  22327. Expression.Call(
  22328. null,
  22329. m,
  22330. Expression.Constant(provider, typeof(IQbservableProvider)),
  22331. begin,
  22332. end
  22333. ),
  22334. Expression.Constant(t1, typeof(TArg1)),
  22335. Expression.Constant(t2, typeof(TArg2)),
  22336. Expression.Constant(t3, typeof(TArg3)),
  22337. Expression.Constant(t4, typeof(TArg4)),
  22338. Expression.Constant(t5, typeof(TArg5)),
  22339. Expression.Constant(t6, typeof(TArg6)),
  22340. Expression.Constant(t7, typeof(TArg7)),
  22341. Expression.Constant(t8, typeof(TArg8)),
  22342. Expression.Constant(t9, typeof(TArg9)),
  22343. Expression.Constant(t10, typeof(TArg10)),
  22344. Expression.Constant(t11, typeof(TArg11)),
  22345. Expression.Constant(t12, typeof(TArg12))
  22346. )
  22347. );
  22348. }
  22349. /// <summary>
  22350. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22351. /// </summary>
  22352. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22353. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22354. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22355. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22356. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22357. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22358. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22359. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22360. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22361. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22362. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22363. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22364. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22365. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22366. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22367. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22368. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22369. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22370. /// <exception cref="ArgumentNullException">
  22371. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22372. /// <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>
  22373. #if PREFERASYNC
  22374. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22375. #endif
  22376. 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)
  22377. {
  22378. if (provider == null)
  22379. throw new ArgumentNullException(nameof(provider));
  22380. if (begin == null)
  22381. throw new ArgumentNullException(nameof(begin));
  22382. if (end == null)
  22383. throw new ArgumentNullException(nameof(end));
  22384. #if CRIPPLED_REFLECTION
  22385. 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>>)));
  22386. #else
  22387. 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));
  22388. #endif
  22389. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  22390. Expression.Invoke(
  22391. Expression.Call(
  22392. null,
  22393. m,
  22394. Expression.Constant(provider, typeof(IQbservableProvider)),
  22395. begin,
  22396. end
  22397. ),
  22398. Expression.Constant(t1, typeof(TArg1)),
  22399. Expression.Constant(t2, typeof(TArg2)),
  22400. Expression.Constant(t3, typeof(TArg3)),
  22401. Expression.Constant(t4, typeof(TArg4)),
  22402. Expression.Constant(t5, typeof(TArg5)),
  22403. Expression.Constant(t6, typeof(TArg6)),
  22404. Expression.Constant(t7, typeof(TArg7)),
  22405. Expression.Constant(t8, typeof(TArg8)),
  22406. Expression.Constant(t9, typeof(TArg9)),
  22407. Expression.Constant(t10, typeof(TArg10)),
  22408. Expression.Constant(t11, typeof(TArg11)),
  22409. Expression.Constant(t12, typeof(TArg12)),
  22410. Expression.Constant(t13, typeof(TArg13))
  22411. )
  22412. );
  22413. }
  22414. /// <summary>
  22415. /// Converts a Begin/End invoke function pair into an asynchronous function.
  22416. /// </summary>
  22417. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  22418. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  22419. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  22420. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  22421. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  22422. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  22423. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  22424. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  22425. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  22426. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  22427. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  22428. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  22429. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  22430. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  22431. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  22432. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  22433. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  22434. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  22435. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  22436. /// <exception cref="ArgumentNullException">
  22437. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  22438. /// <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>
  22439. #if PREFERASYNC
  22440. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  22441. #endif
  22442. 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)
  22443. {
  22444. if (provider == null)
  22445. throw new ArgumentNullException(nameof(provider));
  22446. if (begin == null)
  22447. throw new ArgumentNullException(nameof(begin));
  22448. if (end == null)
  22449. throw new ArgumentNullException(nameof(end));
  22450. #if CRIPPLED_REFLECTION
  22451. 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>>)));
  22452. #else
  22453. 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));
  22454. #endif
  22455. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  22456. Expression.Invoke(
  22457. Expression.Call(
  22458. null,
  22459. m,
  22460. Expression.Constant(provider, typeof(IQbservableProvider)),
  22461. begin,
  22462. end
  22463. ),
  22464. Expression.Constant(t1, typeof(TArg1)),
  22465. Expression.Constant(t2, typeof(TArg2)),
  22466. Expression.Constant(t3, typeof(TArg3)),
  22467. Expression.Constant(t4, typeof(TArg4)),
  22468. Expression.Constant(t5, typeof(TArg5)),
  22469. Expression.Constant(t6, typeof(TArg6)),
  22470. Expression.Constant(t7, typeof(TArg7)),
  22471. Expression.Constant(t8, typeof(TArg8)),
  22472. Expression.Constant(t9, typeof(TArg9)),
  22473. Expression.Constant(t10, typeof(TArg10)),
  22474. Expression.Constant(t11, typeof(TArg11)),
  22475. Expression.Constant(t12, typeof(TArg12)),
  22476. Expression.Constant(t13, typeof(TArg13)),
  22477. Expression.Constant(t14, typeof(TArg14))
  22478. )
  22479. );
  22480. }
  22481. }
  22482. }
  22483. #pragma warning restore 1591