Qbservable.Generated.cs 1.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207
  1. /*
  2. * WARNING: Auto-generated file (5/1/2015 21:21:20)
  3. * Run Rx's auto-homoiconizer tool to generate this file (in the HomoIcon directory).
  4. */
  5. #pragma warning disable 1591
  6. using System;
  7. using System.Reactive.Concurrency;
  8. using System.Collections.Generic;
  9. using System.Reactive.Joins;
  10. using System.Linq;
  11. using System.Linq.Expressions;
  12. using System.Reflection;
  13. using System.Threading;
  14. using System.Reactive;
  15. using System.Reactive.Subjects;
  16. using System.Diagnostics.CodeAnalysis;
  17. using System.Threading.Tasks;
  18. #if !NO_REMOTING
  19. using System.Runtime.Remoting.Lifetime;
  20. #endif
  21. namespace System.Reactive.Linq
  22. {
  23. [ExcludeFromCodeCoverage]
  24. public static partial class Qbservable
  25. {
  26. /// <summary>
  27. /// Applies an accumulator function over an observable sequence, returning the result of the aggregation as a single element in the result sequence.
  28. /// For aggregation behavior with incremental intermediate results, see <see cref="Observable.Scan{TSource}(IObservable{TSource},Func{TSource,TSource,TSource})" />.
  29. /// </summary>
  30. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  31. /// <param name="source">An observable sequence to aggregate over.</param>
  32. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  33. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  34. /// <exception cref="ArgumentNullException">
  35. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  36. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  37. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  38. public static IQbservable<TSource> Aggregate<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  39. {
  40. if (source == null)
  41. throw new ArgumentNullException(nameof(source));
  42. if (accumulator == null)
  43. throw new ArgumentNullException(nameof(accumulator));
  44. return source.Provider.CreateQuery<TSource>(
  45. Expression.Call(
  46. null,
  47. #if CRIPPLED_REFLECTION
  48. InfoOf(() => Qbservable.Aggregate<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  49. #else
  50. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  51. #endif
  52. source.Expression,
  53. accumulator
  54. )
  55. );
  56. }
  57. /// <summary>
  58. /// 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.
  59. /// For aggregation behavior with incremental intermediate results, see <see cref="Observable.Scan{TSource, TAccumulate}(IObservable{TSource}, TAccumulate, Func{TAccumulate, TSource, TAccumulate})" />.
  60. /// </summary>
  61. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  62. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  63. /// <param name="source">An observable sequence to aggregate over.</param>
  64. /// <param name="seed">The initial accumulator value.</param>
  65. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  66. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  67. /// <exception cref="ArgumentNullException">
  68. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  69. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  70. public static IQbservable<TAccumulate> Aggregate<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  71. {
  72. if (source == null)
  73. throw new ArgumentNullException(nameof(source));
  74. if (accumulator == null)
  75. throw new ArgumentNullException(nameof(accumulator));
  76. return source.Provider.CreateQuery<TAccumulate>(
  77. Expression.Call(
  78. null,
  79. #if CRIPPLED_REFLECTION
  80. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  81. #else
  82. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  83. #endif
  84. source.Expression,
  85. Expression.Constant(seed, typeof(TAccumulate)),
  86. accumulator
  87. )
  88. );
  89. }
  90. /// <summary>
  91. /// 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,
  92. /// and the specified result selector function is used to select the result value.
  93. /// </summary>
  94. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  95. /// <typeparam name="TAccumulate">The type of the accumulator value.</typeparam>
  96. /// <typeparam name="TResult">The type of the resulting value.</typeparam>
  97. /// <param name="source">An observable sequence to aggregate over.</param>
  98. /// <param name="seed">The initial accumulator value.</param>
  99. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  100. /// <param name="resultSelector">A function to transform the final accumulator value into the result value.</param>
  101. /// <returns>An observable sequence containing a single element with the final accumulator value.</returns>
  102. /// <exception cref="ArgumentNullException">
  103. /// <paramref name="source" /> or <paramref name="accumulator" /> or <paramref name="resultSelector" /> is null.</exception>
  104. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  105. 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)
  106. {
  107. if (source == null)
  108. throw new ArgumentNullException(nameof(source));
  109. if (accumulator == null)
  110. throw new ArgumentNullException(nameof(accumulator));
  111. if (resultSelector == null)
  112. throw new ArgumentNullException(nameof(resultSelector));
  113. return source.Provider.CreateQuery<TResult>(
  114. Expression.Call(
  115. null,
  116. #if CRIPPLED_REFLECTION
  117. InfoOf(() => Qbservable.Aggregate<TSource, TAccumulate, TResult>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>), default(Expression<Func<TAccumulate, TResult>>))),
  118. #else
  119. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate), typeof(TResult)),
  120. #endif
  121. source.Expression,
  122. Expression.Constant(seed, typeof(TAccumulate)),
  123. accumulator,
  124. resultSelector
  125. )
  126. );
  127. }
  128. /// <summary>
  129. /// Determines whether all elements of an observable sequence satisfy a condition.
  130. /// </summary>
  131. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  132. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  133. /// <param name="predicate">A function to test each element for a condition.</param>
  134. /// <returns>An observable sequence containing a single element determining whether all elements in the source sequence pass the test in the specified predicate.</returns>
  135. /// <exception cref="ArgumentNullException">
  136. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  137. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  138. public static IQbservable<bool> All<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  139. {
  140. if (source == null)
  141. throw new ArgumentNullException(nameof(source));
  142. if (predicate == null)
  143. throw new ArgumentNullException(nameof(predicate));
  144. return source.Provider.CreateQuery<bool>(
  145. Expression.Call(
  146. null,
  147. #if CRIPPLED_REFLECTION
  148. InfoOf(() => Qbservable.All<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  149. #else
  150. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  151. #endif
  152. source.Expression,
  153. predicate
  154. )
  155. );
  156. }
  157. /// <summary>
  158. /// Propagates the observable sequence that reacts first.
  159. /// </summary>
  160. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  161. /// <param name="first">First observable sequence.</param>
  162. /// <param name="second">Second observable sequence.</param>
  163. /// <returns>An observable sequence that surfaces either of the given sequences, whichever reacted first.</returns>
  164. /// <exception cref="ArgumentNullException">
  165. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  166. public static IQbservable<TSource> Amb<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  167. {
  168. if (first == null)
  169. throw new ArgumentNullException(nameof(first));
  170. if (second == null)
  171. throw new ArgumentNullException(nameof(second));
  172. return first.Provider.CreateQuery<TSource>(
  173. Expression.Call(
  174. null,
  175. #if CRIPPLED_REFLECTION
  176. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  177. #else
  178. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  179. #endif
  180. first.Expression,
  181. GetSourceExpression(second)
  182. )
  183. );
  184. }
  185. /// <summary>
  186. /// Propagates the observable sequence that reacts first.
  187. /// </summary>
  188. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  189. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  190. /// <param name="sources">Observable sources competing to react first.</param>
  191. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  192. /// <exception cref="ArgumentNullException">
  193. /// <paramref name="sources" /> is null.</exception>
  194. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  195. {
  196. if (provider == null)
  197. throw new ArgumentNullException(nameof(provider));
  198. if (sources == null)
  199. throw new ArgumentNullException(nameof(sources));
  200. return provider.CreateQuery<TSource>(
  201. Expression.Call(
  202. null,
  203. #if CRIPPLED_REFLECTION
  204. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  205. #else
  206. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  207. #endif
  208. Expression.Constant(provider, typeof(IQbservableProvider)),
  209. GetSourceExpression(sources)
  210. )
  211. );
  212. }
  213. /// <summary>
  214. /// Propagates the observable sequence that reacts first.
  215. /// </summary>
  216. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  217. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  218. /// <param name="sources">Observable sources competing to react first.</param>
  219. /// <returns>An observable sequence that surfaces any of the given sequences, whichever reacted first.</returns>
  220. /// <exception cref="ArgumentNullException">
  221. /// <paramref name="sources" /> is null.</exception>
  222. public static IQbservable<TSource> Amb<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  223. {
  224. if (provider == null)
  225. throw new ArgumentNullException(nameof(provider));
  226. if (sources == null)
  227. throw new ArgumentNullException(nameof(sources));
  228. return provider.CreateQuery<TSource>(
  229. Expression.Call(
  230. null,
  231. #if CRIPPLED_REFLECTION
  232. InfoOf(() => Qbservable.Amb<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  233. #else
  234. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  235. #endif
  236. Expression.Constant(provider, typeof(IQbservableProvider)),
  237. GetSourceExpression(sources)
  238. )
  239. );
  240. }
  241. /// <summary>
  242. /// Determines whether an observable sequence contains any elements.
  243. /// </summary>
  244. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  245. /// <param name="source">An observable sequence to check for non-emptiness.</param>
  246. /// <returns>An observable sequence containing a single element determining whether the source sequence contains any elements.</returns>
  247. /// <exception cref="ArgumentNullException">
  248. /// <paramref name="source" /> is null.</exception>
  249. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  250. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source)
  251. {
  252. if (source == null)
  253. throw new ArgumentNullException(nameof(source));
  254. return source.Provider.CreateQuery<bool>(
  255. Expression.Call(
  256. null,
  257. #if CRIPPLED_REFLECTION
  258. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>))),
  259. #else
  260. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  261. #endif
  262. source.Expression
  263. )
  264. );
  265. }
  266. /// <summary>
  267. /// Determines whether any element of an observable sequence satisfies a condition.
  268. /// </summary>
  269. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  270. /// <param name="source">An observable sequence whose elements to apply the predicate to.</param>
  271. /// <param name="predicate">A function to test each element for a condition.</param>
  272. /// <returns>An observable sequence containing a single element determining whether any elements in the source sequence pass the test in the specified predicate.</returns>
  273. /// <exception cref="ArgumentNullException">
  274. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  275. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  276. public static IQbservable<bool> Any<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  277. {
  278. if (source == null)
  279. throw new ArgumentNullException(nameof(source));
  280. if (predicate == null)
  281. throw new ArgumentNullException(nameof(predicate));
  282. return source.Provider.CreateQuery<bool>(
  283. Expression.Call(
  284. null,
  285. #if CRIPPLED_REFLECTION
  286. InfoOf(() => Qbservable.Any<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  287. #else
  288. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  289. #endif
  290. source.Expression,
  291. predicate
  292. )
  293. );
  294. }
  295. /// <summary>
  296. /// Computes the average of an observable sequence of <see cref="Decimal" /> values.
  297. /// </summary>
  298. /// <param name="source">A sequence of <see cref="Decimal" /> values to calculate the average of.</param>
  299. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  300. /// <exception cref="ArgumentNullException">
  301. /// <paramref name="source" /> is null.</exception>
  302. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  303. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Decimal.MaxValue" />.</exception>
  304. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  305. public static IQbservable<decimal> Average(this IQbservable<decimal> source)
  306. {
  307. if (source == null)
  308. throw new ArgumentNullException(nameof(source));
  309. return source.Provider.CreateQuery<decimal>(
  310. Expression.Call(
  311. null,
  312. #if CRIPPLED_REFLECTION
  313. InfoOf(() => Qbservable.Average(default(IQbservable<decimal>))),
  314. #else
  315. (MethodInfo)MethodInfo.GetCurrentMethod(),
  316. #endif
  317. source.Expression
  318. )
  319. );
  320. }
  321. /// <summary>
  322. /// Computes the average of an observable sequence of <see cref="double" /> values.
  323. /// </summary>
  324. /// <param name="source">A sequence of <see cref="double" /> values to calculate the average of.</param>
  325. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  326. /// <exception cref="ArgumentNullException">
  327. /// <paramref name="source" /> is null.</exception>
  328. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  329. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  330. public static IQbservable<double> Average(this IQbservable<double> source)
  331. {
  332. if (source == null)
  333. throw new ArgumentNullException(nameof(source));
  334. return source.Provider.CreateQuery<double>(
  335. Expression.Call(
  336. null,
  337. #if CRIPPLED_REFLECTION
  338. InfoOf(() => Qbservable.Average(default(IQbservable<double>))),
  339. #else
  340. (MethodInfo)MethodInfo.GetCurrentMethod(),
  341. #endif
  342. source.Expression
  343. )
  344. );
  345. }
  346. /// <summary>
  347. /// Computes the average of an observable sequence of <see cref="int" /> values.
  348. /// </summary>
  349. /// <param name="source">A sequence of <see cref="int" /> values to calculate the average of.</param>
  350. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  351. /// <exception cref="ArgumentNullException">
  352. /// <paramref name="source" /> is null.</exception>
  353. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  354. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  355. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  356. public static IQbservable<double> Average(this IQbservable<int> source)
  357. {
  358. if (source == null)
  359. throw new ArgumentNullException(nameof(source));
  360. return source.Provider.CreateQuery<double>(
  361. Expression.Call(
  362. null,
  363. #if CRIPPLED_REFLECTION
  364. InfoOf(() => Qbservable.Average(default(IQbservable<int>))),
  365. #else
  366. (MethodInfo)MethodInfo.GetCurrentMethod(),
  367. #endif
  368. source.Expression
  369. )
  370. );
  371. }
  372. /// <summary>
  373. /// Computes the average of an observable sequence of <see cref="long" /> values.
  374. /// </summary>
  375. /// <param name="source">A sequence of <see cref="long" /> values to calculate the average of.</param>
  376. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  377. /// <exception cref="ArgumentNullException">
  378. /// <paramref name="source" /> is null.</exception>
  379. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  380. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  381. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  382. public static IQbservable<double> Average(this IQbservable<long> source)
  383. {
  384. if (source == null)
  385. throw new ArgumentNullException(nameof(source));
  386. return source.Provider.CreateQuery<double>(
  387. Expression.Call(
  388. null,
  389. #if CRIPPLED_REFLECTION
  390. InfoOf(() => Qbservable.Average(default(IQbservable<long>))),
  391. #else
  392. (MethodInfo)MethodInfo.GetCurrentMethod(),
  393. #endif
  394. source.Expression
  395. )
  396. );
  397. }
  398. /// <summary>
  399. /// Computes the average of an observable sequence of nullable <see cref="Decimal" /> values.
  400. /// </summary>
  401. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to calculate the average of.</param>
  402. /// <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>
  403. /// <exception cref="ArgumentNullException">
  404. /// <paramref name="source" /> is null.</exception>
  405. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  406. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Decimal.MaxValue" />.</exception>
  407. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  408. public static IQbservable<decimal?> Average(this IQbservable<decimal?> source)
  409. {
  410. if (source == null)
  411. throw new ArgumentNullException(nameof(source));
  412. return source.Provider.CreateQuery<decimal?>(
  413. Expression.Call(
  414. null,
  415. #if CRIPPLED_REFLECTION
  416. InfoOf(() => Qbservable.Average(default(IQbservable<decimal?>))),
  417. #else
  418. (MethodInfo)MethodInfo.GetCurrentMethod(),
  419. #endif
  420. source.Expression
  421. )
  422. );
  423. }
  424. /// <summary>
  425. /// Computes the average of an observable sequence of nullable <see cref="double" /> values.
  426. /// </summary>
  427. /// <param name="source">A sequence of nullable <see cref="double" /> values to calculate the average of.</param>
  428. /// <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>
  429. /// <exception cref="ArgumentNullException">
  430. /// <paramref name="source" /> is null.</exception>
  431. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  432. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  433. public static IQbservable<double?> Average(this IQbservable<double?> source)
  434. {
  435. if (source == null)
  436. throw new ArgumentNullException(nameof(source));
  437. return source.Provider.CreateQuery<double?>(
  438. Expression.Call(
  439. null,
  440. #if CRIPPLED_REFLECTION
  441. InfoOf(() => Qbservable.Average(default(IQbservable<double?>))),
  442. #else
  443. (MethodInfo)MethodInfo.GetCurrentMethod(),
  444. #endif
  445. source.Expression
  446. )
  447. );
  448. }
  449. /// <summary>
  450. /// Computes the average of an observable sequence of nullable <see cref="int" /> values.
  451. /// </summary>
  452. /// <param name="source">A sequence of nullable <see cref="int" /> values to calculate the average of.</param>
  453. /// <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>
  454. /// <exception cref="ArgumentNullException">
  455. /// <paramref name="source" /> is null.</exception>
  456. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  457. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  458. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  459. public static IQbservable<double?> Average(this IQbservable<int?> source)
  460. {
  461. if (source == null)
  462. throw new ArgumentNullException(nameof(source));
  463. return source.Provider.CreateQuery<double?>(
  464. Expression.Call(
  465. null,
  466. #if CRIPPLED_REFLECTION
  467. InfoOf(() => Qbservable.Average(default(IQbservable<int?>))),
  468. #else
  469. (MethodInfo)MethodInfo.GetCurrentMethod(),
  470. #endif
  471. source.Expression
  472. )
  473. );
  474. }
  475. /// <summary>
  476. /// Computes the average of an observable sequence of nullable <see cref="long" /> values.
  477. /// </summary>
  478. /// <param name="source">A sequence of nullable <see cref="long" /> values to calculate the average of.</param>
  479. /// <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>
  480. /// <exception cref="ArgumentNullException">
  481. /// <paramref name="source" /> is null.</exception>
  482. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  483. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  484. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  485. public static IQbservable<double?> Average(this IQbservable<long?> source)
  486. {
  487. if (source == null)
  488. throw new ArgumentNullException(nameof(source));
  489. return source.Provider.CreateQuery<double?>(
  490. Expression.Call(
  491. null,
  492. #if CRIPPLED_REFLECTION
  493. InfoOf(() => Qbservable.Average(default(IQbservable<long?>))),
  494. #else
  495. (MethodInfo)MethodInfo.GetCurrentMethod(),
  496. #endif
  497. source.Expression
  498. )
  499. );
  500. }
  501. /// <summary>
  502. /// Computes the average of an observable sequence of nullable <see cref="Single" /> values.
  503. /// </summary>
  504. /// <param name="source">A sequence of nullable <see cref="Single" /> values to calculate the average of.</param>
  505. /// <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>
  506. /// <exception cref="ArgumentNullException">
  507. /// <paramref name="source" /> is null.</exception>
  508. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  509. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  510. public static IQbservable<float?> Average(this IQbservable<float?> source)
  511. {
  512. if (source == null)
  513. throw new ArgumentNullException(nameof(source));
  514. return source.Provider.CreateQuery<float?>(
  515. Expression.Call(
  516. null,
  517. #if CRIPPLED_REFLECTION
  518. InfoOf(() => Qbservable.Average(default(IQbservable<float?>))),
  519. #else
  520. (MethodInfo)MethodInfo.GetCurrentMethod(),
  521. #endif
  522. source.Expression
  523. )
  524. );
  525. }
  526. /// <summary>
  527. /// Computes the average of an observable sequence of <see cref="Single" /> values.
  528. /// </summary>
  529. /// <param name="source">A sequence of <see cref="Single" /> values to calculate the average of.</param>
  530. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  531. /// <exception cref="ArgumentNullException">
  532. /// <paramref name="source" /> is null.</exception>
  533. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  534. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  535. public static IQbservable<float> Average(this IQbservable<float> source)
  536. {
  537. if (source == null)
  538. throw new ArgumentNullException(nameof(source));
  539. return source.Provider.CreateQuery<float>(
  540. Expression.Call(
  541. null,
  542. #if CRIPPLED_REFLECTION
  543. InfoOf(() => Qbservable.Average(default(IQbservable<float>))),
  544. #else
  545. (MethodInfo)MethodInfo.GetCurrentMethod(),
  546. #endif
  547. source.Expression
  548. )
  549. );
  550. }
  551. /// <summary>
  552. /// 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.
  553. /// </summary>
  554. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  555. /// <param name="source">A sequence of values to calculate the average of.</param>
  556. /// <param name="selector">A transform function to apply to each element.</param>
  557. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  558. /// <exception cref="ArgumentNullException">
  559. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  560. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  561. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Decimal.MaxValue" />.</exception>
  562. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  563. public static IQbservable<decimal> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  564. {
  565. if (source == null)
  566. throw new ArgumentNullException(nameof(source));
  567. if (selector == null)
  568. throw new ArgumentNullException(nameof(selector));
  569. return source.Provider.CreateQuery<decimal>(
  570. Expression.Call(
  571. null,
  572. #if CRIPPLED_REFLECTION
  573. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  574. #else
  575. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  576. #endif
  577. source.Expression,
  578. selector
  579. )
  580. );
  581. }
  582. /// <summary>
  583. /// 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.
  584. /// </summary>
  585. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  586. /// <param name="source">A sequence of values to calculate the average of.</param>
  587. /// <param name="selector">A transform function to apply to each element.</param>
  588. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  589. /// <exception cref="ArgumentNullException">
  590. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  591. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  592. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  593. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  594. {
  595. if (source == null)
  596. throw new ArgumentNullException(nameof(source));
  597. if (selector == null)
  598. throw new ArgumentNullException(nameof(selector));
  599. return source.Provider.CreateQuery<double>(
  600. Expression.Call(
  601. null,
  602. #if CRIPPLED_REFLECTION
  603. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  604. #else
  605. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  606. #endif
  607. source.Expression,
  608. selector
  609. )
  610. );
  611. }
  612. /// <summary>
  613. /// 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.
  614. /// </summary>
  615. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  616. /// <param name="source">A sequence of values to calculate the average of.</param>
  617. /// <param name="selector">A transform function to apply to each element.</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" /> or <paramref name="selector" /> 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<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  624. {
  625. if (source == null)
  626. throw new ArgumentNullException(nameof(source));
  627. if (selector == null)
  628. throw new ArgumentNullException(nameof(selector));
  629. return source.Provider.CreateQuery<float>(
  630. Expression.Call(
  631. null,
  632. #if CRIPPLED_REFLECTION
  633. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  634. #else
  635. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  636. #endif
  637. source.Expression,
  638. selector
  639. )
  640. );
  641. }
  642. /// <summary>
  643. /// 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.
  644. /// </summary>
  645. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  646. /// <param name="source">A sequence of values to calculate the average of.</param>
  647. /// <param name="selector">A transform function to apply to each element.</param>
  648. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  649. /// <exception cref="ArgumentNullException">
  650. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  651. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  652. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  653. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  654. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  655. {
  656. if (source == null)
  657. throw new ArgumentNullException(nameof(source));
  658. if (selector == null)
  659. throw new ArgumentNullException(nameof(selector));
  660. return source.Provider.CreateQuery<double>(
  661. Expression.Call(
  662. null,
  663. #if CRIPPLED_REFLECTION
  664. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  665. #else
  666. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  667. #endif
  668. source.Expression,
  669. selector
  670. )
  671. );
  672. }
  673. /// <summary>
  674. /// 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.
  675. /// </summary>
  676. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  677. /// <param name="source">A sequence of values to calculate the average of.</param>
  678. /// <param name="selector">A transform function to apply to each element.</param>
  679. /// <returns>An observable sequence containing a single element with the average of the sequence of values.</returns>
  680. /// <exception cref="ArgumentNullException">
  681. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  682. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  683. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  684. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  685. public static IQbservable<double> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  686. {
  687. if (source == null)
  688. throw new ArgumentNullException(nameof(source));
  689. if (selector == null)
  690. throw new ArgumentNullException(nameof(selector));
  691. return source.Provider.CreateQuery<double>(
  692. Expression.Call(
  693. null,
  694. #if CRIPPLED_REFLECTION
  695. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  696. #else
  697. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  698. #endif
  699. source.Expression,
  700. selector
  701. )
  702. );
  703. }
  704. /// <summary>
  705. /// 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.
  706. /// </summary>
  707. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  708. /// <param name="source">A sequence of values to calculate the average of.</param>
  709. /// <param name="selector">A transform function to apply to each element.</param>
  710. /// <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>
  711. /// <exception cref="ArgumentNullException">
  712. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  713. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  714. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Decimal.MaxValue" />.</exception>
  715. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  716. public static IQbservable<decimal?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  717. {
  718. if (source == null)
  719. throw new ArgumentNullException(nameof(source));
  720. if (selector == null)
  721. throw new ArgumentNullException(nameof(selector));
  722. return source.Provider.CreateQuery<decimal?>(
  723. Expression.Call(
  724. null,
  725. #if CRIPPLED_REFLECTION
  726. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  727. #else
  728. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  729. #endif
  730. source.Expression,
  731. selector
  732. )
  733. );
  734. }
  735. /// <summary>
  736. /// 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.
  737. /// </summary>
  738. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  739. /// <param name="source">A sequence of values to calculate the average of.</param>
  740. /// <param name="selector">A transform function to apply to each element.</param>
  741. /// <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>
  742. /// <exception cref="ArgumentNullException">
  743. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  744. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  745. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  746. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  747. {
  748. if (source == null)
  749. throw new ArgumentNullException(nameof(source));
  750. if (selector == null)
  751. throw new ArgumentNullException(nameof(selector));
  752. return source.Provider.CreateQuery<double?>(
  753. Expression.Call(
  754. null,
  755. #if CRIPPLED_REFLECTION
  756. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  757. #else
  758. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  759. #endif
  760. source.Expression,
  761. selector
  762. )
  763. );
  764. }
  765. /// <summary>
  766. /// 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.
  767. /// </summary>
  768. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  769. /// <param name="source">A sequence of values to calculate the average of.</param>
  770. /// <param name="selector">A transform function to apply to each element.</param>
  771. /// <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>
  772. /// <exception cref="ArgumentNullException">
  773. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  774. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  775. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  776. public static IQbservable<float?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  777. {
  778. if (source == null)
  779. throw new ArgumentNullException(nameof(source));
  780. if (selector == null)
  781. throw new ArgumentNullException(nameof(selector));
  782. return source.Provider.CreateQuery<float?>(
  783. Expression.Call(
  784. null,
  785. #if CRIPPLED_REFLECTION
  786. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  787. #else
  788. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  789. #endif
  790. source.Expression,
  791. selector
  792. )
  793. );
  794. }
  795. /// <summary>
  796. /// 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.
  797. /// </summary>
  798. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  799. /// <param name="source">A sequence of values to calculate the average of.</param>
  800. /// <param name="selector">A transform function to apply to each element.</param>
  801. /// <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>
  802. /// <exception cref="ArgumentNullException">
  803. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  804. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  805. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  806. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  807. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  808. {
  809. if (source == null)
  810. throw new ArgumentNullException(nameof(source));
  811. if (selector == null)
  812. throw new ArgumentNullException(nameof(selector));
  813. return source.Provider.CreateQuery<double?>(
  814. Expression.Call(
  815. null,
  816. #if CRIPPLED_REFLECTION
  817. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  818. #else
  819. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  820. #endif
  821. source.Expression,
  822. selector
  823. )
  824. );
  825. }
  826. /// <summary>
  827. /// 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.
  828. /// </summary>
  829. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  830. /// <param name="source">A sequence of values to calculate the average of.</param>
  831. /// <param name="selector">A transform function to apply to each element.</param>
  832. /// <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>
  833. /// <exception cref="ArgumentNullException">
  834. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  835. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  836. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  837. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  838. public static IQbservable<double?> Average<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  839. {
  840. if (source == null)
  841. throw new ArgumentNullException(nameof(source));
  842. if (selector == null)
  843. throw new ArgumentNullException(nameof(selector));
  844. return source.Provider.CreateQuery<double?>(
  845. Expression.Call(
  846. null,
  847. #if CRIPPLED_REFLECTION
  848. InfoOf(() => Qbservable.Average<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  849. #else
  850. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  851. #endif
  852. source.Expression,
  853. selector
  854. )
  855. );
  856. }
  857. /// <summary>
  858. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on element count information.
  859. /// </summary>
  860. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  861. /// <param name="source">Source sequence to produce buffers over.</param>
  862. /// <param name="count">Length of each buffer.</param>
  863. /// <returns>An observable sequence of buffers.</returns>
  864. /// <exception cref="ArgumentNullException">
  865. /// <paramref name="source" /> is null.</exception>
  866. /// <exception cref="ArgumentOutOfRangeException">
  867. /// <paramref name="count" /> is less than or equal to zero.</exception>
  868. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count)
  869. {
  870. if (source == null)
  871. throw new ArgumentNullException(nameof(source));
  872. return source.Provider.CreateQuery<IList<TSource>>(
  873. Expression.Call(
  874. null,
  875. #if CRIPPLED_REFLECTION
  876. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int))),
  877. #else
  878. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  879. #endif
  880. source.Expression,
  881. Expression.Constant(count, typeof(int))
  882. )
  883. );
  884. }
  885. /// <summary>
  886. /// Projects each element of an observable sequence into zero or more buffers which are produced based on element count information.
  887. /// </summary>
  888. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  889. /// <param name="source">Source sequence to produce buffers over.</param>
  890. /// <param name="count">Length of each buffer.</param>
  891. /// <param name="skip">Number of elements to skip between creation of consecutive buffers.</param>
  892. /// <returns>An observable sequence of buffers.</returns>
  893. /// <exception cref="ArgumentNullException">
  894. /// <paramref name="source" /> is null.</exception>
  895. /// <exception cref="ArgumentOutOfRangeException">
  896. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  897. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, int count, int skip)
  898. {
  899. if (source == null)
  900. throw new ArgumentNullException(nameof(source));
  901. return source.Provider.CreateQuery<IList<TSource>>(
  902. Expression.Call(
  903. null,
  904. #if CRIPPLED_REFLECTION
  905. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  906. #else
  907. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  908. #endif
  909. source.Expression,
  910. Expression.Constant(count, typeof(int)),
  911. Expression.Constant(skip, typeof(int))
  912. )
  913. );
  914. }
  915. /// <summary>
  916. /// Projects each element of an observable sequence into consecutive non-overlapping buffers which are produced based on timing information.
  917. /// </summary>
  918. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  919. /// <param name="source">Source sequence to produce buffers over.</param>
  920. /// <param name="timeSpan">Length of each buffer.</param>
  921. /// <returns>An observable sequence of buffers.</returns>
  922. /// <exception cref="ArgumentNullException">
  923. /// <paramref name="source" /> is null.</exception>
  924. /// <exception cref="ArgumentOutOfRangeException">
  925. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  926. /// <remarks>
  927. /// 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.
  928. /// 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
  929. /// 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.
  930. /// </remarks>
  931. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  932. {
  933. if (source == null)
  934. throw new ArgumentNullException(nameof(source));
  935. return source.Provider.CreateQuery<IList<TSource>>(
  936. Expression.Call(
  937. null,
  938. #if CRIPPLED_REFLECTION
  939. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  940. #else
  941. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  942. #endif
  943. source.Expression,
  944. Expression.Constant(timeSpan, typeof(TimeSpan))
  945. )
  946. );
  947. }
  948. /// <summary>
  949. /// 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.
  950. /// 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.
  951. /// </summary>
  952. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  953. /// <param name="source">Source sequence to produce buffers over.</param>
  954. /// <param name="timeSpan">Maximum time length of a window.</param>
  955. /// <param name="count">Maximum element count of a window.</param>
  956. /// <returns>An observable sequence of buffers.</returns>
  957. /// <exception cref="ArgumentNullException">
  958. /// <paramref name="source" /> is null.</exception>
  959. /// <exception cref="ArgumentOutOfRangeException">
  960. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  961. /// <remarks>
  962. /// 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.
  963. /// 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
  964. /// 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.
  965. /// </remarks>
  966. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  967. {
  968. if (source == null)
  969. throw new ArgumentNullException(nameof(source));
  970. return source.Provider.CreateQuery<IList<TSource>>(
  971. Expression.Call(
  972. null,
  973. #if CRIPPLED_REFLECTION
  974. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  975. #else
  976. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  977. #endif
  978. source.Expression,
  979. Expression.Constant(timeSpan, typeof(TimeSpan)),
  980. Expression.Constant(count, typeof(int))
  981. )
  982. );
  983. }
  984. /// <summary>
  985. /// 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.
  986. /// 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.
  987. /// </summary>
  988. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  989. /// <param name="source">Source sequence to produce buffers over.</param>
  990. /// <param name="timeSpan">Maximum time length of a buffer.</param>
  991. /// <param name="count">Maximum element count of a buffer.</param>
  992. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  993. /// <returns>An observable sequence of buffers.</returns>
  994. /// <exception cref="ArgumentNullException">
  995. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  996. /// <exception cref="ArgumentOutOfRangeException">
  997. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  998. /// <remarks>
  999. /// 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.
  1000. /// 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
  1001. /// 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.
  1002. /// </remarks>
  1003. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  1004. {
  1005. if (source == null)
  1006. throw new ArgumentNullException(nameof(source));
  1007. if (scheduler == null)
  1008. throw new ArgumentNullException(nameof(scheduler));
  1009. return source.Provider.CreateQuery<IList<TSource>>(
  1010. Expression.Call(
  1011. null,
  1012. #if CRIPPLED_REFLECTION
  1013. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  1014. #else
  1015. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1016. #endif
  1017. source.Expression,
  1018. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1019. Expression.Constant(count, typeof(int)),
  1020. Expression.Constant(scheduler, typeof(IScheduler))
  1021. )
  1022. );
  1023. }
  1024. /// <summary>
  1025. /// 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.
  1026. /// </summary>
  1027. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1028. /// <param name="source">Source sequence to produce buffers over.</param>
  1029. /// <param name="timeSpan">Length of each buffer.</param>
  1030. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1031. /// <returns>An observable sequence of buffers.</returns>
  1032. /// <exception cref="ArgumentNullException">
  1033. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1034. /// <exception cref="ArgumentOutOfRangeException">
  1035. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1036. /// <remarks>
  1037. /// 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.
  1038. /// 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
  1039. /// 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.
  1040. /// </remarks>
  1041. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  1042. {
  1043. if (source == null)
  1044. throw new ArgumentNullException(nameof(source));
  1045. if (scheduler == null)
  1046. throw new ArgumentNullException(nameof(scheduler));
  1047. return source.Provider.CreateQuery<IList<TSource>>(
  1048. Expression.Call(
  1049. null,
  1050. #if CRIPPLED_REFLECTION
  1051. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  1052. #else
  1053. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1054. #endif
  1055. source.Expression,
  1056. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1057. Expression.Constant(scheduler, typeof(IScheduler))
  1058. )
  1059. );
  1060. }
  1061. /// <summary>
  1062. /// Projects each element of an observable sequence into zero or more buffers which are produced based on timing information.
  1063. /// </summary>
  1064. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1065. /// <param name="source">Source sequence to produce buffers over.</param>
  1066. /// <param name="timeSpan">Length of each buffer.</param>
  1067. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1068. /// <returns>An observable sequence of buffers.</returns>
  1069. /// <exception cref="ArgumentNullException">
  1070. /// <paramref name="source" /> is null.</exception>
  1071. /// <exception cref="ArgumentOutOfRangeException">
  1072. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1073. /// <remarks>
  1074. /// <para>
  1075. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1076. /// 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
  1077. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1078. /// </para>
  1079. /// <para>
  1080. /// 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.
  1081. /// 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,
  1082. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1083. /// </para>
  1084. /// </remarks>
  1085. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  1086. {
  1087. if (source == null)
  1088. throw new ArgumentNullException(nameof(source));
  1089. return source.Provider.CreateQuery<IList<TSource>>(
  1090. Expression.Call(
  1091. null,
  1092. #if CRIPPLED_REFLECTION
  1093. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  1094. #else
  1095. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1096. #endif
  1097. source.Expression,
  1098. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1099. Expression.Constant(timeShift, typeof(TimeSpan))
  1100. )
  1101. );
  1102. }
  1103. /// <summary>
  1104. /// 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.
  1105. /// </summary>
  1106. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1107. /// <param name="source">Source sequence to produce buffers over.</param>
  1108. /// <param name="timeSpan">Length of each buffer.</param>
  1109. /// <param name="timeShift">Interval between creation of consecutive buffers.</param>
  1110. /// <param name="scheduler">Scheduler to run buffering timers on.</param>
  1111. /// <returns>An observable sequence of buffers.</returns>
  1112. /// <exception cref="ArgumentNullException">
  1113. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  1114. /// <exception cref="ArgumentOutOfRangeException">
  1115. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  1116. /// <remarks>
  1117. /// <para>
  1118. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create buffers with minimum duration
  1119. /// 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
  1120. /// current buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1121. /// </para>
  1122. /// <para>
  1123. /// 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.
  1124. /// 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,
  1125. /// where the action to create a new buffer may not execute immediately, despite the TimeSpan.Zero due time.
  1126. /// </para>
  1127. /// </remarks>
  1128. public static IQbservable<IList<TSource>> Buffer<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  1129. {
  1130. if (source == null)
  1131. throw new ArgumentNullException(nameof(source));
  1132. if (scheduler == null)
  1133. throw new ArgumentNullException(nameof(scheduler));
  1134. return source.Provider.CreateQuery<IList<TSource>>(
  1135. Expression.Call(
  1136. null,
  1137. #if CRIPPLED_REFLECTION
  1138. InfoOf(() => Qbservable.Buffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  1139. #else
  1140. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1141. #endif
  1142. source.Expression,
  1143. Expression.Constant(timeSpan, typeof(TimeSpan)),
  1144. Expression.Constant(timeShift, typeof(TimeSpan)),
  1145. Expression.Constant(scheduler, typeof(IScheduler))
  1146. )
  1147. );
  1148. }
  1149. /// <summary>
  1150. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  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. /// <typeparam name="TBufferBoundary">The type of the elements in the sequences indicating buffer boundary events.</typeparam>
  1154. /// <param name="source">Source sequence to produce buffers over.</param>
  1155. /// <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>
  1156. /// <returns>An observable sequence of buffers.</returns>
  1157. /// <exception cref="ArgumentNullException">
  1158. /// <paramref name="source" /> or <paramref name="bufferBoundaries" /> is null.</exception>
  1159. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferBoundary>(this IQbservable<TSource> source, IObservable<TBufferBoundary> bufferBoundaries)
  1160. {
  1161. if (source == null)
  1162. throw new ArgumentNullException(nameof(source));
  1163. if (bufferBoundaries == null)
  1164. throw new ArgumentNullException(nameof(bufferBoundaries));
  1165. return source.Provider.CreateQuery<IList<TSource>>(
  1166. Expression.Call(
  1167. null,
  1168. #if CRIPPLED_REFLECTION
  1169. InfoOf(() => Qbservable.Buffer<TSource, TBufferBoundary>(default(IQbservable<TSource>), default(IObservable<TBufferBoundary>))),
  1170. #else
  1171. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferBoundary)),
  1172. #endif
  1173. source.Expression,
  1174. GetSourceExpression(bufferBoundaries)
  1175. )
  1176. );
  1177. }
  1178. /// <summary>
  1179. /// Projects each element of an observable sequence into consecutive non-overlapping buffers.
  1180. /// </summary>
  1181. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1182. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1183. /// <param name="source">Source sequence to produce buffers over.</param>
  1184. /// <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>
  1185. /// <returns>An observable sequence of buffers.</returns>
  1186. /// <exception cref="ArgumentNullException">
  1187. /// <paramref name="source" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1188. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TBufferClosing>>> bufferClosingSelector)
  1189. {
  1190. if (source == null)
  1191. throw new ArgumentNullException(nameof(source));
  1192. if (bufferClosingSelector == null)
  1193. throw new ArgumentNullException(nameof(bufferClosingSelector));
  1194. return source.Provider.CreateQuery<IList<TSource>>(
  1195. Expression.Call(
  1196. null,
  1197. #if CRIPPLED_REFLECTION
  1198. InfoOf(() => Qbservable.Buffer<TSource, TBufferClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TBufferClosing>>>))),
  1199. #else
  1200. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferClosing)),
  1201. #endif
  1202. source.Expression,
  1203. bufferClosingSelector
  1204. )
  1205. );
  1206. }
  1207. /// <summary>
  1208. /// Projects each element of an observable sequence into zero or more buffers.
  1209. /// </summary>
  1210. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the lists in the result sequence.</typeparam>
  1211. /// <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>
  1212. /// <typeparam name="TBufferClosing">The type of the elements in the sequences indicating buffer closing events.</typeparam>
  1213. /// <param name="source">Source sequence to produce buffers over.</param>
  1214. /// <param name="bufferOpenings">Observable sequence whose elements denote the creation of new buffers.</param>
  1215. /// <param name="bufferClosingSelector">A function invoked to define the closing of each produced buffer.</param>
  1216. /// <returns>An observable sequence of buffers.</returns>
  1217. /// <exception cref="ArgumentNullException">
  1218. /// <paramref name="source" /> or <paramref name="bufferOpenings" /> or <paramref name="bufferClosingSelector" /> is null.</exception>
  1219. public static IQbservable<IList<TSource>> Buffer<TSource, TBufferOpening, TBufferClosing>(this IQbservable<TSource> source, IObservable<TBufferOpening> bufferOpenings, Expression<Func<TBufferOpening, IObservable<TBufferClosing>>> bufferClosingSelector)
  1220. {
  1221. if (source == null)
  1222. throw new ArgumentNullException(nameof(source));
  1223. if (bufferOpenings == null)
  1224. throw new ArgumentNullException(nameof(bufferOpenings));
  1225. if (bufferClosingSelector == null)
  1226. throw new ArgumentNullException(nameof(bufferClosingSelector));
  1227. return source.Provider.CreateQuery<IList<TSource>>(
  1228. Expression.Call(
  1229. null,
  1230. #if CRIPPLED_REFLECTION
  1231. InfoOf(() => Qbservable.Buffer<TSource, TBufferOpening, TBufferClosing>(default(IQbservable<TSource>), default(IObservable<TBufferOpening>), default(Expression<Func<TBufferOpening, IObservable<TBufferClosing>>>))),
  1232. #else
  1233. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TBufferOpening), typeof(TBufferClosing)),
  1234. #endif
  1235. source.Expression,
  1236. GetSourceExpression(bufferOpenings),
  1237. bufferClosingSelector
  1238. )
  1239. );
  1240. }
  1241. /// <summary>
  1242. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing an empty sequence if no match is found.
  1243. /// </summary>
  1244. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1245. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1246. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1247. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1248. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1249. /// <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>
  1250. /// <exception cref="ArgumentNullException">
  1251. /// <paramref name="selector" /> or <paramref name="sources" /> is null.</exception>
  1252. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources)
  1253. {
  1254. if (provider == null)
  1255. throw new ArgumentNullException(nameof(provider));
  1256. if (selector == null)
  1257. throw new ArgumentNullException(nameof(selector));
  1258. if (sources == null)
  1259. throw new ArgumentNullException(nameof(sources));
  1260. return provider.CreateQuery<TResult>(
  1261. Expression.Call(
  1262. null,
  1263. #if CRIPPLED_REFLECTION
  1264. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>))),
  1265. #else
  1266. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1267. #endif
  1268. Expression.Constant(provider, typeof(IQbservableProvider)),
  1269. selector,
  1270. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>))
  1271. )
  1272. );
  1273. }
  1274. /// <summary>
  1275. /// Uses <paramref name="selector" /> to determine which source in <paramref name="sources" /> to return, choosing <paramref name="defaultSource" /> if no match is found.
  1276. /// </summary>
  1277. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1278. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1279. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1280. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1281. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1282. /// <param name="defaultSource">Default source to select in case no matching source in <paramref name="sources" /> is found.</param>
  1283. /// <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>
  1284. /// <exception cref="ArgumentNullException">
  1285. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="defaultSource" /> is null.</exception>
  1286. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IObservable<TResult> defaultSource)
  1287. {
  1288. if (provider == null)
  1289. throw new ArgumentNullException(nameof(provider));
  1290. if (selector == null)
  1291. throw new ArgumentNullException(nameof(selector));
  1292. if (sources == null)
  1293. throw new ArgumentNullException(nameof(sources));
  1294. if (defaultSource == null)
  1295. throw new ArgumentNullException(nameof(defaultSource));
  1296. return provider.CreateQuery<TResult>(
  1297. Expression.Call(
  1298. null,
  1299. #if CRIPPLED_REFLECTION
  1300. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IObservable<TResult>))),
  1301. #else
  1302. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1303. #endif
  1304. Expression.Constant(provider, typeof(IQbservableProvider)),
  1305. selector,
  1306. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1307. GetSourceExpression(defaultSource)
  1308. )
  1309. );
  1310. }
  1311. /// <summary>
  1312. /// 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.
  1313. /// </summary>
  1314. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1315. /// <typeparam name="TValue">The type of the value returned by the selector function, used to look up the resulting source.</typeparam>
  1316. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  1317. /// <param name="selector">Selector function invoked to determine the source to lookup in the <paramref name="sources" /> dictionary.</param>
  1318. /// <param name="sources">Dictionary of sources to select from based on the <paramref name="selector" /> invocation result.</param>
  1319. /// <param name="scheduler">Scheduler to generate an empty sequence on in case no matching source in <paramref name="sources" /> is found.</param>
  1320. /// <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>
  1321. /// <exception cref="ArgumentNullException">
  1322. /// <paramref name="selector" /> or <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  1323. public static IQbservable<TResult> Case<TValue, TResult>(this IQbservableProvider provider, Expression<Func<TValue>> selector, IDictionary<TValue, IObservable<TResult>> sources, IScheduler scheduler)
  1324. {
  1325. if (provider == null)
  1326. throw new ArgumentNullException(nameof(provider));
  1327. if (selector == null)
  1328. throw new ArgumentNullException(nameof(selector));
  1329. if (sources == null)
  1330. throw new ArgumentNullException(nameof(sources));
  1331. if (scheduler == null)
  1332. throw new ArgumentNullException(nameof(scheduler));
  1333. return provider.CreateQuery<TResult>(
  1334. Expression.Call(
  1335. null,
  1336. #if CRIPPLED_REFLECTION
  1337. InfoOf(() => Qbservable.Case<TValue, TResult>(default(IQbservableProvider), default(Expression<Func<TValue>>), default(IDictionary<TValue, IObservable<TResult>>), default(IScheduler))),
  1338. #else
  1339. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TValue), typeof(TResult)),
  1340. #endif
  1341. Expression.Constant(provider, typeof(IQbservableProvider)),
  1342. selector,
  1343. Expression.Constant(sources, typeof(IDictionary<TValue, IObservable<TResult>>)),
  1344. Expression.Constant(scheduler, typeof(IScheduler))
  1345. )
  1346. );
  1347. }
  1348. /// <summary>
  1349. /// Converts the elements of an observable sequence to the specified type.
  1350. /// </summary>
  1351. /// <typeparam name="TResult">The type to convert the elements in the source sequence to.</typeparam>
  1352. /// <param name="source">The observable sequence that contains the elements to be converted.</param>
  1353. /// <returns>An observable sequence that contains each element of the source sequence converted to the specified type.</returns>
  1354. /// <exception cref="ArgumentNullException">
  1355. /// <paramref name="source" /> is null.</exception>
  1356. public static IQbservable<TResult> Cast<TResult>(this IQbservable<object> source)
  1357. {
  1358. if (source == null)
  1359. throw new ArgumentNullException(nameof(source));
  1360. return source.Provider.CreateQuery<TResult>(
  1361. Expression.Call(
  1362. null,
  1363. #if CRIPPLED_REFLECTION
  1364. InfoOf(() => Qbservable.Cast<TResult>(default(IQbservable<object>))),
  1365. #else
  1366. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  1367. #endif
  1368. source.Expression
  1369. )
  1370. );
  1371. }
  1372. /// <summary>
  1373. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1374. /// </summary>
  1375. /// <typeparam name="TSource">The type of the elements in the source sequence and handler sequence.</typeparam>
  1376. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  1377. /// <param name="second">Second observable sequence used to produce results when an error occurred in the first sequence.</param>
  1378. /// <returns>An observable sequence containing the first sequence's elements, followed by the elements of the second sequence in case an exception occurred.</returns>
  1379. /// <exception cref="ArgumentNullException">
  1380. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  1381. public static IQbservable<TSource> Catch<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  1382. {
  1383. if (first == null)
  1384. throw new ArgumentNullException(nameof(first));
  1385. if (second == null)
  1386. throw new ArgumentNullException(nameof(second));
  1387. return first.Provider.CreateQuery<TSource>(
  1388. Expression.Call(
  1389. null,
  1390. #if CRIPPLED_REFLECTION
  1391. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  1392. #else
  1393. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1394. #endif
  1395. first.Expression,
  1396. GetSourceExpression(second)
  1397. )
  1398. );
  1399. }
  1400. /// <summary>
  1401. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1402. /// </summary>
  1403. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1404. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1405. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1406. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1407. /// <exception cref="ArgumentNullException">
  1408. /// <paramref name="sources" /> is null.</exception>
  1409. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1410. {
  1411. if (provider == null)
  1412. throw new ArgumentNullException(nameof(provider));
  1413. if (sources == null)
  1414. throw new ArgumentNullException(nameof(sources));
  1415. return provider.CreateQuery<TSource>(
  1416. Expression.Call(
  1417. null,
  1418. #if CRIPPLED_REFLECTION
  1419. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1420. #else
  1421. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1422. #endif
  1423. Expression.Constant(provider, typeof(IQbservableProvider)),
  1424. GetSourceExpression(sources)
  1425. )
  1426. );
  1427. }
  1428. /// <summary>
  1429. /// Continues an observable sequence that is terminated by an exception with the next observable sequence.
  1430. /// </summary>
  1431. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1432. /// <typeparam name="TSource">The type of the elements in the source and handler sequences.</typeparam>
  1433. /// <param name="sources">Observable sequences to catch exceptions for.</param>
  1434. /// <returns>An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully.</returns>
  1435. /// <exception cref="ArgumentNullException">
  1436. /// <paramref name="sources" /> is null.</exception>
  1437. public static IQbservable<TSource> Catch<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1438. {
  1439. if (provider == null)
  1440. throw new ArgumentNullException(nameof(provider));
  1441. if (sources == null)
  1442. throw new ArgumentNullException(nameof(sources));
  1443. return provider.CreateQuery<TSource>(
  1444. Expression.Call(
  1445. null,
  1446. #if CRIPPLED_REFLECTION
  1447. InfoOf(() => Qbservable.Catch<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1448. #else
  1449. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1450. #endif
  1451. Expression.Constant(provider, typeof(IQbservableProvider)),
  1452. GetSourceExpression(sources)
  1453. )
  1454. );
  1455. }
  1456. /// <summary>
  1457. /// Continues an observable sequence that is terminated by an exception of the specified type with the observable sequence produced by the handler.
  1458. /// </summary>
  1459. /// <typeparam name="TSource">The type of the elements in the source sequence and sequences returned by the exception handler function.</typeparam>
  1460. /// <typeparam name="TException">The type of the exception to catch and handle. Needs to derive from <see cref="Exception" />.</typeparam>
  1461. /// <param name="source">Source sequence.</param>
  1462. /// <param name="handler">Exception handler function, producing another observable sequence.</param>
  1463. /// <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>
  1464. /// <exception cref="ArgumentNullException">
  1465. /// <paramref name="source" /> or <paramref name="handler" /> is null.</exception>
  1466. public static IQbservable<TSource> Catch<TSource, TException>(this IQbservable<TSource> source, Expression<Func<TException, IObservable<TSource>>> handler)
  1467. where TException : Exception
  1468. {
  1469. if (source == null)
  1470. throw new ArgumentNullException(nameof(source));
  1471. if (handler == null)
  1472. throw new ArgumentNullException(nameof(handler));
  1473. return source.Provider.CreateQuery<TSource>(
  1474. Expression.Call(
  1475. null,
  1476. #if CRIPPLED_REFLECTION
  1477. InfoOf(() => Qbservable.Catch<TSource, TException>(default(IQbservable<TSource>), default(Expression<Func<TException, IObservable<TSource>>>))),
  1478. #else
  1479. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TException)),
  1480. #endif
  1481. source.Expression,
  1482. handler
  1483. )
  1484. );
  1485. }
  1486. /// <summary>
  1487. /// Produces an enumerable sequence of consecutive (possibly empty) chunks of the source sequence.
  1488. /// </summary>
  1489. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1490. /// <param name="source">Source observable sequence.</param>
  1491. /// <returns>The enumerable sequence that returns consecutive (possibly empty) chunks upon each iteration.</returns>
  1492. /// <exception cref="ArgumentNullException">
  1493. /// <paramref name="source" /> is null.</exception>
  1494. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1495. public static IQueryable<IList<TSource>> Chunkify<TSource>(this IQbservable<TSource> source)
  1496. {
  1497. if (source == null)
  1498. throw new ArgumentNullException(nameof(source));
  1499. return ((IQueryProvider)source.Provider).CreateQuery<IList<TSource>>(
  1500. Expression.Call(
  1501. null,
  1502. #if CRIPPLED_REFLECTION
  1503. InfoOf(() => Qbservable.Chunkify<TSource>(default(IQbservable<TSource>))),
  1504. #else
  1505. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1506. #endif
  1507. source.Expression
  1508. )
  1509. );
  1510. }
  1511. /// <summary>
  1512. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1513. /// </summary>
  1514. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1515. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1516. /// <param name="source">Source observable sequence.</param>
  1517. /// <param name="getInitialCollector">Factory to create the initial collector object.</param>
  1518. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1519. /// <param name="getNewCollector">Factory to replace the current collector by a new collector.</param>
  1520. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1521. /// <exception cref="ArgumentNullException">
  1522. /// <paramref name="source" /> or <paramref name="getInitialCollector" /> or <paramref name="merge" /> or <paramref name="getNewCollector" /> is null.</exception>
  1523. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1524. 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)
  1525. {
  1526. if (source == null)
  1527. throw new ArgumentNullException(nameof(source));
  1528. if (getInitialCollector == null)
  1529. throw new ArgumentNullException(nameof(getInitialCollector));
  1530. if (merge == null)
  1531. throw new ArgumentNullException(nameof(merge));
  1532. if (getNewCollector == null)
  1533. throw new ArgumentNullException(nameof(getNewCollector));
  1534. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1535. Expression.Call(
  1536. null,
  1537. #if CRIPPLED_REFLECTION
  1538. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>), default(Expression<Func<TResult, TResult>>))),
  1539. #else
  1540. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1541. #endif
  1542. source.Expression,
  1543. getInitialCollector,
  1544. merge,
  1545. getNewCollector
  1546. )
  1547. );
  1548. }
  1549. /// <summary>
  1550. /// Produces an enumerable sequence that returns elements collected/aggregated from the source sequence between consecutive iterations.
  1551. /// </summary>
  1552. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  1553. /// <typeparam name="TResult">The type of the elements produced by the merge operation during collection.</typeparam>
  1554. /// <param name="source">Source observable sequence.</param>
  1555. /// <param name="newCollector">Factory to create a new collector object.</param>
  1556. /// <param name="merge">Merges a sequence element with the current collector.</param>
  1557. /// <returns>The enumerable sequence that returns collected/aggregated elements from the source sequence upon each iteration.</returns>
  1558. /// <exception cref="ArgumentNullException">
  1559. /// <paramref name="source" /> or <paramref name="newCollector" /> or <paramref name="merge" /> is null.</exception>
  1560. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  1561. public static IQueryable<TResult> Collect<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TResult>> newCollector, Expression<Func<TResult, TSource, TResult>> merge)
  1562. {
  1563. if (source == null)
  1564. throw new ArgumentNullException(nameof(source));
  1565. if (newCollector == null)
  1566. throw new ArgumentNullException(nameof(newCollector));
  1567. if (merge == null)
  1568. throw new ArgumentNullException(nameof(merge));
  1569. return ((IQueryProvider)source.Provider).CreateQuery<TResult>(
  1570. Expression.Call(
  1571. null,
  1572. #if CRIPPLED_REFLECTION
  1573. InfoOf(() => Qbservable.Collect<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TResult>>), default(Expression<Func<TResult, TSource, TResult>>))),
  1574. #else
  1575. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1576. #endif
  1577. source.Expression,
  1578. newCollector,
  1579. merge
  1580. )
  1581. );
  1582. }
  1583. /// <summary>
  1584. /// 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.
  1585. /// </summary>
  1586. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1587. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1588. /// <param name="sources">Observable sources.</param>
  1589. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1590. /// <exception cref="ArgumentNullException">
  1591. /// <paramref name="sources" /> is null.</exception>
  1592. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  1593. {
  1594. if (provider == null)
  1595. throw new ArgumentNullException(nameof(provider));
  1596. if (sources == null)
  1597. throw new ArgumentNullException(nameof(sources));
  1598. return provider.CreateQuery<IList<TSource>>(
  1599. Expression.Call(
  1600. null,
  1601. #if CRIPPLED_REFLECTION
  1602. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  1603. #else
  1604. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1605. #endif
  1606. Expression.Constant(provider, typeof(IQbservableProvider)),
  1607. GetSourceExpression(sources)
  1608. )
  1609. );
  1610. }
  1611. /// <summary>
  1612. /// 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.
  1613. /// </summary>
  1614. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1615. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  1616. /// <param name="sources">Observable sources.</param>
  1617. /// <returns>An observable sequence containing lists of the latest elements of the sources.</returns>
  1618. /// <exception cref="ArgumentNullException">
  1619. /// <paramref name="sources" /> is null.</exception>
  1620. public static IQbservable<IList<TSource>> CombineLatest<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  1621. {
  1622. if (provider == null)
  1623. throw new ArgumentNullException(nameof(provider));
  1624. if (sources == null)
  1625. throw new ArgumentNullException(nameof(sources));
  1626. return provider.CreateQuery<IList<TSource>>(
  1627. Expression.Call(
  1628. null,
  1629. #if CRIPPLED_REFLECTION
  1630. InfoOf(() => Qbservable.CombineLatest<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  1631. #else
  1632. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  1633. #endif
  1634. Expression.Constant(provider, typeof(IQbservableProvider)),
  1635. GetSourceExpression(sources)
  1636. )
  1637. );
  1638. }
  1639. /// <summary>
  1640. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1641. /// </summary>
  1642. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  1643. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  1644. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1645. /// <param name="sources">Observable sources.</param>
  1646. /// <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>
  1647. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1648. /// <exception cref="ArgumentNullException">
  1649. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  1650. public static IQbservable<TResult> CombineLatest<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  1651. {
  1652. if (provider == null)
  1653. throw new ArgumentNullException(nameof(provider));
  1654. if (sources == null)
  1655. throw new ArgumentNullException(nameof(sources));
  1656. if (resultSelector == null)
  1657. throw new ArgumentNullException(nameof(resultSelector));
  1658. return provider.CreateQuery<TResult>(
  1659. Expression.Call(
  1660. null,
  1661. #if CRIPPLED_REFLECTION
  1662. InfoOf(() => Qbservable.CombineLatest<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  1663. #else
  1664. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  1665. #endif
  1666. Expression.Constant(provider, typeof(IQbservableProvider)),
  1667. GetSourceExpression(sources),
  1668. resultSelector
  1669. )
  1670. );
  1671. }
  1672. /// <summary>
  1673. /// Merges two observable sequences into one observable sequence by using the selector function whenever one of the observable sequences produces an element.
  1674. /// </summary>
  1675. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1676. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1677. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1678. /// <param name="first">First observable source.</param>
  1679. /// <param name="second">Second observable source.</param>
  1680. /// <param name="resultSelector">Function to invoke whenever either of the sources produces an element.</param>
  1681. /// <returns>An observable sequence containing the result of combining elements of both sources using the specified result selector function.</returns>
  1682. /// <exception cref="ArgumentNullException">
  1683. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  1684. public static IQbservable<TResult> CombineLatest<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  1685. {
  1686. if (first == null)
  1687. throw new ArgumentNullException(nameof(first));
  1688. if (second == null)
  1689. throw new ArgumentNullException(nameof(second));
  1690. if (resultSelector == null)
  1691. throw new ArgumentNullException(nameof(resultSelector));
  1692. return first.Provider.CreateQuery<TResult>(
  1693. Expression.Call(
  1694. null,
  1695. #if CRIPPLED_REFLECTION
  1696. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  1697. #else
  1698. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  1699. #endif
  1700. first.Expression,
  1701. GetSourceExpression(second),
  1702. resultSelector
  1703. )
  1704. );
  1705. }
  1706. /// <summary>
  1707. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1708. /// </summary>
  1709. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1710. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1711. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1712. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1713. /// <param name="source1">First observable source.</param>
  1714. /// <param name="source2">Second observable source.</param>
  1715. /// <param name="source3">Third observable source.</param>
  1716. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1717. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1718. /// <exception cref="ArgumentNullException">
  1719. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  1720. 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)
  1721. {
  1722. if (source1 == null)
  1723. throw new ArgumentNullException(nameof(source1));
  1724. if (source2 == null)
  1725. throw new ArgumentNullException(nameof(source2));
  1726. if (source3 == null)
  1727. throw new ArgumentNullException(nameof(source3));
  1728. if (resultSelector == null)
  1729. throw new ArgumentNullException(nameof(resultSelector));
  1730. return source1.Provider.CreateQuery<TResult>(
  1731. Expression.Call(
  1732. null,
  1733. #if CRIPPLED_REFLECTION
  1734. InfoOf(() => Qbservable.CombineLatest<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  1735. #else
  1736. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  1737. #endif
  1738. source1.Expression,
  1739. GetSourceExpression(source2),
  1740. GetSourceExpression(source3),
  1741. resultSelector
  1742. )
  1743. );
  1744. }
  1745. /// <summary>
  1746. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1747. /// </summary>
  1748. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1749. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1750. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1751. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1752. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1753. /// <param name="source1">First observable source.</param>
  1754. /// <param name="source2">Second observable source.</param>
  1755. /// <param name="source3">Third observable source.</param>
  1756. /// <param name="source4">Fourth observable source.</param>
  1757. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1758. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1759. /// <exception cref="ArgumentNullException">
  1760. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  1761. 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)
  1762. {
  1763. if (source1 == null)
  1764. throw new ArgumentNullException(nameof(source1));
  1765. if (source2 == null)
  1766. throw new ArgumentNullException(nameof(source2));
  1767. if (source3 == null)
  1768. throw new ArgumentNullException(nameof(source3));
  1769. if (source4 == null)
  1770. throw new ArgumentNullException(nameof(source4));
  1771. if (resultSelector == null)
  1772. throw new ArgumentNullException(nameof(resultSelector));
  1773. return source1.Provider.CreateQuery<TResult>(
  1774. Expression.Call(
  1775. null,
  1776. #if CRIPPLED_REFLECTION
  1777. 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>>))),
  1778. #else
  1779. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  1780. #endif
  1781. source1.Expression,
  1782. GetSourceExpression(source2),
  1783. GetSourceExpression(source3),
  1784. GetSourceExpression(source4),
  1785. resultSelector
  1786. )
  1787. );
  1788. }
  1789. /// <summary>
  1790. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1791. /// </summary>
  1792. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1793. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1794. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1795. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1796. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1797. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1798. /// <param name="source1">First observable source.</param>
  1799. /// <param name="source2">Second observable source.</param>
  1800. /// <param name="source3">Third observable source.</param>
  1801. /// <param name="source4">Fourth observable source.</param>
  1802. /// <param name="source5">Fifth observable source.</param>
  1803. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1804. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1805. /// <exception cref="ArgumentNullException">
  1806. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="source5" /> or <paramref name="resultSelector" /> is null.</exception>
  1807. 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)
  1808. {
  1809. if (source1 == null)
  1810. throw new ArgumentNullException(nameof(source1));
  1811. if (source2 == null)
  1812. throw new ArgumentNullException(nameof(source2));
  1813. if (source3 == null)
  1814. throw new ArgumentNullException(nameof(source3));
  1815. if (source4 == null)
  1816. throw new ArgumentNullException(nameof(source4));
  1817. if (source5 == null)
  1818. throw new ArgumentNullException(nameof(source5));
  1819. if (resultSelector == null)
  1820. throw new ArgumentNullException(nameof(resultSelector));
  1821. return source1.Provider.CreateQuery<TResult>(
  1822. Expression.Call(
  1823. null,
  1824. #if CRIPPLED_REFLECTION
  1825. 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>>))),
  1826. #else
  1827. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  1828. #endif
  1829. source1.Expression,
  1830. GetSourceExpression(source2),
  1831. GetSourceExpression(source3),
  1832. GetSourceExpression(source4),
  1833. GetSourceExpression(source5),
  1834. resultSelector
  1835. )
  1836. );
  1837. }
  1838. /// <summary>
  1839. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1840. /// </summary>
  1841. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1842. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1843. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1844. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1845. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1846. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1847. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1848. /// <param name="source1">First observable source.</param>
  1849. /// <param name="source2">Second observable source.</param>
  1850. /// <param name="source3">Third observable source.</param>
  1851. /// <param name="source4">Fourth observable source.</param>
  1852. /// <param name="source5">Fifth observable source.</param>
  1853. /// <param name="source6">Sixth observable source.</param>
  1854. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1855. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1856. /// <exception cref="ArgumentNullException">
  1857. /// <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>
  1858. 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)
  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 (source5 == null)
  1869. throw new ArgumentNullException(nameof(source5));
  1870. if (source6 == null)
  1871. throw new ArgumentNullException(nameof(source6));
  1872. if (resultSelector == null)
  1873. throw new ArgumentNullException(nameof(resultSelector));
  1874. return source1.Provider.CreateQuery<TResult>(
  1875. Expression.Call(
  1876. null,
  1877. #if CRIPPLED_REFLECTION
  1878. 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>>))),
  1879. #else
  1880. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  1881. #endif
  1882. source1.Expression,
  1883. GetSourceExpression(source2),
  1884. GetSourceExpression(source3),
  1885. GetSourceExpression(source4),
  1886. GetSourceExpression(source5),
  1887. GetSourceExpression(source6),
  1888. resultSelector
  1889. )
  1890. );
  1891. }
  1892. /// <summary>
  1893. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1894. /// </summary>
  1895. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1896. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1897. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1898. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1899. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1900. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1901. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  1902. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1903. /// <param name="source1">First observable source.</param>
  1904. /// <param name="source2">Second observable source.</param>
  1905. /// <param name="source3">Third observable source.</param>
  1906. /// <param name="source4">Fourth observable source.</param>
  1907. /// <param name="source5">Fifth observable source.</param>
  1908. /// <param name="source6">Sixth observable source.</param>
  1909. /// <param name="source7">Seventh observable source.</param>
  1910. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1911. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1912. /// <exception cref="ArgumentNullException">
  1913. /// <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>
  1914. 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)
  1915. {
  1916. if (source1 == null)
  1917. throw new ArgumentNullException(nameof(source1));
  1918. if (source2 == null)
  1919. throw new ArgumentNullException(nameof(source2));
  1920. if (source3 == null)
  1921. throw new ArgumentNullException(nameof(source3));
  1922. if (source4 == null)
  1923. throw new ArgumentNullException(nameof(source4));
  1924. if (source5 == null)
  1925. throw new ArgumentNullException(nameof(source5));
  1926. if (source6 == null)
  1927. throw new ArgumentNullException(nameof(source6));
  1928. if (source7 == null)
  1929. throw new ArgumentNullException(nameof(source7));
  1930. if (resultSelector == null)
  1931. throw new ArgumentNullException(nameof(resultSelector));
  1932. return source1.Provider.CreateQuery<TResult>(
  1933. Expression.Call(
  1934. null,
  1935. #if CRIPPLED_REFLECTION
  1936. 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>>))),
  1937. #else
  1938. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  1939. #endif
  1940. source1.Expression,
  1941. GetSourceExpression(source2),
  1942. GetSourceExpression(source3),
  1943. GetSourceExpression(source4),
  1944. GetSourceExpression(source5),
  1945. GetSourceExpression(source6),
  1946. GetSourceExpression(source7),
  1947. resultSelector
  1948. )
  1949. );
  1950. }
  1951. /// <summary>
  1952. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  1953. /// </summary>
  1954. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  1955. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  1956. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  1957. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  1958. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  1959. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  1960. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  1961. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  1962. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  1963. /// <param name="source1">First observable source.</param>
  1964. /// <param name="source2">Second observable source.</param>
  1965. /// <param name="source3">Third observable source.</param>
  1966. /// <param name="source4">Fourth observable source.</param>
  1967. /// <param name="source5">Fifth observable source.</param>
  1968. /// <param name="source6">Sixth observable source.</param>
  1969. /// <param name="source7">Seventh observable source.</param>
  1970. /// <param name="source8">Eighth observable source.</param>
  1971. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  1972. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  1973. /// <exception cref="ArgumentNullException">
  1974. /// <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>
  1975. 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)
  1976. {
  1977. if (source1 == null)
  1978. throw new ArgumentNullException(nameof(source1));
  1979. if (source2 == null)
  1980. throw new ArgumentNullException(nameof(source2));
  1981. if (source3 == null)
  1982. throw new ArgumentNullException(nameof(source3));
  1983. if (source4 == null)
  1984. throw new ArgumentNullException(nameof(source4));
  1985. if (source5 == null)
  1986. throw new ArgumentNullException(nameof(source5));
  1987. if (source6 == null)
  1988. throw new ArgumentNullException(nameof(source6));
  1989. if (source7 == null)
  1990. throw new ArgumentNullException(nameof(source7));
  1991. if (source8 == null)
  1992. throw new ArgumentNullException(nameof(source8));
  1993. if (resultSelector == null)
  1994. throw new ArgumentNullException(nameof(resultSelector));
  1995. return source1.Provider.CreateQuery<TResult>(
  1996. Expression.Call(
  1997. null,
  1998. #if CRIPPLED_REFLECTION
  1999. 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>>))),
  2000. #else
  2001. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  2002. #endif
  2003. source1.Expression,
  2004. GetSourceExpression(source2),
  2005. GetSourceExpression(source3),
  2006. GetSourceExpression(source4),
  2007. GetSourceExpression(source5),
  2008. GetSourceExpression(source6),
  2009. GetSourceExpression(source7),
  2010. GetSourceExpression(source8),
  2011. resultSelector
  2012. )
  2013. );
  2014. }
  2015. /// <summary>
  2016. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2017. /// </summary>
  2018. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2019. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2020. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2021. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2022. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2023. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2024. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2025. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2026. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2027. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2028. /// <param name="source1">First observable source.</param>
  2029. /// <param name="source2">Second observable source.</param>
  2030. /// <param name="source3">Third observable source.</param>
  2031. /// <param name="source4">Fourth observable source.</param>
  2032. /// <param name="source5">Fifth observable source.</param>
  2033. /// <param name="source6">Sixth observable source.</param>
  2034. /// <param name="source7">Seventh observable source.</param>
  2035. /// <param name="source8">Eighth observable source.</param>
  2036. /// <param name="source9">Ninth observable source.</param>
  2037. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2038. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2039. /// <exception cref="ArgumentNullException">
  2040. /// <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>
  2041. 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)
  2042. {
  2043. if (source1 == null)
  2044. throw new ArgumentNullException(nameof(source1));
  2045. if (source2 == null)
  2046. throw new ArgumentNullException(nameof(source2));
  2047. if (source3 == null)
  2048. throw new ArgumentNullException(nameof(source3));
  2049. if (source4 == null)
  2050. throw new ArgumentNullException(nameof(source4));
  2051. if (source5 == null)
  2052. throw new ArgumentNullException(nameof(source5));
  2053. if (source6 == null)
  2054. throw new ArgumentNullException(nameof(source6));
  2055. if (source7 == null)
  2056. throw new ArgumentNullException(nameof(source7));
  2057. if (source8 == null)
  2058. throw new ArgumentNullException(nameof(source8));
  2059. if (source9 == null)
  2060. throw new ArgumentNullException(nameof(source9));
  2061. if (resultSelector == null)
  2062. throw new ArgumentNullException(nameof(resultSelector));
  2063. return source1.Provider.CreateQuery<TResult>(
  2064. Expression.Call(
  2065. null,
  2066. #if CRIPPLED_REFLECTION
  2067. 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>>))),
  2068. #else
  2069. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  2070. #endif
  2071. source1.Expression,
  2072. GetSourceExpression(source2),
  2073. GetSourceExpression(source3),
  2074. GetSourceExpression(source4),
  2075. GetSourceExpression(source5),
  2076. GetSourceExpression(source6),
  2077. GetSourceExpression(source7),
  2078. GetSourceExpression(source8),
  2079. GetSourceExpression(source9),
  2080. resultSelector
  2081. )
  2082. );
  2083. }
  2084. /// <summary>
  2085. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2086. /// </summary>
  2087. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2088. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2089. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2090. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2091. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2092. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2093. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2094. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2095. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2096. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2097. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2098. /// <param name="source1">First observable source.</param>
  2099. /// <param name="source2">Second observable source.</param>
  2100. /// <param name="source3">Third observable source.</param>
  2101. /// <param name="source4">Fourth observable source.</param>
  2102. /// <param name="source5">Fifth observable source.</param>
  2103. /// <param name="source6">Sixth observable source.</param>
  2104. /// <param name="source7">Seventh observable source.</param>
  2105. /// <param name="source8">Eighth observable source.</param>
  2106. /// <param name="source9">Ninth observable source.</param>
  2107. /// <param name="source10">Tenth observable source.</param>
  2108. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2109. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2110. /// <exception cref="ArgumentNullException">
  2111. /// <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>
  2112. 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)
  2113. {
  2114. if (source1 == null)
  2115. throw new ArgumentNullException(nameof(source1));
  2116. if (source2 == null)
  2117. throw new ArgumentNullException(nameof(source2));
  2118. if (source3 == null)
  2119. throw new ArgumentNullException(nameof(source3));
  2120. if (source4 == null)
  2121. throw new ArgumentNullException(nameof(source4));
  2122. if (source5 == null)
  2123. throw new ArgumentNullException(nameof(source5));
  2124. if (source6 == null)
  2125. throw new ArgumentNullException(nameof(source6));
  2126. if (source7 == null)
  2127. throw new ArgumentNullException(nameof(source7));
  2128. if (source8 == null)
  2129. throw new ArgumentNullException(nameof(source8));
  2130. if (source9 == null)
  2131. throw new ArgumentNullException(nameof(source9));
  2132. if (source10 == null)
  2133. throw new ArgumentNullException(nameof(source10));
  2134. if (resultSelector == null)
  2135. throw new ArgumentNullException(nameof(resultSelector));
  2136. return source1.Provider.CreateQuery<TResult>(
  2137. Expression.Call(
  2138. null,
  2139. #if CRIPPLED_REFLECTION
  2140. 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>>))),
  2141. #else
  2142. ((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)),
  2143. #endif
  2144. source1.Expression,
  2145. GetSourceExpression(source2),
  2146. GetSourceExpression(source3),
  2147. GetSourceExpression(source4),
  2148. GetSourceExpression(source5),
  2149. GetSourceExpression(source6),
  2150. GetSourceExpression(source7),
  2151. GetSourceExpression(source8),
  2152. GetSourceExpression(source9),
  2153. GetSourceExpression(source10),
  2154. resultSelector
  2155. )
  2156. );
  2157. }
  2158. /// <summary>
  2159. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2160. /// </summary>
  2161. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2162. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2163. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2164. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2165. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2166. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2167. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2168. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2169. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2170. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2171. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2172. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2173. /// <param name="source1">First observable source.</param>
  2174. /// <param name="source2">Second observable source.</param>
  2175. /// <param name="source3">Third observable source.</param>
  2176. /// <param name="source4">Fourth observable source.</param>
  2177. /// <param name="source5">Fifth observable source.</param>
  2178. /// <param name="source6">Sixth observable source.</param>
  2179. /// <param name="source7">Seventh observable source.</param>
  2180. /// <param name="source8">Eighth observable source.</param>
  2181. /// <param name="source9">Ninth observable source.</param>
  2182. /// <param name="source10">Tenth observable source.</param>
  2183. /// <param name="source11">Eleventh observable source.</param>
  2184. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2185. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2186. /// <exception cref="ArgumentNullException">
  2187. /// <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>
  2188. 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)
  2189. {
  2190. if (source1 == null)
  2191. throw new ArgumentNullException(nameof(source1));
  2192. if (source2 == null)
  2193. throw new ArgumentNullException(nameof(source2));
  2194. if (source3 == null)
  2195. throw new ArgumentNullException(nameof(source3));
  2196. if (source4 == null)
  2197. throw new ArgumentNullException(nameof(source4));
  2198. if (source5 == null)
  2199. throw new ArgumentNullException(nameof(source5));
  2200. if (source6 == null)
  2201. throw new ArgumentNullException(nameof(source6));
  2202. if (source7 == null)
  2203. throw new ArgumentNullException(nameof(source7));
  2204. if (source8 == null)
  2205. throw new ArgumentNullException(nameof(source8));
  2206. if (source9 == null)
  2207. throw new ArgumentNullException(nameof(source9));
  2208. if (source10 == null)
  2209. throw new ArgumentNullException(nameof(source10));
  2210. if (source11 == null)
  2211. throw new ArgumentNullException(nameof(source11));
  2212. if (resultSelector == null)
  2213. throw new ArgumentNullException(nameof(resultSelector));
  2214. return source1.Provider.CreateQuery<TResult>(
  2215. Expression.Call(
  2216. null,
  2217. #if CRIPPLED_REFLECTION
  2218. 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>>))),
  2219. #else
  2220. ((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)),
  2221. #endif
  2222. source1.Expression,
  2223. GetSourceExpression(source2),
  2224. GetSourceExpression(source3),
  2225. GetSourceExpression(source4),
  2226. GetSourceExpression(source5),
  2227. GetSourceExpression(source6),
  2228. GetSourceExpression(source7),
  2229. GetSourceExpression(source8),
  2230. GetSourceExpression(source9),
  2231. GetSourceExpression(source10),
  2232. GetSourceExpression(source11),
  2233. resultSelector
  2234. )
  2235. );
  2236. }
  2237. /// <summary>
  2238. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2239. /// </summary>
  2240. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2241. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2242. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2243. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2244. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2245. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2246. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2247. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2248. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2249. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2250. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2251. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2252. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2253. /// <param name="source1">First observable source.</param>
  2254. /// <param name="source2">Second observable source.</param>
  2255. /// <param name="source3">Third observable source.</param>
  2256. /// <param name="source4">Fourth observable source.</param>
  2257. /// <param name="source5">Fifth observable source.</param>
  2258. /// <param name="source6">Sixth observable source.</param>
  2259. /// <param name="source7">Seventh observable source.</param>
  2260. /// <param name="source8">Eighth observable source.</param>
  2261. /// <param name="source9">Ninth observable source.</param>
  2262. /// <param name="source10">Tenth observable source.</param>
  2263. /// <param name="source11">Eleventh observable source.</param>
  2264. /// <param name="source12">Twelfth observable source.</param>
  2265. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2266. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2267. /// <exception cref="ArgumentNullException">
  2268. /// <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>
  2269. 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)
  2270. {
  2271. if (source1 == null)
  2272. throw new ArgumentNullException(nameof(source1));
  2273. if (source2 == null)
  2274. throw new ArgumentNullException(nameof(source2));
  2275. if (source3 == null)
  2276. throw new ArgumentNullException(nameof(source3));
  2277. if (source4 == null)
  2278. throw new ArgumentNullException(nameof(source4));
  2279. if (source5 == null)
  2280. throw new ArgumentNullException(nameof(source5));
  2281. if (source6 == null)
  2282. throw new ArgumentNullException(nameof(source6));
  2283. if (source7 == null)
  2284. throw new ArgumentNullException(nameof(source7));
  2285. if (source8 == null)
  2286. throw new ArgumentNullException(nameof(source8));
  2287. if (source9 == null)
  2288. throw new ArgumentNullException(nameof(source9));
  2289. if (source10 == null)
  2290. throw new ArgumentNullException(nameof(source10));
  2291. if (source11 == null)
  2292. throw new ArgumentNullException(nameof(source11));
  2293. if (source12 == null)
  2294. throw new ArgumentNullException(nameof(source12));
  2295. if (resultSelector == null)
  2296. throw new ArgumentNullException(nameof(resultSelector));
  2297. return source1.Provider.CreateQuery<TResult>(
  2298. Expression.Call(
  2299. null,
  2300. #if CRIPPLED_REFLECTION
  2301. 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>>))),
  2302. #else
  2303. ((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)),
  2304. #endif
  2305. source1.Expression,
  2306. GetSourceExpression(source2),
  2307. GetSourceExpression(source3),
  2308. GetSourceExpression(source4),
  2309. GetSourceExpression(source5),
  2310. GetSourceExpression(source6),
  2311. GetSourceExpression(source7),
  2312. GetSourceExpression(source8),
  2313. GetSourceExpression(source9),
  2314. GetSourceExpression(source10),
  2315. GetSourceExpression(source11),
  2316. GetSourceExpression(source12),
  2317. resultSelector
  2318. )
  2319. );
  2320. }
  2321. /// <summary>
  2322. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2323. /// </summary>
  2324. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2325. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2326. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2327. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2328. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2329. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2330. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2331. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2332. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2333. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2334. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2335. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2336. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2337. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2338. /// <param name="source1">First observable source.</param>
  2339. /// <param name="source2">Second observable source.</param>
  2340. /// <param name="source3">Third observable source.</param>
  2341. /// <param name="source4">Fourth observable source.</param>
  2342. /// <param name="source5">Fifth observable source.</param>
  2343. /// <param name="source6">Sixth observable source.</param>
  2344. /// <param name="source7">Seventh observable source.</param>
  2345. /// <param name="source8">Eighth observable source.</param>
  2346. /// <param name="source9">Ninth observable source.</param>
  2347. /// <param name="source10">Tenth observable source.</param>
  2348. /// <param name="source11">Eleventh observable source.</param>
  2349. /// <param name="source12">Twelfth observable source.</param>
  2350. /// <param name="source13">Thirteenth observable source.</param>
  2351. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2352. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2353. /// <exception cref="ArgumentNullException">
  2354. /// <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>
  2355. 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)
  2356. {
  2357. if (source1 == null)
  2358. throw new ArgumentNullException(nameof(source1));
  2359. if (source2 == null)
  2360. throw new ArgumentNullException(nameof(source2));
  2361. if (source3 == null)
  2362. throw new ArgumentNullException(nameof(source3));
  2363. if (source4 == null)
  2364. throw new ArgumentNullException(nameof(source4));
  2365. if (source5 == null)
  2366. throw new ArgumentNullException(nameof(source5));
  2367. if (source6 == null)
  2368. throw new ArgumentNullException(nameof(source6));
  2369. if (source7 == null)
  2370. throw new ArgumentNullException(nameof(source7));
  2371. if (source8 == null)
  2372. throw new ArgumentNullException(nameof(source8));
  2373. if (source9 == null)
  2374. throw new ArgumentNullException(nameof(source9));
  2375. if (source10 == null)
  2376. throw new ArgumentNullException(nameof(source10));
  2377. if (source11 == null)
  2378. throw new ArgumentNullException(nameof(source11));
  2379. if (source12 == null)
  2380. throw new ArgumentNullException(nameof(source12));
  2381. if (source13 == null)
  2382. throw new ArgumentNullException(nameof(source13));
  2383. if (resultSelector == null)
  2384. throw new ArgumentNullException(nameof(resultSelector));
  2385. return source1.Provider.CreateQuery<TResult>(
  2386. Expression.Call(
  2387. null,
  2388. #if CRIPPLED_REFLECTION
  2389. 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>>))),
  2390. #else
  2391. ((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)),
  2392. #endif
  2393. source1.Expression,
  2394. GetSourceExpression(source2),
  2395. GetSourceExpression(source3),
  2396. GetSourceExpression(source4),
  2397. GetSourceExpression(source5),
  2398. GetSourceExpression(source6),
  2399. GetSourceExpression(source7),
  2400. GetSourceExpression(source8),
  2401. GetSourceExpression(source9),
  2402. GetSourceExpression(source10),
  2403. GetSourceExpression(source11),
  2404. GetSourceExpression(source12),
  2405. GetSourceExpression(source13),
  2406. resultSelector
  2407. )
  2408. );
  2409. }
  2410. /// <summary>
  2411. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2412. /// </summary>
  2413. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2414. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2415. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2416. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2417. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2418. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2419. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2420. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2421. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2422. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2423. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2424. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2425. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2426. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2427. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2428. /// <param name="source1">First observable source.</param>
  2429. /// <param name="source2">Second observable source.</param>
  2430. /// <param name="source3">Third observable source.</param>
  2431. /// <param name="source4">Fourth observable source.</param>
  2432. /// <param name="source5">Fifth observable source.</param>
  2433. /// <param name="source6">Sixth observable source.</param>
  2434. /// <param name="source7">Seventh observable source.</param>
  2435. /// <param name="source8">Eighth observable source.</param>
  2436. /// <param name="source9">Ninth observable source.</param>
  2437. /// <param name="source10">Tenth observable source.</param>
  2438. /// <param name="source11">Eleventh observable source.</param>
  2439. /// <param name="source12">Twelfth observable source.</param>
  2440. /// <param name="source13">Thirteenth observable source.</param>
  2441. /// <param name="source14">Fourteenth observable source.</param>
  2442. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2443. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2444. /// <exception cref="ArgumentNullException">
  2445. /// <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>
  2446. 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)
  2447. {
  2448. if (source1 == null)
  2449. throw new ArgumentNullException(nameof(source1));
  2450. if (source2 == null)
  2451. throw new ArgumentNullException(nameof(source2));
  2452. if (source3 == null)
  2453. throw new ArgumentNullException(nameof(source3));
  2454. if (source4 == null)
  2455. throw new ArgumentNullException(nameof(source4));
  2456. if (source5 == null)
  2457. throw new ArgumentNullException(nameof(source5));
  2458. if (source6 == null)
  2459. throw new ArgumentNullException(nameof(source6));
  2460. if (source7 == null)
  2461. throw new ArgumentNullException(nameof(source7));
  2462. if (source8 == null)
  2463. throw new ArgumentNullException(nameof(source8));
  2464. if (source9 == null)
  2465. throw new ArgumentNullException(nameof(source9));
  2466. if (source10 == null)
  2467. throw new ArgumentNullException(nameof(source10));
  2468. if (source11 == null)
  2469. throw new ArgumentNullException(nameof(source11));
  2470. if (source12 == null)
  2471. throw new ArgumentNullException(nameof(source12));
  2472. if (source13 == null)
  2473. throw new ArgumentNullException(nameof(source13));
  2474. if (source14 == null)
  2475. throw new ArgumentNullException(nameof(source14));
  2476. if (resultSelector == null)
  2477. throw new ArgumentNullException(nameof(resultSelector));
  2478. return source1.Provider.CreateQuery<TResult>(
  2479. Expression.Call(
  2480. null,
  2481. #if CRIPPLED_REFLECTION
  2482. 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>>))),
  2483. #else
  2484. ((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)),
  2485. #endif
  2486. source1.Expression,
  2487. GetSourceExpression(source2),
  2488. GetSourceExpression(source3),
  2489. GetSourceExpression(source4),
  2490. GetSourceExpression(source5),
  2491. GetSourceExpression(source6),
  2492. GetSourceExpression(source7),
  2493. GetSourceExpression(source8),
  2494. GetSourceExpression(source9),
  2495. GetSourceExpression(source10),
  2496. GetSourceExpression(source11),
  2497. GetSourceExpression(source12),
  2498. GetSourceExpression(source13),
  2499. GetSourceExpression(source14),
  2500. resultSelector
  2501. )
  2502. );
  2503. }
  2504. /// <summary>
  2505. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2506. /// </summary>
  2507. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2508. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2509. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2510. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2511. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2512. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2513. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2514. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2515. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2516. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2517. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2518. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2519. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2520. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2521. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2522. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2523. /// <param name="source1">First observable source.</param>
  2524. /// <param name="source2">Second observable source.</param>
  2525. /// <param name="source3">Third observable source.</param>
  2526. /// <param name="source4">Fourth observable source.</param>
  2527. /// <param name="source5">Fifth observable source.</param>
  2528. /// <param name="source6">Sixth observable source.</param>
  2529. /// <param name="source7">Seventh observable source.</param>
  2530. /// <param name="source8">Eighth observable source.</param>
  2531. /// <param name="source9">Ninth observable source.</param>
  2532. /// <param name="source10">Tenth observable source.</param>
  2533. /// <param name="source11">Eleventh observable source.</param>
  2534. /// <param name="source12">Twelfth observable source.</param>
  2535. /// <param name="source13">Thirteenth observable source.</param>
  2536. /// <param name="source14">Fourteenth observable source.</param>
  2537. /// <param name="source15">Fifteenth observable source.</param>
  2538. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2539. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2540. /// <exception cref="ArgumentNullException">
  2541. /// <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>
  2542. 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)
  2543. {
  2544. if (source1 == null)
  2545. throw new ArgumentNullException(nameof(source1));
  2546. if (source2 == null)
  2547. throw new ArgumentNullException(nameof(source2));
  2548. if (source3 == null)
  2549. throw new ArgumentNullException(nameof(source3));
  2550. if (source4 == null)
  2551. throw new ArgumentNullException(nameof(source4));
  2552. if (source5 == null)
  2553. throw new ArgumentNullException(nameof(source5));
  2554. if (source6 == null)
  2555. throw new ArgumentNullException(nameof(source6));
  2556. if (source7 == null)
  2557. throw new ArgumentNullException(nameof(source7));
  2558. if (source8 == null)
  2559. throw new ArgumentNullException(nameof(source8));
  2560. if (source9 == null)
  2561. throw new ArgumentNullException(nameof(source9));
  2562. if (source10 == null)
  2563. throw new ArgumentNullException(nameof(source10));
  2564. if (source11 == null)
  2565. throw new ArgumentNullException(nameof(source11));
  2566. if (source12 == null)
  2567. throw new ArgumentNullException(nameof(source12));
  2568. if (source13 == null)
  2569. throw new ArgumentNullException(nameof(source13));
  2570. if (source14 == null)
  2571. throw new ArgumentNullException(nameof(source14));
  2572. if (source15 == null)
  2573. throw new ArgumentNullException(nameof(source15));
  2574. if (resultSelector == null)
  2575. throw new ArgumentNullException(nameof(resultSelector));
  2576. return source1.Provider.CreateQuery<TResult>(
  2577. Expression.Call(
  2578. null,
  2579. #if CRIPPLED_REFLECTION
  2580. 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>>))),
  2581. #else
  2582. ((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)),
  2583. #endif
  2584. source1.Expression,
  2585. GetSourceExpression(source2),
  2586. GetSourceExpression(source3),
  2587. GetSourceExpression(source4),
  2588. GetSourceExpression(source5),
  2589. GetSourceExpression(source6),
  2590. GetSourceExpression(source7),
  2591. GetSourceExpression(source8),
  2592. GetSourceExpression(source9),
  2593. GetSourceExpression(source10),
  2594. GetSourceExpression(source11),
  2595. GetSourceExpression(source12),
  2596. GetSourceExpression(source13),
  2597. GetSourceExpression(source14),
  2598. GetSourceExpression(source15),
  2599. resultSelector
  2600. )
  2601. );
  2602. }
  2603. /// <summary>
  2604. /// Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element.
  2605. /// </summary>
  2606. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  2607. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  2608. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  2609. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  2610. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  2611. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  2612. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  2613. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  2614. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  2615. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  2616. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  2617. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  2618. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  2619. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  2620. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  2621. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  2622. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  2623. /// <param name="source1">First observable source.</param>
  2624. /// <param name="source2">Second observable source.</param>
  2625. /// <param name="source3">Third observable source.</param>
  2626. /// <param name="source4">Fourth observable source.</param>
  2627. /// <param name="source5">Fifth observable source.</param>
  2628. /// <param name="source6">Sixth observable source.</param>
  2629. /// <param name="source7">Seventh observable source.</param>
  2630. /// <param name="source8">Eighth observable source.</param>
  2631. /// <param name="source9">Ninth observable source.</param>
  2632. /// <param name="source10">Tenth observable source.</param>
  2633. /// <param name="source11">Eleventh observable source.</param>
  2634. /// <param name="source12">Twelfth observable source.</param>
  2635. /// <param name="source13">Thirteenth observable source.</param>
  2636. /// <param name="source14">Fourteenth observable source.</param>
  2637. /// <param name="source15">Fifteenth observable source.</param>
  2638. /// <param name="source16">Sixteenth observable source.</param>
  2639. /// <param name="resultSelector">Function to invoke whenever any of the sources produces an element.</param>
  2640. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  2641. /// <exception cref="ArgumentNullException">
  2642. /// <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>
  2643. 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)
  2644. {
  2645. if (source1 == null)
  2646. throw new ArgumentNullException(nameof(source1));
  2647. if (source2 == null)
  2648. throw new ArgumentNullException(nameof(source2));
  2649. if (source3 == null)
  2650. throw new ArgumentNullException(nameof(source3));
  2651. if (source4 == null)
  2652. throw new ArgumentNullException(nameof(source4));
  2653. if (source5 == null)
  2654. throw new ArgumentNullException(nameof(source5));
  2655. if (source6 == null)
  2656. throw new ArgumentNullException(nameof(source6));
  2657. if (source7 == null)
  2658. throw new ArgumentNullException(nameof(source7));
  2659. if (source8 == null)
  2660. throw new ArgumentNullException(nameof(source8));
  2661. if (source9 == null)
  2662. throw new ArgumentNullException(nameof(source9));
  2663. if (source10 == null)
  2664. throw new ArgumentNullException(nameof(source10));
  2665. if (source11 == null)
  2666. throw new ArgumentNullException(nameof(source11));
  2667. if (source12 == null)
  2668. throw new ArgumentNullException(nameof(source12));
  2669. if (source13 == null)
  2670. throw new ArgumentNullException(nameof(source13));
  2671. if (source14 == null)
  2672. throw new ArgumentNullException(nameof(source14));
  2673. if (source15 == null)
  2674. throw new ArgumentNullException(nameof(source15));
  2675. if (source16 == null)
  2676. throw new ArgumentNullException(nameof(source16));
  2677. if (resultSelector == null)
  2678. throw new ArgumentNullException(nameof(resultSelector));
  2679. return source1.Provider.CreateQuery<TResult>(
  2680. Expression.Call(
  2681. null,
  2682. #if CRIPPLED_REFLECTION
  2683. 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>>))),
  2684. #else
  2685. ((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)),
  2686. #endif
  2687. source1.Expression,
  2688. GetSourceExpression(source2),
  2689. GetSourceExpression(source3),
  2690. GetSourceExpression(source4),
  2691. GetSourceExpression(source5),
  2692. GetSourceExpression(source6),
  2693. GetSourceExpression(source7),
  2694. GetSourceExpression(source8),
  2695. GetSourceExpression(source9),
  2696. GetSourceExpression(source10),
  2697. GetSourceExpression(source11),
  2698. GetSourceExpression(source12),
  2699. GetSourceExpression(source13),
  2700. GetSourceExpression(source14),
  2701. GetSourceExpression(source15),
  2702. GetSourceExpression(source16),
  2703. resultSelector
  2704. )
  2705. );
  2706. }
  2707. /// <summary>
  2708. /// Concatenates the second observable sequence to the first observable sequence upon successful termination of the first.
  2709. /// </summary>
  2710. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2711. /// <param name="first">First observable sequence.</param>
  2712. /// <param name="second">Second observable sequence.</param>
  2713. /// <returns>An observable sequence that contains the elements of the first sequence, followed by those of the second the sequence.</returns>
  2714. /// <exception cref="ArgumentNullException">
  2715. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  2716. public static IQbservable<TSource> Concat<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  2717. {
  2718. if (first == null)
  2719. throw new ArgumentNullException(nameof(first));
  2720. if (second == null)
  2721. throw new ArgumentNullException(nameof(second));
  2722. return first.Provider.CreateQuery<TSource>(
  2723. Expression.Call(
  2724. null,
  2725. #if CRIPPLED_REFLECTION
  2726. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  2727. #else
  2728. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2729. #endif
  2730. first.Expression,
  2731. GetSourceExpression(second)
  2732. )
  2733. );
  2734. }
  2735. /// <summary>
  2736. /// Concatenates all of the specified observable sequences, as long as the previous observable sequence terminated successfully.
  2737. /// </summary>
  2738. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  2739. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2740. /// <param name="sources">Observable sequences to concatenate.</param>
  2741. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2742. /// <exception cref="ArgumentNullException">
  2743. /// <paramref name="sources" /> is null.</exception>
  2744. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  2745. {
  2746. if (provider == null)
  2747. throw new ArgumentNullException(nameof(provider));
  2748. if (sources == null)
  2749. throw new ArgumentNullException(nameof(sources));
  2750. return provider.CreateQuery<TSource>(
  2751. Expression.Call(
  2752. null,
  2753. #if CRIPPLED_REFLECTION
  2754. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  2755. #else
  2756. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2757. #endif
  2758. Expression.Constant(provider, typeof(IQbservableProvider)),
  2759. GetSourceExpression(sources)
  2760. )
  2761. );
  2762. }
  2763. /// <summary>
  2764. /// Concatenates all observable sequences in the given enumerable sequence, as long as the previous observable sequence terminated successfully.
  2765. /// </summary>
  2766. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  2767. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2768. /// <param name="sources">Observable sequences to concatenate.</param>
  2769. /// <returns>An observable sequence that contains the elements of each given sequence, in sequential order.</returns>
  2770. /// <exception cref="ArgumentNullException">
  2771. /// <paramref name="sources" /> is null.</exception>
  2772. public static IQbservable<TSource> Concat<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  2773. {
  2774. if (provider == null)
  2775. throw new ArgumentNullException(nameof(provider));
  2776. if (sources == null)
  2777. throw new ArgumentNullException(nameof(sources));
  2778. return provider.CreateQuery<TSource>(
  2779. Expression.Call(
  2780. null,
  2781. #if CRIPPLED_REFLECTION
  2782. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  2783. #else
  2784. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2785. #endif
  2786. Expression.Constant(provider, typeof(IQbservableProvider)),
  2787. GetSourceExpression(sources)
  2788. )
  2789. );
  2790. }
  2791. /// <summary>
  2792. /// Concatenates all inner observable sequences, as long as the previous observable sequence terminated successfully.
  2793. /// </summary>
  2794. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  2795. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  2796. /// <returns>An observable sequence that contains the elements of each observed inner sequence, in sequential order.</returns>
  2797. /// <exception cref="ArgumentNullException">
  2798. /// <paramref name="sources" /> is null.</exception>
  2799. public static IQbservable<TSource> Concat<TSource>(this IQbservable<IObservable<TSource>> sources)
  2800. {
  2801. if (sources == null)
  2802. throw new ArgumentNullException(nameof(sources));
  2803. return sources.Provider.CreateQuery<TSource>(
  2804. Expression.Call(
  2805. null,
  2806. #if CRIPPLED_REFLECTION
  2807. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<IObservable<TSource>>))),
  2808. #else
  2809. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2810. #endif
  2811. sources.Expression
  2812. )
  2813. );
  2814. }
  2815. /// <summary>
  2816. /// Concatenates all task results, as long as the previous task terminated successfully.
  2817. /// </summary>
  2818. /// <typeparam name="TSource">The type of the results produced by the tasks.</typeparam>
  2819. /// <param name="sources">Observable sequence of tasks.</param>
  2820. /// <returns>An observable sequence that contains the results of each task, in sequential order.</returns>
  2821. /// <exception cref="ArgumentNullException">
  2822. /// <paramref name="sources" /> is null.</exception>
  2823. /// <remarks>If the tasks support cancellation, consider manual conversion of the tasks using <see cref="Observable.FromAsync{TSource}(Func{CancellationToken,Task{TSource}})" />, followed by a concatenation operation using <see cref="Observable.Concat{TSource}(IObservable{IObservable{TSource}})" />.</remarks>
  2824. public static IQbservable<TSource> Concat<TSource>(this IQbservable<Task<TSource>> sources)
  2825. {
  2826. if (sources == null)
  2827. throw new ArgumentNullException(nameof(sources));
  2828. return sources.Provider.CreateQuery<TSource>(
  2829. Expression.Call(
  2830. null,
  2831. #if CRIPPLED_REFLECTION
  2832. InfoOf(() => Qbservable.Concat<TSource>(default(IQbservable<Task<TSource>>))),
  2833. #else
  2834. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2835. #endif
  2836. sources.Expression
  2837. )
  2838. );
  2839. }
  2840. /// <summary>
  2841. /// Determines whether an observable sequence contains a specified element by using the default equality comparer.
  2842. /// </summary>
  2843. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2844. /// <param name="source">An observable sequence in which to locate a value.</param>
  2845. /// <param name="value">The value to locate in the source sequence.</param>
  2846. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2847. /// <exception cref="ArgumentNullException">
  2848. /// <paramref name="source" /> is null.</exception>
  2849. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2850. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value)
  2851. {
  2852. if (source == null)
  2853. throw new ArgumentNullException(nameof(source));
  2854. return source.Provider.CreateQuery<bool>(
  2855. Expression.Call(
  2856. null,
  2857. #if CRIPPLED_REFLECTION
  2858. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource))),
  2859. #else
  2860. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2861. #endif
  2862. source.Expression,
  2863. Expression.Constant(value, typeof(TSource))
  2864. )
  2865. );
  2866. }
  2867. /// <summary>
  2868. /// Determines whether an observable sequence contains a specified element by using a specified <see cref="IEqualityComparer{T}"/>.
  2869. /// </summary>
  2870. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2871. /// <param name="source">An observable sequence in which to locate a value.</param>
  2872. /// <param name="value">The value to locate in the source sequence.</param>
  2873. /// <param name="comparer">An equality comparer to compare elements.</param>
  2874. /// <returns>An observable sequence containing a single element determining whether the source sequence contains an element that has the specified value.</returns>
  2875. /// <exception cref="ArgumentNullException">
  2876. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  2877. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2878. public static IQbservable<bool> Contains<TSource>(this IQbservable<TSource> source, TSource value, IEqualityComparer<TSource> comparer)
  2879. {
  2880. if (source == null)
  2881. throw new ArgumentNullException(nameof(source));
  2882. if (comparer == null)
  2883. throw new ArgumentNullException(nameof(comparer));
  2884. return source.Provider.CreateQuery<bool>(
  2885. Expression.Call(
  2886. null,
  2887. #if CRIPPLED_REFLECTION
  2888. InfoOf(() => Qbservable.Contains<TSource>(default(IQbservable<TSource>), default(TSource), default(IEqualityComparer<TSource>))),
  2889. #else
  2890. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2891. #endif
  2892. source.Expression,
  2893. Expression.Constant(value, typeof(TSource)),
  2894. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  2895. )
  2896. );
  2897. }
  2898. /// <summary>
  2899. /// Returns an observable sequence containing an <see cref="int" /> that represents the total number of elements in an observable sequence.
  2900. /// </summary>
  2901. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2902. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  2903. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  2904. /// <exception cref="ArgumentNullException">
  2905. /// <paramref name="source" /> is null.</exception>
  2906. /// <exception cref="OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  2907. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2908. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source)
  2909. {
  2910. if (source == null)
  2911. throw new ArgumentNullException(nameof(source));
  2912. return source.Provider.CreateQuery<int>(
  2913. Expression.Call(
  2914. null,
  2915. #if CRIPPLED_REFLECTION
  2916. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>))),
  2917. #else
  2918. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2919. #endif
  2920. source.Expression
  2921. )
  2922. );
  2923. }
  2924. /// <summary>
  2925. /// Returns an observable sequence containing an <see cref="int" /> that represents how many elements in the specified observable sequence satisfy a condition.
  2926. /// </summary>
  2927. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  2928. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  2929. /// <param name="predicate">A function to test each element for a condition.</param>
  2930. /// <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>
  2931. /// <exception cref="ArgumentNullException">
  2932. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  2933. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  2934. public static IQbservable<int> Count<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  2935. {
  2936. if (source == null)
  2937. throw new ArgumentNullException(nameof(source));
  2938. if (predicate == null)
  2939. throw new ArgumentNullException(nameof(predicate));
  2940. return source.Provider.CreateQuery<int>(
  2941. Expression.Call(
  2942. null,
  2943. #if CRIPPLED_REFLECTION
  2944. InfoOf(() => Qbservable.Count<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  2945. #else
  2946. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  2947. #endif
  2948. source.Expression,
  2949. predicate
  2950. )
  2951. );
  2952. }
  2953. /// <summary>
  2954. /// Creates an observable sequence from a specified Subscribe method implementation.
  2955. /// </summary>
  2956. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  2957. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  2958. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method.</param>
  2959. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  2960. /// <exception cref="ArgumentNullException">
  2961. /// <paramref name="subscribe" /> is null.</exception>
  2962. /// <remarks>
  2963. /// Use of this operator is preferred over manual implementation of the <see cref="IObservable{T}"/> interface. In case
  2964. /// you need a type implementing <see cref="IObservable{T}"/> rather than an anonymous implementation, consider using
  2965. /// the <see cref="Reactive.ObservableBase{TResult}" /> abstract base class.
  2966. /// </remarks>
  2967. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, IDisposable>> subscribe)
  2968. {
  2969. if (provider == null)
  2970. throw new ArgumentNullException(nameof(provider));
  2971. if (subscribe == null)
  2972. throw new ArgumentNullException(nameof(subscribe));
  2973. return provider.CreateQuery<TResult>(
  2974. Expression.Call(
  2975. null,
  2976. #if CRIPPLED_REFLECTION
  2977. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, IDisposable>>))),
  2978. #else
  2979. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  2980. #endif
  2981. Expression.Constant(provider, typeof(IQbservableProvider)),
  2982. subscribe
  2983. )
  2984. );
  2985. }
  2986. /// <summary>
  2987. /// Creates an observable sequence from a specified Subscribe method implementation.
  2988. /// </summary>
  2989. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  2990. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  2991. /// <param name="subscribe">Implementation of the resulting observable sequence's Subscribe method, returning an Action delegate that will be wrapped in an IDisposable.</param>
  2992. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  2993. /// <exception cref="ArgumentNullException">
  2994. /// <paramref name="subscribe" /> is null.</exception>
  2995. /// <remarks>
  2996. /// Use of this operator is preferred over manual implementation of the <see cref="IObservable{T}"/> interface. In case
  2997. /// you need a type implementing <see cref="IObservable{T}"/> rather than an anonymous implementation, consider using
  2998. /// the <see cref="Reactive.ObservableBase{TResult}" /> abstract base class.
  2999. /// </remarks>
  3000. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Action>> subscribe)
  3001. {
  3002. if (provider == null)
  3003. throw new ArgumentNullException(nameof(provider));
  3004. if (subscribe == null)
  3005. throw new ArgumentNullException(nameof(subscribe));
  3006. return provider.CreateQuery<TResult>(
  3007. Expression.Call(
  3008. null,
  3009. #if CRIPPLED_REFLECTION
  3010. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Action>>))),
  3011. #else
  3012. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3013. #endif
  3014. Expression.Constant(provider, typeof(IQbservableProvider)),
  3015. subscribe
  3016. )
  3017. );
  3018. }
  3019. /// <summary>
  3020. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3021. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3022. /// </summary>
  3023. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3024. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3025. /// <param name="subscribeAsync">Asynchronous method used to produce elements.</param>
  3026. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3027. /// <exception cref="ArgumentNullException">
  3028. /// <paramref name="subscribeAsync" /> is null.</exception>
  3029. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3030. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3031. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task>> subscribeAsync)
  3032. {
  3033. if (provider == null)
  3034. throw new ArgumentNullException(nameof(provider));
  3035. if (subscribeAsync == null)
  3036. throw new ArgumentNullException(nameof(subscribeAsync));
  3037. return provider.CreateQuery<TResult>(
  3038. Expression.Call(
  3039. null,
  3040. #if CRIPPLED_REFLECTION
  3041. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task>>))),
  3042. #else
  3043. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3044. #endif
  3045. Expression.Constant(provider, typeof(IQbservableProvider)),
  3046. subscribeAsync
  3047. )
  3048. );
  3049. }
  3050. /// <summary>
  3051. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3052. /// </summary>
  3053. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3054. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3055. /// <param name="subscribeAsync">Asynchronous method used to produce elements.</param>
  3056. /// <returns>The observable sequence surfacing the elements produced by the asynchronous method.</returns>
  3057. /// <exception cref="ArgumentNullException">
  3058. /// <paramref name="subscribeAsync" /> is null.</exception>
  3059. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3060. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task>> subscribeAsync)
  3061. {
  3062. if (provider == null)
  3063. throw new ArgumentNullException(nameof(provider));
  3064. if (subscribeAsync == null)
  3065. throw new ArgumentNullException(nameof(subscribeAsync));
  3066. return provider.CreateQuery<TResult>(
  3067. Expression.Call(
  3068. null,
  3069. #if CRIPPLED_REFLECTION
  3070. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task>>))),
  3071. #else
  3072. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3073. #endif
  3074. Expression.Constant(provider, typeof(IQbservableProvider)),
  3075. subscribeAsync
  3076. )
  3077. );
  3078. }
  3079. /// <summary>
  3080. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3081. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3082. /// </summary>
  3083. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3084. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3085. /// <param name="subscribeAsync">Asynchronous method used to implement the resulting sequence's Subscribe method.</param>
  3086. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3087. /// <exception cref="ArgumentNullException">
  3088. /// <paramref name="subscribeAsync" /> is null.</exception>
  3089. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3090. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3091. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task<IDisposable>>> subscribeAsync)
  3092. {
  3093. if (provider == null)
  3094. throw new ArgumentNullException(nameof(provider));
  3095. if (subscribeAsync == null)
  3096. throw new ArgumentNullException(nameof(subscribeAsync));
  3097. return provider.CreateQuery<TResult>(
  3098. Expression.Call(
  3099. null,
  3100. #if CRIPPLED_REFLECTION
  3101. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task<IDisposable>>>))),
  3102. #else
  3103. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3104. #endif
  3105. Expression.Constant(provider, typeof(IQbservableProvider)),
  3106. subscribeAsync
  3107. )
  3108. );
  3109. }
  3110. /// <summary>
  3111. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3112. /// </summary>
  3113. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3114. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3115. /// <param name="subscribeAsync">Asynchronous method used to implement the resulting sequence's Subscribe method.</param>
  3116. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3117. /// <exception cref="ArgumentNullException">
  3118. /// <paramref name="subscribeAsync" /> is null.</exception>
  3119. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3120. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task<IDisposable>>> subscribeAsync)
  3121. {
  3122. if (provider == null)
  3123. throw new ArgumentNullException(nameof(provider));
  3124. if (subscribeAsync == null)
  3125. throw new ArgumentNullException(nameof(subscribeAsync));
  3126. return provider.CreateQuery<TResult>(
  3127. Expression.Call(
  3128. null,
  3129. #if CRIPPLED_REFLECTION
  3130. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task<IDisposable>>>))),
  3131. #else
  3132. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3133. #endif
  3134. Expression.Constant(provider, typeof(IQbservableProvider)),
  3135. subscribeAsync
  3136. )
  3137. );
  3138. }
  3139. /// <summary>
  3140. /// Creates an observable sequence from a specified cancellable asynchronous Subscribe method.
  3141. /// The CancellationToken passed to the asynchronous Subscribe method is tied to the returned disposable subscription, allowing best-effort cancellation.
  3142. /// </summary>
  3143. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3144. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3145. /// <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>
  3146. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3147. /// <exception cref="ArgumentNullException">
  3148. /// <paramref name="subscribeAsync" /> is null.</exception>
  3149. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3150. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous subscribe function will be signaled.</remarks>
  3151. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, CancellationToken, Task<Action>>> subscribeAsync)
  3152. {
  3153. if (provider == null)
  3154. throw new ArgumentNullException(nameof(provider));
  3155. if (subscribeAsync == null)
  3156. throw new ArgumentNullException(nameof(subscribeAsync));
  3157. return provider.CreateQuery<TResult>(
  3158. Expression.Call(
  3159. null,
  3160. #if CRIPPLED_REFLECTION
  3161. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, CancellationToken, Task<Action>>>))),
  3162. #else
  3163. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3164. #endif
  3165. Expression.Constant(provider, typeof(IQbservableProvider)),
  3166. subscribeAsync
  3167. )
  3168. );
  3169. }
  3170. /// <summary>
  3171. /// Creates an observable sequence from a specified asynchronous Subscribe method.
  3172. /// </summary>
  3173. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3174. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  3175. /// <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>
  3176. /// <returns>The observable sequence with the specified implementation for the Subscribe method.</returns>
  3177. /// <exception cref="ArgumentNullException">
  3178. /// <paramref name="subscribeAsync" /> is null.</exception>
  3179. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3180. public static IQbservable<TResult> Create<TResult>(this IQbservableProvider provider, Expression<Func<IObserver<TResult>, Task<Action>>> subscribeAsync)
  3181. {
  3182. if (provider == null)
  3183. throw new ArgumentNullException(nameof(provider));
  3184. if (subscribeAsync == null)
  3185. throw new ArgumentNullException(nameof(subscribeAsync));
  3186. return provider.CreateQuery<TResult>(
  3187. Expression.Call(
  3188. null,
  3189. #if CRIPPLED_REFLECTION
  3190. InfoOf(() => Qbservable.Create<TResult>(default(IQbservableProvider), default(Expression<Func<IObserver<TResult>, Task<Action>>>))),
  3191. #else
  3192. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3193. #endif
  3194. Expression.Constant(provider, typeof(IQbservableProvider)),
  3195. subscribeAsync
  3196. )
  3197. );
  3198. }
  3199. /// <summary>
  3200. /// Returns the elements of the specified sequence or the type parameter's default value in a singleton sequence if the sequence is empty.
  3201. /// </summary>
  3202. /// <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>
  3203. /// <param name="source">The sequence to return a default value for if it is empty.</param>
  3204. /// <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>
  3205. /// <exception cref="ArgumentNullException">
  3206. /// <paramref name="source" /> is null.</exception>
  3207. public static IQbservable<TSource> DefaultIfEmpty<TSource>(this IQbservable<TSource> source)
  3208. {
  3209. if (source == null)
  3210. throw new ArgumentNullException(nameof(source));
  3211. return source.Provider.CreateQuery<TSource>(
  3212. Expression.Call(
  3213. null,
  3214. #if CRIPPLED_REFLECTION
  3215. InfoOf(() => Qbservable.DefaultIfEmpty<TSource>(default(IQbservable<TSource>))),
  3216. #else
  3217. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3218. #endif
  3219. source.Expression
  3220. )
  3221. );
  3222. }
  3223. /// <summary>
  3224. /// Returns the elements of the specified sequence or the specified value in a singleton sequence if the sequence is empty.
  3225. /// </summary>
  3226. /// <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>
  3227. /// <param name="source">The sequence to return the specified value for if it is empty.</param>
  3228. /// <param name="defaultValue">The value to return if the sequence is empty.</param>
  3229. /// <returns>An observable sequence that contains the specified default value if the source is empty; otherwise, the elements of the source itself.</returns>
  3230. /// <exception cref="ArgumentNullException">
  3231. /// <paramref name="source" /> is null.</exception>
  3232. public static IQbservable<TSource> DefaultIfEmpty<TSource>(this IQbservable<TSource> source, TSource defaultValue)
  3233. {
  3234. if (source == null)
  3235. throw new ArgumentNullException(nameof(source));
  3236. return source.Provider.CreateQuery<TSource>(
  3237. Expression.Call(
  3238. null,
  3239. #if CRIPPLED_REFLECTION
  3240. InfoOf(() => Qbservable.DefaultIfEmpty<TSource>(default(IQbservable<TSource>), default(TSource))),
  3241. #else
  3242. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3243. #endif
  3244. source.Expression,
  3245. Expression.Constant(defaultValue, typeof(TSource))
  3246. )
  3247. );
  3248. }
  3249. /// <summary>
  3250. /// Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes.
  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 sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3254. /// <param name="observableFactory">Observable factory function to invoke for each observer that subscribes to the resulting sequence.</param>
  3255. /// <returns>An observable sequence whose observers trigger an invocation of the given observable factory function.</returns>
  3256. /// <exception cref="ArgumentNullException">
  3257. /// <paramref name="observableFactory" /> is null.</exception>
  3258. public static IQbservable<TResult> Defer<TResult>(this IQbservableProvider provider, Expression<Func<IObservable<TResult>>> observableFactory)
  3259. {
  3260. if (provider == null)
  3261. throw new ArgumentNullException(nameof(provider));
  3262. if (observableFactory == null)
  3263. throw new ArgumentNullException(nameof(observableFactory));
  3264. return provider.CreateQuery<TResult>(
  3265. Expression.Call(
  3266. null,
  3267. #if CRIPPLED_REFLECTION
  3268. InfoOf(() => Qbservable.Defer<TResult>(default(IQbservableProvider), default(Expression<Func<IObservable<TResult>>>))),
  3269. #else
  3270. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3271. #endif
  3272. Expression.Constant(provider, typeof(IQbservableProvider)),
  3273. observableFactory
  3274. )
  3275. );
  3276. }
  3277. /// <summary>
  3278. /// Returns an observable sequence that starts the specified asynchronous factory function whenever a new observer subscribes.
  3279. /// </summary>
  3280. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3281. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3282. /// <param name="observableFactoryAsync">Asynchronous factory function to start for each observer that subscribes to the resulting sequence.</param>
  3283. /// <returns>An observable sequence whose observers trigger the given asynchronous observable factory function to be started.</returns>
  3284. /// <exception cref="ArgumentNullException">
  3285. /// <paramref name="observableFactoryAsync" /> is null.</exception>
  3286. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3287. public static IQbservable<TResult> Defer<TResult>(this IQbservableProvider provider, Expression<Func<Task<IObservable<TResult>>>> observableFactoryAsync)
  3288. {
  3289. if (provider == null)
  3290. throw new ArgumentNullException(nameof(provider));
  3291. if (observableFactoryAsync == null)
  3292. throw new ArgumentNullException(nameof(observableFactoryAsync));
  3293. return provider.CreateQuery<TResult>(
  3294. Expression.Call(
  3295. null,
  3296. #if CRIPPLED_REFLECTION
  3297. InfoOf(() => Qbservable.Defer<TResult>(default(IQbservableProvider), default(Expression<Func<Task<IObservable<TResult>>>>))),
  3298. #else
  3299. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3300. #endif
  3301. Expression.Constant(provider, typeof(IQbservableProvider)),
  3302. observableFactoryAsync
  3303. )
  3304. );
  3305. }
  3306. /// <summary>
  3307. /// Returns an observable sequence that starts the specified cancellable asynchronous factory function whenever a new observer subscribes.
  3308. /// The CancellationToken passed to the asynchronous factory function is tied to the returned disposable subscription, allowing best-effort cancellation.
  3309. /// </summary>
  3310. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  3311. /// <typeparam name="TResult">The type of the elements in the sequence returned by the factory function, and in the resulting sequence.</typeparam>
  3312. /// <param name="observableFactoryAsync">Asynchronous factory function to start for each observer that subscribes to the resulting sequence.</param>
  3313. /// <returns>An observable sequence whose observers trigger the given asynchronous observable factory function to be started.</returns>
  3314. /// <exception cref="ArgumentNullException">
  3315. /// <paramref name="observableFactoryAsync" /> is null.</exception>
  3316. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  3317. /// <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>
  3318. public static IQbservable<TResult> DeferAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  3319. {
  3320. if (provider == null)
  3321. throw new ArgumentNullException(nameof(provider));
  3322. if (observableFactoryAsync == null)
  3323. throw new ArgumentNullException(nameof(observableFactoryAsync));
  3324. return provider.CreateQuery<TResult>(
  3325. Expression.Call(
  3326. null,
  3327. #if CRIPPLED_REFLECTION
  3328. InfoOf(() => Qbservable.DeferAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<IObservable<TResult>>>>))),
  3329. #else
  3330. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  3331. #endif
  3332. Expression.Constant(provider, typeof(IQbservableProvider)),
  3333. observableFactoryAsync
  3334. )
  3335. );
  3336. }
  3337. /// <summary>
  3338. /// Time shifts the observable sequence to start propagating notifications at the specified absolute time.
  3339. /// The relative time intervals between the values are preserved.
  3340. /// </summary>
  3341. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3342. /// <param name="source">Source sequence to delay values for.</param>
  3343. /// <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>
  3344. /// <returns>Time-shifted sequence.</returns>
  3345. /// <exception cref="ArgumentNullException">
  3346. /// <paramref name="source" /> is null.</exception>
  3347. /// <remarks>
  3348. /// <para>
  3349. /// This operator is less efficient than <see cref="Observable.DelaySubscription{TSource}(IObservable{TSource},DateTimeOffset)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3350. /// </para>
  3351. /// <para>
  3352. /// Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
  3353. /// </para>
  3354. /// <para>
  3355. /// 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.
  3356. /// In order to delay error propagation, consider using the <see cref="Observable.Materialize{TSource}(IObservable{TSource})">Observable.Materialize</see> and <see cref="Observable.Dematerialize{TSource}(IObservable{Notification{TSource}})">Observable.Dematerialize</see> operators, or use <see cref="Observable.DelaySubscription{TSource}(IObservable{TSource},DateTimeOffset)">DelaySubscription</see>.
  3357. /// </para>
  3358. /// </remarks>
  3359. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  3360. {
  3361. if (source == null)
  3362. throw new ArgumentNullException(nameof(source));
  3363. return source.Provider.CreateQuery<TSource>(
  3364. Expression.Call(
  3365. null,
  3366. #if CRIPPLED_REFLECTION
  3367. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  3368. #else
  3369. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3370. #endif
  3371. source.Expression,
  3372. Expression.Constant(dueTime, typeof(DateTimeOffset))
  3373. )
  3374. );
  3375. }
  3376. /// <summary>
  3377. /// Time shifts the observable sequence to start propagating notifications at the specified absolute time, using the specified scheduler to run timers.
  3378. /// The relative time intervals between the values are preserved.
  3379. /// </summary>
  3380. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3381. /// <param name="source">Source sequence to delay values for.</param>
  3382. /// <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>
  3383. /// <param name="scheduler">Scheduler to run the delay timers on.</param>
  3384. /// <returns>Time-shifted sequence.</returns>
  3385. /// <exception cref="ArgumentNullException">
  3386. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3387. /// <remarks>
  3388. /// <para>
  3389. /// This operator is less efficient than <see cref="Observable.DelaySubscription{TSource}(IObservable{TSource},DateTimeOffset,IScheduler)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3390. /// </para>
  3391. /// <para>
  3392. /// Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
  3393. /// </para>
  3394. /// <para>
  3395. /// 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.
  3396. /// In order to delay error propagation, consider using the <see cref="Observable.Materialize{TSource}(IObservable{TSource})">Observable.Materialize</see> and <see cref="Observable.Dematerialize{TSource}(IObservable{Notification{TSource}})">Observable.Dematerialize</see> operators, or use <see cref="Observable.DelaySubscription{TSource}(IObservable{TSource},DateTimeOffset,IScheduler)">DelaySubscription</see>.
  3397. /// </para>
  3398. /// </remarks>
  3399. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  3400. {
  3401. if (source == null)
  3402. throw new ArgumentNullException(nameof(source));
  3403. if (scheduler == null)
  3404. throw new ArgumentNullException(nameof(scheduler));
  3405. return source.Provider.CreateQuery<TSource>(
  3406. Expression.Call(
  3407. null,
  3408. #if CRIPPLED_REFLECTION
  3409. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  3410. #else
  3411. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3412. #endif
  3413. source.Expression,
  3414. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  3415. Expression.Constant(scheduler, typeof(IScheduler))
  3416. )
  3417. );
  3418. }
  3419. /// <summary>
  3420. /// Time shifts the observable sequence by the specified relative time duration.
  3421. /// The relative time intervals between the values are preserved.
  3422. /// </summary>
  3423. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3424. /// <param name="source">Source sequence to delay values for.</param>
  3425. /// <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>
  3426. /// <returns>Time-shifted sequence.</returns>
  3427. /// <exception cref="ArgumentNullException">
  3428. /// <paramref name="source" /> is null.</exception>
  3429. /// <exception cref="ArgumentOutOfRangeException">
  3430. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3431. /// <remarks>
  3432. /// <para>
  3433. /// This operator is less efficient than <see cref="Observable.DelaySubscription{TSource}(IObservable{TSource},TimeSpan)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3434. /// </para>
  3435. /// <para>
  3436. /// Observer callbacks for the resulting sequence will be run on the default scheduler. This effect is similar to using ObserveOn.
  3437. /// </para>
  3438. /// <para>
  3439. /// 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.
  3440. /// In order to delay error propagation, consider using the <see cref="Observable.Materialize{TSource}(IObservable{TSource})">Observable.Materialize</see> and <see cref="Observable.Dematerialize{TSource}(IObservable{Notification{TSource}})">Observable.Dematerialize</see> operators, or use <see cref="Observable.DelaySubscription{TSource}(IObservable{TSource},TimeSpan)">DelaySubscription</see>.
  3441. /// </para>
  3442. /// </remarks>
  3443. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  3444. {
  3445. if (source == null)
  3446. throw new ArgumentNullException(nameof(source));
  3447. return source.Provider.CreateQuery<TSource>(
  3448. Expression.Call(
  3449. null,
  3450. #if CRIPPLED_REFLECTION
  3451. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  3452. #else
  3453. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3454. #endif
  3455. source.Expression,
  3456. Expression.Constant(dueTime, typeof(TimeSpan))
  3457. )
  3458. );
  3459. }
  3460. /// <summary>
  3461. /// Time shifts the observable sequence by the specified relative time duration, using the specified scheduler to run timers.
  3462. /// The relative time intervals between the values are preserved.
  3463. /// </summary>
  3464. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3465. /// <param name="source">Source sequence to delay values for.</param>
  3466. /// <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>
  3467. /// <param name="scheduler">Scheduler to run the delay timers on.</param>
  3468. /// <returns>Time-shifted sequence.</returns>
  3469. /// <exception cref="ArgumentNullException">
  3470. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3471. /// <exception cref="ArgumentOutOfRangeException">
  3472. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3473. /// <remarks>
  3474. /// <para>
  3475. /// This operator is less efficient than <see cref="Observable.DelaySubscription{TSource}(IObservable{TSource},TimeSpan,IScheduler)">DelaySubscription</see> because it records all notifications and time-delays those. This allows for immediate propagation of errors.
  3476. /// </para>
  3477. /// <para>
  3478. /// Observer callbacks for the resulting sequence will be run on the specified scheduler. This effect is similar to using ObserveOn.
  3479. /// </para>
  3480. /// <para>
  3481. /// 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.
  3482. /// </para>
  3483. /// <para>
  3484. /// 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.
  3485. /// In order to delay error propagation, consider using the <see cref="Observable.Materialize{TSource}(IObservable{TSource})">Observable.Materialize</see> and <see cref="Observable.Dematerialize{TSource}(IObservable{Notification{TSource}})">Observable.Dematerialize</see> operators, or use <see cref="Observable.DelaySubscription{TSource}(IObservable{TSource},TimeSpan,IScheduler)">DelaySubscription</see>.
  3486. /// </para>
  3487. /// </remarks>
  3488. public static IQbservable<TSource> Delay<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  3489. {
  3490. if (source == null)
  3491. throw new ArgumentNullException(nameof(source));
  3492. if (scheduler == null)
  3493. throw new ArgumentNullException(nameof(scheduler));
  3494. return source.Provider.CreateQuery<TSource>(
  3495. Expression.Call(
  3496. null,
  3497. #if CRIPPLED_REFLECTION
  3498. InfoOf(() => Qbservable.Delay<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  3499. #else
  3500. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3501. #endif
  3502. source.Expression,
  3503. Expression.Constant(dueTime, typeof(TimeSpan)),
  3504. Expression.Constant(scheduler, typeof(IScheduler))
  3505. )
  3506. );
  3507. }
  3508. /// <summary>
  3509. /// Time shifts the observable sequence based on a delay selector function for each element.
  3510. /// </summary>
  3511. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3512. /// <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>
  3513. /// <param name="source">Source sequence to delay values for.</param>
  3514. /// <param name="delayDurationSelector">Selector function to retrieve a sequence indicating the delay for each given element.</param>
  3515. /// <returns>Time-shifted sequence.</returns>
  3516. /// <exception cref="ArgumentNullException">
  3517. /// <paramref name="source" /> or <paramref name="delayDurationSelector" /> is null.</exception>
  3518. public static IQbservable<TSource> Delay<TSource, TDelay>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TDelay>>> delayDurationSelector)
  3519. {
  3520. if (source == null)
  3521. throw new ArgumentNullException(nameof(source));
  3522. if (delayDurationSelector == null)
  3523. throw new ArgumentNullException(nameof(delayDurationSelector));
  3524. return source.Provider.CreateQuery<TSource>(
  3525. Expression.Call(
  3526. null,
  3527. #if CRIPPLED_REFLECTION
  3528. InfoOf(() => Qbservable.Delay<TSource, TDelay>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TDelay>>>))),
  3529. #else
  3530. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TDelay)),
  3531. #endif
  3532. source.Expression,
  3533. delayDurationSelector
  3534. )
  3535. );
  3536. }
  3537. /// <summary>
  3538. /// Time shifts the observable sequence based on a subscription delay and a delay selector function for each element.
  3539. /// </summary>
  3540. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3541. /// <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>
  3542. /// <param name="source">Source sequence to delay values for.</param>
  3543. /// <param name="subscriptionDelay">Sequence indicating the delay for the subscription to the source.</param>
  3544. /// <param name="delayDurationSelector">Selector function to retrieve a sequence indicating the delay for each given element.</param>
  3545. /// <returns>Time-shifted sequence.</returns>
  3546. /// <exception cref="ArgumentNullException">
  3547. /// <paramref name="source" /> or <paramref name="subscriptionDelay" /> or <paramref name="delayDurationSelector" /> is null.</exception>
  3548. public static IQbservable<TSource> Delay<TSource, TDelay>(this IQbservable<TSource> source, IObservable<TDelay> subscriptionDelay, Expression<Func<TSource, IObservable<TDelay>>> delayDurationSelector)
  3549. {
  3550. if (source == null)
  3551. throw new ArgumentNullException(nameof(source));
  3552. if (subscriptionDelay == null)
  3553. throw new ArgumentNullException(nameof(subscriptionDelay));
  3554. if (delayDurationSelector == null)
  3555. throw new ArgumentNullException(nameof(delayDurationSelector));
  3556. return source.Provider.CreateQuery<TSource>(
  3557. Expression.Call(
  3558. null,
  3559. #if CRIPPLED_REFLECTION
  3560. InfoOf(() => Qbservable.Delay<TSource, TDelay>(default(IQbservable<TSource>), default(IObservable<TDelay>), default(Expression<Func<TSource, IObservable<TDelay>>>))),
  3561. #else
  3562. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TDelay)),
  3563. #endif
  3564. source.Expression,
  3565. GetSourceExpression(subscriptionDelay),
  3566. delayDurationSelector
  3567. )
  3568. );
  3569. }
  3570. /// <summary>
  3571. /// Time shifts the observable sequence by delaying the subscription to the specified absolute time.
  3572. /// </summary>
  3573. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3574. /// <param name="source">Source sequence to delay subscription for.</param>
  3575. /// <param name="dueTime">Absolute time to perform the subscription at.</param>
  3576. /// <returns>Time-shifted sequence.</returns>
  3577. /// <exception cref="ArgumentNullException">
  3578. /// <paramref name="source" /> is null.</exception>
  3579. /// <remarks>
  3580. /// <para>
  3581. /// This operator is more efficient than <see cref="Observable.Delay{TSource}(IObservable{TSource},DateTimeOffset)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3582. /// </para>
  3583. /// <para>
  3584. /// The side-effects of subscribing to the source sequence will be run on the default scheduler. Observer callbacks will not be affected.
  3585. /// </para>
  3586. /// </remarks>
  3587. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  3588. {
  3589. if (source == null)
  3590. throw new ArgumentNullException(nameof(source));
  3591. return source.Provider.CreateQuery<TSource>(
  3592. Expression.Call(
  3593. null,
  3594. #if CRIPPLED_REFLECTION
  3595. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  3596. #else
  3597. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3598. #endif
  3599. source.Expression,
  3600. Expression.Constant(dueTime, typeof(DateTimeOffset))
  3601. )
  3602. );
  3603. }
  3604. /// <summary>
  3605. /// Time shifts the observable sequence by delaying the subscription to the specified absolute time, using the specified scheduler to run timers.
  3606. /// </summary>
  3607. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3608. /// <param name="source">Source sequence to delay subscription for.</param>
  3609. /// <param name="dueTime">Absolute time to perform the subscription at.</param>
  3610. /// <param name="scheduler">Scheduler to run the subscription delay timer on.</param>
  3611. /// <returns>Time-shifted sequence.</returns>
  3612. /// <exception cref="ArgumentNullException">
  3613. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3614. /// <remarks>
  3615. /// <para>
  3616. /// This operator is more efficient than <see cref="Observable.Delay{TSource}(IObservable{TSource},DateTimeOffset,IScheduler)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3617. /// </para>
  3618. /// <para>
  3619. /// The side-effects of subscribing to the source sequence will be run on the specified scheduler. Observer callbacks will not be affected.
  3620. /// </para>
  3621. /// </remarks>
  3622. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  3623. {
  3624. if (source == null)
  3625. throw new ArgumentNullException(nameof(source));
  3626. if (scheduler == null)
  3627. throw new ArgumentNullException(nameof(scheduler));
  3628. return source.Provider.CreateQuery<TSource>(
  3629. Expression.Call(
  3630. null,
  3631. #if CRIPPLED_REFLECTION
  3632. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  3633. #else
  3634. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3635. #endif
  3636. source.Expression,
  3637. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  3638. Expression.Constant(scheduler, typeof(IScheduler))
  3639. )
  3640. );
  3641. }
  3642. /// <summary>
  3643. /// Time shifts the observable sequence by delaying the subscription with the specified relative time duration.
  3644. /// </summary>
  3645. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3646. /// <param name="source">Source sequence to delay subscription for.</param>
  3647. /// <param name="dueTime">Relative time shift of the subscription.</param>
  3648. /// <returns>Time-shifted sequence.</returns>
  3649. /// <exception cref="ArgumentNullException">
  3650. /// <paramref name="source" /> is null.</exception>
  3651. /// <exception cref="ArgumentOutOfRangeException">
  3652. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3653. /// <remarks>
  3654. /// <para>
  3655. /// This operator is more efficient than <see cref="Observable.Delay{TSource}(IObservable{TSource},TimeSpan)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3656. /// </para>
  3657. /// <para>
  3658. /// The side-effects of subscribing to the source sequence will be run on the default scheduler. Observer callbacks will not be affected.
  3659. /// </para>
  3660. /// </remarks>
  3661. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  3662. {
  3663. if (source == null)
  3664. throw new ArgumentNullException(nameof(source));
  3665. return source.Provider.CreateQuery<TSource>(
  3666. Expression.Call(
  3667. null,
  3668. #if CRIPPLED_REFLECTION
  3669. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  3670. #else
  3671. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3672. #endif
  3673. source.Expression,
  3674. Expression.Constant(dueTime, typeof(TimeSpan))
  3675. )
  3676. );
  3677. }
  3678. /// <summary>
  3679. /// Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers.
  3680. /// </summary>
  3681. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3682. /// <param name="source">Source sequence to delay subscription for.</param>
  3683. /// <param name="dueTime">Relative time shift of the subscription.</param>
  3684. /// <param name="scheduler">Scheduler to run the subscription delay timer on.</param>
  3685. /// <returns>Time-shifted sequence.</returns>
  3686. /// <exception cref="ArgumentNullException">
  3687. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  3688. /// <exception cref="ArgumentOutOfRangeException">
  3689. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  3690. /// <remarks>
  3691. /// <para>
  3692. /// This operator is more efficient than <see cref="Observable.Delay{TSource}(IObservable{TSource},TimeSpan,IScheduler)">Delay</see> but postpones all side-effects of subscription and affects error propagation timing.
  3693. /// </para>
  3694. /// <para>
  3695. /// The side-effects of subscribing to the source sequence will be run on the specified scheduler. Observer callbacks will not be affected.
  3696. /// </para>
  3697. /// </remarks>
  3698. public static IQbservable<TSource> DelaySubscription<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  3699. {
  3700. if (source == null)
  3701. throw new ArgumentNullException(nameof(source));
  3702. if (scheduler == null)
  3703. throw new ArgumentNullException(nameof(scheduler));
  3704. return source.Provider.CreateQuery<TSource>(
  3705. Expression.Call(
  3706. null,
  3707. #if CRIPPLED_REFLECTION
  3708. InfoOf(() => Qbservable.DelaySubscription<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  3709. #else
  3710. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3711. #endif
  3712. source.Expression,
  3713. Expression.Constant(dueTime, typeof(TimeSpan)),
  3714. Expression.Constant(scheduler, typeof(IScheduler))
  3715. )
  3716. );
  3717. }
  3718. /// <summary>
  3719. /// Dematerializes the explicit notification values of an observable sequence as implicit notifications.
  3720. /// </summary>
  3721. /// <typeparam name="TSource">The type of the elements materialized in the source sequence notification objects.</typeparam>
  3722. /// <param name="source">An observable sequence containing explicit notification values which have to be turned into implicit notifications.</param>
  3723. /// <returns>An observable sequence exhibiting the behavior corresponding to the source sequence's notification values.</returns>
  3724. /// <exception cref="ArgumentNullException">
  3725. /// <paramref name="source" /> is null.</exception>
  3726. public static IQbservable<TSource> Dematerialize<TSource>(this IQbservable<Notification<TSource>> source)
  3727. {
  3728. if (source == null)
  3729. throw new ArgumentNullException(nameof(source));
  3730. return source.Provider.CreateQuery<TSource>(
  3731. Expression.Call(
  3732. null,
  3733. #if CRIPPLED_REFLECTION
  3734. InfoOf(() => Qbservable.Dematerialize<TSource>(default(IQbservable<Notification<TSource>>))),
  3735. #else
  3736. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3737. #endif
  3738. source.Expression
  3739. )
  3740. );
  3741. }
  3742. /// <summary>
  3743. /// Returns an observable sequence that contains only distinct elements.
  3744. /// </summary>
  3745. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3746. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3747. /// <returns>An observable sequence only containing the distinct elements from the source sequence.</returns>
  3748. /// <exception cref="ArgumentNullException">
  3749. /// <paramref name="source" /> is null.</exception>
  3750. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3751. public static IQbservable<TSource> Distinct<TSource>(this IQbservable<TSource> source)
  3752. {
  3753. if (source == null)
  3754. throw new ArgumentNullException(nameof(source));
  3755. return source.Provider.CreateQuery<TSource>(
  3756. Expression.Call(
  3757. null,
  3758. #if CRIPPLED_REFLECTION
  3759. InfoOf(() => Qbservable.Distinct<TSource>(default(IQbservable<TSource>))),
  3760. #else
  3761. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3762. #endif
  3763. source.Expression
  3764. )
  3765. );
  3766. }
  3767. /// <summary>
  3768. /// Returns an observable sequence that contains only distinct elements according to the comparer.
  3769. /// </summary>
  3770. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3771. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3772. /// <param name="comparer">Equality comparer for source elements.</param>
  3773. /// <returns>An observable sequence only containing the distinct elements from the source sequence.</returns>
  3774. /// <exception cref="ArgumentNullException">
  3775. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  3776. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3777. public static IQbservable<TSource> Distinct<TSource>(this IQbservable<TSource> source, IEqualityComparer<TSource> comparer)
  3778. {
  3779. if (source == null)
  3780. throw new ArgumentNullException(nameof(source));
  3781. if (comparer == null)
  3782. throw new ArgumentNullException(nameof(comparer));
  3783. return source.Provider.CreateQuery<TSource>(
  3784. Expression.Call(
  3785. null,
  3786. #if CRIPPLED_REFLECTION
  3787. InfoOf(() => Qbservable.Distinct<TSource>(default(IQbservable<TSource>), default(IEqualityComparer<TSource>))),
  3788. #else
  3789. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3790. #endif
  3791. source.Expression,
  3792. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  3793. )
  3794. );
  3795. }
  3796. /// <summary>
  3797. /// Returns an observable sequence that contains only distinct elements according to the keySelector.
  3798. /// </summary>
  3799. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3800. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3801. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3802. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3803. /// <returns>An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.</returns>
  3804. /// <exception cref="ArgumentNullException">
  3805. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  3806. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3807. public static IQbservable<TSource> Distinct<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  3808. {
  3809. if (source == null)
  3810. throw new ArgumentNullException(nameof(source));
  3811. if (keySelector == null)
  3812. throw new ArgumentNullException(nameof(keySelector));
  3813. return source.Provider.CreateQuery<TSource>(
  3814. Expression.Call(
  3815. null,
  3816. #if CRIPPLED_REFLECTION
  3817. InfoOf(() => Qbservable.Distinct<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  3818. #else
  3819. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3820. #endif
  3821. source.Expression,
  3822. keySelector
  3823. )
  3824. );
  3825. }
  3826. /// <summary>
  3827. /// Returns an observable sequence that contains only distinct elements according to the keySelector and the comparer.
  3828. /// </summary>
  3829. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3830. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3831. /// <param name="source">An observable sequence to retain distinct elements for.</param>
  3832. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3833. /// <param name="comparer">Equality comparer for source elements.</param>
  3834. /// <returns>An observable sequence only containing the distinct elements, based on a computed key value, from the source sequence.</returns>
  3835. /// <exception cref="ArgumentNullException">
  3836. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  3837. /// <remarks>Usage of this operator should be considered carefully due to the maintenance of an internal lookup structure which can grow large.</remarks>
  3838. public static IQbservable<TSource> Distinct<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  3839. {
  3840. if (source == null)
  3841. throw new ArgumentNullException(nameof(source));
  3842. if (keySelector == null)
  3843. throw new ArgumentNullException(nameof(keySelector));
  3844. if (comparer == null)
  3845. throw new ArgumentNullException(nameof(comparer));
  3846. return source.Provider.CreateQuery<TSource>(
  3847. Expression.Call(
  3848. null,
  3849. #if CRIPPLED_REFLECTION
  3850. InfoOf(() => Qbservable.Distinct<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  3851. #else
  3852. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3853. #endif
  3854. source.Expression,
  3855. keySelector,
  3856. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  3857. )
  3858. );
  3859. }
  3860. /// <summary>
  3861. /// Returns an observable sequence that contains only distinct contiguous elements.
  3862. /// </summary>
  3863. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3864. /// <param name="source">An observable sequence to retain distinct contiguous elements for.</param>
  3865. /// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
  3866. /// <exception cref="ArgumentNullException">
  3867. /// <paramref name="source" /> is null.</exception>
  3868. public static IQbservable<TSource> DistinctUntilChanged<TSource>(this IQbservable<TSource> source)
  3869. {
  3870. if (source == null)
  3871. throw new ArgumentNullException(nameof(source));
  3872. return source.Provider.CreateQuery<TSource>(
  3873. Expression.Call(
  3874. null,
  3875. #if CRIPPLED_REFLECTION
  3876. InfoOf(() => Qbservable.DistinctUntilChanged<TSource>(default(IQbservable<TSource>))),
  3877. #else
  3878. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3879. #endif
  3880. source.Expression
  3881. )
  3882. );
  3883. }
  3884. /// <summary>
  3885. /// Returns an observable sequence that contains only distinct contiguous elements according to the comparer.
  3886. /// </summary>
  3887. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3888. /// <param name="source">An observable sequence to retain distinct contiguous elements for.</param>
  3889. /// <param name="comparer">Equality comparer for source elements.</param>
  3890. /// <returns>An observable sequence only containing the distinct contiguous elements from the source sequence.</returns>
  3891. /// <exception cref="ArgumentNullException">
  3892. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  3893. public static IQbservable<TSource> DistinctUntilChanged<TSource>(this IQbservable<TSource> source, IEqualityComparer<TSource> comparer)
  3894. {
  3895. if (source == null)
  3896. throw new ArgumentNullException(nameof(source));
  3897. if (comparer == null)
  3898. throw new ArgumentNullException(nameof(comparer));
  3899. return source.Provider.CreateQuery<TSource>(
  3900. Expression.Call(
  3901. null,
  3902. #if CRIPPLED_REFLECTION
  3903. InfoOf(() => Qbservable.DistinctUntilChanged<TSource>(default(IQbservable<TSource>), default(IEqualityComparer<TSource>))),
  3904. #else
  3905. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3906. #endif
  3907. source.Expression,
  3908. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  3909. )
  3910. );
  3911. }
  3912. /// <summary>
  3913. /// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector.
  3914. /// </summary>
  3915. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3916. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3917. /// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
  3918. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3919. /// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
  3920. /// <exception cref="ArgumentNullException">
  3921. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  3922. public static IQbservable<TSource> DistinctUntilChanged<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  3923. {
  3924. if (source == null)
  3925. throw new ArgumentNullException(nameof(source));
  3926. if (keySelector == null)
  3927. throw new ArgumentNullException(nameof(keySelector));
  3928. return source.Provider.CreateQuery<TSource>(
  3929. Expression.Call(
  3930. null,
  3931. #if CRIPPLED_REFLECTION
  3932. InfoOf(() => Qbservable.DistinctUntilChanged<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  3933. #else
  3934. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3935. #endif
  3936. source.Expression,
  3937. keySelector
  3938. )
  3939. );
  3940. }
  3941. /// <summary>
  3942. /// Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer.
  3943. /// </summary>
  3944. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3945. /// <typeparam name="TKey">The type of the discriminator key computed for each element in the source sequence.</typeparam>
  3946. /// <param name="source">An observable sequence to retain distinct contiguous elements for, based on a computed key value.</param>
  3947. /// <param name="keySelector">A function to compute the comparison key for each element.</param>
  3948. /// <param name="comparer">Equality comparer for computed key values.</param>
  3949. /// <returns>An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence.</returns>
  3950. /// <exception cref="ArgumentNullException">
  3951. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  3952. public static IQbservable<TSource> DistinctUntilChanged<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  3953. {
  3954. if (source == null)
  3955. throw new ArgumentNullException(nameof(source));
  3956. if (keySelector == null)
  3957. throw new ArgumentNullException(nameof(keySelector));
  3958. if (comparer == null)
  3959. throw new ArgumentNullException(nameof(comparer));
  3960. return source.Provider.CreateQuery<TSource>(
  3961. Expression.Call(
  3962. null,
  3963. #if CRIPPLED_REFLECTION
  3964. InfoOf(() => Qbservable.DistinctUntilChanged<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  3965. #else
  3966. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  3967. #endif
  3968. source.Expression,
  3969. keySelector,
  3970. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  3971. )
  3972. );
  3973. }
  3974. /// <summary>
  3975. /// Invokes the observer's methods for each message in the source sequence.
  3976. /// 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.
  3977. /// </summary>
  3978. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  3979. /// <param name="source">Source sequence.</param>
  3980. /// <param name="observer">Observer whose methods to invoke as part of the source sequence's observation.</param>
  3981. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  3982. /// <exception cref="ArgumentNullException">
  3983. /// <paramref name="source" /> or <paramref name="observer" /> is null.</exception>
  3984. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, IObserver<TSource> observer)
  3985. {
  3986. if (source == null)
  3987. throw new ArgumentNullException(nameof(source));
  3988. if (observer == null)
  3989. throw new ArgumentNullException(nameof(observer));
  3990. return source.Provider.CreateQuery<TSource>(
  3991. Expression.Call(
  3992. null,
  3993. #if CRIPPLED_REFLECTION
  3994. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(IObserver<TSource>))),
  3995. #else
  3996. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  3997. #endif
  3998. source.Expression,
  3999. Expression.Constant(observer, typeof(IObserver<TSource>))
  4000. )
  4001. );
  4002. }
  4003. /// <summary>
  4004. /// Invokes an action for each element in the observable sequence, and propagates all observer messages through the result sequence.
  4005. /// 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.
  4006. /// </summary>
  4007. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4008. /// <param name="source">Source sequence.</param>
  4009. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4010. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4011. /// <exception cref="ArgumentNullException">
  4012. /// <paramref name="source" /> or <paramref name="onNext" /> is null.</exception>
  4013. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext)
  4014. {
  4015. if (source == null)
  4016. throw new ArgumentNullException(nameof(source));
  4017. if (onNext == null)
  4018. throw new ArgumentNullException(nameof(onNext));
  4019. return source.Provider.CreateQuery<TSource>(
  4020. Expression.Call(
  4021. null,
  4022. #if CRIPPLED_REFLECTION
  4023. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>))),
  4024. #else
  4025. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4026. #endif
  4027. source.Expression,
  4028. onNext
  4029. )
  4030. );
  4031. }
  4032. /// <summary>
  4033. /// Invokes an action for each element in the observable sequence and invokes an action upon graceful termination of the observable sequence.
  4034. /// 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.
  4035. /// </summary>
  4036. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4037. /// <param name="source">Source sequence.</param>
  4038. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4039. /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
  4040. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4041. /// <exception cref="ArgumentNullException">
  4042. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onCompleted" /> is null.</exception>
  4043. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action> onCompleted)
  4044. {
  4045. if (source == null)
  4046. throw new ArgumentNullException(nameof(source));
  4047. if (onNext == null)
  4048. throw new ArgumentNullException(nameof(onNext));
  4049. if (onCompleted == null)
  4050. throw new ArgumentNullException(nameof(onCompleted));
  4051. return source.Provider.CreateQuery<TSource>(
  4052. Expression.Call(
  4053. null,
  4054. #if CRIPPLED_REFLECTION
  4055. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action>))),
  4056. #else
  4057. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4058. #endif
  4059. source.Expression,
  4060. onNext,
  4061. onCompleted
  4062. )
  4063. );
  4064. }
  4065. /// <summary>
  4066. /// Invokes an action for each element in the observable sequence and invokes an action upon exceptional termination of the observable sequence.
  4067. /// 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.
  4068. /// </summary>
  4069. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4070. /// <param name="source">Source sequence.</param>
  4071. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4072. /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
  4073. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4074. /// <exception cref="ArgumentNullException">
  4075. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> is null.</exception>
  4076. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError)
  4077. {
  4078. if (source == null)
  4079. throw new ArgumentNullException(nameof(source));
  4080. if (onNext == null)
  4081. throw new ArgumentNullException(nameof(onNext));
  4082. if (onError == null)
  4083. throw new ArgumentNullException(nameof(onError));
  4084. return source.Provider.CreateQuery<TSource>(
  4085. Expression.Call(
  4086. null,
  4087. #if CRIPPLED_REFLECTION
  4088. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>))),
  4089. #else
  4090. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4091. #endif
  4092. source.Expression,
  4093. onNext,
  4094. onError
  4095. )
  4096. );
  4097. }
  4098. /// <summary>
  4099. /// Invokes an action for each element in the observable sequence and invokes an action upon graceful or exceptional termination of the observable sequence.
  4100. /// 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.
  4101. /// </summary>
  4102. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4103. /// <param name="source">Source sequence.</param>
  4104. /// <param name="onNext">Action to invoke for each element in the observable sequence.</param>
  4105. /// <param name="onError">Action to invoke upon exceptional termination of the observable sequence.</param>
  4106. /// <param name="onCompleted">Action to invoke upon graceful termination of the observable sequence.</param>
  4107. /// <returns>The source sequence with the side-effecting behavior applied.</returns>
  4108. /// <exception cref="ArgumentNullException">
  4109. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  4110. public static IQbservable<TSource> Do<TSource>(this IQbservable<TSource> source, Expression<Action<TSource>> onNext, Expression<Action<Exception>> onError, Expression<Action> onCompleted)
  4111. {
  4112. if (source == null)
  4113. throw new ArgumentNullException(nameof(source));
  4114. if (onNext == null)
  4115. throw new ArgumentNullException(nameof(onNext));
  4116. if (onError == null)
  4117. throw new ArgumentNullException(nameof(onError));
  4118. if (onCompleted == null)
  4119. throw new ArgumentNullException(nameof(onCompleted));
  4120. return source.Provider.CreateQuery<TSource>(
  4121. Expression.Call(
  4122. null,
  4123. #if CRIPPLED_REFLECTION
  4124. InfoOf(() => Qbservable.Do<TSource>(default(IQbservable<TSource>), default(Expression<Action<TSource>>), default(Expression<Action<Exception>>), default(Expression<Action>))),
  4125. #else
  4126. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4127. #endif
  4128. source.Expression,
  4129. onNext,
  4130. onError,
  4131. onCompleted
  4132. )
  4133. );
  4134. }
  4135. /// <summary>
  4136. /// 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.
  4137. /// </summary>
  4138. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4139. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  4140. /// <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>
  4141. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  4142. /// <exception cref="ArgumentNullException">
  4143. /// <paramref name="source" /> or <paramref name="condition" /> is null.</exception>
  4144. public static IQbservable<TSource> DoWhile<TSource>(this IQbservable<TSource> source, Expression<Func<bool>> condition)
  4145. {
  4146. if (source == null)
  4147. throw new ArgumentNullException(nameof(source));
  4148. if (condition == null)
  4149. throw new ArgumentNullException(nameof(condition));
  4150. return source.Provider.CreateQuery<TSource>(
  4151. Expression.Call(
  4152. null,
  4153. #if CRIPPLED_REFLECTION
  4154. InfoOf(() => Qbservable.DoWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<bool>>))),
  4155. #else
  4156. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4157. #endif
  4158. source.Expression,
  4159. condition
  4160. )
  4161. );
  4162. }
  4163. /// <summary>
  4164. /// Returns the element at a specified index in a sequence.
  4165. /// </summary>
  4166. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4167. /// <param name="source">Observable sequence to return the element from.</param>
  4168. /// <param name="index">The zero-based index of the element to retrieve.</param>
  4169. /// <returns>An observable sequence that produces the element at the specified position in the source sequence.</returns>
  4170. /// <exception cref="ArgumentNullException">
  4171. /// <paramref name="source" /> is null.</exception>
  4172. /// <exception cref="ArgumentOutOfRangeException">
  4173. /// <paramref name="index" /> is less than zero.</exception>
  4174. /// <exception cref="ArgumentOutOfRangeException">(Asynchronous) <paramref name="index" /> is greater than or equal to the number of elements in the source sequence.</exception>
  4175. public static IQbservable<TSource> ElementAt<TSource>(this IQbservable<TSource> source, int index)
  4176. {
  4177. if (source == null)
  4178. throw new ArgumentNullException(nameof(source));
  4179. return source.Provider.CreateQuery<TSource>(
  4180. Expression.Call(
  4181. null,
  4182. #if CRIPPLED_REFLECTION
  4183. InfoOf(() => Qbservable.ElementAt<TSource>(default(IQbservable<TSource>), default(int))),
  4184. #else
  4185. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4186. #endif
  4187. source.Expression,
  4188. Expression.Constant(index, typeof(int))
  4189. )
  4190. );
  4191. }
  4192. /// <summary>
  4193. /// Returns the element at a specified index in a sequence or a default value if the index is out of range.
  4194. /// </summary>
  4195. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4196. /// <param name="source">Observable sequence to return the element from.</param>
  4197. /// <param name="index">The zero-based index of the element to retrieve.</param>
  4198. /// <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>
  4199. /// <exception cref="ArgumentNullException">
  4200. /// <paramref name="source" /> is null.</exception>
  4201. /// <exception cref="ArgumentOutOfRangeException">
  4202. /// <paramref name="index" /> is less than zero.</exception>
  4203. public static IQbservable<TSource> ElementAtOrDefault<TSource>(this IQbservable<TSource> source, int index)
  4204. {
  4205. if (source == null)
  4206. throw new ArgumentNullException(nameof(source));
  4207. return source.Provider.CreateQuery<TSource>(
  4208. Expression.Call(
  4209. null,
  4210. #if CRIPPLED_REFLECTION
  4211. InfoOf(() => Qbservable.ElementAtOrDefault<TSource>(default(IQbservable<TSource>), default(int))),
  4212. #else
  4213. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4214. #endif
  4215. source.Expression,
  4216. Expression.Constant(index, typeof(int))
  4217. )
  4218. );
  4219. }
  4220. /// <summary>
  4221. /// Returns an empty observable sequence.
  4222. /// </summary>
  4223. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4224. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}"/> type parameter of the resulting sequence.</typeparam>
  4225. /// <returns>An observable sequence with no elements.</returns>
  4226. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider)
  4227. {
  4228. if (provider == null)
  4229. throw new ArgumentNullException(nameof(provider));
  4230. return provider.CreateQuery<TResult>(
  4231. Expression.Call(
  4232. null,
  4233. #if CRIPPLED_REFLECTION
  4234. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider))),
  4235. #else
  4236. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4237. #endif
  4238. Expression.Constant(provider, typeof(IQbservableProvider))
  4239. )
  4240. );
  4241. }
  4242. /// <summary>
  4243. /// Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
  4244. /// </summary>
  4245. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4246. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}"/> type parameter of the resulting sequence.</typeparam>
  4247. /// <param name="scheduler">Scheduler to send the termination call on.</param>
  4248. /// <returns>An observable sequence with no elements.</returns>
  4249. /// <exception cref="ArgumentNullException">
  4250. /// <paramref name="scheduler" /> is null.</exception>
  4251. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, IScheduler scheduler)
  4252. {
  4253. if (provider == null)
  4254. throw new ArgumentNullException(nameof(provider));
  4255. if (scheduler == null)
  4256. throw new ArgumentNullException(nameof(scheduler));
  4257. return provider.CreateQuery<TResult>(
  4258. Expression.Call(
  4259. null,
  4260. #if CRIPPLED_REFLECTION
  4261. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(IScheduler))),
  4262. #else
  4263. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4264. #endif
  4265. Expression.Constant(provider, typeof(IQbservableProvider)),
  4266. Expression.Constant(scheduler, typeof(IScheduler))
  4267. )
  4268. );
  4269. }
  4270. /// <summary>
  4271. /// Returns an empty observable sequence, using the specified scheduler to send out the single OnCompleted message.
  4272. /// </summary>
  4273. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4274. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}"/> type parameter of the resulting sequence.</typeparam>
  4275. /// <param name="scheduler">Scheduler to send the termination call on.</param>
  4276. /// <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>
  4277. /// <returns>An observable sequence with no elements.</returns>
  4278. /// <exception cref="ArgumentNullException">
  4279. /// <paramref name="scheduler" /> is null.</exception>
  4280. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, IScheduler scheduler, TResult witness)
  4281. {
  4282. if (provider == null)
  4283. throw new ArgumentNullException(nameof(provider));
  4284. if (scheduler == null)
  4285. throw new ArgumentNullException(nameof(scheduler));
  4286. return provider.CreateQuery<TResult>(
  4287. Expression.Call(
  4288. null,
  4289. #if CRIPPLED_REFLECTION
  4290. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(IScheduler), default(TResult))),
  4291. #else
  4292. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4293. #endif
  4294. Expression.Constant(provider, typeof(IQbservableProvider)),
  4295. Expression.Constant(scheduler, typeof(IScheduler)),
  4296. Expression.Constant(witness, typeof(TResult))
  4297. )
  4298. );
  4299. }
  4300. /// <summary>
  4301. /// Returns an empty observable sequence.
  4302. /// </summary>
  4303. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4304. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}"/> type parameter of the resulting sequence.</typeparam>
  4305. /// <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>
  4306. /// <returns>An observable sequence with no elements.</returns>
  4307. public static IQbservable<TResult> Empty<TResult>(this IQbservableProvider provider, TResult witness)
  4308. {
  4309. if (provider == null)
  4310. throw new ArgumentNullException(nameof(provider));
  4311. return provider.CreateQuery<TResult>(
  4312. Expression.Call(
  4313. null,
  4314. #if CRIPPLED_REFLECTION
  4315. InfoOf(() => Qbservable.Empty<TResult>(default(IQbservableProvider), default(TResult))),
  4316. #else
  4317. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4318. #endif
  4319. Expression.Constant(provider, typeof(IQbservableProvider)),
  4320. Expression.Constant(witness, typeof(TResult))
  4321. )
  4322. );
  4323. }
  4324. /// <summary>
  4325. /// Invokes a specified action after the source observable sequence terminates gracefully or exceptionally.
  4326. /// </summary>
  4327. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4328. /// <param name="source">Source sequence.</param>
  4329. /// <param name="finallyAction">Action to invoke after the source observable sequence terminates.</param>
  4330. /// <returns>Source sequence with the action-invoking termination behavior applied.</returns>
  4331. /// <exception cref="ArgumentNullException">
  4332. /// <paramref name="source" /> or <paramref name="finallyAction" /> is null.</exception>
  4333. public static IQbservable<TSource> Finally<TSource>(this IQbservable<TSource> source, Expression<Action> finallyAction)
  4334. {
  4335. if (source == null)
  4336. throw new ArgumentNullException(nameof(source));
  4337. if (finallyAction == null)
  4338. throw new ArgumentNullException(nameof(finallyAction));
  4339. return source.Provider.CreateQuery<TSource>(
  4340. Expression.Call(
  4341. null,
  4342. #if CRIPPLED_REFLECTION
  4343. InfoOf(() => Qbservable.Finally<TSource>(default(IQbservable<TSource>), default(Expression<Action>))),
  4344. #else
  4345. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4346. #endif
  4347. source.Expression,
  4348. finallyAction
  4349. )
  4350. );
  4351. }
  4352. /// <summary>
  4353. /// Returns the first element of an observable sequence.
  4354. /// </summary>
  4355. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4356. /// <param name="source">Source observable sequence.</param>
  4357. /// <returns>Sequence containing the first element in the observable sequence.</returns>
  4358. /// <exception cref="ArgumentNullException">
  4359. /// <paramref name="source" /> is null.</exception>
  4360. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  4361. public static IQbservable<TSource> FirstAsync<TSource>(this IQbservable<TSource> source)
  4362. {
  4363. if (source == null)
  4364. throw new ArgumentNullException(nameof(source));
  4365. return source.Provider.CreateQuery<TSource>(
  4366. Expression.Call(
  4367. null,
  4368. #if CRIPPLED_REFLECTION
  4369. InfoOf(() => Qbservable.FirstAsync<TSource>(default(IQbservable<TSource>))),
  4370. #else
  4371. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4372. #endif
  4373. source.Expression
  4374. )
  4375. );
  4376. }
  4377. /// <summary>
  4378. /// Returns the first element of an observable sequence that satisfies the condition in the predicate.
  4379. /// </summary>
  4380. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4381. /// <param name="source">Source observable sequence.</param>
  4382. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  4383. /// <returns>Sequence containing the first element in the observable sequence that satisfies the condition in the predicate.</returns>
  4384. /// <exception cref="ArgumentNullException">
  4385. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  4386. /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  4387. public static IQbservable<TSource> FirstAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  4388. {
  4389. if (source == null)
  4390. throw new ArgumentNullException(nameof(source));
  4391. if (predicate == null)
  4392. throw new ArgumentNullException(nameof(predicate));
  4393. return source.Provider.CreateQuery<TSource>(
  4394. Expression.Call(
  4395. null,
  4396. #if CRIPPLED_REFLECTION
  4397. InfoOf(() => Qbservable.FirstAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  4398. #else
  4399. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4400. #endif
  4401. source.Expression,
  4402. predicate
  4403. )
  4404. );
  4405. }
  4406. /// <summary>
  4407. /// Returns the first element of an observable sequence, or a default value if no such element exists.
  4408. /// </summary>
  4409. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4410. /// <param name="source">Source observable sequence.</param>
  4411. /// <returns>Sequence containing the first element in the observable sequence, or a default value if no such element exists.</returns>
  4412. /// <exception cref="ArgumentNullException">
  4413. /// <paramref name="source" /> is null.</exception>
  4414. public static IQbservable<TSource> FirstOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  4415. {
  4416. if (source == null)
  4417. throw new ArgumentNullException(nameof(source));
  4418. return source.Provider.CreateQuery<TSource>(
  4419. Expression.Call(
  4420. null,
  4421. #if CRIPPLED_REFLECTION
  4422. InfoOf(() => Qbservable.FirstOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  4423. #else
  4424. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4425. #endif
  4426. source.Expression
  4427. )
  4428. );
  4429. }
  4430. /// <summary>
  4431. /// Returns the first element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  4432. /// </summary>
  4433. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  4434. /// <param name="source">Source observable sequence.</param>
  4435. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  4436. /// <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>
  4437. /// <exception cref="ArgumentNullException">
  4438. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  4439. public static IQbservable<TSource> FirstOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  4440. {
  4441. if (source == null)
  4442. throw new ArgumentNullException(nameof(source));
  4443. if (predicate == null)
  4444. throw new ArgumentNullException(nameof(predicate));
  4445. return source.Provider.CreateQuery<TSource>(
  4446. Expression.Call(
  4447. null,
  4448. #if CRIPPLED_REFLECTION
  4449. InfoOf(() => Qbservable.FirstOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  4450. #else
  4451. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  4452. #endif
  4453. source.Expression,
  4454. predicate
  4455. )
  4456. );
  4457. }
  4458. /// <summary>
  4459. /// Concatenates the observable sequences obtained by running the <paramref name="resultSelector" /> for each element in the given enumerable <paramref name="source" />.
  4460. /// </summary>
  4461. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4462. /// <typeparam name="TSource">The type of the elements in the enumerable source sequence.</typeparam>
  4463. /// <typeparam name="TResult">The type of the elements in the observable result sequence.</typeparam>
  4464. /// <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>
  4465. /// <param name="resultSelector">Function to select an observable source for each element in the <paramref name="source" />.</param>
  4466. /// <returns>The observable sequence obtained by concatenating the sources returned by <paramref name="resultSelector" /> for each element in the <paramref name="source" />.</returns>
  4467. /// <exception cref="ArgumentNullException">
  4468. /// <paramref name="source" /> or <paramref name="resultSelector" /> is null.</exception>
  4469. public static IQbservable<TResult> For<TSource, TResult>(this IQbservableProvider provider, IEnumerable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> resultSelector)
  4470. {
  4471. if (provider == null)
  4472. throw new ArgumentNullException(nameof(provider));
  4473. if (source == null)
  4474. throw new ArgumentNullException(nameof(source));
  4475. if (resultSelector == null)
  4476. throw new ArgumentNullException(nameof(resultSelector));
  4477. return provider.CreateQuery<TResult>(
  4478. Expression.Call(
  4479. null,
  4480. #if CRIPPLED_REFLECTION
  4481. InfoOf(() => Qbservable.For<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  4482. #else
  4483. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  4484. #endif
  4485. Expression.Constant(provider, typeof(IQbservableProvider)),
  4486. GetSourceExpression(source),
  4487. resultSelector
  4488. )
  4489. );
  4490. }
  4491. /// <summary>
  4492. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4493. /// </summary>
  4494. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4495. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4496. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4497. /// <exception cref="ArgumentNullException">
  4498. /// <paramref name="actionAsync" /> is null.</exception>
  4499. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  4500. {
  4501. if (provider == null)
  4502. throw new ArgumentNullException(nameof(provider));
  4503. if (actionAsync == null)
  4504. throw new ArgumentNullException(nameof(actionAsync));
  4505. return provider.CreateQuery<Unit>(
  4506. Expression.Call(
  4507. null,
  4508. #if CRIPPLED_REFLECTION
  4509. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  4510. #else
  4511. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4512. #endif
  4513. Expression.Constant(provider, typeof(IQbservableProvider)),
  4514. actionAsync
  4515. )
  4516. );
  4517. }
  4518. /// <summary>
  4519. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4520. /// </summary>
  4521. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4522. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4523. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4524. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4525. /// <exception cref="ArgumentNullException">
  4526. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4527. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync, IScheduler scheduler)
  4528. {
  4529. if (provider == null)
  4530. throw new ArgumentNullException(nameof(provider));
  4531. if (actionAsync == null)
  4532. throw new ArgumentNullException(nameof(actionAsync));
  4533. if (scheduler == null)
  4534. throw new ArgumentNullException(nameof(scheduler));
  4535. return provider.CreateQuery<Unit>(
  4536. Expression.Call(
  4537. null,
  4538. #if CRIPPLED_REFLECTION
  4539. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<Task>>), default(IScheduler))),
  4540. #else
  4541. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4542. #endif
  4543. Expression.Constant(provider, typeof(IQbservableProvider)),
  4544. actionAsync,
  4545. Expression.Constant(scheduler, typeof(IScheduler))
  4546. )
  4547. );
  4548. }
  4549. /// <summary>
  4550. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4551. /// 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.
  4552. /// </summary>
  4553. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4554. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4555. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4556. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4557. /// <exception cref="ArgumentNullException">
  4558. /// <paramref name="actionAsync" /> is null.</exception>
  4559. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  4560. {
  4561. if (provider == null)
  4562. throw new ArgumentNullException(nameof(provider));
  4563. if (actionAsync == null)
  4564. throw new ArgumentNullException(nameof(actionAsync));
  4565. return provider.CreateQuery<Unit>(
  4566. Expression.Call(
  4567. null,
  4568. #if CRIPPLED_REFLECTION
  4569. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  4570. #else
  4571. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4572. #endif
  4573. Expression.Constant(provider, typeof(IQbservableProvider)),
  4574. actionAsync
  4575. )
  4576. );
  4577. }
  4578. /// <summary>
  4579. /// Converts to asynchronous action into an observable sequence. Each subscription to the resulting sequence causes the action to be started.
  4580. /// 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.
  4581. /// </summary>
  4582. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4583. /// <param name="actionAsync">Asynchronous action to convert.</param>
  4584. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4585. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  4586. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4587. /// <exception cref="ArgumentNullException">
  4588. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4589. public static IQbservable<Unit> FromAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync, IScheduler scheduler)
  4590. {
  4591. if (provider == null)
  4592. throw new ArgumentNullException(nameof(provider));
  4593. if (actionAsync == null)
  4594. throw new ArgumentNullException(nameof(actionAsync));
  4595. if (scheduler == null)
  4596. throw new ArgumentNullException(nameof(scheduler));
  4597. return provider.CreateQuery<Unit>(
  4598. Expression.Call(
  4599. null,
  4600. #if CRIPPLED_REFLECTION
  4601. InfoOf(() => Qbservable.FromAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>), default(IScheduler))),
  4602. #else
  4603. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4604. #endif
  4605. Expression.Constant(provider, typeof(IQbservableProvider)),
  4606. actionAsync,
  4607. Expression.Constant(scheduler, typeof(IScheduler))
  4608. )
  4609. );
  4610. }
  4611. /// <summary>
  4612. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4613. /// </summary>
  4614. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4615. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4616. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4617. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4618. /// <exception cref="ArgumentNullException">
  4619. /// <paramref name="functionAsync" /> is null.</exception>
  4620. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  4621. {
  4622. if (provider == null)
  4623. throw new ArgumentNullException(nameof(provider));
  4624. if (functionAsync == null)
  4625. throw new ArgumentNullException(nameof(functionAsync));
  4626. return provider.CreateQuery<TResult>(
  4627. Expression.Call(
  4628. null,
  4629. #if CRIPPLED_REFLECTION
  4630. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  4631. #else
  4632. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4633. #endif
  4634. Expression.Constant(provider, typeof(IQbservableProvider)),
  4635. functionAsync
  4636. )
  4637. );
  4638. }
  4639. /// <summary>
  4640. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4641. /// 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.
  4642. /// </summary>
  4643. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4644. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4645. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4646. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4647. /// <exception cref="ArgumentNullException">
  4648. /// <paramref name="functionAsync" /> is null.</exception>
  4649. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4650. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  4651. {
  4652. if (provider == null)
  4653. throw new ArgumentNullException(nameof(provider));
  4654. if (functionAsync == null)
  4655. throw new ArgumentNullException(nameof(functionAsync));
  4656. return provider.CreateQuery<TResult>(
  4657. Expression.Call(
  4658. null,
  4659. #if CRIPPLED_REFLECTION
  4660. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  4661. #else
  4662. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4663. #endif
  4664. Expression.Constant(provider, typeof(IQbservableProvider)),
  4665. functionAsync
  4666. )
  4667. );
  4668. }
  4669. /// <summary>
  4670. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4671. /// </summary>
  4672. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4673. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4674. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4675. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4676. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4677. /// <exception cref="ArgumentNullException">
  4678. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4679. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync, IScheduler scheduler)
  4680. {
  4681. if (provider == null)
  4682. throw new ArgumentNullException(nameof(provider));
  4683. if (functionAsync == null)
  4684. throw new ArgumentNullException(nameof(functionAsync));
  4685. if (scheduler == null)
  4686. throw new ArgumentNullException(nameof(scheduler));
  4687. return provider.CreateQuery<TResult>(
  4688. Expression.Call(
  4689. null,
  4690. #if CRIPPLED_REFLECTION
  4691. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>), default(IScheduler))),
  4692. #else
  4693. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4694. #endif
  4695. Expression.Constant(provider, typeof(IQbservableProvider)),
  4696. functionAsync,
  4697. Expression.Constant(scheduler, typeof(IScheduler))
  4698. )
  4699. );
  4700. }
  4701. /// <summary>
  4702. /// Converts to asynchronous function into an observable sequence. Each subscription to the resulting sequence causes the function to be started.
  4703. /// 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.
  4704. /// </summary>
  4705. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4706. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  4707. /// <param name="functionAsync">Asynchronous function to convert.</param>
  4708. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  4709. /// <returns>An observable sequence exposing the result of invoking the function, or an exception.</returns>
  4710. /// <exception cref="ArgumentNullException">
  4711. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  4712. /// <remarks>When a subscription to the resulting sequence is disposed, the CancellationToken that was fed to the asynchronous function will be signaled.</remarks>
  4713. public static IQbservable<TResult> FromAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync, IScheduler scheduler)
  4714. {
  4715. if (provider == null)
  4716. throw new ArgumentNullException(nameof(provider));
  4717. if (functionAsync == null)
  4718. throw new ArgumentNullException(nameof(functionAsync));
  4719. if (scheduler == null)
  4720. throw new ArgumentNullException(nameof(scheduler));
  4721. return provider.CreateQuery<TResult>(
  4722. Expression.Call(
  4723. null,
  4724. #if CRIPPLED_REFLECTION
  4725. InfoOf(() => Qbservable.FromAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>), default(IScheduler))),
  4726. #else
  4727. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  4728. #endif
  4729. Expression.Constant(provider, typeof(IQbservableProvider)),
  4730. functionAsync,
  4731. Expression.Constant(scheduler, typeof(IScheduler))
  4732. )
  4733. );
  4734. }
  4735. /// <summary>
  4736. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4737. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4738. /// </summary>
  4739. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4740. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4741. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4742. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4743. /// <exception cref="ArgumentNullException">
  4744. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4745. /// <remarks>
  4746. /// <para>
  4747. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4748. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4749. /// </para>
  4750. /// <para>
  4751. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  4752. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4753. /// </para>
  4754. /// <para>
  4755. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4756. /// making the Subscribe or Dispose call, respectively.
  4757. /// </para>
  4758. /// <para>
  4759. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4760. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4761. /// more concise and easier to understand.
  4762. /// </para>
  4763. /// </remarks>
  4764. /// <seealso cref="Observable.ToEvent(IObservable{Reactive.Unit})" />
  4765. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler)
  4766. {
  4767. if (provider == null)
  4768. throw new ArgumentNullException(nameof(provider));
  4769. if (addHandler == null)
  4770. throw new ArgumentNullException(nameof(addHandler));
  4771. if (removeHandler == null)
  4772. throw new ArgumentNullException(nameof(removeHandler));
  4773. return provider.CreateQuery<Unit>(
  4774. Expression.Call(
  4775. null,
  4776. #if CRIPPLED_REFLECTION
  4777. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>))),
  4778. #else
  4779. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4780. #endif
  4781. Expression.Constant(provider, typeof(IQbservableProvider)),
  4782. addHandler,
  4783. removeHandler
  4784. )
  4785. );
  4786. }
  4787. /// <summary>
  4788. /// Converts an Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  4789. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4790. /// </summary>
  4791. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4792. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4793. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4794. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4795. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4796. /// <exception cref="ArgumentNullException">
  4797. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4798. /// <remarks>
  4799. /// <para>
  4800. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4801. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4802. /// </para>
  4803. /// <para>
  4804. /// 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
  4805. /// accessed from the same context, as required by some UI frameworks.
  4806. /// </para>
  4807. /// <para>
  4808. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4809. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4810. /// parameter. For more information, see the remarks section on those overloads.
  4811. /// </para>
  4812. /// </remarks>
  4813. /// <seealso cref="Observable.ToEvent(IObservable{Reactive.Unit})" />
  4814. public static IQbservable<Unit> FromEvent(this IQbservableProvider provider, Expression<Action<Action>> addHandler, Expression<Action<Action>> removeHandler, IScheduler scheduler)
  4815. {
  4816. if (provider == null)
  4817. throw new ArgumentNullException(nameof(provider));
  4818. if (addHandler == null)
  4819. throw new ArgumentNullException(nameof(addHandler));
  4820. if (removeHandler == null)
  4821. throw new ArgumentNullException(nameof(removeHandler));
  4822. if (scheduler == null)
  4823. throw new ArgumentNullException(nameof(scheduler));
  4824. return provider.CreateQuery<Unit>(
  4825. Expression.Call(
  4826. null,
  4827. #if CRIPPLED_REFLECTION
  4828. InfoOf(() => Qbservable.FromEvent(default(IQbservableProvider), default(Expression<Action<Action>>), default(Expression<Action<Action>>), default(IScheduler))),
  4829. #else
  4830. (MethodInfo)MethodInfo.GetCurrentMethod(),
  4831. #endif
  4832. Expression.Constant(provider, typeof(IQbservableProvider)),
  4833. addHandler,
  4834. removeHandler,
  4835. Expression.Constant(scheduler, typeof(IScheduler))
  4836. )
  4837. );
  4838. }
  4839. /// <summary>
  4840. /// 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.
  4841. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4842. /// </summary>
  4843. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4844. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4845. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4846. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4847. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4848. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4849. /// <exception cref="ArgumentNullException">
  4850. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  4851. /// <remarks>
  4852. /// <para>
  4853. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4854. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4855. /// </para>
  4856. /// <para>
  4857. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  4858. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  4859. /// </para>
  4860. /// <para>
  4861. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  4862. /// making the Subscribe or Dispose call, respectively.
  4863. /// </para>
  4864. /// <para>
  4865. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  4866. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  4867. /// more concise and easier to understand.
  4868. /// </para>
  4869. /// </remarks>
  4870. /// <seealso cref="Observable.ToEvent(IObservable{Reactive.Unit})" />
  4871. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  4872. {
  4873. if (provider == null)
  4874. throw new ArgumentNullException(nameof(provider));
  4875. if (addHandler == null)
  4876. throw new ArgumentNullException(nameof(addHandler));
  4877. if (removeHandler == null)
  4878. throw new ArgumentNullException(nameof(removeHandler));
  4879. return provider.CreateQuery<TEventArgs>(
  4880. Expression.Call(
  4881. null,
  4882. #if CRIPPLED_REFLECTION
  4883. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  4884. #else
  4885. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4886. #endif
  4887. Expression.Constant(provider, typeof(IQbservableProvider)),
  4888. addHandler,
  4889. removeHandler
  4890. )
  4891. );
  4892. }
  4893. /// <summary>
  4894. /// 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.
  4895. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4896. /// </summary>
  4897. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4898. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4899. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4900. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  4901. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  4902. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  4903. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  4904. /// <exception cref="ArgumentNullException">
  4905. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  4906. /// <remarks>
  4907. /// <para>
  4908. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  4909. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  4910. /// </para>
  4911. /// <para>
  4912. /// 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
  4913. /// accessed from the same context, as required by some UI frameworks.
  4914. /// </para>
  4915. /// <para>
  4916. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  4917. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  4918. /// parameter. For more information, see the remarks section on those overloads.
  4919. /// </para>
  4920. /// </remarks>
  4921. /// <seealso cref="Observable.ToEvent(IObservable{Reactive.Unit})" />
  4922. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  4923. {
  4924. if (provider == null)
  4925. throw new ArgumentNullException(nameof(provider));
  4926. if (addHandler == null)
  4927. throw new ArgumentNullException(nameof(addHandler));
  4928. if (removeHandler == null)
  4929. throw new ArgumentNullException(nameof(removeHandler));
  4930. if (scheduler == null)
  4931. throw new ArgumentNullException(nameof(scheduler));
  4932. return provider.CreateQuery<TEventArgs>(
  4933. Expression.Call(
  4934. null,
  4935. #if CRIPPLED_REFLECTION
  4936. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  4937. #else
  4938. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4939. #endif
  4940. Expression.Constant(provider, typeof(IQbservableProvider)),
  4941. addHandler,
  4942. removeHandler,
  4943. Expression.Constant(scheduler, typeof(IScheduler))
  4944. )
  4945. );
  4946. }
  4947. /// <summary>
  4948. /// 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.
  4949. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  4950. /// </summary>
  4951. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  4952. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  4953. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  4954. /// <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>
  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="conversion" /> or <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="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="Observable.ToEvent(IObservable{Reactive.Unit})" />
  4980. public static IQbservable<TEventArgs> FromEvent<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Func<Action<TEventArgs>, TDelegate>> conversion, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  4981. {
  4982. if (provider == null)
  4983. throw new ArgumentNullException(nameof(provider));
  4984. if (conversion == null)
  4985. throw new ArgumentNullException(nameof(conversion));
  4986. if (addHandler == null)
  4987. throw new ArgumentNullException(nameof(addHandler));
  4988. if (removeHandler == null)
  4989. throw new ArgumentNullException(nameof(removeHandler));
  4990. return provider.CreateQuery<TEventArgs>(
  4991. Expression.Call(
  4992. null,
  4993. #if CRIPPLED_REFLECTION
  4994. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  4995. #else
  4996. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  4997. #endif
  4998. Expression.Constant(provider, typeof(IQbservableProvider)),
  4999. conversion,
  5000. addHandler,
  5001. removeHandler
  5002. )
  5003. );
  5004. }
  5005. /// <summary>
  5006. /// 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.
  5007. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5008. /// </summary>
  5009. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5010. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5011. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5012. /// <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>
  5013. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5014. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5015. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5016. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5017. /// <exception cref="ArgumentNullException">
  5018. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5019. /// <remarks>
  5020. /// <para>
  5021. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5022. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5023. /// </para>
  5024. /// <para>
  5025. /// 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
  5026. /// accessed from the same context, as required by some UI frameworks.
  5027. /// </para>
  5028. /// <para>
  5029. /// It's recommended to lift FromEvent calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5030. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEvent that omit the IScheduler
  5031. /// parameter. For more information, see the remarks section on those overloads.
  5032. /// </para>
  5033. /// </remarks>
  5034. /// <seealso cref="Observable.ToEvent(IObservable{Reactive.Unit})" />
  5035. 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)
  5036. {
  5037. if (provider == null)
  5038. throw new ArgumentNullException(nameof(provider));
  5039. if (conversion == null)
  5040. throw new ArgumentNullException(nameof(conversion));
  5041. if (addHandler == null)
  5042. throw new ArgumentNullException(nameof(addHandler));
  5043. if (removeHandler == null)
  5044. throw new ArgumentNullException(nameof(removeHandler));
  5045. if (scheduler == null)
  5046. throw new ArgumentNullException(nameof(scheduler));
  5047. return provider.CreateQuery<TEventArgs>(
  5048. Expression.Call(
  5049. null,
  5050. #if CRIPPLED_REFLECTION
  5051. InfoOf(() => Qbservable.FromEvent<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<Action<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5052. #else
  5053. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5054. #endif
  5055. Expression.Constant(provider, typeof(IQbservableProvider)),
  5056. conversion,
  5057. addHandler,
  5058. removeHandler,
  5059. Expression.Constant(scheduler, typeof(IScheduler))
  5060. )
  5061. );
  5062. }
  5063. /// <summary>
  5064. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5065. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5066. /// </summary>
  5067. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5068. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5069. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5070. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5071. /// <returns>The observable sequence that contains the event argument objects passed to the invocations of the underlying .NET event.</returns>
  5072. /// <exception cref="ArgumentNullException">
  5073. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5074. /// <remarks>
  5075. /// <para>
  5076. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5077. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5078. /// </para>
  5079. /// <para>
  5080. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEvent, and is used to post add and remove handler invocations.
  5081. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5082. /// </para>
  5083. /// <para>
  5084. /// If no SynchronizationContext is present at the point of calling FromEvent, add and remove handler invocations are made synchronously on the thread
  5085. /// making the Subscribe or Dispose call, respectively.
  5086. /// </para>
  5087. /// <para>
  5088. /// It's recommended to lift FromEvent calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5089. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5090. /// more concise and easier to understand.
  5091. /// </para>
  5092. /// </remarks>
  5093. /// <seealso cref="Observable.ToEvent(IObservable{Reactive.Unit})" />
  5094. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler)
  5095. {
  5096. if (provider == null)
  5097. throw new ArgumentNullException(nameof(provider));
  5098. if (addHandler == null)
  5099. throw new ArgumentNullException(nameof(addHandler));
  5100. if (removeHandler == null)
  5101. throw new ArgumentNullException(nameof(removeHandler));
  5102. return provider.CreateQuery<TEventArgs>(
  5103. Expression.Call(
  5104. null,
  5105. #if CRIPPLED_REFLECTION
  5106. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>))),
  5107. #else
  5108. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5109. #endif
  5110. Expression.Constant(provider, typeof(IQbservableProvider)),
  5111. addHandler,
  5112. removeHandler
  5113. )
  5114. );
  5115. }
  5116. /// <summary>
  5117. /// Converts a generic Action-based .NET event to an observable sequence. Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5118. /// For conversion of events conforming to the standard .NET event pattern, use any of the FromEventPattern overloads instead.
  5119. /// </summary>
  5120. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5121. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  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="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="Observable.ToEvent(IObservable{Reactive.Unit})" />
  5144. public static IQbservable<TEventArgs> FromEvent<TEventArgs>(this IQbservableProvider provider, Expression<Action<Action<TEventArgs>>> addHandler, Expression<Action<Action<TEventArgs>>> removeHandler, IScheduler scheduler)
  5145. {
  5146. if (provider == null)
  5147. throw new ArgumentNullException(nameof(provider));
  5148. if (addHandler == null)
  5149. throw new ArgumentNullException(nameof(addHandler));
  5150. if (removeHandler == null)
  5151. throw new ArgumentNullException(nameof(removeHandler));
  5152. if (scheduler == null)
  5153. throw new ArgumentNullException(nameof(scheduler));
  5154. return provider.CreateQuery<TEventArgs>(
  5155. Expression.Call(
  5156. null,
  5157. #if CRIPPLED_REFLECTION
  5158. InfoOf(() => Qbservable.FromEvent<TEventArgs>(default(IQbservableProvider), default(Expression<Action<Action<TEventArgs>>>), default(Expression<Action<Action<TEventArgs>>>), default(IScheduler))),
  5159. #else
  5160. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5161. #endif
  5162. Expression.Constant(provider, typeof(IQbservableProvider)),
  5163. addHandler,
  5164. removeHandler,
  5165. Expression.Constant(scheduler, typeof(IScheduler))
  5166. )
  5167. );
  5168. }
  5169. /// <summary>
  5170. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler" />, to an observable sequence.
  5171. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5172. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5173. /// </summary>
  5174. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5175. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5176. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5177. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5178. /// <exception cref="ArgumentNullException">
  5179. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5180. /// <remarks>
  5181. /// <para>
  5182. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5183. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5184. /// </para>
  5185. /// <para>
  5186. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5187. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5188. /// </para>
  5189. /// <para>
  5190. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5191. /// making the Subscribe or Dispose call, respectively.
  5192. /// </para>
  5193. /// <para>
  5194. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5195. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5196. /// more concise and easier to understand.
  5197. /// </para>
  5198. /// </remarks>
  5199. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5200. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler)
  5201. {
  5202. if (provider == null)
  5203. throw new ArgumentNullException(nameof(provider));
  5204. if (addHandler == null)
  5205. throw new ArgumentNullException(nameof(addHandler));
  5206. if (removeHandler == null)
  5207. throw new ArgumentNullException(nameof(removeHandler));
  5208. return provider.CreateQuery<EventPattern<object>>(
  5209. Expression.Call(
  5210. null,
  5211. #if CRIPPLED_REFLECTION
  5212. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>))),
  5213. #else
  5214. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5215. #endif
  5216. Expression.Constant(provider, typeof(IQbservableProvider)),
  5217. addHandler,
  5218. removeHandler
  5219. )
  5220. );
  5221. }
  5222. /// <summary>
  5223. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler" />, to an observable sequence.
  5224. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5225. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5226. /// </summary>
  5227. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5228. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5229. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5230. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5231. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5232. /// <exception cref="ArgumentNullException">
  5233. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5234. /// <remarks>
  5235. /// <para>
  5236. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5237. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5238. /// </para>
  5239. /// <para>
  5240. /// 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
  5241. /// accessed from the same context, as required by some UI frameworks.
  5242. /// </para>
  5243. /// <para>
  5244. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5245. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5246. /// parameter. For more information, see the remarks section on those overloads.
  5247. /// </para>
  5248. /// </remarks>
  5249. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5250. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Expression<Action<EventHandler>> addHandler, Expression<Action<EventHandler>> removeHandler, IScheduler scheduler)
  5251. {
  5252. if (provider == null)
  5253. throw new ArgumentNullException(nameof(provider));
  5254. if (addHandler == null)
  5255. throw new ArgumentNullException(nameof(addHandler));
  5256. if (removeHandler == null)
  5257. throw new ArgumentNullException(nameof(removeHandler));
  5258. if (scheduler == null)
  5259. throw new ArgumentNullException(nameof(scheduler));
  5260. return provider.CreateQuery<EventPattern<object>>(
  5261. Expression.Call(
  5262. null,
  5263. #if CRIPPLED_REFLECTION
  5264. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Expression<Action<EventHandler>>), default(Expression<Action<EventHandler>>), default(IScheduler))),
  5265. #else
  5266. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5267. #endif
  5268. Expression.Constant(provider, typeof(IQbservableProvider)),
  5269. addHandler,
  5270. removeHandler,
  5271. Expression.Constant(scheduler, typeof(IScheduler))
  5272. )
  5273. );
  5274. }
  5275. /// <summary>
  5276. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5277. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5278. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5279. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5280. /// </summary>
  5281. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5282. /// <param name="target">Object instance that exposes the event to convert.</param>
  5283. /// <param name="eventName">Name of the event to convert.</param>
  5284. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5285. /// <exception cref="ArgumentNullException">
  5286. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  5287. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5288. /// <remarks>
  5289. /// <para>
  5290. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5291. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5292. /// </para>
  5293. /// <para>
  5294. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5295. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5296. /// </para>
  5297. /// <para>
  5298. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5299. /// making the Subscribe or Dispose call, respectively.
  5300. /// </para>
  5301. /// <para>
  5302. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5303. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5304. /// more concise and easier to understand.
  5305. /// </para>
  5306. /// </remarks>
  5307. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5308. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName)
  5309. {
  5310. if (provider == null)
  5311. throw new ArgumentNullException(nameof(provider));
  5312. if (target == null)
  5313. throw new ArgumentNullException(nameof(target));
  5314. if (eventName == null)
  5315. throw new ArgumentNullException(nameof(eventName));
  5316. return provider.CreateQuery<EventPattern<object>>(
  5317. Expression.Call(
  5318. null,
  5319. #if CRIPPLED_REFLECTION
  5320. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string))),
  5321. #else
  5322. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5323. #endif
  5324. Expression.Constant(provider, typeof(IQbservableProvider)),
  5325. Expression.Constant(target, typeof(object)),
  5326. Expression.Constant(eventName, typeof(string))
  5327. )
  5328. );
  5329. }
  5330. /// <summary>
  5331. /// Converts an instance .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5332. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5333. /// Reflection is used to discover the event based on the target object type and the specified event name.
  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="target">Object instance that exposes the event to convert.</param>
  5338. /// <param name="eventName">Name of the event to convert.</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="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5343. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5344. /// <remarks>
  5345. /// <para>
  5346. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5347. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5348. /// </para>
  5349. /// <para>
  5350. /// 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
  5351. /// accessed from the same context, as required by some UI frameworks.
  5352. /// </para>
  5353. /// <para>
  5354. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5355. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5356. /// parameter. For more information, see the remarks section on those overloads.
  5357. /// </para>
  5358. /// </remarks>
  5359. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5360. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  5361. {
  5362. if (provider == null)
  5363. throw new ArgumentNullException(nameof(provider));
  5364. if (target == null)
  5365. throw new ArgumentNullException(nameof(target));
  5366. if (eventName == null)
  5367. throw new ArgumentNullException(nameof(eventName));
  5368. if (scheduler == null)
  5369. throw new ArgumentNullException(nameof(scheduler));
  5370. return provider.CreateQuery<EventPattern<object>>(
  5371. Expression.Call(
  5372. null,
  5373. #if CRIPPLED_REFLECTION
  5374. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  5375. #else
  5376. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5377. #endif
  5378. Expression.Constant(provider, typeof(IQbservableProvider)),
  5379. Expression.Constant(target, typeof(object)),
  5380. Expression.Constant(eventName, typeof(string)),
  5381. Expression.Constant(scheduler, typeof(IScheduler))
  5382. )
  5383. );
  5384. }
  5385. /// <summary>
  5386. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5387. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5388. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5389. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5390. /// </summary>
  5391. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5392. /// <param name="type">Type that exposes the static event to convert.</param>
  5393. /// <param name="eventName">Name of the event to convert.</param>
  5394. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5395. /// <exception cref="ArgumentNullException">
  5396. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  5397. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5398. /// <remarks>
  5399. /// <para>
  5400. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5401. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5402. /// </para>
  5403. /// <para>
  5404. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5405. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5406. /// </para>
  5407. /// <para>
  5408. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5409. /// making the Subscribe or Dispose call, respectively.
  5410. /// </para>
  5411. /// <para>
  5412. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5413. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5414. /// more concise and easier to understand.
  5415. /// </para>
  5416. /// </remarks>
  5417. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5418. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName)
  5419. {
  5420. if (provider == null)
  5421. throw new ArgumentNullException(nameof(provider));
  5422. if (type == null)
  5423. throw new ArgumentNullException(nameof(type));
  5424. if (eventName == null)
  5425. throw new ArgumentNullException(nameof(eventName));
  5426. return provider.CreateQuery<EventPattern<object>>(
  5427. Expression.Call(
  5428. null,
  5429. #if CRIPPLED_REFLECTION
  5430. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string))),
  5431. #else
  5432. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5433. #endif
  5434. Expression.Constant(provider, typeof(IQbservableProvider)),
  5435. Expression.Constant(type, typeof(Type)),
  5436. Expression.Constant(eventName, typeof(string))
  5437. )
  5438. );
  5439. }
  5440. /// <summary>
  5441. /// Converts a static .NET event, conforming to the standard .NET event pattern with an <see cref="EventArgs" /> parameter, to an observable sequence.
  5442. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5443. /// Reflection is used to discover the event based on the specified type and the specified event name.
  5444. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5445. /// </summary>
  5446. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5447. /// <param name="type">Type that exposes the static event to convert.</param>
  5448. /// <param name="eventName">Name of the event to convert.</param>
  5449. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5450. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5451. /// <exception cref="ArgumentNullException">
  5452. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  5453. /// <exception cref="InvalidOperationException">The event could not be found. -or- The event does not conform to the standard .NET event pattern.</exception>
  5454. /// <remarks>
  5455. /// <para>
  5456. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5457. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5458. /// </para>
  5459. /// <para>
  5460. /// 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
  5461. /// accessed from the same context, as required by some UI frameworks.
  5462. /// </para>
  5463. /// <para>
  5464. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5465. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5466. /// parameter. For more information, see the remarks section on those overloads.
  5467. /// </para>
  5468. /// </remarks>
  5469. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5470. public static IQbservable<EventPattern<object>> FromEventPattern(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  5471. {
  5472. if (provider == null)
  5473. throw new ArgumentNullException(nameof(provider));
  5474. if (type == null)
  5475. throw new ArgumentNullException(nameof(type));
  5476. if (eventName == null)
  5477. throw new ArgumentNullException(nameof(eventName));
  5478. if (scheduler == null)
  5479. throw new ArgumentNullException(nameof(scheduler));
  5480. return provider.CreateQuery<EventPattern<object>>(
  5481. Expression.Call(
  5482. null,
  5483. #if CRIPPLED_REFLECTION
  5484. InfoOf(() => Qbservable.FromEventPattern(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  5485. #else
  5486. (MethodInfo)MethodInfo.GetCurrentMethod(),
  5487. #endif
  5488. Expression.Constant(provider, typeof(IQbservableProvider)),
  5489. Expression.Constant(type, typeof(Type)),
  5490. Expression.Constant(eventName, typeof(string)),
  5491. Expression.Constant(scheduler, typeof(IScheduler))
  5492. )
  5493. );
  5494. }
  5495. /// <summary>
  5496. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5497. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  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. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5502. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5503. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5504. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5505. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5506. /// <exception cref="ArgumentNullException">
  5507. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5508. /// <remarks>
  5509. /// <para>
  5510. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5511. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5512. /// </para>
  5513. /// <para>
  5514. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5515. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5516. /// </para>
  5517. /// <para>
  5518. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5519. /// making the Subscribe or Dispose call, respectively.
  5520. /// </para>
  5521. /// <para>
  5522. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5523. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5524. /// more concise and easier to understand.
  5525. /// </para>
  5526. /// </remarks>
  5527. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5528. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5529. {
  5530. if (provider == null)
  5531. throw new ArgumentNullException(nameof(provider));
  5532. if (addHandler == null)
  5533. throw new ArgumentNullException(nameof(addHandler));
  5534. if (removeHandler == null)
  5535. throw new ArgumentNullException(nameof(removeHandler));
  5536. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5537. Expression.Call(
  5538. null,
  5539. #if CRIPPLED_REFLECTION
  5540. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5541. #else
  5542. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5543. #endif
  5544. Expression.Constant(provider, typeof(IQbservableProvider)),
  5545. addHandler,
  5546. removeHandler
  5547. )
  5548. );
  5549. }
  5550. /// <summary>
  5551. /// Converts a .NET event, conforming to the standard .NET event pattern based on a supplied event delegate type, to an observable sequence.
  5552. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  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. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5557. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5558. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5559. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5560. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5561. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5562. /// <exception cref="ArgumentNullException">
  5563. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5564. /// <remarks>
  5565. /// <para>
  5566. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5567. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5568. /// </para>
  5569. /// <para>
  5570. /// 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
  5571. /// accessed from the same context, as required by some UI frameworks.
  5572. /// </para>
  5573. /// <para>
  5574. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5575. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5576. /// parameter. For more information, see the remarks section on those overloads.
  5577. /// </para>
  5578. /// </remarks>
  5579. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5580. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TDelegate, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5581. {
  5582. if (provider == null)
  5583. throw new ArgumentNullException(nameof(provider));
  5584. if (addHandler == null)
  5585. throw new ArgumentNullException(nameof(addHandler));
  5586. if (removeHandler == null)
  5587. throw new ArgumentNullException(nameof(removeHandler));
  5588. if (scheduler == null)
  5589. throw new ArgumentNullException(nameof(scheduler));
  5590. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5591. Expression.Call(
  5592. null,
  5593. #if CRIPPLED_REFLECTION
  5594. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5595. #else
  5596. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5597. #endif
  5598. Expression.Constant(provider, typeof(IQbservableProvider)),
  5599. addHandler,
  5600. removeHandler,
  5601. Expression.Constant(scheduler, typeof(IScheduler))
  5602. )
  5603. );
  5604. }
  5605. /// <summary>
  5606. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler{TEventArgs}" />, to an observable sequence.
  5607. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5608. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5609. /// </summary>
  5610. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5611. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5612. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5613. /// <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>
  5614. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5615. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5616. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5617. /// <exception cref="ArgumentNullException">
  5618. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5619. /// <remarks>
  5620. /// <para>
  5621. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5622. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5623. /// </para>
  5624. /// <para>
  5625. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5626. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5627. /// </para>
  5628. /// <para>
  5629. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5630. /// making the Subscribe or Dispose call, respectively.
  5631. /// </para>
  5632. /// <para>
  5633. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5634. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5635. /// more concise and easier to understand.
  5636. /// </para>
  5637. /// </remarks>
  5638. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5639. 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)
  5640. {
  5641. if (provider == null)
  5642. throw new ArgumentNullException(nameof(provider));
  5643. if (conversion == null)
  5644. throw new ArgumentNullException(nameof(conversion));
  5645. if (addHandler == null)
  5646. throw new ArgumentNullException(nameof(addHandler));
  5647. if (removeHandler == null)
  5648. throw new ArgumentNullException(nameof(removeHandler));
  5649. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5650. Expression.Call(
  5651. null,
  5652. #if CRIPPLED_REFLECTION
  5653. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5654. #else
  5655. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5656. #endif
  5657. Expression.Constant(provider, typeof(IQbservableProvider)),
  5658. conversion,
  5659. addHandler,
  5660. removeHandler
  5661. )
  5662. );
  5663. }
  5664. /// <summary>
  5665. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler{TEventArgs}" />, to an observable sequence.
  5666. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5667. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5668. /// </summary>
  5669. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5670. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5671. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5672. /// <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>
  5673. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5674. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5675. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5676. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5677. /// <exception cref="ArgumentNullException">
  5678. /// <paramref name="conversion" /> or <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5679. /// <remarks>
  5680. /// <para>
  5681. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5682. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5683. /// </para>
  5684. /// <para>
  5685. /// 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
  5686. /// accessed from the same context, as required by some UI frameworks.
  5687. /// </para>
  5688. /// <para>
  5689. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5690. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5691. /// parameter. For more information, see the remarks section on those overloads.
  5692. /// </para>
  5693. /// </remarks>
  5694. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5695. 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)
  5696. {
  5697. if (provider == null)
  5698. throw new ArgumentNullException(nameof(provider));
  5699. if (conversion == null)
  5700. throw new ArgumentNullException(nameof(conversion));
  5701. if (addHandler == null)
  5702. throw new ArgumentNullException(nameof(addHandler));
  5703. if (removeHandler == null)
  5704. throw new ArgumentNullException(nameof(removeHandler));
  5705. if (scheduler == null)
  5706. throw new ArgumentNullException(nameof(scheduler));
  5707. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5708. Expression.Call(
  5709. null,
  5710. #if CRIPPLED_REFLECTION
  5711. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TEventArgs>(default(IQbservableProvider), default(Expression<Func<EventHandler<TEventArgs>, TDelegate>>), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5712. #else
  5713. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TEventArgs)),
  5714. #endif
  5715. Expression.Constant(provider, typeof(IQbservableProvider)),
  5716. conversion,
  5717. addHandler,
  5718. removeHandler,
  5719. Expression.Constant(scheduler, typeof(IScheduler))
  5720. )
  5721. );
  5722. }
  5723. /// <summary>
  5724. /// 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.
  5725. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5726. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5727. /// </summary>
  5728. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5729. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5730. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  5731. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5732. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5733. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5734. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5735. /// <exception cref="ArgumentNullException">
  5736. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> is null.</exception>
  5737. /// <remarks>
  5738. /// <para>
  5739. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5740. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5741. /// </para>
  5742. /// <para>
  5743. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5744. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5745. /// </para>
  5746. /// <para>
  5747. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5748. /// making the Subscribe or Dispose call, respectively.
  5749. /// </para>
  5750. /// <para>
  5751. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5752. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5753. /// more concise and easier to understand.
  5754. /// </para>
  5755. /// </remarks>
  5756. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5757. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler)
  5758. {
  5759. if (provider == null)
  5760. throw new ArgumentNullException(nameof(provider));
  5761. if (addHandler == null)
  5762. throw new ArgumentNullException(nameof(addHandler));
  5763. if (removeHandler == null)
  5764. throw new ArgumentNullException(nameof(removeHandler));
  5765. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  5766. Expression.Call(
  5767. null,
  5768. #if CRIPPLED_REFLECTION
  5769. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>))),
  5770. #else
  5771. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  5772. #endif
  5773. Expression.Constant(provider, typeof(IQbservableProvider)),
  5774. addHandler,
  5775. removeHandler
  5776. )
  5777. );
  5778. }
  5779. /// <summary>
  5780. /// 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.
  5781. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5782. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5783. /// </summary>
  5784. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5785. /// <typeparam name="TDelegate">The delegate type of the event to be converted.</typeparam>
  5786. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  5787. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5788. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5789. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5790. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5791. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5792. /// <exception cref="ArgumentNullException">
  5793. /// <paramref name="addHandler" /> or <paramref name="removeHandler" /> or <paramref name="scheduler" /> is null.</exception>
  5794. /// <remarks>
  5795. /// <para>
  5796. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5797. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5798. /// </para>
  5799. /// <para>
  5800. /// 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
  5801. /// accessed from the same context, as required by some UI frameworks.
  5802. /// </para>
  5803. /// <para>
  5804. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5805. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5806. /// parameter. For more information, see the remarks section on those overloads.
  5807. /// </para>
  5808. /// </remarks>
  5809. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5810. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TDelegate, TSender, TEventArgs>(this IQbservableProvider provider, Expression<Action<TDelegate>> addHandler, Expression<Action<TDelegate>> removeHandler, IScheduler scheduler)
  5811. {
  5812. if (provider == null)
  5813. throw new ArgumentNullException(nameof(provider));
  5814. if (addHandler == null)
  5815. throw new ArgumentNullException(nameof(addHandler));
  5816. if (removeHandler == null)
  5817. throw new ArgumentNullException(nameof(removeHandler));
  5818. if (scheduler == null)
  5819. throw new ArgumentNullException(nameof(scheduler));
  5820. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  5821. Expression.Call(
  5822. null,
  5823. #if CRIPPLED_REFLECTION
  5824. InfoOf(() => Qbservable.FromEventPattern<TDelegate, TSender, TEventArgs>(default(IQbservableProvider), default(Expression<Action<TDelegate>>), default(Expression<Action<TDelegate>>), default(IScheduler))),
  5825. #else
  5826. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TDelegate), typeof(TSender), typeof(TEventArgs)),
  5827. #endif
  5828. Expression.Constant(provider, typeof(IQbservableProvider)),
  5829. addHandler,
  5830. removeHandler,
  5831. Expression.Constant(scheduler, typeof(IScheduler))
  5832. )
  5833. );
  5834. }
  5835. /// <summary>
  5836. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler{TEventArgs}" />, to an observable sequence.
  5837. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5838. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5839. /// </summary>
  5840. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5841. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5842. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5843. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5844. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5845. /// <remarks>
  5846. /// <para>
  5847. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5848. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5849. /// </para>
  5850. /// <para>
  5851. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5852. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5853. /// </para>
  5854. /// <para>
  5855. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5856. /// making the Subscribe or Dispose call, respectively.
  5857. /// </para>
  5858. /// <para>
  5859. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5860. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5861. /// more concise and easier to understand.
  5862. /// </para>
  5863. /// </remarks>
  5864. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5865. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler)
  5866. {
  5867. if (provider == null)
  5868. throw new ArgumentNullException(nameof(provider));
  5869. if (addHandler == null)
  5870. throw new ArgumentNullException(nameof(addHandler));
  5871. if (removeHandler == null)
  5872. throw new ArgumentNullException(nameof(removeHandler));
  5873. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5874. Expression.Call(
  5875. null,
  5876. #if CRIPPLED_REFLECTION
  5877. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>))),
  5878. #else
  5879. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5880. #endif
  5881. Expression.Constant(provider, typeof(IQbservableProvider)),
  5882. addHandler,
  5883. removeHandler
  5884. )
  5885. );
  5886. }
  5887. /// <summary>
  5888. /// Converts a .NET event, conforming to the standard .NET event pattern based on <see cref="EventHandler{TEventArgs}" />, to an observable sequence.
  5889. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5890. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5891. /// </summary>
  5892. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5893. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5894. /// <param name="addHandler">Action that attaches the given event handler to the underlying .NET event.</param>
  5895. /// <param name="removeHandler">Action that detaches the given event handler from the underlying .NET event.</param>
  5896. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  5897. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5898. /// <remarks>
  5899. /// <para>
  5900. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5901. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5902. /// </para>
  5903. /// <para>
  5904. /// 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
  5905. /// accessed from the same context, as required by some UI frameworks.
  5906. /// </para>
  5907. /// <para>
  5908. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  5909. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  5910. /// parameter. For more information, see the remarks section on those overloads.
  5911. /// </para>
  5912. /// </remarks>
  5913. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5914. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Expression<Action<EventHandler<TEventArgs>>> addHandler, Expression<Action<EventHandler<TEventArgs>>> removeHandler, IScheduler scheduler)
  5915. {
  5916. if (provider == null)
  5917. throw new ArgumentNullException(nameof(provider));
  5918. if (addHandler == null)
  5919. throw new ArgumentNullException(nameof(addHandler));
  5920. if (removeHandler == null)
  5921. throw new ArgumentNullException(nameof(removeHandler));
  5922. if (scheduler == null)
  5923. throw new ArgumentNullException(nameof(scheduler));
  5924. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5925. Expression.Call(
  5926. null,
  5927. #if CRIPPLED_REFLECTION
  5928. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Expression<Action<EventHandler<TEventArgs>>>), default(Expression<Action<EventHandler<TEventArgs>>>), default(IScheduler))),
  5929. #else
  5930. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5931. #endif
  5932. Expression.Constant(provider, typeof(IQbservableProvider)),
  5933. addHandler,
  5934. removeHandler,
  5935. Expression.Constant(scheduler, typeof(IScheduler))
  5936. )
  5937. );
  5938. }
  5939. /// <summary>
  5940. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  5941. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5942. /// Reflection is used to discover the event based on the target object type and the specified event name.
  5943. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  5944. /// </summary>
  5945. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  5946. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  5947. /// <param name="target">Object instance that exposes the event to convert.</param>
  5948. /// <param name="eventName">Name of the event to convert.</param>
  5949. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  5950. /// <exception cref="ArgumentNullException">
  5951. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  5952. /// <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>
  5953. /// <remarks>
  5954. /// <para>
  5955. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  5956. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  5957. /// </para>
  5958. /// <para>
  5959. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  5960. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  5961. /// </para>
  5962. /// <para>
  5963. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  5964. /// making the Subscribe or Dispose call, respectively.
  5965. /// </para>
  5966. /// <para>
  5967. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  5968. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  5969. /// more concise and easier to understand.
  5970. /// </para>
  5971. /// </remarks>
  5972. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  5973. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  5974. {
  5975. if (provider == null)
  5976. throw new ArgumentNullException(nameof(provider));
  5977. if (target == null)
  5978. throw new ArgumentNullException(nameof(target));
  5979. if (eventName == null)
  5980. throw new ArgumentNullException(nameof(eventName));
  5981. return provider.CreateQuery<EventPattern<TEventArgs>>(
  5982. Expression.Call(
  5983. null,
  5984. #if CRIPPLED_REFLECTION
  5985. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  5986. #else
  5987. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  5988. #endif
  5989. Expression.Constant(provider, typeof(IQbservableProvider)),
  5990. Expression.Constant(target, typeof(object)),
  5991. Expression.Constant(eventName, typeof(string))
  5992. )
  5993. );
  5994. }
  5995. /// <summary>
  5996. /// Converts an instance .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  5997. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  5998. /// Reflection is used to discover the event based on the target object type and the specified event name.
  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="target">Object instance that exposes the event to convert.</param>
  6004. /// <param name="eventName">Name of the event to convert.</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. /// <exception cref="ArgumentNullException">
  6008. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6009. /// <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>
  6010. /// <remarks>
  6011. /// <para>
  6012. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6013. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6014. /// </para>
  6015. /// <para>
  6016. /// 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
  6017. /// accessed from the same context, as required by some UI frameworks.
  6018. /// </para>
  6019. /// <para>
  6020. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6021. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6022. /// parameter. For more information, see the remarks section on those overloads.
  6023. /// </para>
  6024. /// </remarks>
  6025. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  6026. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6027. {
  6028. if (provider == null)
  6029. throw new ArgumentNullException(nameof(provider));
  6030. if (target == null)
  6031. throw new ArgumentNullException(nameof(target));
  6032. if (eventName == null)
  6033. throw new ArgumentNullException(nameof(eventName));
  6034. if (scheduler == null)
  6035. throw new ArgumentNullException(nameof(scheduler));
  6036. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6037. Expression.Call(
  6038. null,
  6039. #if CRIPPLED_REFLECTION
  6040. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6041. #else
  6042. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6043. #endif
  6044. Expression.Constant(provider, typeof(IQbservableProvider)),
  6045. Expression.Constant(target, typeof(object)),
  6046. Expression.Constant(eventName, typeof(string)),
  6047. Expression.Constant(scheduler, typeof(IScheduler))
  6048. )
  6049. );
  6050. }
  6051. /// <summary>
  6052. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6053. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6054. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6055. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6056. /// </summary>
  6057. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6058. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6059. /// <param name="type">Type that exposes the static event to convert.</param>
  6060. /// <param name="eventName">Name of the event to convert.</param>
  6061. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6062. /// <exception cref="ArgumentNullException">
  6063. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6064. /// <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>
  6065. /// <remarks>
  6066. /// <para>
  6067. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6068. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6069. /// </para>
  6070. /// <para>
  6071. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6072. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6073. /// </para>
  6074. /// <para>
  6075. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6076. /// making the Subscribe or Dispose call, respectively.
  6077. /// </para>
  6078. /// <para>
  6079. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6080. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6081. /// more concise and easier to understand.
  6082. /// </para>
  6083. /// </remarks>
  6084. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  6085. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6086. {
  6087. if (provider == null)
  6088. throw new ArgumentNullException(nameof(provider));
  6089. if (type == null)
  6090. throw new ArgumentNullException(nameof(type));
  6091. if (eventName == null)
  6092. throw new ArgumentNullException(nameof(eventName));
  6093. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6094. Expression.Call(
  6095. null,
  6096. #if CRIPPLED_REFLECTION
  6097. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6098. #else
  6099. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6100. #endif
  6101. Expression.Constant(provider, typeof(IQbservableProvider)),
  6102. Expression.Constant(type, typeof(Type)),
  6103. Expression.Constant(eventName, typeof(string))
  6104. )
  6105. );
  6106. }
  6107. /// <summary>
  6108. /// Converts a static .NET event, conforming to the standard .NET event pattern with strongly typed event arguments, to an observable sequence.
  6109. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6110. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6111. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6112. /// </summary>
  6113. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6114. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6115. /// <param name="type">Type that exposes the static event to convert.</param>
  6116. /// <param name="eventName">Name of the event to convert.</param>
  6117. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6118. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6119. /// <exception cref="ArgumentNullException">
  6120. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6121. /// <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>
  6122. /// <remarks>
  6123. /// <para>
  6124. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6125. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6126. /// </para>
  6127. /// <para>
  6128. /// 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
  6129. /// accessed from the same context, as required by some UI frameworks.
  6130. /// </para>
  6131. /// <para>
  6132. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6133. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6134. /// parameter. For more information, see the remarks section on those overloads.
  6135. /// </para>
  6136. /// </remarks>
  6137. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  6138. public static IQbservable<EventPattern<TEventArgs>> FromEventPattern<TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6139. {
  6140. if (provider == null)
  6141. throw new ArgumentNullException(nameof(provider));
  6142. if (type == null)
  6143. throw new ArgumentNullException(nameof(type));
  6144. if (eventName == null)
  6145. throw new ArgumentNullException(nameof(eventName));
  6146. if (scheduler == null)
  6147. throw new ArgumentNullException(nameof(scheduler));
  6148. return provider.CreateQuery<EventPattern<TEventArgs>>(
  6149. Expression.Call(
  6150. null,
  6151. #if CRIPPLED_REFLECTION
  6152. InfoOf(() => Qbservable.FromEventPattern<TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6153. #else
  6154. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TEventArgs)),
  6155. #endif
  6156. Expression.Constant(provider, typeof(IQbservableProvider)),
  6157. Expression.Constant(type, typeof(Type)),
  6158. Expression.Constant(eventName, typeof(string)),
  6159. Expression.Constant(scheduler, typeof(IScheduler))
  6160. )
  6161. );
  6162. }
  6163. /// <summary>
  6164. /// 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.
  6165. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6166. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6167. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6168. /// </summary>
  6169. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6170. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6171. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6172. /// <param name="target">Object instance that exposes the event to convert.</param>
  6173. /// <param name="eventName">Name of the event to convert.</param>
  6174. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6175. /// <exception cref="ArgumentNullException">
  6176. /// <paramref name="target" /> or <paramref name="eventName" /> is null.</exception>
  6177. /// <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>
  6178. /// <remarks>
  6179. /// <para>
  6180. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6181. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6182. /// </para>
  6183. /// <para>
  6184. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6185. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6186. /// </para>
  6187. /// <para>
  6188. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6189. /// making the Subscribe or Dispose call, respectively.
  6190. /// </para>
  6191. /// <para>
  6192. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6193. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6194. /// more concise and easier to understand.
  6195. /// </para>
  6196. /// </remarks>
  6197. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  6198. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName)
  6199. {
  6200. if (provider == null)
  6201. throw new ArgumentNullException(nameof(provider));
  6202. if (target == null)
  6203. throw new ArgumentNullException(nameof(target));
  6204. if (eventName == null)
  6205. throw new ArgumentNullException(nameof(eventName));
  6206. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6207. Expression.Call(
  6208. null,
  6209. #if CRIPPLED_REFLECTION
  6210. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string))),
  6211. #else
  6212. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6213. #endif
  6214. Expression.Constant(provider, typeof(IQbservableProvider)),
  6215. Expression.Constant(target, typeof(object)),
  6216. Expression.Constant(eventName, typeof(string))
  6217. )
  6218. );
  6219. }
  6220. /// <summary>
  6221. /// 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.
  6222. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6223. /// Reflection is used to discover the event based on the target object type and the specified event name.
  6224. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6225. /// </summary>
  6226. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6227. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6228. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6229. /// <param name="target">Object instance that exposes the event to convert.</param>
  6230. /// <param name="eventName">Name of the event to convert.</param>
  6231. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6232. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6233. /// <exception cref="ArgumentNullException">
  6234. /// <paramref name="target" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6235. /// <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>
  6236. /// <remarks>
  6237. /// <para>
  6238. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6239. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6240. /// </para>
  6241. /// <para>
  6242. /// 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
  6243. /// accessed from the same context, as required by some UI frameworks.
  6244. /// </para>
  6245. /// <para>
  6246. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6247. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6248. /// parameter. For more information, see the remarks section on those overloads.
  6249. /// </para>
  6250. /// </remarks>
  6251. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  6252. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, object target, string eventName, IScheduler scheduler)
  6253. {
  6254. if (provider == null)
  6255. throw new ArgumentNullException(nameof(provider));
  6256. if (target == null)
  6257. throw new ArgumentNullException(nameof(target));
  6258. if (eventName == null)
  6259. throw new ArgumentNullException(nameof(eventName));
  6260. if (scheduler == null)
  6261. throw new ArgumentNullException(nameof(scheduler));
  6262. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6263. Expression.Call(
  6264. null,
  6265. #if CRIPPLED_REFLECTION
  6266. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(object), default(string), default(IScheduler))),
  6267. #else
  6268. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6269. #endif
  6270. Expression.Constant(provider, typeof(IQbservableProvider)),
  6271. Expression.Constant(target, typeof(object)),
  6272. Expression.Constant(eventName, typeof(string)),
  6273. Expression.Constant(scheduler, typeof(IScheduler))
  6274. )
  6275. );
  6276. }
  6277. /// <summary>
  6278. /// 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.
  6279. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6280. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6281. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6282. /// </summary>
  6283. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6284. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6285. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6286. /// <param name="type">Type that exposes the static event to convert.</param>
  6287. /// <param name="eventName">Name of the event to convert.</param>
  6288. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6289. /// <exception cref="ArgumentNullException">
  6290. /// <paramref name="type" /> or <paramref name="eventName" /> is null.</exception>
  6291. /// <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>
  6292. /// <remarks>
  6293. /// <para>
  6294. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6295. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6296. /// </para>
  6297. /// <para>
  6298. /// The current <see cref="SynchronizationContext" /> is captured during the call to FromEventPattern, and is used to post add and remove handler invocations.
  6299. /// This behavior ensures add and remove handler operations for thread-affine events are accessed from the same context, as required by some UI frameworks.
  6300. /// </para>
  6301. /// <para>
  6302. /// If no SynchronizationContext is present at the point of calling FromEventPattern, add and remove handler invocations are made synchronously on the thread
  6303. /// making the Subscribe or Dispose call, respectively.
  6304. /// </para>
  6305. /// <para>
  6306. /// It's recommended to lift FromEventPattern calls outside event stream query expressions due to the free-threaded nature of Reactive Extensions. Doing so
  6307. /// makes the captured SynchronizationContext predictable. This best practice also reduces clutter of bridging code inside queries, making the query expressions
  6308. /// more concise and easier to understand.
  6309. /// </para>
  6310. /// </remarks>
  6311. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  6312. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName)
  6313. {
  6314. if (provider == null)
  6315. throw new ArgumentNullException(nameof(provider));
  6316. if (type == null)
  6317. throw new ArgumentNullException(nameof(type));
  6318. if (eventName == null)
  6319. throw new ArgumentNullException(nameof(eventName));
  6320. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6321. Expression.Call(
  6322. null,
  6323. #if CRIPPLED_REFLECTION
  6324. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string))),
  6325. #else
  6326. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6327. #endif
  6328. Expression.Constant(provider, typeof(IQbservableProvider)),
  6329. Expression.Constant(type, typeof(Type)),
  6330. Expression.Constant(eventName, typeof(string))
  6331. )
  6332. );
  6333. }
  6334. /// <summary>
  6335. /// 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.
  6336. /// Each event invocation is surfaced through an OnNext message in the resulting sequence.
  6337. /// Reflection is used to discover the event based on the specified type and the specified event name.
  6338. /// For conversion of events that don't conform to the standard .NET event pattern, use any of the FromEvent overloads instead.
  6339. /// </summary>
  6340. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6341. /// <typeparam name="TSender">The type of the sender that raises the event.</typeparam>
  6342. /// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
  6343. /// <param name="type">Type that exposes the static event to convert.</param>
  6344. /// <param name="eventName">Name of the event to convert.</param>
  6345. /// <param name="scheduler">The scheduler to run the add and remove event handler logic on.</param>
  6346. /// <returns>The observable sequence that contains data representations of invocations of the underlying .NET event.</returns>
  6347. /// <exception cref="ArgumentNullException">
  6348. /// <paramref name="type" /> or <paramref name="eventName" /> or <paramref name="scheduler" /> is null.</exception>
  6349. /// <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>
  6350. /// <remarks>
  6351. /// <para>
  6352. /// Add and remove handler invocations are made whenever the number of observers grows beyond zero.
  6353. /// As such, an event handler may be shared by multiple simultaneously active observers, using a subject for multicasting.
  6354. /// </para>
  6355. /// <para>
  6356. /// 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
  6357. /// accessed from the same context, as required by some UI frameworks.
  6358. /// </para>
  6359. /// <para>
  6360. /// It's recommended to lift FromEventPattern calls outside event stream query expressions. This best practice reduces clutter of bridging code inside queries,
  6361. /// making the query expressions more concise and easier to understand. This has additional benefits for overloads of FromEventPattern that omit the IScheduler
  6362. /// parameter. For more information, see the remarks section on those overloads.
  6363. /// </para>
  6364. /// </remarks>
  6365. /// <seealso cref="Observable.ToEventPattern{TEventArgs}(IObservable{EventPattern{TEventArgs}})" />
  6366. public static IQbservable<EventPattern<TSender, TEventArgs>> FromEventPattern<TSender, TEventArgs>(this IQbservableProvider provider, Type type, string eventName, IScheduler scheduler)
  6367. {
  6368. if (provider == null)
  6369. throw new ArgumentNullException(nameof(provider));
  6370. if (type == null)
  6371. throw new ArgumentNullException(nameof(type));
  6372. if (eventName == null)
  6373. throw new ArgumentNullException(nameof(eventName));
  6374. if (scheduler == null)
  6375. throw new ArgumentNullException(nameof(scheduler));
  6376. return provider.CreateQuery<EventPattern<TSender, TEventArgs>>(
  6377. Expression.Call(
  6378. null,
  6379. #if CRIPPLED_REFLECTION
  6380. InfoOf(() => Qbservable.FromEventPattern<TSender, TEventArgs>(default(IQbservableProvider), default(Type), default(string), default(IScheduler))),
  6381. #else
  6382. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSender), typeof(TEventArgs)),
  6383. #endif
  6384. Expression.Constant(provider, typeof(IQbservableProvider)),
  6385. Expression.Constant(type, typeof(Type)),
  6386. Expression.Constant(eventName, typeof(string)),
  6387. Expression.Constant(scheduler, typeof(IScheduler))
  6388. )
  6389. );
  6390. }
  6391. /// <summary>
  6392. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements.
  6393. /// </summary>
  6394. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6395. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6396. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6397. /// <param name="initialState">Initial state.</param>
  6398. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6399. /// <param name="iterate">Iteration step function.</param>
  6400. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6401. /// <returns>The generated sequence.</returns>
  6402. /// <exception cref="ArgumentNullException">
  6403. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> is null.</exception>
  6404. 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)
  6405. {
  6406. if (provider == null)
  6407. throw new ArgumentNullException(nameof(provider));
  6408. if (condition == null)
  6409. throw new ArgumentNullException(nameof(condition));
  6410. if (iterate == null)
  6411. throw new ArgumentNullException(nameof(iterate));
  6412. if (resultSelector == null)
  6413. throw new ArgumentNullException(nameof(resultSelector));
  6414. return provider.CreateQuery<TResult>(
  6415. Expression.Call(
  6416. null,
  6417. #if CRIPPLED_REFLECTION
  6418. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>))),
  6419. #else
  6420. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6421. #endif
  6422. Expression.Constant(provider, typeof(IQbservableProvider)),
  6423. Expression.Constant(initialState, typeof(TState)),
  6424. condition,
  6425. iterate,
  6426. resultSelector
  6427. )
  6428. );
  6429. }
  6430. /// <summary>
  6431. /// Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler to send out observer messages.
  6432. /// </summary>
  6433. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6434. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6435. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6436. /// <param name="initialState">Initial state.</param>
  6437. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6438. /// <param name="iterate">Iteration step function.</param>
  6439. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6440. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6441. /// <returns>The generated sequence.</returns>
  6442. /// <exception cref="ArgumentNullException">
  6443. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6444. 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)
  6445. {
  6446. if (provider == null)
  6447. throw new ArgumentNullException(nameof(provider));
  6448. if (condition == null)
  6449. throw new ArgumentNullException(nameof(condition));
  6450. if (iterate == null)
  6451. throw new ArgumentNullException(nameof(iterate));
  6452. if (resultSelector == null)
  6453. throw new ArgumentNullException(nameof(resultSelector));
  6454. if (scheduler == null)
  6455. throw new ArgumentNullException(nameof(scheduler));
  6456. return provider.CreateQuery<TResult>(
  6457. Expression.Call(
  6458. null,
  6459. #if CRIPPLED_REFLECTION
  6460. 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))),
  6461. #else
  6462. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6463. #endif
  6464. Expression.Constant(provider, typeof(IQbservableProvider)),
  6465. Expression.Constant(initialState, typeof(TState)),
  6466. condition,
  6467. iterate,
  6468. resultSelector,
  6469. Expression.Constant(scheduler, typeof(IScheduler))
  6470. )
  6471. );
  6472. }
  6473. /// <summary>
  6474. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6475. /// </summary>
  6476. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6477. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6478. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6479. /// <param name="initialState">Initial state.</param>
  6480. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6481. /// <param name="iterate">Iteration step function.</param>
  6482. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6483. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6484. /// <returns>The generated sequence.</returns>
  6485. /// <exception cref="ArgumentNullException">
  6486. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6487. 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)
  6488. {
  6489. if (provider == null)
  6490. throw new ArgumentNullException(nameof(provider));
  6491. if (condition == null)
  6492. throw new ArgumentNullException(nameof(condition));
  6493. if (iterate == null)
  6494. throw new ArgumentNullException(nameof(iterate));
  6495. if (resultSelector == null)
  6496. throw new ArgumentNullException(nameof(resultSelector));
  6497. if (timeSelector == null)
  6498. throw new ArgumentNullException(nameof(timeSelector));
  6499. return provider.CreateQuery<TResult>(
  6500. Expression.Call(
  6501. null,
  6502. #if CRIPPLED_REFLECTION
  6503. InfoOf(() => Qbservable.Generate<TState, TResult>(default(IQbservableProvider), default(TState), default(Expression<Func<TState, bool>>), default(Expression<Func<TState, TState>>), default(Expression<Func<TState, TResult>>), default(Expression<Func<TState, TimeSpan>>))),
  6504. #else
  6505. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6506. #endif
  6507. Expression.Constant(provider, typeof(IQbservableProvider)),
  6508. Expression.Constant(initialState, typeof(TState)),
  6509. condition,
  6510. iterate,
  6511. resultSelector,
  6512. timeSelector
  6513. )
  6514. );
  6515. }
  6516. /// <summary>
  6517. /// Generates an observable sequence by running a state-driven and temporal loop producing the sequence's elements.
  6518. /// </summary>
  6519. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6520. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6521. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6522. /// <param name="initialState">Initial state.</param>
  6523. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6524. /// <param name="iterate">Iteration step function.</param>
  6525. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6526. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6527. /// <returns>The generated sequence.</returns>
  6528. /// <exception cref="ArgumentNullException">
  6529. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> is null.</exception>
  6530. 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)
  6531. {
  6532. if (provider == null)
  6533. throw new ArgumentNullException(nameof(provider));
  6534. if (condition == null)
  6535. throw new ArgumentNullException(nameof(condition));
  6536. if (iterate == null)
  6537. throw new ArgumentNullException(nameof(iterate));
  6538. if (resultSelector == null)
  6539. throw new ArgumentNullException(nameof(resultSelector));
  6540. if (timeSelector == null)
  6541. throw new ArgumentNullException(nameof(timeSelector));
  6542. return provider.CreateQuery<TResult>(
  6543. Expression.Call(
  6544. null,
  6545. #if CRIPPLED_REFLECTION
  6546. 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>>))),
  6547. #else
  6548. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6549. #endif
  6550. Expression.Constant(provider, typeof(IQbservableProvider)),
  6551. Expression.Constant(initialState, typeof(TState)),
  6552. condition,
  6553. iterate,
  6554. resultSelector,
  6555. timeSelector
  6556. )
  6557. );
  6558. }
  6559. /// <summary>
  6560. /// 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.
  6561. /// </summary>
  6562. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6563. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6564. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6565. /// <param name="initialState">Initial state.</param>
  6566. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6567. /// <param name="iterate">Iteration step function.</param>
  6568. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6569. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6570. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6571. /// <returns>The generated sequence.</returns>
  6572. /// <exception cref="ArgumentNullException">
  6573. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6574. public static IQbservable<TResult> Generate<TState, TResult>(this IQbservableProvider provider, TState initialState, Expression<Func<TState, bool>> condition, Expression<Func<TState, TState>> iterate, Expression<Func<TState, TResult>> resultSelector, Expression<Func<TState, TimeSpan>> timeSelector, IScheduler scheduler)
  6575. {
  6576. if (provider == null)
  6577. throw new ArgumentNullException(nameof(provider));
  6578. if (condition == null)
  6579. throw new ArgumentNullException(nameof(condition));
  6580. if (iterate == null)
  6581. throw new ArgumentNullException(nameof(iterate));
  6582. if (resultSelector == null)
  6583. throw new ArgumentNullException(nameof(resultSelector));
  6584. if (timeSelector == null)
  6585. throw new ArgumentNullException(nameof(timeSelector));
  6586. if (scheduler == null)
  6587. throw new ArgumentNullException(nameof(scheduler));
  6588. return provider.CreateQuery<TResult>(
  6589. Expression.Call(
  6590. null,
  6591. #if CRIPPLED_REFLECTION
  6592. 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))),
  6593. #else
  6594. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6595. #endif
  6596. Expression.Constant(provider, typeof(IQbservableProvider)),
  6597. Expression.Constant(initialState, typeof(TState)),
  6598. condition,
  6599. iterate,
  6600. resultSelector,
  6601. timeSelector,
  6602. Expression.Constant(scheduler, typeof(IScheduler))
  6603. )
  6604. );
  6605. }
  6606. /// <summary>
  6607. /// 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.
  6608. /// </summary>
  6609. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  6610. /// <typeparam name="TState">The type of the state used in the generator loop.</typeparam>
  6611. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  6612. /// <param name="initialState">Initial state.</param>
  6613. /// <param name="condition">Condition to terminate generation (upon returning false).</param>
  6614. /// <param name="iterate">Iteration step function.</param>
  6615. /// <param name="resultSelector">Selector function for results produced in the sequence.</param>
  6616. /// <param name="timeSelector">Time selector function to control the speed of values being produced each iteration.</param>
  6617. /// <param name="scheduler">Scheduler on which to run the generator loop.</param>
  6618. /// <returns>The generated sequence.</returns>
  6619. /// <exception cref="ArgumentNullException">
  6620. /// <paramref name="condition" /> or <paramref name="iterate" /> or <paramref name="resultSelector" /> or <paramref name="timeSelector" /> or <paramref name="scheduler" /> is null.</exception>
  6621. 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)
  6622. {
  6623. if (provider == null)
  6624. throw new ArgumentNullException(nameof(provider));
  6625. if (condition == null)
  6626. throw new ArgumentNullException(nameof(condition));
  6627. if (iterate == null)
  6628. throw new ArgumentNullException(nameof(iterate));
  6629. if (resultSelector == null)
  6630. throw new ArgumentNullException(nameof(resultSelector));
  6631. if (timeSelector == null)
  6632. throw new ArgumentNullException(nameof(timeSelector));
  6633. if (scheduler == null)
  6634. throw new ArgumentNullException(nameof(scheduler));
  6635. return provider.CreateQuery<TResult>(
  6636. Expression.Call(
  6637. null,
  6638. #if CRIPPLED_REFLECTION
  6639. 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))),
  6640. #else
  6641. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TState), typeof(TResult)),
  6642. #endif
  6643. Expression.Constant(provider, typeof(IQbservableProvider)),
  6644. Expression.Constant(initialState, typeof(TState)),
  6645. condition,
  6646. iterate,
  6647. resultSelector,
  6648. timeSelector,
  6649. Expression.Constant(scheduler, typeof(IScheduler))
  6650. )
  6651. );
  6652. }
  6653. /// <summary>
  6654. /// Groups the elements of an observable sequence according to a specified key selector function.
  6655. /// </summary>
  6656. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6657. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6658. /// <param name="source">An observable sequence whose elements to group.</param>
  6659. /// <param name="keySelector">A function to extract the key for each element.</param>
  6660. /// <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>
  6661. /// <exception cref="ArgumentNullException">
  6662. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  6663. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  6664. {
  6665. if (source == null)
  6666. throw new ArgumentNullException(nameof(source));
  6667. if (keySelector == null)
  6668. throw new ArgumentNullException(nameof(keySelector));
  6669. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6670. Expression.Call(
  6671. null,
  6672. #if CRIPPLED_REFLECTION
  6673. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  6674. #else
  6675. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6676. #endif
  6677. source.Expression,
  6678. keySelector
  6679. )
  6680. );
  6681. }
  6682. /// <summary>
  6683. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  6684. /// </summary>
  6685. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6686. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6687. /// <param name="source">An observable sequence whose elements to group.</param>
  6688. /// <param name="keySelector">A function to extract the key for each element.</param>
  6689. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6690. /// <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>
  6691. /// <exception cref="ArgumentNullException">
  6692. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  6693. /// <exception cref="ArgumentOutOfRangeException">
  6694. /// <paramref name="capacity" /> is less than 0.</exception>
  6695. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity)
  6696. {
  6697. if (source == null)
  6698. throw new ArgumentNullException(nameof(source));
  6699. if (keySelector == null)
  6700. throw new ArgumentNullException(nameof(keySelector));
  6701. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6702. Expression.Call(
  6703. null,
  6704. #if CRIPPLED_REFLECTION
  6705. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int))),
  6706. #else
  6707. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6708. #endif
  6709. source.Expression,
  6710. keySelector,
  6711. Expression.Constant(capacity, typeof(int))
  6712. )
  6713. );
  6714. }
  6715. /// <summary>
  6716. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  6717. /// </summary>
  6718. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6719. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6720. /// <param name="source">An observable sequence whose elements to group.</param>
  6721. /// <param name="keySelector">A function to extract the key for each element.</param>
  6722. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6723. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6724. /// <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>
  6725. /// <exception cref="ArgumentNullException">
  6726. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  6727. /// <exception cref="ArgumentOutOfRangeException">
  6728. /// <paramref name="capacity" /> is less than 0.</exception>
  6729. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, int capacity, IEqualityComparer<TKey> comparer)
  6730. {
  6731. if (source == null)
  6732. throw new ArgumentNullException(nameof(source));
  6733. if (keySelector == null)
  6734. throw new ArgumentNullException(nameof(keySelector));
  6735. if (comparer == null)
  6736. throw new ArgumentNullException(nameof(comparer));
  6737. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6738. Expression.Call(
  6739. null,
  6740. #if CRIPPLED_REFLECTION
  6741. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(int), default(IEqualityComparer<TKey>))),
  6742. #else
  6743. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6744. #endif
  6745. source.Expression,
  6746. keySelector,
  6747. Expression.Constant(capacity, typeof(int)),
  6748. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6749. )
  6750. );
  6751. }
  6752. /// <summary>
  6753. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  6754. /// </summary>
  6755. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6756. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6757. /// <param name="source">An observable sequence whose elements to group.</param>
  6758. /// <param name="keySelector">A function to extract the key for each element.</param>
  6759. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6760. /// <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>
  6761. /// <exception cref="ArgumentNullException">
  6762. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  6763. public static IQbservable<IGroupedObservable<TKey, TSource>> GroupBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  6764. {
  6765. if (source == null)
  6766. throw new ArgumentNullException(nameof(source));
  6767. if (keySelector == null)
  6768. throw new ArgumentNullException(nameof(keySelector));
  6769. if (comparer == null)
  6770. throw new ArgumentNullException(nameof(comparer));
  6771. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6772. Expression.Call(
  6773. null,
  6774. #if CRIPPLED_REFLECTION
  6775. InfoOf(() => Qbservable.GroupBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  6776. #else
  6777. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  6778. #endif
  6779. source.Expression,
  6780. keySelector,
  6781. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6782. )
  6783. );
  6784. }
  6785. /// <summary>
  6786. /// Groups the elements of an observable sequence and selects the resulting elements by using a specified function.
  6787. /// </summary>
  6788. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6789. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6790. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6791. /// <param name="source">An observable sequence whose elements to group.</param>
  6792. /// <param name="keySelector">A function to extract the key for each element.</param>
  6793. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6794. /// <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>
  6795. /// <exception cref="ArgumentNullException">
  6796. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  6797. public static IQbservable<IGroupedObservable<TKey, TElement>> GroupBy<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  6798. {
  6799. if (source == null)
  6800. throw new ArgumentNullException(nameof(source));
  6801. if (keySelector == null)
  6802. throw new ArgumentNullException(nameof(keySelector));
  6803. if (elementSelector == null)
  6804. throw new ArgumentNullException(nameof(elementSelector));
  6805. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6806. Expression.Call(
  6807. null,
  6808. #if CRIPPLED_REFLECTION
  6809. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  6810. #else
  6811. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6812. #endif
  6813. source.Expression,
  6814. keySelector,
  6815. elementSelector
  6816. )
  6817. );
  6818. }
  6819. /// <summary>
  6820. /// Groups the elements of an observable sequence with the specified initial capacity and selects the resulting elements by using a specified function.
  6821. /// </summary>
  6822. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6823. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6824. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6825. /// <param name="source">An observable sequence whose elements to group.</param>
  6826. /// <param name="keySelector">A function to extract the key for each element.</param>
  6827. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6828. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6829. /// <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>
  6830. /// <exception cref="ArgumentNullException">
  6831. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  6832. /// <exception cref="ArgumentOutOfRangeException">
  6833. /// <paramref name="capacity" /> is less than 0.</exception>
  6834. 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)
  6835. {
  6836. if (source == null)
  6837. throw new ArgumentNullException(nameof(source));
  6838. if (keySelector == null)
  6839. throw new ArgumentNullException(nameof(keySelector));
  6840. if (elementSelector == null)
  6841. throw new ArgumentNullException(nameof(elementSelector));
  6842. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6843. Expression.Call(
  6844. null,
  6845. #if CRIPPLED_REFLECTION
  6846. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int))),
  6847. #else
  6848. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6849. #endif
  6850. source.Expression,
  6851. keySelector,
  6852. elementSelector,
  6853. Expression.Constant(capacity, typeof(int))
  6854. )
  6855. );
  6856. }
  6857. /// <summary>
  6858. /// 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.
  6859. /// </summary>
  6860. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6861. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6862. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6863. /// <param name="source">An observable sequence whose elements to group.</param>
  6864. /// <param name="keySelector">A function to extract the key for each element.</param>
  6865. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6866. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6867. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6868. /// <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>
  6869. /// <exception cref="ArgumentNullException">
  6870. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  6871. /// <exception cref="ArgumentOutOfRangeException">
  6872. /// <paramref name="capacity" /> is less than 0.</exception>
  6873. 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)
  6874. {
  6875. if (source == null)
  6876. throw new ArgumentNullException(nameof(source));
  6877. if (keySelector == null)
  6878. throw new ArgumentNullException(nameof(keySelector));
  6879. if (elementSelector == null)
  6880. throw new ArgumentNullException(nameof(elementSelector));
  6881. if (comparer == null)
  6882. throw new ArgumentNullException(nameof(comparer));
  6883. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6884. Expression.Call(
  6885. null,
  6886. #if CRIPPLED_REFLECTION
  6887. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(int), default(IEqualityComparer<TKey>))),
  6888. #else
  6889. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6890. #endif
  6891. source.Expression,
  6892. keySelector,
  6893. elementSelector,
  6894. Expression.Constant(capacity, typeof(int)),
  6895. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6896. )
  6897. );
  6898. }
  6899. /// <summary>
  6900. /// 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.
  6901. /// </summary>
  6902. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6903. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6904. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  6905. /// <param name="source">An observable sequence whose elements to group.</param>
  6906. /// <param name="keySelector">A function to extract the key for each element.</param>
  6907. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  6908. /// <param name="comparer">An equality comparer to compare keys with.</param>
  6909. /// <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>
  6910. /// <exception cref="ArgumentNullException">
  6911. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  6912. 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)
  6913. {
  6914. if (source == null)
  6915. throw new ArgumentNullException(nameof(source));
  6916. if (keySelector == null)
  6917. throw new ArgumentNullException(nameof(keySelector));
  6918. if (elementSelector == null)
  6919. throw new ArgumentNullException(nameof(elementSelector));
  6920. if (comparer == null)
  6921. throw new ArgumentNullException(nameof(comparer));
  6922. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  6923. Expression.Call(
  6924. null,
  6925. #if CRIPPLED_REFLECTION
  6926. InfoOf(() => Qbservable.GroupBy<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  6927. #else
  6928. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  6929. #endif
  6930. source.Expression,
  6931. keySelector,
  6932. elementSelector,
  6933. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  6934. )
  6935. );
  6936. }
  6937. /// <summary>
  6938. /// Groups the elements of an observable sequence according to a specified key selector function.
  6939. /// 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
  6940. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  6941. /// </summary>
  6942. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6943. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6944. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  6945. /// <param name="source">An observable sequence whose elements to group.</param>
  6946. /// <param name="keySelector">A function to extract the key for each element.</param>
  6947. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  6948. /// <returns>
  6949. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  6950. /// 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 encoutered.
  6951. /// </returns>
  6952. /// <exception cref="ArgumentNullException">
  6953. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  6954. 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)
  6955. {
  6956. if (source == null)
  6957. throw new ArgumentNullException(nameof(source));
  6958. if (keySelector == null)
  6959. throw new ArgumentNullException(nameof(keySelector));
  6960. if (durationSelector == null)
  6961. throw new ArgumentNullException(nameof(durationSelector));
  6962. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  6963. Expression.Call(
  6964. null,
  6965. #if CRIPPLED_REFLECTION
  6966. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>))),
  6967. #else
  6968. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  6969. #endif
  6970. source.Expression,
  6971. keySelector,
  6972. durationSelector
  6973. )
  6974. );
  6975. }
  6976. /// <summary>
  6977. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function.
  6978. /// 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
  6979. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  6980. /// </summary>
  6981. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  6982. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  6983. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  6984. /// <param name="source">An observable sequence whose elements to group.</param>
  6985. /// <param name="keySelector">A function to extract the key for each element.</param>
  6986. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  6987. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  6988. /// <returns>
  6989. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  6990. /// 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 encoutered.
  6991. /// </returns>
  6992. /// <exception cref="ArgumentNullException">
  6993. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> is null.</exception>
  6994. /// <exception cref="ArgumentOutOfRangeException">
  6995. /// <paramref name="capacity" /> is less than 0.</exception>
  6996. 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)
  6997. {
  6998. if (source == null)
  6999. throw new ArgumentNullException(nameof(source));
  7000. if (keySelector == null)
  7001. throw new ArgumentNullException(nameof(keySelector));
  7002. if (durationSelector == null)
  7003. throw new ArgumentNullException(nameof(durationSelector));
  7004. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7005. Expression.Call(
  7006. null,
  7007. #if CRIPPLED_REFLECTION
  7008. InfoOf(() => Qbservable.GroupByUntil<TSource, TKey, TDuration>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<IGroupedObservable<TKey, TSource>, IObservable<TDuration>>>), default(int))),
  7009. #else
  7010. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7011. #endif
  7012. source.Expression,
  7013. keySelector,
  7014. durationSelector,
  7015. Expression.Constant(capacity, typeof(int))
  7016. )
  7017. );
  7018. }
  7019. /// <summary>
  7020. /// Groups the elements of an observable sequence with the specified initial capacity according to a specified key selector function and comparer.
  7021. /// 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
  7022. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7023. /// </summary>
  7024. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7025. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7026. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7027. /// <param name="source">An observable sequence whose elements to group.</param>
  7028. /// <param name="keySelector">A function to extract the key for each element.</param>
  7029. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7030. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7031. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7032. /// <returns>
  7033. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7034. /// 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 encoutered.
  7035. /// </returns>
  7036. /// <exception cref="ArgumentNullException">
  7037. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7038. /// <exception cref="ArgumentOutOfRangeException">
  7039. /// <paramref name="capacity" /> is less than 0.</exception>
  7040. 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)
  7041. {
  7042. if (source == null)
  7043. throw new ArgumentNullException(nameof(source));
  7044. if (keySelector == null)
  7045. throw new ArgumentNullException(nameof(keySelector));
  7046. if (durationSelector == null)
  7047. throw new ArgumentNullException(nameof(durationSelector));
  7048. if (comparer == null)
  7049. throw new ArgumentNullException(nameof(comparer));
  7050. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7051. Expression.Call(
  7052. null,
  7053. #if CRIPPLED_REFLECTION
  7054. 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>))),
  7055. #else
  7056. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7057. #endif
  7058. source.Expression,
  7059. keySelector,
  7060. durationSelector,
  7061. Expression.Constant(capacity, typeof(int)),
  7062. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7063. )
  7064. );
  7065. }
  7066. /// <summary>
  7067. /// Groups the elements of an observable sequence according to a specified key selector function and comparer.
  7068. /// 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
  7069. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7070. /// </summary>
  7071. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7072. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7073. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7074. /// <param name="source">An observable sequence whose elements to group.</param>
  7075. /// <param name="keySelector">A function to extract the key for each element.</param>
  7076. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7077. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7078. /// <returns>
  7079. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7080. /// 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 encoutered.
  7081. /// </returns>
  7082. /// <exception cref="ArgumentNullException">
  7083. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7084. 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)
  7085. {
  7086. if (source == null)
  7087. throw new ArgumentNullException(nameof(source));
  7088. if (keySelector == null)
  7089. throw new ArgumentNullException(nameof(keySelector));
  7090. if (durationSelector == null)
  7091. throw new ArgumentNullException(nameof(durationSelector));
  7092. if (comparer == null)
  7093. throw new ArgumentNullException(nameof(comparer));
  7094. return source.Provider.CreateQuery<IGroupedObservable<TKey, TSource>>(
  7095. Expression.Call(
  7096. null,
  7097. #if CRIPPLED_REFLECTION
  7098. 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>))),
  7099. #else
  7100. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TDuration)),
  7101. #endif
  7102. source.Expression,
  7103. keySelector,
  7104. durationSelector,
  7105. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7106. )
  7107. );
  7108. }
  7109. /// <summary>
  7110. /// Groups the elements of an observable sequence according to a specified key selector function and selects the resulting elements by using a specified function.
  7111. /// 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
  7112. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7113. /// </summary>
  7114. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7115. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7116. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7117. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7118. /// <param name="source">An observable sequence whose elements to group.</param>
  7119. /// <param name="keySelector">A function to extract the key for each element.</param>
  7120. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7121. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7122. /// <returns>
  7123. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7124. /// 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 encoutered.
  7125. /// </returns>
  7126. /// <exception cref="ArgumentNullException">
  7127. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7128. 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)
  7129. {
  7130. if (source == null)
  7131. throw new ArgumentNullException(nameof(source));
  7132. if (keySelector == null)
  7133. throw new ArgumentNullException(nameof(keySelector));
  7134. if (elementSelector == null)
  7135. throw new ArgumentNullException(nameof(elementSelector));
  7136. if (durationSelector == null)
  7137. throw new ArgumentNullException(nameof(durationSelector));
  7138. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7139. Expression.Call(
  7140. null,
  7141. #if CRIPPLED_REFLECTION
  7142. 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>>>))),
  7143. #else
  7144. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7145. #endif
  7146. source.Expression,
  7147. keySelector,
  7148. elementSelector,
  7149. durationSelector
  7150. )
  7151. );
  7152. }
  7153. /// <summary>
  7154. /// 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.
  7155. /// A duration selector function is used to control the lifetime of groups. When a group expires, it receives an OnCompleted notification. When a new element with the same
  7156. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7157. /// </summary>
  7158. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7159. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7160. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7161. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7162. /// <param name="source">An observable sequence whose elements to group.</param>
  7163. /// <param name="keySelector">A function to extract the key for each element.</param>
  7164. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7165. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7166. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7167. /// <returns>
  7168. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7169. /// 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 encoutered.
  7170. /// </returns>
  7171. /// <exception cref="ArgumentNullException">
  7172. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> is null.</exception>
  7173. /// <exception cref="ArgumentOutOfRangeException">
  7174. /// <paramref name="capacity" /> is less than 0.</exception>
  7175. 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)
  7176. {
  7177. if (source == null)
  7178. throw new ArgumentNullException(nameof(source));
  7179. if (keySelector == null)
  7180. throw new ArgumentNullException(nameof(keySelector));
  7181. if (elementSelector == null)
  7182. throw new ArgumentNullException(nameof(elementSelector));
  7183. if (durationSelector == null)
  7184. throw new ArgumentNullException(nameof(durationSelector));
  7185. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7186. Expression.Call(
  7187. null,
  7188. #if CRIPPLED_REFLECTION
  7189. 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))),
  7190. #else
  7191. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7192. #endif
  7193. source.Expression,
  7194. keySelector,
  7195. elementSelector,
  7196. durationSelector,
  7197. Expression.Constant(capacity, typeof(int))
  7198. )
  7199. );
  7200. }
  7201. /// <summary>
  7202. /// 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.
  7203. /// 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
  7204. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7205. /// </summary>
  7206. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7207. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7208. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7209. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7210. /// <param name="source">An observable sequence whose elements to group.</param>
  7211. /// <param name="keySelector">A function to extract the key for each element.</param>
  7212. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7213. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7214. /// <param name="capacity">The initial number of elements that the underlying dictionary can contain.</param>
  7215. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7216. /// <returns>
  7217. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7218. /// 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.
  7219. /// </returns>
  7220. /// <exception cref="ArgumentNullException">
  7221. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7222. /// <exception cref="ArgumentOutOfRangeException">
  7223. /// <paramref name="capacity" /> is less than 0.</exception>
  7224. 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)
  7225. {
  7226. if (source == null)
  7227. throw new ArgumentNullException(nameof(source));
  7228. if (keySelector == null)
  7229. throw new ArgumentNullException(nameof(keySelector));
  7230. if (elementSelector == null)
  7231. throw new ArgumentNullException(nameof(elementSelector));
  7232. if (durationSelector == null)
  7233. throw new ArgumentNullException(nameof(durationSelector));
  7234. if (comparer == null)
  7235. throw new ArgumentNullException(nameof(comparer));
  7236. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7237. Expression.Call(
  7238. null,
  7239. #if CRIPPLED_REFLECTION
  7240. 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>))),
  7241. #else
  7242. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7243. #endif
  7244. source.Expression,
  7245. keySelector,
  7246. elementSelector,
  7247. durationSelector,
  7248. Expression.Constant(capacity, typeof(int)),
  7249. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7250. )
  7251. );
  7252. }
  7253. /// <summary>
  7254. /// 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.
  7255. /// 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
  7256. /// key value as a reclaimed group occurs, the group will be reborn with a new lifetime request.
  7257. /// </summary>
  7258. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7259. /// <typeparam name="TKey">The type of the grouping key computed for each element in the source sequence.</typeparam>
  7260. /// <typeparam name="TElement">The type of the elements within the groups computed for each element in the source sequence.</typeparam>
  7261. /// <typeparam name="TDuration">The type of the elements in the duration sequences obtained for each group to denote its lifetime.</typeparam>
  7262. /// <param name="source">An observable sequence whose elements to group.</param>
  7263. /// <param name="keySelector">A function to extract the key for each element.</param>
  7264. /// <param name="elementSelector">A function to map each source element to an element in an observable group.</param>
  7265. /// <param name="durationSelector">A function to signal the expiration of a group.</param>
  7266. /// <param name="comparer">An equality comparer to compare keys with.</param>
  7267. /// <returns>
  7268. /// A sequence of observable groups, each of which corresponds to a unique key value, containing all elements that share that same key value.
  7269. /// 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.
  7270. /// </returns>
  7271. /// <exception cref="ArgumentNullException">
  7272. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="durationSelector" /> or <paramref name="comparer" /> is null.</exception>
  7273. 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)
  7274. {
  7275. if (source == null)
  7276. throw new ArgumentNullException(nameof(source));
  7277. if (keySelector == null)
  7278. throw new ArgumentNullException(nameof(keySelector));
  7279. if (elementSelector == null)
  7280. throw new ArgumentNullException(nameof(elementSelector));
  7281. if (durationSelector == null)
  7282. throw new ArgumentNullException(nameof(durationSelector));
  7283. if (comparer == null)
  7284. throw new ArgumentNullException(nameof(comparer));
  7285. return source.Provider.CreateQuery<IGroupedObservable<TKey, TElement>>(
  7286. Expression.Call(
  7287. null,
  7288. #if CRIPPLED_REFLECTION
  7289. 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>))),
  7290. #else
  7291. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement), typeof(TDuration)),
  7292. #endif
  7293. source.Expression,
  7294. keySelector,
  7295. elementSelector,
  7296. durationSelector,
  7297. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  7298. )
  7299. );
  7300. }
  7301. /// <summary>
  7302. /// Correlates the elements of two sequences based on overlapping durations, and groups the results.
  7303. /// </summary>
  7304. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7305. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7306. /// <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>
  7307. /// <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>
  7308. /// <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>
  7309. /// <param name="left">The left observable sequence to join elements for.</param>
  7310. /// <param name="right">The right observable sequence to join elements for.</param>
  7311. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7312. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7313. /// <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>
  7314. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7315. /// <exception cref="ArgumentNullException">
  7316. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7317. 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)
  7318. {
  7319. if (left == null)
  7320. throw new ArgumentNullException(nameof(left));
  7321. if (right == null)
  7322. throw new ArgumentNullException(nameof(right));
  7323. if (leftDurationSelector == null)
  7324. throw new ArgumentNullException(nameof(leftDurationSelector));
  7325. if (rightDurationSelector == null)
  7326. throw new ArgumentNullException(nameof(rightDurationSelector));
  7327. if (resultSelector == null)
  7328. throw new ArgumentNullException(nameof(resultSelector));
  7329. return left.Provider.CreateQuery<TResult>(
  7330. Expression.Call(
  7331. null,
  7332. #if CRIPPLED_REFLECTION
  7333. 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>>))),
  7334. #else
  7335. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7336. #endif
  7337. left.Expression,
  7338. GetSourceExpression(right),
  7339. leftDurationSelector,
  7340. rightDurationSelector,
  7341. resultSelector
  7342. )
  7343. );
  7344. }
  7345. /// <summary>
  7346. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence.
  7347. /// </summary>
  7348. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7349. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7350. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7351. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7352. /// <returns>
  7353. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7354. /// <exception cref="ArgumentNullException">
  7355. /// <paramref name="condition" /> or <paramref name="thenSource" /> is null.</exception>
  7356. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource)
  7357. {
  7358. if (provider == null)
  7359. throw new ArgumentNullException(nameof(provider));
  7360. if (condition == null)
  7361. throw new ArgumentNullException(nameof(condition));
  7362. if (thenSource == null)
  7363. throw new ArgumentNullException(nameof(thenSource));
  7364. return provider.CreateQuery<TResult>(
  7365. Expression.Call(
  7366. null,
  7367. #if CRIPPLED_REFLECTION
  7368. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>))),
  7369. #else
  7370. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7371. #endif
  7372. Expression.Constant(provider, typeof(IQbservableProvider)),
  7373. condition,
  7374. GetSourceExpression(thenSource)
  7375. )
  7376. );
  7377. }
  7378. /// <summary>
  7379. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, select the <paramref name="elseSource" /> sequence.
  7380. /// </summary>
  7381. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7382. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7383. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7384. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7385. /// <param name="elseSource">Sequence returned in case <paramref name="condition" /> evaluates false.</param>
  7386. /// <returns>
  7387. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; <paramref name="elseSource" /> otherwise.</returns>
  7388. /// <exception cref="ArgumentNullException">
  7389. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="elseSource" /> is null.</exception>
  7390. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IObservable<TResult> elseSource)
  7391. {
  7392. if (provider == null)
  7393. throw new ArgumentNullException(nameof(provider));
  7394. if (condition == null)
  7395. throw new ArgumentNullException(nameof(condition));
  7396. if (thenSource == null)
  7397. throw new ArgumentNullException(nameof(thenSource));
  7398. if (elseSource == null)
  7399. throw new ArgumentNullException(nameof(elseSource));
  7400. return provider.CreateQuery<TResult>(
  7401. Expression.Call(
  7402. null,
  7403. #if CRIPPLED_REFLECTION
  7404. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IObservable<TResult>))),
  7405. #else
  7406. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7407. #endif
  7408. Expression.Constant(provider, typeof(IQbservableProvider)),
  7409. condition,
  7410. GetSourceExpression(thenSource),
  7411. GetSourceExpression(elseSource)
  7412. )
  7413. );
  7414. }
  7415. /// <summary>
  7416. /// If the specified <paramref name="condition" /> evaluates true, select the <paramref name="thenSource" /> sequence. Otherwise, return an empty sequence generated on the specified scheduler.
  7417. /// </summary>
  7418. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7419. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  7420. /// <param name="condition">Condition evaluated to decide which sequence to return.</param>
  7421. /// <param name="thenSource">Sequence returned in case <paramref name="condition" /> evaluates true.</param>
  7422. /// <param name="scheduler">Scheduler to generate an empty sequence on in case <paramref name="condition" /> evaluates false.</param>
  7423. /// <returns>
  7424. /// <paramref name="thenSource" /> if <paramref name="condition" /> evaluates true; an empty sequence otherwise.</returns>
  7425. /// <exception cref="ArgumentNullException">
  7426. /// <paramref name="condition" /> or <paramref name="thenSource" /> or <paramref name="scheduler" /> is null.</exception>
  7427. public static IQbservable<TResult> If<TResult>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TResult> thenSource, IScheduler scheduler)
  7428. {
  7429. if (provider == null)
  7430. throw new ArgumentNullException(nameof(provider));
  7431. if (condition == null)
  7432. throw new ArgumentNullException(nameof(condition));
  7433. if (thenSource == null)
  7434. throw new ArgumentNullException(nameof(thenSource));
  7435. if (scheduler == null)
  7436. throw new ArgumentNullException(nameof(scheduler));
  7437. return provider.CreateQuery<TResult>(
  7438. Expression.Call(
  7439. null,
  7440. #if CRIPPLED_REFLECTION
  7441. InfoOf(() => Qbservable.If<TResult>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TResult>), default(IScheduler))),
  7442. #else
  7443. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  7444. #endif
  7445. Expression.Constant(provider, typeof(IQbservableProvider)),
  7446. condition,
  7447. GetSourceExpression(thenSource),
  7448. Expression.Constant(scheduler, typeof(IScheduler))
  7449. )
  7450. );
  7451. }
  7452. /// <summary>
  7453. /// Ignores all elements in an observable sequence leaving only the termination messages.
  7454. /// </summary>
  7455. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7456. /// <param name="source">Source sequence.</param>
  7457. /// <returns>An empty observable sequence that signals termination, successful or exceptional, of the source sequence.</returns>
  7458. /// <exception cref="ArgumentNullException">
  7459. /// <paramref name="source" /> is null.</exception>
  7460. public static IQbservable<TSource> IgnoreElements<TSource>(this IQbservable<TSource> source)
  7461. {
  7462. if (source == null)
  7463. throw new ArgumentNullException(nameof(source));
  7464. return source.Provider.CreateQuery<TSource>(
  7465. Expression.Call(
  7466. null,
  7467. #if CRIPPLED_REFLECTION
  7468. InfoOf(() => Qbservable.IgnoreElements<TSource>(default(IQbservable<TSource>))),
  7469. #else
  7470. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7471. #endif
  7472. source.Expression
  7473. )
  7474. );
  7475. }
  7476. /// <summary>
  7477. /// Returns an observable sequence that produces a value after each period.
  7478. /// </summary>
  7479. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7480. /// <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>
  7481. /// <returns>An observable sequence that produces a value after each period.</returns>
  7482. /// <exception cref="ArgumentOutOfRangeException">
  7483. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7484. /// <remarks>
  7485. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7486. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7487. /// 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
  7488. /// <see cref="Observable.Generate{T, R}(T,Func{T,Boolean},Func{T,T},Func{T,R},Func{T,TimeSpan})" /> operator instead.
  7489. /// </remarks>
  7490. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period)
  7491. {
  7492. if (provider == null)
  7493. throw new ArgumentNullException(nameof(provider));
  7494. return provider.CreateQuery<long>(
  7495. Expression.Call(
  7496. null,
  7497. #if CRIPPLED_REFLECTION
  7498. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan))),
  7499. #else
  7500. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7501. #endif
  7502. Expression.Constant(provider, typeof(IQbservableProvider)),
  7503. Expression.Constant(period, typeof(TimeSpan))
  7504. )
  7505. );
  7506. }
  7507. /// <summary>
  7508. /// Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages.
  7509. /// </summary>
  7510. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  7511. /// <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>
  7512. /// <param name="scheduler">Scheduler to run the timer on.</param>
  7513. /// <returns>An observable sequence that produces a value after each period.</returns>
  7514. /// <exception cref="ArgumentOutOfRangeException">
  7515. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  7516. /// <exception cref="ArgumentNullException">
  7517. /// <paramref name="scheduler" /> is null.</exception>
  7518. /// <remarks>
  7519. /// Intervals are measured between the start of subsequent notifications, not between the end of the previous and the start of the next notification.
  7520. /// If the observer takes longer than the interval period to handle the message, the subsequent notification will be delivered immediately after the
  7521. /// 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
  7522. /// <see cref="Observable.Generate{T, R}(T,Func{T,Boolean},Func{T,T},Func{T,R},Func{T,TimeSpan},IScheduler)" /> operator instead.
  7523. /// </remarks>
  7524. public static IQbservable<long> Interval(this IQbservableProvider provider, TimeSpan period, IScheduler scheduler)
  7525. {
  7526. if (provider == null)
  7527. throw new ArgumentNullException(nameof(provider));
  7528. if (scheduler == null)
  7529. throw new ArgumentNullException(nameof(scheduler));
  7530. return provider.CreateQuery<long>(
  7531. Expression.Call(
  7532. null,
  7533. #if CRIPPLED_REFLECTION
  7534. InfoOf(() => Qbservable.Interval(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  7535. #else
  7536. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7537. #endif
  7538. Expression.Constant(provider, typeof(IQbservableProvider)),
  7539. Expression.Constant(period, typeof(TimeSpan)),
  7540. Expression.Constant(scheduler, typeof(IScheduler))
  7541. )
  7542. );
  7543. }
  7544. /// <summary>
  7545. /// Determines whether an observable sequence is empty.
  7546. /// </summary>
  7547. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7548. /// <param name="source">An observable sequence to check for emptiness.</param>
  7549. /// <returns>An observable sequence containing a single element determining whether the source sequence is empty.</returns>
  7550. /// <exception cref="ArgumentNullException">
  7551. /// <paramref name="source" /> is null.</exception>
  7552. public static IQbservable<bool> IsEmpty<TSource>(this IQbservable<TSource> source)
  7553. {
  7554. if (source == null)
  7555. throw new ArgumentNullException(nameof(source));
  7556. return source.Provider.CreateQuery<bool>(
  7557. Expression.Call(
  7558. null,
  7559. #if CRIPPLED_REFLECTION
  7560. InfoOf(() => Qbservable.IsEmpty<TSource>(default(IQbservable<TSource>))),
  7561. #else
  7562. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7563. #endif
  7564. source.Expression
  7565. )
  7566. );
  7567. }
  7568. /// <summary>
  7569. /// Correlates the elements of two sequences based on overlapping durations.
  7570. /// </summary>
  7571. /// <typeparam name="TLeft">The type of the elements in the left source sequence.</typeparam>
  7572. /// <typeparam name="TRight">The type of the elements in the right source sequence.</typeparam>
  7573. /// <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>
  7574. /// <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>
  7575. /// <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>
  7576. /// <param name="left">The left observable sequence to join elements for.</param>
  7577. /// <param name="right">The right observable sequence to join elements for.</param>
  7578. /// <param name="leftDurationSelector">A function to select the duration of each element of the left observable sequence, used to determine overlap.</param>
  7579. /// <param name="rightDurationSelector">A function to select the duration of each element of the right observable sequence, used to determine overlap.</param>
  7580. /// <param name="resultSelector">A function invoked to compute a result element for any two overlapping elements of the left and right observable sequences.</param>
  7581. /// <returns>An observable sequence that contains result elements computed from source elements that have an overlapping duration.</returns>
  7582. /// <exception cref="ArgumentNullException">
  7583. /// <paramref name="left" /> or <paramref name="right" /> or <paramref name="leftDurationSelector" /> or <paramref name="rightDurationSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  7584. 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)
  7585. {
  7586. if (left == null)
  7587. throw new ArgumentNullException(nameof(left));
  7588. if (right == null)
  7589. throw new ArgumentNullException(nameof(right));
  7590. if (leftDurationSelector == null)
  7591. throw new ArgumentNullException(nameof(leftDurationSelector));
  7592. if (rightDurationSelector == null)
  7593. throw new ArgumentNullException(nameof(rightDurationSelector));
  7594. if (resultSelector == null)
  7595. throw new ArgumentNullException(nameof(resultSelector));
  7596. return left.Provider.CreateQuery<TResult>(
  7597. Expression.Call(
  7598. null,
  7599. #if CRIPPLED_REFLECTION
  7600. 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>>))),
  7601. #else
  7602. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TLeft), typeof(TRight), typeof(TLeftDuration), typeof(TRightDuration), typeof(TResult)),
  7603. #endif
  7604. left.Expression,
  7605. GetSourceExpression(right),
  7606. leftDurationSelector,
  7607. rightDurationSelector,
  7608. resultSelector
  7609. )
  7610. );
  7611. }
  7612. /// <summary>
  7613. /// Returns the last element of an observable sequence.
  7614. /// </summary>
  7615. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7616. /// <param name="source">Source observable sequence.</param>
  7617. /// <returns>Sequence containing the last element in the observable sequence.</returns>
  7618. /// <exception cref="ArgumentNullException">
  7619. /// <paramref name="source" /> is null.</exception>
  7620. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence is empty.</exception>
  7621. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source)
  7622. {
  7623. if (source == null)
  7624. throw new ArgumentNullException(nameof(source));
  7625. return source.Provider.CreateQuery<TSource>(
  7626. Expression.Call(
  7627. null,
  7628. #if CRIPPLED_REFLECTION
  7629. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>))),
  7630. #else
  7631. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7632. #endif
  7633. source.Expression
  7634. )
  7635. );
  7636. }
  7637. /// <summary>
  7638. /// Returns the last element of an observable sequence that satisfies the condition in the predicate.
  7639. /// </summary>
  7640. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7641. /// <param name="source">Source observable sequence.</param>
  7642. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7643. /// <returns>Sequence containing the last element in the observable sequence that satisfies the condition in the predicate.</returns>
  7644. /// <exception cref="ArgumentNullException">
  7645. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7646. /// <exception cref="InvalidOperationException">(Asynchronous) No element satisfies the condition in the predicate. -or- The source sequence is empty.</exception>
  7647. public static IQbservable<TSource> LastAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7648. {
  7649. if (source == null)
  7650. throw new ArgumentNullException(nameof(source));
  7651. if (predicate == null)
  7652. throw new ArgumentNullException(nameof(predicate));
  7653. return source.Provider.CreateQuery<TSource>(
  7654. Expression.Call(
  7655. null,
  7656. #if CRIPPLED_REFLECTION
  7657. InfoOf(() => Qbservable.LastAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7658. #else
  7659. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7660. #endif
  7661. source.Expression,
  7662. predicate
  7663. )
  7664. );
  7665. }
  7666. /// <summary>
  7667. /// Returns the last element of an observable sequence, or a default value if no such element exists.
  7668. /// </summary>
  7669. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7670. /// <param name="source">Source observable sequence.</param>
  7671. /// <returns>Sequence containing the last element in the observable sequence, or a default value if no such element exists.</returns>
  7672. /// <exception cref="ArgumentNullException">
  7673. /// <paramref name="source" /> is null.</exception>
  7674. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  7675. {
  7676. if (source == null)
  7677. throw new ArgumentNullException(nameof(source));
  7678. return source.Provider.CreateQuery<TSource>(
  7679. Expression.Call(
  7680. null,
  7681. #if CRIPPLED_REFLECTION
  7682. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  7683. #else
  7684. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7685. #endif
  7686. source.Expression
  7687. )
  7688. );
  7689. }
  7690. /// <summary>
  7691. /// Returns the last element of an observable sequence that satisfies the condition in the predicate, or a default value if no such element exists.
  7692. /// </summary>
  7693. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7694. /// <param name="source">Source observable sequence.</param>
  7695. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  7696. /// <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>
  7697. /// <exception cref="ArgumentNullException">
  7698. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7699. public static IQbservable<TSource> LastOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7700. {
  7701. if (source == null)
  7702. throw new ArgumentNullException(nameof(source));
  7703. if (predicate == null)
  7704. throw new ArgumentNullException(nameof(predicate));
  7705. return source.Provider.CreateQuery<TSource>(
  7706. Expression.Call(
  7707. null,
  7708. #if CRIPPLED_REFLECTION
  7709. InfoOf(() => Qbservable.LastOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7710. #else
  7711. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7712. #endif
  7713. source.Expression,
  7714. predicate
  7715. )
  7716. );
  7717. }
  7718. /// <summary>
  7719. /// Returns an enumerable sequence whose enumeration returns the latest observed element in the source observable sequence.
  7720. /// Enumerators on the resulting sequence will never produce the same element repeatedly, and will block until the next element becomes available.
  7721. /// </summary>
  7722. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7723. /// <param name="source">Source observable sequence.</param>
  7724. /// <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>
  7725. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  7726. public static IQueryable<TSource> Latest<TSource>(this IQbservable<TSource> source)
  7727. {
  7728. if (source == null)
  7729. throw new ArgumentNullException(nameof(source));
  7730. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  7731. Expression.Call(
  7732. null,
  7733. #if CRIPPLED_REFLECTION
  7734. InfoOf(() => Qbservable.Latest<TSource>(default(IQbservable<TSource>))),
  7735. #else
  7736. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7737. #endif
  7738. source.Expression
  7739. )
  7740. );
  7741. }
  7742. /// <summary>
  7743. /// Returns an observable sequence containing an <see cref="long" /> that represents the total number of elements in an observable sequence.
  7744. /// </summary>
  7745. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7746. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  7747. /// <returns>An observable sequence containing a single element with the number of elements in the input sequence.</returns>
  7748. /// <exception cref="ArgumentNullException">
  7749. /// <paramref name="source" /> is null.</exception>
  7750. /// <exception cref="OverflowException">(Asynchronous) The number of elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  7751. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7752. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source)
  7753. {
  7754. if (source == null)
  7755. throw new ArgumentNullException(nameof(source));
  7756. return source.Provider.CreateQuery<long>(
  7757. Expression.Call(
  7758. null,
  7759. #if CRIPPLED_REFLECTION
  7760. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>))),
  7761. #else
  7762. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7763. #endif
  7764. source.Expression
  7765. )
  7766. );
  7767. }
  7768. /// <summary>
  7769. /// Returns an observable sequence containing an <see cref="long" /> that represents how many elements in the specified observable sequence satisfy a condition.
  7770. /// </summary>
  7771. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7772. /// <param name="source">An observable sequence that contains elements to be counted.</param>
  7773. /// <param name="predicate">A function to test each element for a condition.</param>
  7774. /// <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>
  7775. /// <exception cref="ArgumentNullException">
  7776. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  7777. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7778. public static IQbservable<long> LongCount<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  7779. {
  7780. if (source == null)
  7781. throw new ArgumentNullException(nameof(source));
  7782. if (predicate == null)
  7783. throw new ArgumentNullException(nameof(predicate));
  7784. return source.Provider.CreateQuery<long>(
  7785. Expression.Call(
  7786. null,
  7787. #if CRIPPLED_REFLECTION
  7788. InfoOf(() => Qbservable.LongCount<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  7789. #else
  7790. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7791. #endif
  7792. source.Expression,
  7793. predicate
  7794. )
  7795. );
  7796. }
  7797. /// <summary>
  7798. /// Materializes the implicit notifications of an observable sequence as explicit notification values.
  7799. /// </summary>
  7800. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  7801. /// <param name="source">An observable sequence to get notification values for.</param>
  7802. /// <returns>An observable sequence containing the materialized notification values from the source sequence.</returns>
  7803. /// <exception cref="ArgumentNullException">
  7804. /// <paramref name="source" /> is null.</exception>
  7805. public static IQbservable<Notification<TSource>> Materialize<TSource>(this IQbservable<TSource> source)
  7806. {
  7807. if (source == null)
  7808. throw new ArgumentNullException(nameof(source));
  7809. return source.Provider.CreateQuery<Notification<TSource>>(
  7810. Expression.Call(
  7811. null,
  7812. #if CRIPPLED_REFLECTION
  7813. InfoOf(() => Qbservable.Materialize<TSource>(default(IQbservable<TSource>))),
  7814. #else
  7815. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  7816. #endif
  7817. source.Expression
  7818. )
  7819. );
  7820. }
  7821. /// <summary>
  7822. /// Returns the maximum value in an observable sequence of <see cref="Decimal" /> values.
  7823. /// </summary>
  7824. /// <param name="source">A sequence of <see cref="Decimal" /> values to determine the maximum value of.</param>
  7825. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7826. /// <exception cref="ArgumentNullException">
  7827. /// <paramref name="source" /> is null.</exception>
  7828. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7829. public static IQbservable<decimal> Max(this IQbservable<decimal> source)
  7830. {
  7831. if (source == null)
  7832. throw new ArgumentNullException(nameof(source));
  7833. return source.Provider.CreateQuery<decimal>(
  7834. Expression.Call(
  7835. null,
  7836. #if CRIPPLED_REFLECTION
  7837. InfoOf(() => Qbservable.Max(default(IQbservable<decimal>))),
  7838. #else
  7839. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7840. #endif
  7841. source.Expression
  7842. )
  7843. );
  7844. }
  7845. /// <summary>
  7846. /// Returns the maximum value in an observable sequence of <see cref="double" /> values.
  7847. /// </summary>
  7848. /// <param name="source">A sequence of <see cref="double" /> values to determine the maximum value of.</param>
  7849. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7850. /// <exception cref="ArgumentNullException">
  7851. /// <paramref name="source" /> is null.</exception>
  7852. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7853. public static IQbservable<double> Max(this IQbservable<double> source)
  7854. {
  7855. if (source == null)
  7856. throw new ArgumentNullException(nameof(source));
  7857. return source.Provider.CreateQuery<double>(
  7858. Expression.Call(
  7859. null,
  7860. #if CRIPPLED_REFLECTION
  7861. InfoOf(() => Qbservable.Max(default(IQbservable<double>))),
  7862. #else
  7863. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7864. #endif
  7865. source.Expression
  7866. )
  7867. );
  7868. }
  7869. /// <summary>
  7870. /// Returns the maximum value in an observable sequence of <see cref="int" /> values.
  7871. /// </summary>
  7872. /// <param name="source">A sequence of <see cref="int" /> values to determine the maximum value of.</param>
  7873. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7874. /// <exception cref="ArgumentNullException">
  7875. /// <paramref name="source" /> is null.</exception>
  7876. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7877. public static IQbservable<int> Max(this IQbservable<int> source)
  7878. {
  7879. if (source == null)
  7880. throw new ArgumentNullException(nameof(source));
  7881. return source.Provider.CreateQuery<int>(
  7882. Expression.Call(
  7883. null,
  7884. #if CRIPPLED_REFLECTION
  7885. InfoOf(() => Qbservable.Max(default(IQbservable<int>))),
  7886. #else
  7887. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7888. #endif
  7889. source.Expression
  7890. )
  7891. );
  7892. }
  7893. /// <summary>
  7894. /// Returns the maximum value in an observable sequence of <see cref="long" /> values.
  7895. /// </summary>
  7896. /// <param name="source">A sequence of <see cref="long" /> values to determine the maximum value of.</param>
  7897. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7898. /// <exception cref="ArgumentNullException">
  7899. /// <paramref name="source" /> is null.</exception>
  7900. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7901. public static IQbservable<long> Max(this IQbservable<long> source)
  7902. {
  7903. if (source == null)
  7904. throw new ArgumentNullException(nameof(source));
  7905. return source.Provider.CreateQuery<long>(
  7906. Expression.Call(
  7907. null,
  7908. #if CRIPPLED_REFLECTION
  7909. InfoOf(() => Qbservable.Max(default(IQbservable<long>))),
  7910. #else
  7911. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7912. #endif
  7913. source.Expression
  7914. )
  7915. );
  7916. }
  7917. /// <summary>
  7918. /// Returns the maximum value in an observable sequence of nullable <see cref="Decimal" /> values.
  7919. /// </summary>
  7920. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to determine the maximum value of.</param>
  7921. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7922. /// <exception cref="ArgumentNullException">
  7923. /// <paramref name="source" /> is null.</exception>
  7924. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7925. public static IQbservable<decimal?> Max(this IQbservable<decimal?> source)
  7926. {
  7927. if (source == null)
  7928. throw new ArgumentNullException(nameof(source));
  7929. return source.Provider.CreateQuery<decimal?>(
  7930. Expression.Call(
  7931. null,
  7932. #if CRIPPLED_REFLECTION
  7933. InfoOf(() => Qbservable.Max(default(IQbservable<decimal?>))),
  7934. #else
  7935. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7936. #endif
  7937. source.Expression
  7938. )
  7939. );
  7940. }
  7941. /// <summary>
  7942. /// Returns the maximum value in an observable sequence of nullable <see cref="double" /> values.
  7943. /// </summary>
  7944. /// <param name="source">A sequence of nullable <see cref="double" /> values to determine the maximum value of.</param>
  7945. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7946. /// <exception cref="ArgumentNullException">
  7947. /// <paramref name="source" /> is null.</exception>
  7948. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7949. public static IQbservable<double?> Max(this IQbservable<double?> source)
  7950. {
  7951. if (source == null)
  7952. throw new ArgumentNullException(nameof(source));
  7953. return source.Provider.CreateQuery<double?>(
  7954. Expression.Call(
  7955. null,
  7956. #if CRIPPLED_REFLECTION
  7957. InfoOf(() => Qbservable.Max(default(IQbservable<double?>))),
  7958. #else
  7959. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7960. #endif
  7961. source.Expression
  7962. )
  7963. );
  7964. }
  7965. /// <summary>
  7966. /// Returns the maximum value in an observable sequence of nullable <see cref="int" /> values.
  7967. /// </summary>
  7968. /// <param name="source">A sequence of nullable <see cref="int" /> values to determine the maximum value of.</param>
  7969. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7970. /// <exception cref="ArgumentNullException">
  7971. /// <paramref name="source" /> is null.</exception>
  7972. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7973. public static IQbservable<int?> Max(this IQbservable<int?> source)
  7974. {
  7975. if (source == null)
  7976. throw new ArgumentNullException(nameof(source));
  7977. return source.Provider.CreateQuery<int?>(
  7978. Expression.Call(
  7979. null,
  7980. #if CRIPPLED_REFLECTION
  7981. InfoOf(() => Qbservable.Max(default(IQbservable<int?>))),
  7982. #else
  7983. (MethodInfo)MethodInfo.GetCurrentMethod(),
  7984. #endif
  7985. source.Expression
  7986. )
  7987. );
  7988. }
  7989. /// <summary>
  7990. /// Returns the maximum value in an observable sequence of nullable <see cref="long" /> values.
  7991. /// </summary>
  7992. /// <param name="source">A sequence of nullable <see cref="long" /> values to determine the maximum value of.</param>
  7993. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  7994. /// <exception cref="ArgumentNullException">
  7995. /// <paramref name="source" /> is null.</exception>
  7996. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  7997. public static IQbservable<long?> Max(this IQbservable<long?> source)
  7998. {
  7999. if (source == null)
  8000. throw new ArgumentNullException(nameof(source));
  8001. return source.Provider.CreateQuery<long?>(
  8002. Expression.Call(
  8003. null,
  8004. #if CRIPPLED_REFLECTION
  8005. InfoOf(() => Qbservable.Max(default(IQbservable<long?>))),
  8006. #else
  8007. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8008. #endif
  8009. source.Expression
  8010. )
  8011. );
  8012. }
  8013. /// <summary>
  8014. /// Returns the maximum value in an observable sequence of nullable <see cref="Single" /> values.
  8015. /// </summary>
  8016. /// <param name="source">A sequence of nullable <see cref="Single" /> values to determine the maximum value of.</param>
  8017. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8018. /// <exception cref="ArgumentNullException">
  8019. /// <paramref name="source" /> is null.</exception>
  8020. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8021. public static IQbservable<float?> Max(this IQbservable<float?> source)
  8022. {
  8023. if (source == null)
  8024. throw new ArgumentNullException(nameof(source));
  8025. return source.Provider.CreateQuery<float?>(
  8026. Expression.Call(
  8027. null,
  8028. #if CRIPPLED_REFLECTION
  8029. InfoOf(() => Qbservable.Max(default(IQbservable<float?>))),
  8030. #else
  8031. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8032. #endif
  8033. source.Expression
  8034. )
  8035. );
  8036. }
  8037. /// <summary>
  8038. /// Returns the maximum value in an observable sequence of <see cref="Single" /> values.
  8039. /// </summary>
  8040. /// <param name="source">A sequence of <see cref="Single" /> values to determine the maximum value of.</param>
  8041. /// <returns>An observable sequence containing a single element with the maximum value in the source sequence.</returns>
  8042. /// <exception cref="ArgumentNullException">
  8043. /// <paramref name="source" /> is null.</exception>
  8044. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8045. public static IQbservable<float> Max(this IQbservable<float> source)
  8046. {
  8047. if (source == null)
  8048. throw new ArgumentNullException(nameof(source));
  8049. return source.Provider.CreateQuery<float>(
  8050. Expression.Call(
  8051. null,
  8052. #if CRIPPLED_REFLECTION
  8053. InfoOf(() => Qbservable.Max(default(IQbservable<float>))),
  8054. #else
  8055. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8056. #endif
  8057. source.Expression
  8058. )
  8059. );
  8060. }
  8061. /// <summary>
  8062. /// Returns the maximum element in an observable sequence.
  8063. /// </summary>
  8064. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8065. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8066. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8067. /// <exception cref="ArgumentNullException">
  8068. /// <paramref name="source" /> is null.</exception>
  8069. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8070. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source)
  8071. {
  8072. if (source == null)
  8073. throw new ArgumentNullException(nameof(source));
  8074. return source.Provider.CreateQuery<TSource>(
  8075. Expression.Call(
  8076. null,
  8077. #if CRIPPLED_REFLECTION
  8078. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>))),
  8079. #else
  8080. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8081. #endif
  8082. source.Expression
  8083. )
  8084. );
  8085. }
  8086. /// <summary>
  8087. /// Returns the maximum value in an observable sequence according to the specified comparer.
  8088. /// </summary>
  8089. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8090. /// <param name="source">An observable sequence to determine the maximum element of.</param>
  8091. /// <param name="comparer">Comparer used to compare elements.</param>
  8092. /// <returns>An observable sequence containing a single element with the maximum element in the source sequence.</returns>
  8093. /// <exception cref="ArgumentNullException">
  8094. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  8095. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8096. public static IQbservable<TSource> Max<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  8097. {
  8098. if (source == null)
  8099. throw new ArgumentNullException(nameof(source));
  8100. if (comparer == null)
  8101. throw new ArgumentNullException(nameof(comparer));
  8102. return source.Provider.CreateQuery<TSource>(
  8103. Expression.Call(
  8104. null,
  8105. #if CRIPPLED_REFLECTION
  8106. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  8107. #else
  8108. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8109. #endif
  8110. source.Expression,
  8111. Expression.Constant(comparer, typeof(IComparer<TSource>))
  8112. )
  8113. );
  8114. }
  8115. /// <summary>
  8116. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="Decimal" /> value.
  8117. /// </summary>
  8118. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8119. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8120. /// <param name="selector">A transform function to apply to each element.</param>
  8121. /// <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>
  8122. /// <exception cref="ArgumentNullException">
  8123. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8124. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8125. public static IQbservable<decimal> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  8126. {
  8127. if (source == null)
  8128. throw new ArgumentNullException(nameof(source));
  8129. if (selector == null)
  8130. throw new ArgumentNullException(nameof(selector));
  8131. return source.Provider.CreateQuery<decimal>(
  8132. Expression.Call(
  8133. null,
  8134. #if CRIPPLED_REFLECTION
  8135. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  8136. #else
  8137. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8138. #endif
  8139. source.Expression,
  8140. selector
  8141. )
  8142. );
  8143. }
  8144. /// <summary>
  8145. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="int" /> value.
  8146. /// </summary>
  8147. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8148. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8149. /// <param name="selector">A transform function to apply to each element.</param>
  8150. /// <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>
  8151. /// <exception cref="ArgumentNullException">
  8152. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8153. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8154. public static IQbservable<int> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  8155. {
  8156. if (source == null)
  8157. throw new ArgumentNullException(nameof(source));
  8158. if (selector == null)
  8159. throw new ArgumentNullException(nameof(selector));
  8160. return source.Provider.CreateQuery<int>(
  8161. Expression.Call(
  8162. null,
  8163. #if CRIPPLED_REFLECTION
  8164. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  8165. #else
  8166. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8167. #endif
  8168. source.Expression,
  8169. selector
  8170. )
  8171. );
  8172. }
  8173. /// <summary>
  8174. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="long" /> value.
  8175. /// </summary>
  8176. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8177. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8178. /// <param name="selector">A transform function to apply to each element.</param>
  8179. /// <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>
  8180. /// <exception cref="ArgumentNullException">
  8181. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8182. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8183. public static IQbservable<long> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  8184. {
  8185. if (source == null)
  8186. throw new ArgumentNullException(nameof(source));
  8187. if (selector == null)
  8188. throw new ArgumentNullException(nameof(selector));
  8189. return source.Provider.CreateQuery<long>(
  8190. Expression.Call(
  8191. null,
  8192. #if CRIPPLED_REFLECTION
  8193. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  8194. #else
  8195. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8196. #endif
  8197. source.Expression,
  8198. selector
  8199. )
  8200. );
  8201. }
  8202. /// <summary>
  8203. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="double" /> value.
  8204. /// </summary>
  8205. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8206. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8207. /// <param name="selector">A transform function to apply to each element.</param>
  8208. /// <returns>An observable sequence containing a single element with the value of type <see cref="Nullable{Double}" /> that corresponds to the maximum value in the source sequence.</returns>
  8209. /// <exception cref="ArgumentNullException">
  8210. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8211. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8212. public static IQbservable<double?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  8213. {
  8214. if (source == null)
  8215. throw new ArgumentNullException(nameof(source));
  8216. if (selector == null)
  8217. throw new ArgumentNullException(nameof(selector));
  8218. return source.Provider.CreateQuery<double?>(
  8219. Expression.Call(
  8220. null,
  8221. #if CRIPPLED_REFLECTION
  8222. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  8223. #else
  8224. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8225. #endif
  8226. source.Expression,
  8227. selector
  8228. )
  8229. );
  8230. }
  8231. /// <summary>
  8232. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="Single" /> value.
  8233. /// </summary>
  8234. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8235. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8236. /// <param name="selector">A transform function to apply to each element.</param>
  8237. /// <returns>An observable sequence containing a single element with the value of type <see cref="Nullable{Single}" /> that corresponds to the maximum value in the source sequence.</returns>
  8238. /// <exception cref="ArgumentNullException">
  8239. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8240. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8241. public static IQbservable<float?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  8242. {
  8243. if (source == null)
  8244. throw new ArgumentNullException(nameof(source));
  8245. if (selector == null)
  8246. throw new ArgumentNullException(nameof(selector));
  8247. return source.Provider.CreateQuery<float?>(
  8248. Expression.Call(
  8249. null,
  8250. #if CRIPPLED_REFLECTION
  8251. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  8252. #else
  8253. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8254. #endif
  8255. source.Expression,
  8256. selector
  8257. )
  8258. );
  8259. }
  8260. /// <summary>
  8261. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="Decimal" /> value.
  8262. /// </summary>
  8263. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8264. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8265. /// <param name="selector">A transform function to apply to each element.</param>
  8266. /// <returns>An observable sequence containing a single element with the value of type <see cref="Nullable{Decimal}" /> that corresponds to the maximum value in the source sequence.</returns>
  8267. /// <exception cref="ArgumentNullException">
  8268. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8269. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8270. public static IQbservable<decimal?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  8271. {
  8272. if (source == null)
  8273. throw new ArgumentNullException(nameof(source));
  8274. if (selector == null)
  8275. throw new ArgumentNullException(nameof(selector));
  8276. return source.Provider.CreateQuery<decimal?>(
  8277. Expression.Call(
  8278. null,
  8279. #if CRIPPLED_REFLECTION
  8280. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  8281. #else
  8282. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8283. #endif
  8284. source.Expression,
  8285. selector
  8286. )
  8287. );
  8288. }
  8289. /// <summary>
  8290. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="int" /> value.
  8291. /// </summary>
  8292. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8293. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8294. /// <param name="selector">A transform function to apply to each element.</param>
  8295. /// <returns>An observable sequence containing a single element with the value of type <see cref="Nullable{Int32}" /> that corresponds to the maximum value in the source sequence.</returns>
  8296. /// <exception cref="ArgumentNullException">
  8297. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8298. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8299. public static IQbservable<int?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  8300. {
  8301. if (source == null)
  8302. throw new ArgumentNullException(nameof(source));
  8303. if (selector == null)
  8304. throw new ArgumentNullException(nameof(selector));
  8305. return source.Provider.CreateQuery<int?>(
  8306. Expression.Call(
  8307. null,
  8308. #if CRIPPLED_REFLECTION
  8309. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  8310. #else
  8311. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8312. #endif
  8313. source.Expression,
  8314. selector
  8315. )
  8316. );
  8317. }
  8318. /// <summary>
  8319. /// Invokes a transform function on each element of a sequence and returns the maximum nullable <see cref="long" /> value.
  8320. /// </summary>
  8321. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8322. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8323. /// <param name="selector">A transform function to apply to each element.</param>
  8324. /// <returns>An observable sequence containing a single element with the value of type <see cref="Nullable{Int64}" /> that corresponds to the maximum value in the source sequence.</returns>
  8325. /// <exception cref="ArgumentNullException">
  8326. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8327. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8328. public static IQbservable<long?> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  8329. {
  8330. if (source == null)
  8331. throw new ArgumentNullException(nameof(source));
  8332. if (selector == null)
  8333. throw new ArgumentNullException(nameof(selector));
  8334. return source.Provider.CreateQuery<long?>(
  8335. Expression.Call(
  8336. null,
  8337. #if CRIPPLED_REFLECTION
  8338. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  8339. #else
  8340. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8341. #endif
  8342. source.Expression,
  8343. selector
  8344. )
  8345. );
  8346. }
  8347. /// <summary>
  8348. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="double" /> value.
  8349. /// </summary>
  8350. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8351. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8352. /// <param name="selector">A transform function to apply to each element.</param>
  8353. /// <returns>An observable sequence containing a single element with the value of type <see cref="double" /> that corresponds to the maximum value in the source sequence.</returns>
  8354. /// <exception cref="ArgumentNullException">
  8355. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8356. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8357. public static IQbservable<double> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  8358. {
  8359. if (source == null)
  8360. throw new ArgumentNullException(nameof(source));
  8361. if (selector == null)
  8362. throw new ArgumentNullException(nameof(selector));
  8363. return source.Provider.CreateQuery<double>(
  8364. Expression.Call(
  8365. null,
  8366. #if CRIPPLED_REFLECTION
  8367. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  8368. #else
  8369. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8370. #endif
  8371. source.Expression,
  8372. selector
  8373. )
  8374. );
  8375. }
  8376. /// <summary>
  8377. /// Invokes a transform function on each element of a sequence and returns the maximum <see cref="Single" /> value.
  8378. /// </summary>
  8379. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8380. /// <param name="source">A sequence of values to determine the maximum value of.</param>
  8381. /// <param name="selector">A transform function to apply to each element.</param>
  8382. /// <returns>An observable sequence containing a single element with the value of type <see cref="Single" /> that corresponds to the maximum value in the source sequence.</returns>
  8383. /// <exception cref="ArgumentNullException">
  8384. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8385. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8386. public static IQbservable<float> Max<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  8387. {
  8388. if (source == null)
  8389. throw new ArgumentNullException(nameof(source));
  8390. if (selector == null)
  8391. throw new ArgumentNullException(nameof(selector));
  8392. return source.Provider.CreateQuery<float>(
  8393. Expression.Call(
  8394. null,
  8395. #if CRIPPLED_REFLECTION
  8396. InfoOf(() => Qbservable.Max<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  8397. #else
  8398. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8399. #endif
  8400. source.Expression,
  8401. selector
  8402. )
  8403. );
  8404. }
  8405. /// <summary>
  8406. /// Invokes a transform function on each element of a sequence and returns the maximum value.
  8407. /// </summary>
  8408. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8409. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8410. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  8411. /// <param name="selector">A transform function to apply to each element.</param>
  8412. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8413. /// <exception cref="ArgumentNullException">
  8414. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  8415. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8416. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  8417. {
  8418. if (source == null)
  8419. throw new ArgumentNullException(nameof(source));
  8420. if (selector == null)
  8421. throw new ArgumentNullException(nameof(selector));
  8422. return source.Provider.CreateQuery<TResult>(
  8423. Expression.Call(
  8424. null,
  8425. #if CRIPPLED_REFLECTION
  8426. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  8427. #else
  8428. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8429. #endif
  8430. source.Expression,
  8431. selector
  8432. )
  8433. );
  8434. }
  8435. /// <summary>
  8436. /// Invokes a transform function on each element of a sequence and returns the maximum value according to the specified comparer.
  8437. /// </summary>
  8438. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8439. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the maximum of.</typeparam>
  8440. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  8441. /// <param name="selector">A transform function to apply to each element.</param>
  8442. /// <param name="comparer">Comparer used to compare elements.</param>
  8443. /// <returns>An observable sequence containing a single element with the value that corresponds to the maximum element in the source sequence.</returns>
  8444. /// <exception cref="ArgumentNullException">
  8445. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  8446. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8447. public static IQbservable<TResult> Max<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  8448. {
  8449. if (source == null)
  8450. throw new ArgumentNullException(nameof(source));
  8451. if (selector == null)
  8452. throw new ArgumentNullException(nameof(selector));
  8453. if (comparer == null)
  8454. throw new ArgumentNullException(nameof(comparer));
  8455. return source.Provider.CreateQuery<TResult>(
  8456. Expression.Call(
  8457. null,
  8458. #if CRIPPLED_REFLECTION
  8459. InfoOf(() => Qbservable.Max<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  8460. #else
  8461. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  8462. #endif
  8463. source.Expression,
  8464. selector,
  8465. Expression.Constant(comparer, typeof(IComparer<TResult>))
  8466. )
  8467. );
  8468. }
  8469. /// <summary>
  8470. /// Returns the elements in an observable sequence with the maximum key value.
  8471. /// </summary>
  8472. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8473. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8474. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8475. /// <param name="keySelector">Key selector function.</param>
  8476. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8477. /// <exception cref="ArgumentNullException">
  8478. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  8479. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8480. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  8481. {
  8482. if (source == null)
  8483. throw new ArgumentNullException(nameof(source));
  8484. if (keySelector == null)
  8485. throw new ArgumentNullException(nameof(keySelector));
  8486. return source.Provider.CreateQuery<IList<TSource>>(
  8487. Expression.Call(
  8488. null,
  8489. #if CRIPPLED_REFLECTION
  8490. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  8491. #else
  8492. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8493. #endif
  8494. source.Expression,
  8495. keySelector
  8496. )
  8497. );
  8498. }
  8499. /// <summary>
  8500. /// Returns the elements in an observable sequence with the maximum key value according to the specified comparer.
  8501. /// </summary>
  8502. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  8503. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  8504. /// <param name="source">An observable sequence to get the maximum elements for.</param>
  8505. /// <param name="keySelector">Key selector function.</param>
  8506. /// <param name="comparer">Comparer used to compare key values.</param>
  8507. /// <returns>An observable sequence containing a list of zero or more elements that have a maximum key value.</returns>
  8508. /// <exception cref="ArgumentNullException">
  8509. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  8510. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8511. public static IQbservable<IList<TSource>> MaxBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  8512. {
  8513. if (source == null)
  8514. throw new ArgumentNullException(nameof(source));
  8515. if (keySelector == null)
  8516. throw new ArgumentNullException(nameof(keySelector));
  8517. if (comparer == null)
  8518. throw new ArgumentNullException(nameof(comparer));
  8519. return source.Provider.CreateQuery<IList<TSource>>(
  8520. Expression.Call(
  8521. null,
  8522. #if CRIPPLED_REFLECTION
  8523. InfoOf(() => Qbservable.MaxBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  8524. #else
  8525. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  8526. #endif
  8527. source.Expression,
  8528. keySelector,
  8529. Expression.Constant(comparer, typeof(IComparer<TKey>))
  8530. )
  8531. );
  8532. }
  8533. /// <summary>
  8534. /// Merges elements from two observable sequences into a single observable sequence.
  8535. /// </summary>
  8536. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8537. /// <param name="first">First observable sequence.</param>
  8538. /// <param name="second">Second observable sequence.</param>
  8539. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8540. /// <exception cref="ArgumentNullException">
  8541. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  8542. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  8543. {
  8544. if (first == null)
  8545. throw new ArgumentNullException(nameof(first));
  8546. if (second == null)
  8547. throw new ArgumentNullException(nameof(second));
  8548. return first.Provider.CreateQuery<TSource>(
  8549. Expression.Call(
  8550. null,
  8551. #if CRIPPLED_REFLECTION
  8552. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  8553. #else
  8554. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8555. #endif
  8556. first.Expression,
  8557. GetSourceExpression(second)
  8558. )
  8559. );
  8560. }
  8561. /// <summary>
  8562. /// Merges elements from two observable sequences into a single observable sequence, using the specified scheduler for enumeration of and subscription to the sources.
  8563. /// </summary>
  8564. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8565. /// <param name="first">First observable sequence.</param>
  8566. /// <param name="second">Second observable sequence.</param>
  8567. /// <param name="scheduler">Scheduler used to introduce concurrency for making subscriptions to the given sequences.</param>
  8568. /// <returns>The observable sequence that merges the elements of the given sequences.</returns>
  8569. /// <exception cref="ArgumentNullException">
  8570. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="scheduler" /> is null.</exception>
  8571. public static IQbservable<TSource> Merge<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IScheduler scheduler)
  8572. {
  8573. if (first == null)
  8574. throw new ArgumentNullException(nameof(first));
  8575. if (second == null)
  8576. throw new ArgumentNullException(nameof(second));
  8577. if (scheduler == null)
  8578. throw new ArgumentNullException(nameof(scheduler));
  8579. return first.Provider.CreateQuery<TSource>(
  8580. Expression.Call(
  8581. null,
  8582. #if CRIPPLED_REFLECTION
  8583. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IScheduler))),
  8584. #else
  8585. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8586. #endif
  8587. first.Expression,
  8588. GetSourceExpression(second),
  8589. Expression.Constant(scheduler, typeof(IScheduler))
  8590. )
  8591. );
  8592. }
  8593. /// <summary>
  8594. /// 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.
  8595. /// </summary>
  8596. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8597. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8598. /// <param name="sources">Observable sequences.</param>
  8599. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8600. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8601. /// <exception cref="ArgumentNullException">
  8602. /// <paramref name="scheduler" /> or <paramref name="sources" /> is null.</exception>
  8603. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IScheduler scheduler, params IObservable<TSource>[] sources)
  8604. {
  8605. if (provider == null)
  8606. throw new ArgumentNullException(nameof(provider));
  8607. if (scheduler == null)
  8608. throw new ArgumentNullException(nameof(scheduler));
  8609. if (sources == null)
  8610. throw new ArgumentNullException(nameof(sources));
  8611. return provider.CreateQuery<TSource>(
  8612. Expression.Call(
  8613. null,
  8614. #if CRIPPLED_REFLECTION
  8615. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IScheduler), default(IObservable<TSource>[]))),
  8616. #else
  8617. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8618. #endif
  8619. Expression.Constant(provider, typeof(IQbservableProvider)),
  8620. Expression.Constant(scheduler, typeof(IScheduler)),
  8621. GetSourceExpression(sources)
  8622. )
  8623. );
  8624. }
  8625. /// <summary>
  8626. /// Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence.
  8627. /// </summary>
  8628. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8629. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8630. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8631. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8632. /// <exception cref="ArgumentNullException">
  8633. /// <paramref name="sources" /> is null.</exception>
  8634. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  8635. {
  8636. if (provider == null)
  8637. throw new ArgumentNullException(nameof(provider));
  8638. if (sources == null)
  8639. throw new ArgumentNullException(nameof(sources));
  8640. return provider.CreateQuery<TSource>(
  8641. Expression.Call(
  8642. null,
  8643. #if CRIPPLED_REFLECTION
  8644. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  8645. #else
  8646. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8647. #endif
  8648. Expression.Constant(provider, typeof(IQbservableProvider)),
  8649. GetSourceExpression(sources)
  8650. )
  8651. );
  8652. }
  8653. /// <summary>
  8654. /// Merges elements from all inner observable sequences into a single observable sequence.
  8655. /// </summary>
  8656. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8657. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8658. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8659. /// <exception cref="ArgumentNullException">
  8660. /// <paramref name="sources" /> is null.</exception>
  8661. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources)
  8662. {
  8663. if (sources == null)
  8664. throw new ArgumentNullException(nameof(sources));
  8665. return sources.Provider.CreateQuery<TSource>(
  8666. Expression.Call(
  8667. null,
  8668. #if CRIPPLED_REFLECTION
  8669. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>))),
  8670. #else
  8671. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8672. #endif
  8673. sources.Expression
  8674. )
  8675. );
  8676. }
  8677. /// <summary>
  8678. /// Merges results from all source tasks into a single observable sequence.
  8679. /// </summary>
  8680. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  8681. /// <param name="sources">Observable sequence of tasks.</param>
  8682. /// <returns>The observable sequence that merges the results of the source tasks.</returns>
  8683. /// <exception cref="ArgumentNullException">
  8684. /// <paramref name="sources" /> is null.</exception>
  8685. /// <remarks>If the tasks support cancellation, consider manual conversion of the tasks using <see cref="Observable.FromAsync{TSource}(Func{CancellationToken,Task{TSource}})" />, followed by a merge operation using <see cref="Observable.Merge{TSource}(IObservable{IObservable{TSource}})" />.</remarks>
  8686. public static IQbservable<TSource> Merge<TSource>(this IQbservable<Task<TSource>> sources)
  8687. {
  8688. if (sources == null)
  8689. throw new ArgumentNullException(nameof(sources));
  8690. return sources.Provider.CreateQuery<TSource>(
  8691. Expression.Call(
  8692. null,
  8693. #if CRIPPLED_REFLECTION
  8694. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<Task<TSource>>))),
  8695. #else
  8696. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8697. #endif
  8698. sources.Expression
  8699. )
  8700. );
  8701. }
  8702. /// <summary>
  8703. /// Merges elements from all of the specified observable sequences into a single observable sequence.
  8704. /// </summary>
  8705. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8706. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8707. /// <param name="sources">Observable sequences.</param>
  8708. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8709. /// <exception cref="ArgumentNullException">
  8710. /// <paramref name="sources" /> is null.</exception>
  8711. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  8712. {
  8713. if (provider == null)
  8714. throw new ArgumentNullException(nameof(provider));
  8715. if (sources == null)
  8716. throw new ArgumentNullException(nameof(sources));
  8717. return provider.CreateQuery<TSource>(
  8718. Expression.Call(
  8719. null,
  8720. #if CRIPPLED_REFLECTION
  8721. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  8722. #else
  8723. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8724. #endif
  8725. Expression.Constant(provider, typeof(IQbservableProvider)),
  8726. GetSourceExpression(sources)
  8727. )
  8728. );
  8729. }
  8730. /// <summary>
  8731. /// Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences.
  8732. /// </summary>
  8733. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8734. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  8735. /// <param name="maxConcurrent">Maximum number of inner observable sequences being subscribed to concurrently.</param>
  8736. /// <returns>The observable sequence that merges the elements of the inner sequences.</returns>
  8737. /// <exception cref="ArgumentNullException">
  8738. /// <paramref name="sources" /> is null.</exception>
  8739. /// <exception cref="ArgumentOutOfRangeException">
  8740. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8741. public static IQbservable<TSource> Merge<TSource>(this IQbservable<IObservable<TSource>> sources, int maxConcurrent)
  8742. {
  8743. if (sources == null)
  8744. throw new ArgumentNullException(nameof(sources));
  8745. return sources.Provider.CreateQuery<TSource>(
  8746. Expression.Call(
  8747. null,
  8748. #if CRIPPLED_REFLECTION
  8749. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservable<IObservable<TSource>>), default(int))),
  8750. #else
  8751. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8752. #endif
  8753. sources.Expression,
  8754. Expression.Constant(maxConcurrent, typeof(int))
  8755. )
  8756. );
  8757. }
  8758. /// <summary>
  8759. /// 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.
  8760. /// </summary>
  8761. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8762. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8763. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8764. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  8765. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8766. /// <exception cref="ArgumentNullException">
  8767. /// <paramref name="sources" /> is null.</exception>
  8768. /// <exception cref="ArgumentOutOfRangeException">
  8769. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8770. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent)
  8771. {
  8772. if (provider == null)
  8773. throw new ArgumentNullException(nameof(provider));
  8774. if (sources == null)
  8775. throw new ArgumentNullException(nameof(sources));
  8776. return provider.CreateQuery<TSource>(
  8777. Expression.Call(
  8778. null,
  8779. #if CRIPPLED_REFLECTION
  8780. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int))),
  8781. #else
  8782. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8783. #endif
  8784. Expression.Constant(provider, typeof(IQbservableProvider)),
  8785. GetSourceExpression(sources),
  8786. Expression.Constant(maxConcurrent, typeof(int))
  8787. )
  8788. );
  8789. }
  8790. /// <summary>
  8791. /// 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.
  8792. /// </summary>
  8793. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8794. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8795. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8796. /// <param name="maxConcurrent">Maximum number of observable sequences being subscribed to concurrently.</param>
  8797. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8798. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8799. /// <exception cref="ArgumentNullException">
  8800. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  8801. /// <exception cref="ArgumentOutOfRangeException">
  8802. /// <paramref name="maxConcurrent" /> is less than or equal to zero.</exception>
  8803. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, int maxConcurrent, IScheduler scheduler)
  8804. {
  8805. if (provider == null)
  8806. throw new ArgumentNullException(nameof(provider));
  8807. if (sources == null)
  8808. throw new ArgumentNullException(nameof(sources));
  8809. if (scheduler == null)
  8810. throw new ArgumentNullException(nameof(scheduler));
  8811. return provider.CreateQuery<TSource>(
  8812. Expression.Call(
  8813. null,
  8814. #if CRIPPLED_REFLECTION
  8815. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(int), default(IScheduler))),
  8816. #else
  8817. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8818. #endif
  8819. Expression.Constant(provider, typeof(IQbservableProvider)),
  8820. GetSourceExpression(sources),
  8821. Expression.Constant(maxConcurrent, typeof(int)),
  8822. Expression.Constant(scheduler, typeof(IScheduler))
  8823. )
  8824. );
  8825. }
  8826. /// <summary>
  8827. /// 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.
  8828. /// </summary>
  8829. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  8830. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  8831. /// <param name="sources">Enumerable sequence of observable sequences.</param>
  8832. /// <param name="scheduler">Scheduler to run the enumeration of the sequence of sources on.</param>
  8833. /// <returns>The observable sequence that merges the elements of the observable sequences.</returns>
  8834. /// <exception cref="ArgumentNullException">
  8835. /// <paramref name="sources" /> or <paramref name="scheduler" /> is null.</exception>
  8836. public static IQbservable<TSource> Merge<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, IScheduler scheduler)
  8837. {
  8838. if (provider == null)
  8839. throw new ArgumentNullException(nameof(provider));
  8840. if (sources == null)
  8841. throw new ArgumentNullException(nameof(sources));
  8842. if (scheduler == null)
  8843. throw new ArgumentNullException(nameof(scheduler));
  8844. return provider.CreateQuery<TSource>(
  8845. Expression.Call(
  8846. null,
  8847. #if CRIPPLED_REFLECTION
  8848. InfoOf(() => Qbservable.Merge<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(IScheduler))),
  8849. #else
  8850. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  8851. #endif
  8852. Expression.Constant(provider, typeof(IQbservableProvider)),
  8853. GetSourceExpression(sources),
  8854. Expression.Constant(scheduler, typeof(IScheduler))
  8855. )
  8856. );
  8857. }
  8858. /// <summary>
  8859. /// Returns the minimum value in an observable sequence of <see cref="Decimal" /> values.
  8860. /// </summary>
  8861. /// <param name="source">A sequence of <see cref="Decimal" /> values to determine the minimum value of.</param>
  8862. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8863. /// <exception cref="ArgumentNullException">
  8864. /// <paramref name="source" /> is null.</exception>
  8865. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8866. public static IQbservable<decimal> Min(this IQbservable<decimal> source)
  8867. {
  8868. if (source == null)
  8869. throw new ArgumentNullException(nameof(source));
  8870. return source.Provider.CreateQuery<decimal>(
  8871. Expression.Call(
  8872. null,
  8873. #if CRIPPLED_REFLECTION
  8874. InfoOf(() => Qbservable.Min(default(IQbservable<decimal>))),
  8875. #else
  8876. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8877. #endif
  8878. source.Expression
  8879. )
  8880. );
  8881. }
  8882. /// <summary>
  8883. /// Returns the minimum value in an observable sequence of <see cref="double" /> values.
  8884. /// </summary>
  8885. /// <param name="source">A sequence of <see cref="double" /> values to determine the minimum value of.</param>
  8886. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8887. /// <exception cref="ArgumentNullException">
  8888. /// <paramref name="source" /> is null.</exception>
  8889. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8890. public static IQbservable<double> Min(this IQbservable<double> source)
  8891. {
  8892. if (source == null)
  8893. throw new ArgumentNullException(nameof(source));
  8894. return source.Provider.CreateQuery<double>(
  8895. Expression.Call(
  8896. null,
  8897. #if CRIPPLED_REFLECTION
  8898. InfoOf(() => Qbservable.Min(default(IQbservable<double>))),
  8899. #else
  8900. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8901. #endif
  8902. source.Expression
  8903. )
  8904. );
  8905. }
  8906. /// <summary>
  8907. /// Returns the minimum value in an observable sequence of <see cref="int" /> values.
  8908. /// </summary>
  8909. /// <param name="source">A sequence of <see cref="int" /> values to determine the minimum value of.</param>
  8910. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8911. /// <exception cref="ArgumentNullException">
  8912. /// <paramref name="source" /> is null.</exception>
  8913. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8914. public static IQbservable<int> Min(this IQbservable<int> source)
  8915. {
  8916. if (source == null)
  8917. throw new ArgumentNullException(nameof(source));
  8918. return source.Provider.CreateQuery<int>(
  8919. Expression.Call(
  8920. null,
  8921. #if CRIPPLED_REFLECTION
  8922. InfoOf(() => Qbservable.Min(default(IQbservable<int>))),
  8923. #else
  8924. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8925. #endif
  8926. source.Expression
  8927. )
  8928. );
  8929. }
  8930. /// <summary>
  8931. /// Returns the minimum value in an observable sequence of <see cref="long" /> values.
  8932. /// </summary>
  8933. /// <param name="source">A sequence of <see cref="long" /> values to determine the minimum value of.</param>
  8934. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8935. /// <exception cref="ArgumentNullException">
  8936. /// <paramref name="source" /> is null.</exception>
  8937. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8938. public static IQbservable<long> Min(this IQbservable<long> source)
  8939. {
  8940. if (source == null)
  8941. throw new ArgumentNullException(nameof(source));
  8942. return source.Provider.CreateQuery<long>(
  8943. Expression.Call(
  8944. null,
  8945. #if CRIPPLED_REFLECTION
  8946. InfoOf(() => Qbservable.Min(default(IQbservable<long>))),
  8947. #else
  8948. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8949. #endif
  8950. source.Expression
  8951. )
  8952. );
  8953. }
  8954. /// <summary>
  8955. /// Returns the minimum value in an observable sequence of nullable <see cref="Decimal" /> values.
  8956. /// </summary>
  8957. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to determine the minimum value of.</param>
  8958. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8959. /// <exception cref="ArgumentNullException">
  8960. /// <paramref name="source" /> is null.</exception>
  8961. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8962. public static IQbservable<decimal?> Min(this IQbservable<decimal?> source)
  8963. {
  8964. if (source == null)
  8965. throw new ArgumentNullException(nameof(source));
  8966. return source.Provider.CreateQuery<decimal?>(
  8967. Expression.Call(
  8968. null,
  8969. #if CRIPPLED_REFLECTION
  8970. InfoOf(() => Qbservable.Min(default(IQbservable<decimal?>))),
  8971. #else
  8972. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8973. #endif
  8974. source.Expression
  8975. )
  8976. );
  8977. }
  8978. /// <summary>
  8979. /// Returns the minimum value in an observable sequence of nullable <see cref="double" /> values.
  8980. /// </summary>
  8981. /// <param name="source">A sequence of nullable <see cref="double" /> values to determine the minimum value of.</param>
  8982. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  8983. /// <exception cref="ArgumentNullException">
  8984. /// <paramref name="source" /> is null.</exception>
  8985. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  8986. public static IQbservable<double?> Min(this IQbservable<double?> source)
  8987. {
  8988. if (source == null)
  8989. throw new ArgumentNullException(nameof(source));
  8990. return source.Provider.CreateQuery<double?>(
  8991. Expression.Call(
  8992. null,
  8993. #if CRIPPLED_REFLECTION
  8994. InfoOf(() => Qbservable.Min(default(IQbservable<double?>))),
  8995. #else
  8996. (MethodInfo)MethodInfo.GetCurrentMethod(),
  8997. #endif
  8998. source.Expression
  8999. )
  9000. );
  9001. }
  9002. /// <summary>
  9003. /// Returns the minimum value in an observable sequence of nullable <see cref="int" /> values.
  9004. /// </summary>
  9005. /// <param name="source">A sequence of nullable <see cref="int" /> values to determine the minimum value of.</param>
  9006. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9007. /// <exception cref="ArgumentNullException">
  9008. /// <paramref name="source" /> is null.</exception>
  9009. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9010. public static IQbservable<int?> Min(this IQbservable<int?> source)
  9011. {
  9012. if (source == null)
  9013. throw new ArgumentNullException(nameof(source));
  9014. return source.Provider.CreateQuery<int?>(
  9015. Expression.Call(
  9016. null,
  9017. #if CRIPPLED_REFLECTION
  9018. InfoOf(() => Qbservable.Min(default(IQbservable<int?>))),
  9019. #else
  9020. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9021. #endif
  9022. source.Expression
  9023. )
  9024. );
  9025. }
  9026. /// <summary>
  9027. /// Returns the minimum value in an observable sequence of nullable <see cref="long" /> values.
  9028. /// </summary>
  9029. /// <param name="source">A sequence of nullable <see cref="long" /> values to determine the minimum value of.</param>
  9030. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9031. /// <exception cref="ArgumentNullException">
  9032. /// <paramref name="source" /> is null.</exception>
  9033. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9034. public static IQbservable<long?> Min(this IQbservable<long?> source)
  9035. {
  9036. if (source == null)
  9037. throw new ArgumentNullException(nameof(source));
  9038. return source.Provider.CreateQuery<long?>(
  9039. Expression.Call(
  9040. null,
  9041. #if CRIPPLED_REFLECTION
  9042. InfoOf(() => Qbservable.Min(default(IQbservable<long?>))),
  9043. #else
  9044. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9045. #endif
  9046. source.Expression
  9047. )
  9048. );
  9049. }
  9050. /// <summary>
  9051. /// Returns the minimum value in an observable sequence of nullable <see cref="Single" /> values.
  9052. /// </summary>
  9053. /// <param name="source">A sequence of nullable <see cref="Single" /> values to determine the minimum value of.</param>
  9054. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9055. /// <exception cref="ArgumentNullException">
  9056. /// <paramref name="source" /> is null.</exception>
  9057. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9058. public static IQbservable<float?> Min(this IQbservable<float?> source)
  9059. {
  9060. if (source == null)
  9061. throw new ArgumentNullException(nameof(source));
  9062. return source.Provider.CreateQuery<float?>(
  9063. Expression.Call(
  9064. null,
  9065. #if CRIPPLED_REFLECTION
  9066. InfoOf(() => Qbservable.Min(default(IQbservable<float?>))),
  9067. #else
  9068. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9069. #endif
  9070. source.Expression
  9071. )
  9072. );
  9073. }
  9074. /// <summary>
  9075. /// Returns the minimum value in an observable sequence of <see cref="Single" /> values.
  9076. /// </summary>
  9077. /// <param name="source">A sequence of <see cref="Single" /> values to determine the minimum value of.</param>
  9078. /// <returns>An observable sequence containing a single element with the minimum value in the source sequence.</returns>
  9079. /// <exception cref="ArgumentNullException">
  9080. /// <paramref name="source" /> is null.</exception>
  9081. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9082. public static IQbservable<float> Min(this IQbservable<float> source)
  9083. {
  9084. if (source == null)
  9085. throw new ArgumentNullException(nameof(source));
  9086. return source.Provider.CreateQuery<float>(
  9087. Expression.Call(
  9088. null,
  9089. #if CRIPPLED_REFLECTION
  9090. InfoOf(() => Qbservable.Min(default(IQbservable<float>))),
  9091. #else
  9092. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9093. #endif
  9094. source.Expression
  9095. )
  9096. );
  9097. }
  9098. /// <summary>
  9099. /// Returns the minimum element in an observable sequence.
  9100. /// </summary>
  9101. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9102. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9103. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9104. /// <exception cref="ArgumentNullException">
  9105. /// <paramref name="source" /> is null.</exception>
  9106. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9107. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source)
  9108. {
  9109. if (source == null)
  9110. throw new ArgumentNullException(nameof(source));
  9111. return source.Provider.CreateQuery<TSource>(
  9112. Expression.Call(
  9113. null,
  9114. #if CRIPPLED_REFLECTION
  9115. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>))),
  9116. #else
  9117. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9118. #endif
  9119. source.Expression
  9120. )
  9121. );
  9122. }
  9123. /// <summary>
  9124. /// Returns the minimum element in an observable sequence according to the specified comparer.
  9125. /// </summary>
  9126. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9127. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9128. /// <param name="comparer">Comparer used to compare elements.</param>
  9129. /// <returns>An observable sequence containing a single element with the minimum element in the source sequence.</returns>
  9130. /// <exception cref="ArgumentNullException">
  9131. /// <paramref name="source" /> or <paramref name="comparer" /> is null.</exception>
  9132. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9133. public static IQbservable<TSource> Min<TSource>(this IQbservable<TSource> source, IComparer<TSource> comparer)
  9134. {
  9135. if (source == null)
  9136. throw new ArgumentNullException(nameof(source));
  9137. if (comparer == null)
  9138. throw new ArgumentNullException(nameof(comparer));
  9139. return source.Provider.CreateQuery<TSource>(
  9140. Expression.Call(
  9141. null,
  9142. #if CRIPPLED_REFLECTION
  9143. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(IComparer<TSource>))),
  9144. #else
  9145. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9146. #endif
  9147. source.Expression,
  9148. Expression.Constant(comparer, typeof(IComparer<TSource>))
  9149. )
  9150. );
  9151. }
  9152. /// <summary>
  9153. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="double" /> value.
  9154. /// </summary>
  9155. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9156. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9157. /// <param name="selector">A transform function to apply to each element.</param>
  9158. /// <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>
  9159. /// <exception cref="ArgumentNullException">
  9160. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9161. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9162. public static IQbservable<double> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  9163. {
  9164. if (source == null)
  9165. throw new ArgumentNullException(nameof(source));
  9166. if (selector == null)
  9167. throw new ArgumentNullException(nameof(selector));
  9168. return source.Provider.CreateQuery<double>(
  9169. Expression.Call(
  9170. null,
  9171. #if CRIPPLED_REFLECTION
  9172. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  9173. #else
  9174. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9175. #endif
  9176. source.Expression,
  9177. selector
  9178. )
  9179. );
  9180. }
  9181. /// <summary>
  9182. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="Single" /> value.
  9183. /// </summary>
  9184. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9185. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9186. /// <param name="selector">A transform function to apply to each element.</param>
  9187. /// <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>
  9188. /// <exception cref="ArgumentNullException">
  9189. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9190. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9191. public static IQbservable<float> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  9192. {
  9193. if (source == null)
  9194. throw new ArgumentNullException(nameof(source));
  9195. if (selector == null)
  9196. throw new ArgumentNullException(nameof(selector));
  9197. return source.Provider.CreateQuery<float>(
  9198. Expression.Call(
  9199. null,
  9200. #if CRIPPLED_REFLECTION
  9201. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  9202. #else
  9203. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9204. #endif
  9205. source.Expression,
  9206. selector
  9207. )
  9208. );
  9209. }
  9210. /// <summary>
  9211. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="Decimal" /> value.
  9212. /// </summary>
  9213. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9214. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9215. /// <param name="selector">A transform function to apply to each element.</param>
  9216. /// <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>
  9217. /// <exception cref="ArgumentNullException">
  9218. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9219. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9220. public static IQbservable<decimal> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  9221. {
  9222. if (source == null)
  9223. throw new ArgumentNullException(nameof(source));
  9224. if (selector == null)
  9225. throw new ArgumentNullException(nameof(selector));
  9226. return source.Provider.CreateQuery<decimal>(
  9227. Expression.Call(
  9228. null,
  9229. #if CRIPPLED_REFLECTION
  9230. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  9231. #else
  9232. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9233. #endif
  9234. source.Expression,
  9235. selector
  9236. )
  9237. );
  9238. }
  9239. /// <summary>
  9240. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="int" /> value.
  9241. /// </summary>
  9242. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9243. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9244. /// <param name="selector">A transform function to apply to each element.</param>
  9245. /// <returns>An observable sequence containing a single element with the value of type <see cref="int" /> that corresponds to the minimum value in the source sequence.</returns>
  9246. /// <exception cref="ArgumentNullException">
  9247. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9248. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9249. public static IQbservable<int> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  9250. {
  9251. if (source == null)
  9252. throw new ArgumentNullException(nameof(source));
  9253. if (selector == null)
  9254. throw new ArgumentNullException(nameof(selector));
  9255. return source.Provider.CreateQuery<int>(
  9256. Expression.Call(
  9257. null,
  9258. #if CRIPPLED_REFLECTION
  9259. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  9260. #else
  9261. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9262. #endif
  9263. source.Expression,
  9264. selector
  9265. )
  9266. );
  9267. }
  9268. /// <summary>
  9269. /// Invokes a transform function on each element of a sequence and returns the minimum <see cref="long" /> value.
  9270. /// </summary>
  9271. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9272. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9273. /// <param name="selector">A transform function to apply to each element.</param>
  9274. /// <returns>An observable sequence containing a single element with the value of type <see cref="long" /> that corresponds to the minimum value in the source sequence.</returns>
  9275. /// <exception cref="ArgumentNullException">
  9276. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9277. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9278. public static IQbservable<long> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  9279. {
  9280. if (source == null)
  9281. throw new ArgumentNullException(nameof(source));
  9282. if (selector == null)
  9283. throw new ArgumentNullException(nameof(selector));
  9284. return source.Provider.CreateQuery<long>(
  9285. Expression.Call(
  9286. null,
  9287. #if CRIPPLED_REFLECTION
  9288. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  9289. #else
  9290. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9291. #endif
  9292. source.Expression,
  9293. selector
  9294. )
  9295. );
  9296. }
  9297. /// <summary>
  9298. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="double" /> value.
  9299. /// </summary>
  9300. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9301. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9302. /// <param name="selector">A transform function to apply to each element.</param>
  9303. /// <returns>An observable sequence containing a single element with the value of type <see cref="Nullable{Double}" /> that corresponds to the minimum value in the source sequence.</returns>
  9304. /// <exception cref="ArgumentNullException">
  9305. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9306. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9307. public static IQbservable<double?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  9308. {
  9309. if (source == null)
  9310. throw new ArgumentNullException(nameof(source));
  9311. if (selector == null)
  9312. throw new ArgumentNullException(nameof(selector));
  9313. return source.Provider.CreateQuery<double?>(
  9314. Expression.Call(
  9315. null,
  9316. #if CRIPPLED_REFLECTION
  9317. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  9318. #else
  9319. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9320. #endif
  9321. source.Expression,
  9322. selector
  9323. )
  9324. );
  9325. }
  9326. /// <summary>
  9327. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="Single" /> value.
  9328. /// </summary>
  9329. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9330. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9331. /// <param name="selector">A transform function to apply to each element.</param>
  9332. /// <returns>An observable sequence containing a single element with the value of type <see cref="Nullable{Single}" /> that corresponds to the minimum value in the source sequence.</returns>
  9333. /// <exception cref="ArgumentNullException">
  9334. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9335. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9336. public static IQbservable<float?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  9337. {
  9338. if (source == null)
  9339. throw new ArgumentNullException(nameof(source));
  9340. if (selector == null)
  9341. throw new ArgumentNullException(nameof(selector));
  9342. return source.Provider.CreateQuery<float?>(
  9343. Expression.Call(
  9344. null,
  9345. #if CRIPPLED_REFLECTION
  9346. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  9347. #else
  9348. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9349. #endif
  9350. source.Expression,
  9351. selector
  9352. )
  9353. );
  9354. }
  9355. /// <summary>
  9356. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="Decimal" /> value.
  9357. /// </summary>
  9358. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9359. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9360. /// <param name="selector">A transform function to apply to each element.</param>
  9361. /// <returns>An observable sequence containing a single element with the value of type <see cref="Nullable{Decimal}" /> that corresponds to the minimum value in the source sequence.</returns>
  9362. /// <exception cref="ArgumentNullException">
  9363. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9364. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9365. public static IQbservable<decimal?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  9366. {
  9367. if (source == null)
  9368. throw new ArgumentNullException(nameof(source));
  9369. if (selector == null)
  9370. throw new ArgumentNullException(nameof(selector));
  9371. return source.Provider.CreateQuery<decimal?>(
  9372. Expression.Call(
  9373. null,
  9374. #if CRIPPLED_REFLECTION
  9375. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  9376. #else
  9377. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9378. #endif
  9379. source.Expression,
  9380. selector
  9381. )
  9382. );
  9383. }
  9384. /// <summary>
  9385. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="int" /> value.
  9386. /// </summary>
  9387. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9388. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9389. /// <param name="selector">A transform function to apply to each element.</param>
  9390. /// <returns>An observable sequence containing a single element with the value of type <see cref="Nullable{Int32}" /> that corresponds to the minimum value in the source sequence.</returns>
  9391. /// <exception cref="ArgumentNullException">
  9392. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9393. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9394. public static IQbservable<int?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  9395. {
  9396. if (source == null)
  9397. throw new ArgumentNullException(nameof(source));
  9398. if (selector == null)
  9399. throw new ArgumentNullException(nameof(selector));
  9400. return source.Provider.CreateQuery<int?>(
  9401. Expression.Call(
  9402. null,
  9403. #if CRIPPLED_REFLECTION
  9404. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  9405. #else
  9406. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9407. #endif
  9408. source.Expression,
  9409. selector
  9410. )
  9411. );
  9412. }
  9413. /// <summary>
  9414. /// Invokes a transform function on each element of a sequence and returns the minimum nullable <see cref="long" /> value.
  9415. /// </summary>
  9416. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9417. /// <param name="source">A sequence of values to determine the minimum value of.</param>
  9418. /// <param name="selector">A transform function to apply to each element.</param>
  9419. /// <returns>An observable sequence containing a single element with the value of type <see cref="Nullable{Int64}" /> that corresponds to the minimum value in the source sequence.</returns>
  9420. /// <exception cref="ArgumentNullException">
  9421. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9422. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9423. public static IQbservable<long?> Min<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  9424. {
  9425. if (source == null)
  9426. throw new ArgumentNullException(nameof(source));
  9427. if (selector == null)
  9428. throw new ArgumentNullException(nameof(selector));
  9429. return source.Provider.CreateQuery<long?>(
  9430. Expression.Call(
  9431. null,
  9432. #if CRIPPLED_REFLECTION
  9433. InfoOf(() => Qbservable.Min<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  9434. #else
  9435. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9436. #endif
  9437. source.Expression,
  9438. selector
  9439. )
  9440. );
  9441. }
  9442. /// <summary>
  9443. /// Invokes a transform function on each element of a sequence and returns the minimum value.
  9444. /// </summary>
  9445. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9446. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9447. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9448. /// <param name="selector">A transform function to apply to each element.</param>
  9449. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9450. /// <exception cref="ArgumentNullException">
  9451. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9452. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9453. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  9454. {
  9455. if (source == null)
  9456. throw new ArgumentNullException(nameof(source));
  9457. if (selector == null)
  9458. throw new ArgumentNullException(nameof(selector));
  9459. return source.Provider.CreateQuery<TResult>(
  9460. Expression.Call(
  9461. null,
  9462. #if CRIPPLED_REFLECTION
  9463. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  9464. #else
  9465. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9466. #endif
  9467. source.Expression,
  9468. selector
  9469. )
  9470. );
  9471. }
  9472. /// <summary>
  9473. /// Invokes a transform function on each element of a sequence and returns the minimum value according to the specified comparer.
  9474. /// </summary>
  9475. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9476. /// <typeparam name="TResult">The type of the objects derived from the elements in the source sequence to determine the minimum of.</typeparam>
  9477. /// <param name="source">An observable sequence to determine the mimimum element of.</param>
  9478. /// <param name="selector">A transform function to apply to each element.</param>
  9479. /// <param name="comparer">Comparer used to compare elements.</param>
  9480. /// <returns>An observable sequence containing a single element with the value that corresponds to the minimum element in the source sequence.</returns>
  9481. /// <exception cref="ArgumentNullException">
  9482. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="comparer" /> is null.</exception>
  9483. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9484. public static IQbservable<TResult> Min<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector, IComparer<TResult> comparer)
  9485. {
  9486. if (source == null)
  9487. throw new ArgumentNullException(nameof(source));
  9488. if (selector == null)
  9489. throw new ArgumentNullException(nameof(selector));
  9490. if (comparer == null)
  9491. throw new ArgumentNullException(nameof(comparer));
  9492. return source.Provider.CreateQuery<TResult>(
  9493. Expression.Call(
  9494. null,
  9495. #if CRIPPLED_REFLECTION
  9496. InfoOf(() => Qbservable.Min<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>), default(IComparer<TResult>))),
  9497. #else
  9498. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9499. #endif
  9500. source.Expression,
  9501. selector,
  9502. Expression.Constant(comparer, typeof(IComparer<TResult>))
  9503. )
  9504. );
  9505. }
  9506. /// <summary>
  9507. /// Returns the elements in an observable sequence with the minimum key value.
  9508. /// </summary>
  9509. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9510. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9511. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9512. /// <param name="keySelector">Key selector function.</param>
  9513. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9514. /// <exception cref="ArgumentNullException">
  9515. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  9516. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9517. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  9518. {
  9519. if (source == null)
  9520. throw new ArgumentNullException(nameof(source));
  9521. if (keySelector == null)
  9522. throw new ArgumentNullException(nameof(keySelector));
  9523. return source.Provider.CreateQuery<IList<TSource>>(
  9524. Expression.Call(
  9525. null,
  9526. #if CRIPPLED_REFLECTION
  9527. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  9528. #else
  9529. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9530. #endif
  9531. source.Expression,
  9532. keySelector
  9533. )
  9534. );
  9535. }
  9536. /// <summary>
  9537. /// Returns the elements in an observable sequence with the minimum key value according to the specified comparer.
  9538. /// </summary>
  9539. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9540. /// <typeparam name="TKey">The type of the key computed for each element in the source sequence.</typeparam>
  9541. /// <param name="source">An observable sequence to get the minimum elements for.</param>
  9542. /// <param name="keySelector">Key selector function.</param>
  9543. /// <param name="comparer">Comparer used to compare key values.</param>
  9544. /// <returns>An observable sequence containing a list of zero or more elements that have a minimum key value.</returns>
  9545. /// <exception cref="ArgumentNullException">
  9546. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  9547. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  9548. public static IQbservable<IList<TSource>> MinBy<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IComparer<TKey> comparer)
  9549. {
  9550. if (source == null)
  9551. throw new ArgumentNullException(nameof(source));
  9552. if (keySelector == null)
  9553. throw new ArgumentNullException(nameof(keySelector));
  9554. if (comparer == null)
  9555. throw new ArgumentNullException(nameof(comparer));
  9556. return source.Provider.CreateQuery<IList<TSource>>(
  9557. Expression.Call(
  9558. null,
  9559. #if CRIPPLED_REFLECTION
  9560. InfoOf(() => Qbservable.MinBy<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IComparer<TKey>))),
  9561. #else
  9562. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  9563. #endif
  9564. source.Expression,
  9565. keySelector,
  9566. Expression.Constant(comparer, typeof(IComparer<TKey>))
  9567. )
  9568. );
  9569. }
  9570. /// <summary>
  9571. /// 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.
  9572. /// Enumerators on the resulting sequence never block and can produce the same element repeatedly.
  9573. /// </summary>
  9574. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9575. /// <param name="source">Source observable sequence.</param>
  9576. /// <param name="initialValue">Initial value that will be yielded by the enumerable sequence if no element has been sampled yet.</param>
  9577. /// <returns>The enumerable sequence that returns the last sampled element upon each iteration.</returns>
  9578. /// <exception cref="ArgumentNullException">
  9579. /// <paramref name="source" /> is null.</exception>
  9580. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9581. public static IQueryable<TSource> MostRecent<TSource>(this IQbservable<TSource> source, TSource initialValue)
  9582. {
  9583. if (source == null)
  9584. throw new ArgumentNullException(nameof(source));
  9585. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9586. Expression.Call(
  9587. null,
  9588. #if CRIPPLED_REFLECTION
  9589. InfoOf(() => Qbservable.MostRecent<TSource>(default(IQbservable<TSource>), default(TSource))),
  9590. #else
  9591. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9592. #endif
  9593. source.Expression,
  9594. Expression.Constant(initialValue, typeof(TSource))
  9595. )
  9596. );
  9597. }
  9598. /// <summary>
  9599. /// Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. Each
  9600. /// subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's
  9601. /// invocation. For specializations with fixed subject types, see Publish, PublishLast, and Replay.
  9602. /// </summary>
  9603. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9604. /// <typeparam name="TIntermediate">The type of the elements produced by the intermediate subject.</typeparam>
  9605. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9606. /// <param name="source">Source sequence which will be multicasted in the specified selector function.</param>
  9607. /// <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>
  9608. /// <param name="selector">Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject.</param>
  9609. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9610. /// <exception cref="ArgumentNullException">
  9611. /// <paramref name="source" /> or <paramref name="subjectSelector" /> or <paramref name="selector" /> is null.</exception>
  9612. 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)
  9613. {
  9614. if (source == null)
  9615. throw new ArgumentNullException(nameof(source));
  9616. if (subjectSelector == null)
  9617. throw new ArgumentNullException(nameof(subjectSelector));
  9618. if (selector == null)
  9619. throw new ArgumentNullException(nameof(selector));
  9620. return source.Provider.CreateQuery<TResult>(
  9621. Expression.Call(
  9622. null,
  9623. #if CRIPPLED_REFLECTION
  9624. InfoOf(() => Qbservable.Multicast<TSource, TIntermediate, TResult>(default(IQbservable<TSource>), default(Expression<Func<ISubject<TSource, TIntermediate>>>), default(Expression<Func<IObservable<TIntermediate>, IObservable<TResult>>>))),
  9625. #else
  9626. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TIntermediate), typeof(TResult)),
  9627. #endif
  9628. source.Expression,
  9629. subjectSelector,
  9630. selector
  9631. )
  9632. );
  9633. }
  9634. /// <summary>
  9635. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9636. /// </summary>
  9637. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9638. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}"/> type parameter of the resulting sequence.</typeparam>
  9639. /// <returns>An observable sequence whose observers will never get called.</returns>
  9640. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider)
  9641. {
  9642. if (provider == null)
  9643. throw new ArgumentNullException(nameof(provider));
  9644. return provider.CreateQuery<TResult>(
  9645. Expression.Call(
  9646. null,
  9647. #if CRIPPLED_REFLECTION
  9648. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider))),
  9649. #else
  9650. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9651. #endif
  9652. Expression.Constant(provider, typeof(IQbservableProvider))
  9653. )
  9654. );
  9655. }
  9656. /// <summary>
  9657. /// Returns a non-terminating observable sequence, which can be used to denote an infinite duration (e.g. when using reactive joins).
  9658. /// </summary>
  9659. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9660. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}"/> type parameter of the resulting sequence.</typeparam>
  9661. /// <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>
  9662. /// <returns>An observable sequence whose observers will never get called.</returns>
  9663. public static IQbservable<TResult> Never<TResult>(this IQbservableProvider provider, TResult witness)
  9664. {
  9665. if (provider == null)
  9666. throw new ArgumentNullException(nameof(provider));
  9667. return provider.CreateQuery<TResult>(
  9668. Expression.Call(
  9669. null,
  9670. #if CRIPPLED_REFLECTION
  9671. InfoOf(() => Qbservable.Never<TResult>(default(IQbservableProvider), default(TResult))),
  9672. #else
  9673. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9674. #endif
  9675. Expression.Constant(provider, typeof(IQbservableProvider)),
  9676. Expression.Constant(witness, typeof(TResult))
  9677. )
  9678. );
  9679. }
  9680. /// <summary>
  9681. /// Returns an enumerable sequence whose enumeration blocks until the next element in the source observable sequence becomes available.
  9682. /// Enumerators on the resulting sequence will block until the next element becomes available.
  9683. /// </summary>
  9684. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9685. /// <param name="source">Source observable sequence.</param>
  9686. /// <returns>The enumerable sequence that blocks upon each iteration until the next element in the observable source sequence becomes available.</returns>
  9687. /// <exception cref="ArgumentNullException">
  9688. /// <paramref name="source" /> is null.</exception>
  9689. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  9690. public static IQueryable<TSource> Next<TSource>(this IQbservable<TSource> source)
  9691. {
  9692. if (source == null)
  9693. throw new ArgumentNullException(nameof(source));
  9694. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  9695. Expression.Call(
  9696. null,
  9697. #if CRIPPLED_REFLECTION
  9698. InfoOf(() => Qbservable.Next<TSource>(default(IQbservable<TSource>))),
  9699. #else
  9700. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9701. #endif
  9702. source.Expression
  9703. )
  9704. );
  9705. }
  9706. /// <summary>
  9707. /// Wraps the source sequence in order to run its observer callbacks on the specified synchronization context.
  9708. /// </summary>
  9709. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9710. /// <param name="source">Source sequence.</param>
  9711. /// <param name="context">Synchronization context to notify observers on.</param>
  9712. /// <returns>The source sequence whose observations happen on the specified synchronization context.</returns>
  9713. /// <exception cref="ArgumentNullException">
  9714. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  9715. /// <remarks>
  9716. /// This only invokes observer callbacks on a synchronization context. In case the subscription and/or unsubscription actions have side-effects
  9717. /// that require to be run on a synchronization context, use <see cref="Observable.SubscribeOn{TSource}(IObservable{TSource},SynchronizationContext)" />.
  9718. /// </remarks>
  9719. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  9720. {
  9721. if (source == null)
  9722. throw new ArgumentNullException(nameof(source));
  9723. if (context == null)
  9724. throw new ArgumentNullException(nameof(context));
  9725. return source.Provider.CreateQuery<TSource>(
  9726. Expression.Call(
  9727. null,
  9728. #if CRIPPLED_REFLECTION
  9729. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  9730. #else
  9731. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9732. #endif
  9733. source.Expression,
  9734. Expression.Constant(context, typeof(SynchronizationContext))
  9735. )
  9736. );
  9737. }
  9738. /// <summary>
  9739. /// Wraps the source sequence in order to run its observer callbacks on the specified scheduler.
  9740. /// </summary>
  9741. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9742. /// <param name="source">Source sequence.</param>
  9743. /// <param name="scheduler">Scheduler to notify observers on.</param>
  9744. /// <returns>The source sequence whose observations happen on the specified scheduler.</returns>
  9745. /// <exception cref="ArgumentNullException">
  9746. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  9747. /// <remarks>
  9748. /// This only invokes observer callbacks on a scheduler. In case the subscription and/or unsubscription actions have side-effects
  9749. /// that require to be run on a scheduler, use <see cref="Observable.SubscribeOn{TSource}(IObservable{TSource},IScheduler)" />.
  9750. /// </remarks>
  9751. public static IQbservable<TSource> ObserveOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  9752. {
  9753. if (source == null)
  9754. throw new ArgumentNullException(nameof(source));
  9755. if (scheduler == null)
  9756. throw new ArgumentNullException(nameof(scheduler));
  9757. return source.Provider.CreateQuery<TSource>(
  9758. Expression.Call(
  9759. null,
  9760. #if CRIPPLED_REFLECTION
  9761. InfoOf(() => Qbservable.ObserveOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  9762. #else
  9763. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9764. #endif
  9765. source.Expression,
  9766. Expression.Constant(scheduler, typeof(IScheduler))
  9767. )
  9768. );
  9769. }
  9770. /// <summary>
  9771. /// Filters the elements of an observable sequence based on the specified type.
  9772. /// </summary>
  9773. /// <typeparam name="TResult">The type to filter the elements in the source sequence on.</typeparam>
  9774. /// <param name="source">The observable sequence that contains the elements to be filtered.</param>
  9775. /// <returns>An observable sequence that contains elements from the input sequence of type TResult.</returns>
  9776. /// <exception cref="ArgumentNullException">
  9777. /// <paramref name="source" /> is null.</exception>
  9778. public static IQbservable<TResult> OfType<TResult>(this IQbservable<object> source)
  9779. {
  9780. if (source == null)
  9781. throw new ArgumentNullException(nameof(source));
  9782. return source.Provider.CreateQuery<TResult>(
  9783. Expression.Call(
  9784. null,
  9785. #if CRIPPLED_REFLECTION
  9786. InfoOf(() => Qbservable.OfType<TResult>(default(IQbservable<object>))),
  9787. #else
  9788. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  9789. #endif
  9790. source.Expression
  9791. )
  9792. );
  9793. }
  9794. /// <summary>
  9795. /// Concatenates the second observable sequence to the first observable sequence upon successful or exceptional termination of the first.
  9796. /// </summary>
  9797. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9798. /// <param name="first">First observable sequence whose exception (if any) is caught.</param>
  9799. /// <param name="second">Second observable sequence used to produce results after the first sequence terminates.</param>
  9800. /// <returns>An observable sequence that concatenates the first and second sequence, even if the first sequence terminates exceptionally.</returns>
  9801. /// <exception cref="ArgumentNullException">
  9802. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  9803. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  9804. {
  9805. if (first == null)
  9806. throw new ArgumentNullException(nameof(first));
  9807. if (second == null)
  9808. throw new ArgumentNullException(nameof(second));
  9809. return first.Provider.CreateQuery<TSource>(
  9810. Expression.Call(
  9811. null,
  9812. #if CRIPPLED_REFLECTION
  9813. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  9814. #else
  9815. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9816. #endif
  9817. first.Expression,
  9818. GetSourceExpression(second)
  9819. )
  9820. );
  9821. }
  9822. /// <summary>
  9823. /// Concatenates all of the specified observable sequences, even if the previous observable sequence terminated exceptionally.
  9824. /// </summary>
  9825. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9826. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9827. /// <param name="sources">Observable sequences to concatenate.</param>
  9828. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  9829. /// <exception cref="ArgumentNullException">
  9830. /// <paramref name="sources" /> is null.</exception>
  9831. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  9832. {
  9833. if (provider == null)
  9834. throw new ArgumentNullException(nameof(provider));
  9835. if (sources == null)
  9836. throw new ArgumentNullException(nameof(sources));
  9837. return provider.CreateQuery<TSource>(
  9838. Expression.Call(
  9839. null,
  9840. #if CRIPPLED_REFLECTION
  9841. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  9842. #else
  9843. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9844. #endif
  9845. Expression.Constant(provider, typeof(IQbservableProvider)),
  9846. GetSourceExpression(sources)
  9847. )
  9848. );
  9849. }
  9850. /// <summary>
  9851. /// Concatenates all observable sequences in the given enumerable sequence, even if the previous observable sequence terminated exceptionally.
  9852. /// </summary>
  9853. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9854. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  9855. /// <param name="sources">Observable sequences to concatenate.</param>
  9856. /// <returns>An observable sequence that concatenates the source sequences, even if a sequence terminates exceptionally.</returns>
  9857. /// <exception cref="ArgumentNullException">
  9858. /// <paramref name="sources" /> is null.</exception>
  9859. public static IQbservable<TSource> OnErrorResumeNext<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  9860. {
  9861. if (provider == null)
  9862. throw new ArgumentNullException(nameof(provider));
  9863. if (sources == null)
  9864. throw new ArgumentNullException(nameof(sources));
  9865. return provider.CreateQuery<TSource>(
  9866. Expression.Call(
  9867. null,
  9868. #if CRIPPLED_REFLECTION
  9869. InfoOf(() => Qbservable.OnErrorResumeNext<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  9870. #else
  9871. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  9872. #endif
  9873. Expression.Constant(provider, typeof(IQbservableProvider)),
  9874. GetSourceExpression(sources)
  9875. )
  9876. );
  9877. }
  9878. /// <summary>
  9879. /// 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.
  9880. /// This operator is a specialization of Multicast using a regular <see cref="Reactive.Subjects.Subject{TResult}" />.
  9881. /// </summary>
  9882. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9883. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9884. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  9885. /// <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>
  9886. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9887. /// <exception cref="ArgumentNullException">
  9888. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9889. /// <seealso cref="Reactive.Subjects.Subject{TResult}" />
  9890. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  9891. {
  9892. if (source == null)
  9893. throw new ArgumentNullException(nameof(source));
  9894. if (selector == null)
  9895. throw new ArgumentNullException(nameof(selector));
  9896. return source.Provider.CreateQuery<TResult>(
  9897. Expression.Call(
  9898. null,
  9899. #if CRIPPLED_REFLECTION
  9900. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  9901. #else
  9902. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9903. #endif
  9904. source.Expression,
  9905. selector
  9906. )
  9907. );
  9908. }
  9909. /// <summary>
  9910. /// 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.
  9911. /// This operator is a specialization of Multicast using a <see cref="Reactive.Subjects.BehaviorSubject{TResult}" />.
  9912. /// </summary>
  9913. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9914. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9915. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  9916. /// <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>
  9917. /// <param name="initialValue">Initial value received by observers upon subscription.</param>
  9918. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9919. /// <exception cref="ArgumentNullException">
  9920. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9921. /// <seealso cref="Reactive.Subjects.BehaviorSubject{TResult}" />
  9922. public static IQbservable<TResult> Publish<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TSource initialValue)
  9923. {
  9924. if (source == null)
  9925. throw new ArgumentNullException(nameof(source));
  9926. if (selector == null)
  9927. throw new ArgumentNullException(nameof(selector));
  9928. return source.Provider.CreateQuery<TResult>(
  9929. Expression.Call(
  9930. null,
  9931. #if CRIPPLED_REFLECTION
  9932. InfoOf(() => Qbservable.Publish<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TSource))),
  9933. #else
  9934. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9935. #endif
  9936. source.Expression,
  9937. selector,
  9938. Expression.Constant(initialValue, typeof(TSource))
  9939. )
  9940. );
  9941. }
  9942. /// <summary>
  9943. /// 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.
  9944. /// This operator is a specialization of Multicast using a <see cref="Reactive.Subjects.AsyncSubject{TResult}" />.
  9945. /// </summary>
  9946. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  9947. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  9948. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  9949. /// <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>
  9950. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  9951. /// <exception cref="ArgumentNullException">
  9952. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  9953. /// <seealso cref="Reactive.Subjects.AsyncSubject{TResult}" />
  9954. public static IQbservable<TResult> PublishLast<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  9955. {
  9956. if (source == null)
  9957. throw new ArgumentNullException(nameof(source));
  9958. if (selector == null)
  9959. throw new ArgumentNullException(nameof(selector));
  9960. return source.Provider.CreateQuery<TResult>(
  9961. Expression.Call(
  9962. null,
  9963. #if CRIPPLED_REFLECTION
  9964. InfoOf(() => Qbservable.PublishLast<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  9965. #else
  9966. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  9967. #endif
  9968. source.Expression,
  9969. selector
  9970. )
  9971. );
  9972. }
  9973. /// <summary>
  9974. /// Generates an observable sequence of integral numbers within a specified range.
  9975. /// </summary>
  9976. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  9977. /// <param name="start">The value of the first integer in the sequence.</param>
  9978. /// <param name="count">The number of sequential integers to generate.</param>
  9979. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  9980. /// <exception cref="ArgumentOutOfRangeException">
  9981. /// <paramref name="count" /> is less than zero. -or- <paramref name="start" /> + <paramref name="count" /> - 1 is larger than <see cref="Int32.MaxValue" />.</exception>
  9982. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count)
  9983. {
  9984. if (provider == null)
  9985. throw new ArgumentNullException(nameof(provider));
  9986. return provider.CreateQuery<int>(
  9987. Expression.Call(
  9988. null,
  9989. #if CRIPPLED_REFLECTION
  9990. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int))),
  9991. #else
  9992. (MethodInfo)MethodInfo.GetCurrentMethod(),
  9993. #endif
  9994. Expression.Constant(provider, typeof(IQbservableProvider)),
  9995. Expression.Constant(start, typeof(int)),
  9996. Expression.Constant(count, typeof(int))
  9997. )
  9998. );
  9999. }
  10000. /// <summary>
  10001. /// Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to send out observer messages.
  10002. /// </summary>
  10003. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10004. /// <param name="start">The value of the first integer in the sequence.</param>
  10005. /// <param name="count">The number of sequential integers to generate.</param>
  10006. /// <param name="scheduler">Scheduler to run the generator loop on.</param>
  10007. /// <returns>An observable sequence that contains a range of sequential integral numbers.</returns>
  10008. /// <exception cref="ArgumentOutOfRangeException">
  10009. /// <paramref name="count" /> is less than zero. -or- <paramref name="start" /> + <paramref name="count" /> - 1 is larger than <see cref="Int32.MaxValue" />.</exception>
  10010. /// <exception cref="ArgumentNullException">
  10011. /// <paramref name="scheduler" /> is null.</exception>
  10012. public static IQbservable<int> Range(this IQbservableProvider provider, int start, int count, IScheduler scheduler)
  10013. {
  10014. if (provider == null)
  10015. throw new ArgumentNullException(nameof(provider));
  10016. if (scheduler == null)
  10017. throw new ArgumentNullException(nameof(scheduler));
  10018. return provider.CreateQuery<int>(
  10019. Expression.Call(
  10020. null,
  10021. #if CRIPPLED_REFLECTION
  10022. InfoOf(() => Qbservable.Range(default(IQbservableProvider), default(int), default(int), default(IScheduler))),
  10023. #else
  10024. (MethodInfo)MethodInfo.GetCurrentMethod(),
  10025. #endif
  10026. Expression.Constant(provider, typeof(IQbservableProvider)),
  10027. Expression.Constant(start, typeof(int)),
  10028. Expression.Constant(count, typeof(int)),
  10029. Expression.Constant(scheduler, typeof(IScheduler))
  10030. )
  10031. );
  10032. }
  10033. /// <summary>
  10034. /// Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.
  10035. /// </summary>
  10036. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10037. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10038. /// <param name="source">Connectable observable sequence.</param>
  10039. /// <returns>An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence.</returns>
  10040. /// <exception cref="ArgumentNullException">
  10041. /// <paramref name="source" /> is null.</exception>
  10042. public static IQbservable<TSource> RefCount<TSource>(this IQbservableProvider provider, IConnectableObservable<TSource> source)
  10043. {
  10044. if (provider == null)
  10045. throw new ArgumentNullException(nameof(provider));
  10046. if (source == null)
  10047. throw new ArgumentNullException(nameof(source));
  10048. return provider.CreateQuery<TSource>(
  10049. Expression.Call(
  10050. null,
  10051. #if CRIPPLED_REFLECTION
  10052. InfoOf(() => Qbservable.RefCount<TSource>(default(IQbservableProvider), default(IConnectableObservable<TSource>))),
  10053. #else
  10054. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10055. #endif
  10056. Expression.Constant(provider, typeof(IQbservableProvider)),
  10057. Expression.Constant(source, typeof(IConnectableObservable<TSource>))
  10058. )
  10059. );
  10060. }
  10061. /// <summary>
  10062. /// Generates an observable sequence that repeats the given element infinitely.
  10063. /// </summary>
  10064. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10065. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10066. /// <param name="value">Element to repeat.</param>
  10067. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10068. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value)
  10069. {
  10070. if (provider == null)
  10071. throw new ArgumentNullException(nameof(provider));
  10072. return provider.CreateQuery<TResult>(
  10073. Expression.Call(
  10074. null,
  10075. #if CRIPPLED_REFLECTION
  10076. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult))),
  10077. #else
  10078. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10079. #endif
  10080. Expression.Constant(provider, typeof(IQbservableProvider)),
  10081. Expression.Constant(value, typeof(TResult))
  10082. )
  10083. );
  10084. }
  10085. /// <summary>
  10086. /// Generates an observable sequence that repeats the given element the specified number of times.
  10087. /// </summary>
  10088. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10089. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10090. /// <param name="value">Element to repeat.</param>
  10091. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10092. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10093. /// <exception cref="ArgumentOutOfRangeException">
  10094. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10095. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount)
  10096. {
  10097. if (provider == null)
  10098. throw new ArgumentNullException(nameof(provider));
  10099. return provider.CreateQuery<TResult>(
  10100. Expression.Call(
  10101. null,
  10102. #if CRIPPLED_REFLECTION
  10103. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int))),
  10104. #else
  10105. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10106. #endif
  10107. Expression.Constant(provider, typeof(IQbservableProvider)),
  10108. Expression.Constant(value, typeof(TResult)),
  10109. Expression.Constant(repeatCount, typeof(int))
  10110. )
  10111. );
  10112. }
  10113. /// <summary>
  10114. /// Generates an observable sequence that repeats the given element the specified number of times, using the specified scheduler to send out observer messages.
  10115. /// </summary>
  10116. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10117. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10118. /// <param name="value">Element to repeat.</param>
  10119. /// <param name="repeatCount">Number of times to repeat the element.</param>
  10120. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10121. /// <returns>An observable sequence that repeats the given element the specified number of times.</returns>
  10122. /// <exception cref="ArgumentOutOfRangeException">
  10123. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10124. /// <exception cref="ArgumentNullException">
  10125. /// <paramref name="scheduler" /> is null.</exception>
  10126. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, int repeatCount, IScheduler scheduler)
  10127. {
  10128. if (provider == null)
  10129. throw new ArgumentNullException(nameof(provider));
  10130. if (scheduler == null)
  10131. throw new ArgumentNullException(nameof(scheduler));
  10132. return provider.CreateQuery<TResult>(
  10133. Expression.Call(
  10134. null,
  10135. #if CRIPPLED_REFLECTION
  10136. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(int), default(IScheduler))),
  10137. #else
  10138. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10139. #endif
  10140. Expression.Constant(provider, typeof(IQbservableProvider)),
  10141. Expression.Constant(value, typeof(TResult)),
  10142. Expression.Constant(repeatCount, typeof(int)),
  10143. Expression.Constant(scheduler, typeof(IScheduler))
  10144. )
  10145. );
  10146. }
  10147. /// <summary>
  10148. /// Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages.
  10149. /// </summary>
  10150. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10151. /// <typeparam name="TResult">The type of the element that will be repeated in the produced sequence.</typeparam>
  10152. /// <param name="value">Element to repeat.</param>
  10153. /// <param name="scheduler">Scheduler to run the producer loop on.</param>
  10154. /// <returns>An observable sequence that repeats the given element infinitely.</returns>
  10155. /// <exception cref="ArgumentNullException">
  10156. /// <paramref name="scheduler" /> is null.</exception>
  10157. public static IQbservable<TResult> Repeat<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10158. {
  10159. if (provider == null)
  10160. throw new ArgumentNullException(nameof(provider));
  10161. if (scheduler == null)
  10162. throw new ArgumentNullException(nameof(scheduler));
  10163. return provider.CreateQuery<TResult>(
  10164. Expression.Call(
  10165. null,
  10166. #if CRIPPLED_REFLECTION
  10167. InfoOf(() => Qbservable.Repeat<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10168. #else
  10169. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10170. #endif
  10171. Expression.Constant(provider, typeof(IQbservableProvider)),
  10172. Expression.Constant(value, typeof(TResult)),
  10173. Expression.Constant(scheduler, typeof(IScheduler))
  10174. )
  10175. );
  10176. }
  10177. /// <summary>
  10178. /// Repeats the observable sequence indefinitely.
  10179. /// </summary>
  10180. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10181. /// <param name="source">Observable sequence to repeat.</param>
  10182. /// <returns>The observable sequence producing the elements of the given sequence repeatedly and sequentially.</returns>
  10183. /// <exception cref="ArgumentNullException">
  10184. /// <paramref name="source" /> is null.</exception>
  10185. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source)
  10186. {
  10187. if (source == null)
  10188. throw new ArgumentNullException(nameof(source));
  10189. return source.Provider.CreateQuery<TSource>(
  10190. Expression.Call(
  10191. null,
  10192. #if CRIPPLED_REFLECTION
  10193. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>))),
  10194. #else
  10195. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10196. #endif
  10197. source.Expression
  10198. )
  10199. );
  10200. }
  10201. /// <summary>
  10202. /// Repeats the observable sequence a specified number of times.
  10203. /// </summary>
  10204. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10205. /// <param name="source">Observable sequence to repeat.</param>
  10206. /// <param name="repeatCount">Number of times to repeat the sequence.</param>
  10207. /// <returns>The observable sequence producing the elements of the given sequence repeatedly.</returns>
  10208. /// <exception cref="ArgumentNullException">
  10209. /// <paramref name="source" /> is null.</exception>
  10210. /// <exception cref="ArgumentOutOfRangeException">
  10211. /// <paramref name="repeatCount" /> is less than zero.</exception>
  10212. public static IQbservable<TSource> Repeat<TSource>(this IQbservable<TSource> source, int repeatCount)
  10213. {
  10214. if (source == null)
  10215. throw new ArgumentNullException(nameof(source));
  10216. return source.Provider.CreateQuery<TSource>(
  10217. Expression.Call(
  10218. null,
  10219. #if CRIPPLED_REFLECTION
  10220. InfoOf(() => Qbservable.Repeat<TSource>(default(IQbservable<TSource>), default(int))),
  10221. #else
  10222. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10223. #endif
  10224. source.Expression,
  10225. Expression.Constant(repeatCount, typeof(int))
  10226. )
  10227. );
  10228. }
  10229. /// <summary>
  10230. /// 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.
  10231. /// This operator is a specialization of Multicast using a <see cref="Reactive.Subjects.ReplaySubject{TResult}" />.
  10232. /// </summary>
  10233. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10234. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10235. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10236. /// <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>
  10237. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10238. /// <exception cref="ArgumentNullException">
  10239. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10240. /// <seealso cref="Reactive.Subjects.ReplaySubject{TResult}" />
  10241. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector)
  10242. {
  10243. if (source == null)
  10244. throw new ArgumentNullException(nameof(source));
  10245. if (selector == null)
  10246. throw new ArgumentNullException(nameof(selector));
  10247. return source.Provider.CreateQuery<TResult>(
  10248. Expression.Call(
  10249. null,
  10250. #if CRIPPLED_REFLECTION
  10251. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>))),
  10252. #else
  10253. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10254. #endif
  10255. source.Expression,
  10256. selector
  10257. )
  10258. );
  10259. }
  10260. /// <summary>
  10261. /// 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.
  10262. /// This operator is a specialization of Multicast using a <see cref="Reactive.Subjects.ReplaySubject{TResult}" />.
  10263. /// </summary>
  10264. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10265. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10266. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10267. /// <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>
  10268. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10269. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10270. /// <exception cref="ArgumentNullException">
  10271. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10272. /// <exception cref="ArgumentOutOfRangeException">
  10273. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10274. /// <seealso cref="Reactive.Subjects.ReplaySubject{TResult}" />
  10275. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize)
  10276. {
  10277. if (source == null)
  10278. throw new ArgumentNullException(nameof(source));
  10279. if (selector == null)
  10280. throw new ArgumentNullException(nameof(selector));
  10281. return source.Provider.CreateQuery<TResult>(
  10282. Expression.Call(
  10283. null,
  10284. #if CRIPPLED_REFLECTION
  10285. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int))),
  10286. #else
  10287. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10288. #endif
  10289. source.Expression,
  10290. selector,
  10291. Expression.Constant(bufferSize, typeof(int))
  10292. )
  10293. );
  10294. }
  10295. /// <summary>
  10296. /// 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.
  10297. /// This operator is a specialization of Multicast using a <see cref="Reactive.Subjects.ReplaySubject{TResult}" />.
  10298. /// </summary>
  10299. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10300. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10301. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10302. /// <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>
  10303. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10304. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10305. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10306. /// <exception cref="ArgumentNullException">
  10307. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10308. /// <exception cref="ArgumentOutOfRangeException">
  10309. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10310. /// <seealso cref="Reactive.Subjects.ReplaySubject{TResult}" />
  10311. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, IScheduler scheduler)
  10312. {
  10313. if (source == null)
  10314. throw new ArgumentNullException(nameof(source));
  10315. if (selector == null)
  10316. throw new ArgumentNullException(nameof(selector));
  10317. if (scheduler == null)
  10318. throw new ArgumentNullException(nameof(scheduler));
  10319. return source.Provider.CreateQuery<TResult>(
  10320. Expression.Call(
  10321. null,
  10322. #if CRIPPLED_REFLECTION
  10323. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(IScheduler))),
  10324. #else
  10325. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10326. #endif
  10327. source.Expression,
  10328. selector,
  10329. Expression.Constant(bufferSize, typeof(int)),
  10330. Expression.Constant(scheduler, typeof(IScheduler))
  10331. )
  10332. );
  10333. }
  10334. /// <summary>
  10335. /// 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.
  10336. /// This operator is a specialization of Multicast using a <see cref="Reactive.Subjects.ReplaySubject{TResult}" />.
  10337. /// </summary>
  10338. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10339. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10340. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10341. /// <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>
  10342. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10343. /// <param name="window">Maximum time length of the replay buffer.</param>
  10344. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10345. /// <exception cref="ArgumentNullException">
  10346. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10347. /// <exception cref="ArgumentOutOfRangeException">
  10348. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10349. /// <exception cref="ArgumentOutOfRangeException">
  10350. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10351. /// <seealso cref="Reactive.Subjects.ReplaySubject{TResult}" />
  10352. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window)
  10353. {
  10354. if (source == null)
  10355. throw new ArgumentNullException(nameof(source));
  10356. if (selector == null)
  10357. throw new ArgumentNullException(nameof(selector));
  10358. return source.Provider.CreateQuery<TResult>(
  10359. Expression.Call(
  10360. null,
  10361. #if CRIPPLED_REFLECTION
  10362. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan))),
  10363. #else
  10364. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10365. #endif
  10366. source.Expression,
  10367. selector,
  10368. Expression.Constant(bufferSize, typeof(int)),
  10369. Expression.Constant(window, typeof(TimeSpan))
  10370. )
  10371. );
  10372. }
  10373. /// <summary>
  10374. /// 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.
  10375. /// This operator is a specialization of Multicast using a <see cref="Reactive.Subjects.ReplaySubject{TResult}" />.
  10376. /// </summary>
  10377. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10378. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10379. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10380. /// <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>
  10381. /// <param name="bufferSize">Maximum element count of the replay buffer.</param>
  10382. /// <param name="window">Maximum time length of the replay buffer.</param>
  10383. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10384. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10385. /// <exception cref="ArgumentNullException">
  10386. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10387. /// <exception cref="ArgumentOutOfRangeException">
  10388. /// <paramref name="bufferSize" /> is less than zero.</exception>
  10389. /// <exception cref="ArgumentOutOfRangeException">
  10390. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10391. /// <seealso cref="Reactive.Subjects.ReplaySubject{TResult}" />
  10392. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, int bufferSize, TimeSpan window, IScheduler scheduler)
  10393. {
  10394. if (source == null)
  10395. throw new ArgumentNullException(nameof(source));
  10396. if (selector == null)
  10397. throw new ArgumentNullException(nameof(selector));
  10398. if (scheduler == null)
  10399. throw new ArgumentNullException(nameof(scheduler));
  10400. return source.Provider.CreateQuery<TResult>(
  10401. Expression.Call(
  10402. null,
  10403. #if CRIPPLED_REFLECTION
  10404. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(int), default(TimeSpan), default(IScheduler))),
  10405. #else
  10406. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10407. #endif
  10408. source.Expression,
  10409. selector,
  10410. Expression.Constant(bufferSize, typeof(int)),
  10411. Expression.Constant(window, typeof(TimeSpan)),
  10412. Expression.Constant(scheduler, typeof(IScheduler))
  10413. )
  10414. );
  10415. }
  10416. /// <summary>
  10417. /// 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.
  10418. /// This operator is a specialization of Multicast using a <see cref="Reactive.Subjects.ReplaySubject{TResult}" />.
  10419. /// </summary>
  10420. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10421. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10422. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10423. /// <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>
  10424. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10425. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10426. /// <exception cref="ArgumentNullException">
  10427. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10428. /// <seealso cref="Reactive.Subjects.ReplaySubject{TResult}" />
  10429. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, IScheduler scheduler)
  10430. {
  10431. if (source == null)
  10432. throw new ArgumentNullException(nameof(source));
  10433. if (selector == null)
  10434. throw new ArgumentNullException(nameof(selector));
  10435. if (scheduler == null)
  10436. throw new ArgumentNullException(nameof(scheduler));
  10437. return source.Provider.CreateQuery<TResult>(
  10438. Expression.Call(
  10439. null,
  10440. #if CRIPPLED_REFLECTION
  10441. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(IScheduler))),
  10442. #else
  10443. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10444. #endif
  10445. source.Expression,
  10446. selector,
  10447. Expression.Constant(scheduler, typeof(IScheduler))
  10448. )
  10449. );
  10450. }
  10451. /// <summary>
  10452. /// 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.
  10453. /// This operator is a specialization of Multicast using a <see cref="Reactive.Subjects.ReplaySubject{TResult}" />.
  10454. /// </summary>
  10455. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10456. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10457. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10458. /// <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>
  10459. /// <param name="window">Maximum time length of the replay buffer.</param>
  10460. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10461. /// <exception cref="ArgumentNullException">
  10462. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10463. /// <exception cref="ArgumentOutOfRangeException">
  10464. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10465. /// <seealso cref="Reactive.Subjects.ReplaySubject{TResult}" />
  10466. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window)
  10467. {
  10468. if (source == null)
  10469. throw new ArgumentNullException(nameof(source));
  10470. if (selector == null)
  10471. throw new ArgumentNullException(nameof(selector));
  10472. return source.Provider.CreateQuery<TResult>(
  10473. Expression.Call(
  10474. null,
  10475. #if CRIPPLED_REFLECTION
  10476. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan))),
  10477. #else
  10478. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10479. #endif
  10480. source.Expression,
  10481. selector,
  10482. Expression.Constant(window, typeof(TimeSpan))
  10483. )
  10484. );
  10485. }
  10486. /// <summary>
  10487. /// 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.
  10488. /// This operator is a specialization of Multicast using a <see cref="Reactive.Subjects.ReplaySubject{TResult}" />.
  10489. /// </summary>
  10490. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10491. /// <typeparam name="TResult">The type of the elements in the result sequence.</typeparam>
  10492. /// <param name="source">Source sequence whose elements will be multicasted through a single shared subscription.</param>
  10493. /// <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>
  10494. /// <param name="window">Maximum time length of the replay buffer.</param>
  10495. /// <param name="scheduler">Scheduler where connected observers within the selector function will be invoked on.</param>
  10496. /// <returns>An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function.</returns>
  10497. /// <exception cref="ArgumentNullException">
  10498. /// <paramref name="source" /> or <paramref name="selector" /> or <paramref name="scheduler" /> is null.</exception>
  10499. /// <exception cref="ArgumentOutOfRangeException">
  10500. /// <paramref name="window" /> is less than TimeSpan.Zero.</exception>
  10501. /// <seealso cref="Reactive.Subjects.ReplaySubject{TResult}" />
  10502. public static IQbservable<TResult> Replay<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<IObservable<TSource>, IObservable<TResult>>> selector, TimeSpan window, IScheduler scheduler)
  10503. {
  10504. if (source == null)
  10505. throw new ArgumentNullException(nameof(source));
  10506. if (selector == null)
  10507. throw new ArgumentNullException(nameof(selector));
  10508. if (scheduler == null)
  10509. throw new ArgumentNullException(nameof(scheduler));
  10510. return source.Provider.CreateQuery<TResult>(
  10511. Expression.Call(
  10512. null,
  10513. #if CRIPPLED_REFLECTION
  10514. InfoOf(() => Qbservable.Replay<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TSource>, IObservable<TResult>>>), default(TimeSpan), default(IScheduler))),
  10515. #else
  10516. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10517. #endif
  10518. source.Expression,
  10519. selector,
  10520. Expression.Constant(window, typeof(TimeSpan)),
  10521. Expression.Constant(scheduler, typeof(IScheduler))
  10522. )
  10523. );
  10524. }
  10525. /// <summary>
  10526. /// Repeats the source observable sequence until it successfully terminates.
  10527. /// </summary>
  10528. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10529. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10530. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10531. /// <exception cref="ArgumentNullException">
  10532. /// <paramref name="source" /> is null.</exception>
  10533. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source)
  10534. {
  10535. if (source == null)
  10536. throw new ArgumentNullException(nameof(source));
  10537. return source.Provider.CreateQuery<TSource>(
  10538. Expression.Call(
  10539. null,
  10540. #if CRIPPLED_REFLECTION
  10541. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>))),
  10542. #else
  10543. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10544. #endif
  10545. source.Expression
  10546. )
  10547. );
  10548. }
  10549. /// <summary>
  10550. /// Repeats the source observable sequence the specified number of times or until it successfully terminates.
  10551. /// </summary>
  10552. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10553. /// <param name="source">Observable sequence to repeat until it successfully terminates.</param>
  10554. /// <param name="retryCount">Number of times to repeat the sequence.</param>
  10555. /// <returns>An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully.</returns>
  10556. /// <exception cref="ArgumentNullException">
  10557. /// <paramref name="source" /> is null.</exception>
  10558. /// <exception cref="ArgumentOutOfRangeException">
  10559. /// <paramref name="retryCount" /> is less than zero.</exception>
  10560. public static IQbservable<TSource> Retry<TSource>(this IQbservable<TSource> source, int retryCount)
  10561. {
  10562. if (source == null)
  10563. throw new ArgumentNullException(nameof(source));
  10564. return source.Provider.CreateQuery<TSource>(
  10565. Expression.Call(
  10566. null,
  10567. #if CRIPPLED_REFLECTION
  10568. InfoOf(() => Qbservable.Retry<TSource>(default(IQbservable<TSource>), default(int))),
  10569. #else
  10570. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10571. #endif
  10572. source.Expression,
  10573. Expression.Constant(retryCount, typeof(int))
  10574. )
  10575. );
  10576. }
  10577. /// <summary>
  10578. /// Returns an observable sequence that contains a single element.
  10579. /// </summary>
  10580. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10581. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  10582. /// <param name="value">Single element in the resulting observable sequence.</param>
  10583. /// <returns>An observable sequence containing the single specified element.</returns>
  10584. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value)
  10585. {
  10586. if (provider == null)
  10587. throw new ArgumentNullException(nameof(provider));
  10588. return provider.CreateQuery<TResult>(
  10589. Expression.Call(
  10590. null,
  10591. #if CRIPPLED_REFLECTION
  10592. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult))),
  10593. #else
  10594. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10595. #endif
  10596. Expression.Constant(provider, typeof(IQbservableProvider)),
  10597. Expression.Constant(value, typeof(TResult))
  10598. )
  10599. );
  10600. }
  10601. /// <summary>
  10602. /// Returns an observable sequence that contains a single element, using the specified scheduler to send out observer messages.
  10603. /// </summary>
  10604. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  10605. /// <typeparam name="TResult">The type of the element that will be returned in the produced sequence.</typeparam>
  10606. /// <param name="value">Single element in the resulting observable sequence.</param>
  10607. /// <param name="scheduler">Scheduler to send the single element on.</param>
  10608. /// <returns>An observable sequence containing the single specified element.</returns>
  10609. /// <exception cref="ArgumentNullException">
  10610. /// <paramref name="scheduler" /> is null.</exception>
  10611. public static IQbservable<TResult> Return<TResult>(this IQbservableProvider provider, TResult value, IScheduler scheduler)
  10612. {
  10613. if (provider == null)
  10614. throw new ArgumentNullException(nameof(provider));
  10615. if (scheduler == null)
  10616. throw new ArgumentNullException(nameof(scheduler));
  10617. return provider.CreateQuery<TResult>(
  10618. Expression.Call(
  10619. null,
  10620. #if CRIPPLED_REFLECTION
  10621. InfoOf(() => Qbservable.Return<TResult>(default(IQbservableProvider), default(TResult), default(IScheduler))),
  10622. #else
  10623. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  10624. #endif
  10625. Expression.Constant(provider, typeof(IQbservableProvider)),
  10626. Expression.Constant(value, typeof(TResult)),
  10627. Expression.Constant(scheduler, typeof(IScheduler))
  10628. )
  10629. );
  10630. }
  10631. /// <summary>
  10632. /// Samples the observable sequence at each interval.
  10633. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10634. /// </summary>
  10635. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10636. /// <param name="source">Source sequence to sample.</param>
  10637. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  10638. /// <returns>Sampled observable sequence.</returns>
  10639. /// <exception cref="ArgumentNullException">
  10640. /// <paramref name="source" /> is null.</exception>
  10641. /// <exception cref="ArgumentOutOfRangeException">
  10642. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  10643. /// <remarks>
  10644. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  10645. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  10646. /// </remarks>
  10647. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval)
  10648. {
  10649. if (source == null)
  10650. throw new ArgumentNullException(nameof(source));
  10651. return source.Provider.CreateQuery<TSource>(
  10652. Expression.Call(
  10653. null,
  10654. #if CRIPPLED_REFLECTION
  10655. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  10656. #else
  10657. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10658. #endif
  10659. source.Expression,
  10660. Expression.Constant(interval, typeof(TimeSpan))
  10661. )
  10662. );
  10663. }
  10664. /// <summary>
  10665. /// Samples the observable sequence at each interval, using the specified scheduler to run sampling timers.
  10666. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10667. /// </summary>
  10668. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10669. /// <param name="source">Source sequence to sample.</param>
  10670. /// <param name="interval">Interval at which to sample. If this value is equal to TimeSpan.Zero, the scheduler will continuously sample the stream.</param>
  10671. /// <param name="scheduler">Scheduler to run the sampling timer on.</param>
  10672. /// <returns>Sampled observable sequence.</returns>
  10673. /// <exception cref="ArgumentNullException">
  10674. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  10675. /// <exception cref="ArgumentOutOfRangeException">
  10676. /// <paramref name="interval" /> is less than TimeSpan.Zero.</exception>
  10677. /// <remarks>
  10678. /// Specifying a TimeSpan.Zero value for <paramref name="interval" /> doesn't guarantee all source sequence elements will be preserved. This is a side-effect
  10679. /// of the asynchrony introduced by the scheduler, where the sampling action may not execute immediately, despite the TimeSpan.Zero due time.
  10680. /// </remarks>
  10681. public static IQbservable<TSource> Sample<TSource>(this IQbservable<TSource> source, TimeSpan interval, IScheduler scheduler)
  10682. {
  10683. if (source == null)
  10684. throw new ArgumentNullException(nameof(source));
  10685. if (scheduler == null)
  10686. throw new ArgumentNullException(nameof(scheduler));
  10687. return source.Provider.CreateQuery<TSource>(
  10688. Expression.Call(
  10689. null,
  10690. #if CRIPPLED_REFLECTION
  10691. InfoOf(() => Qbservable.Sample<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  10692. #else
  10693. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10694. #endif
  10695. source.Expression,
  10696. Expression.Constant(interval, typeof(TimeSpan)),
  10697. Expression.Constant(scheduler, typeof(IScheduler))
  10698. )
  10699. );
  10700. }
  10701. /// <summary>
  10702. /// Samples the source observable sequence using a samper observable sequence producing sampling ticks.
  10703. /// Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence.
  10704. /// </summary>
  10705. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10706. /// <typeparam name="TSample">The type of the elements in the sampling sequence.</typeparam>
  10707. /// <param name="source">Source sequence to sample.</param>
  10708. /// <param name="sampler">Sampling tick sequence.</param>
  10709. /// <returns>Sampled observable sequence.</returns>
  10710. /// <exception cref="ArgumentNullException">
  10711. /// <paramref name="source" /> or <paramref name="sampler" /> is null.</exception>
  10712. public static IQbservable<TSource> Sample<TSource, TSample>(this IQbservable<TSource> source, IObservable<TSample> sampler)
  10713. {
  10714. if (source == null)
  10715. throw new ArgumentNullException(nameof(source));
  10716. if (sampler == null)
  10717. throw new ArgumentNullException(nameof(sampler));
  10718. return source.Provider.CreateQuery<TSource>(
  10719. Expression.Call(
  10720. null,
  10721. #if CRIPPLED_REFLECTION
  10722. InfoOf(() => Qbservable.Sample<TSource, TSample>(default(IQbservable<TSource>), default(IObservable<TSample>))),
  10723. #else
  10724. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TSample)),
  10725. #endif
  10726. source.Expression,
  10727. GetSourceExpression(sampler)
  10728. )
  10729. );
  10730. }
  10731. /// <summary>
  10732. /// Applies an accumulator function over an observable sequence and returns each intermediate result.
  10733. /// For aggregation behavior with no intermediate results, see <see cref="Observable.Aggregate{TSource}(IObservable{TSource},Func{TSource,TSource,TSource})" />.
  10734. /// </summary>
  10735. /// <typeparam name="TSource">The type of the elements in the source sequence and the result of the aggregation.</typeparam>
  10736. /// <param name="source">An observable sequence to accumulate over.</param>
  10737. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  10738. /// <returns>An observable sequence containing the accumulated values.</returns>
  10739. /// <exception cref="ArgumentNullException">
  10740. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  10741. public static IQbservable<TSource> Scan<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, TSource, TSource>> accumulator)
  10742. {
  10743. if (source == null)
  10744. throw new ArgumentNullException(nameof(source));
  10745. if (accumulator == null)
  10746. throw new ArgumentNullException(nameof(accumulator));
  10747. return source.Provider.CreateQuery<TSource>(
  10748. Expression.Call(
  10749. null,
  10750. #if CRIPPLED_REFLECTION
  10751. InfoOf(() => Qbservable.Scan<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, TSource, TSource>>))),
  10752. #else
  10753. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  10754. #endif
  10755. source.Expression,
  10756. accumulator
  10757. )
  10758. );
  10759. }
  10760. /// <summary>
  10761. /// Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value.
  10762. /// For aggregation behavior with no intermediate results, see <see cref="Observable.Aggregate{TSource,TAccumulate}(IObservable{TSource},TAccumulate,Func{TAccumulate,TSource,TAccumulate})" />.
  10763. /// </summary>
  10764. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10765. /// <typeparam name="TAccumulate">The type of the result of the aggregation.</typeparam>
  10766. /// <param name="source">An observable sequence to accumulate over.</param>
  10767. /// <param name="seed">The initial accumulator value.</param>
  10768. /// <param name="accumulator">An accumulator function to be invoked on each element.</param>
  10769. /// <returns>An observable sequence containing the accumulated values.</returns>
  10770. /// <exception cref="ArgumentNullException">
  10771. /// <paramref name="source" /> or <paramref name="accumulator" /> is null.</exception>
  10772. public static IQbservable<TAccumulate> Scan<TSource, TAccumulate>(this IQbservable<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> accumulator)
  10773. {
  10774. if (source == null)
  10775. throw new ArgumentNullException(nameof(source));
  10776. if (accumulator == null)
  10777. throw new ArgumentNullException(nameof(accumulator));
  10778. return source.Provider.CreateQuery<TAccumulate>(
  10779. Expression.Call(
  10780. null,
  10781. #if CRIPPLED_REFLECTION
  10782. InfoOf(() => Qbservable.Scan<TSource, TAccumulate>(default(IQbservable<TSource>), default(TAccumulate), default(Expression<Func<TAccumulate, TSource, TAccumulate>>))),
  10783. #else
  10784. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TAccumulate)),
  10785. #endif
  10786. source.Expression,
  10787. Expression.Constant(seed, typeof(TAccumulate)),
  10788. accumulator
  10789. )
  10790. );
  10791. }
  10792. /// <summary>
  10793. /// Projects each element of an observable sequence into a new form.
  10794. /// </summary>
  10795. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10796. /// <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>
  10797. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  10798. /// <param name="selector">A transform function to apply to each source element.</param>
  10799. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  10800. /// <exception cref="ArgumentNullException">
  10801. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10802. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, TResult>> selector)
  10803. {
  10804. if (source == null)
  10805. throw new ArgumentNullException(nameof(source));
  10806. if (selector == null)
  10807. throw new ArgumentNullException(nameof(selector));
  10808. return source.Provider.CreateQuery<TResult>(
  10809. Expression.Call(
  10810. null,
  10811. #if CRIPPLED_REFLECTION
  10812. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, TResult>>))),
  10813. #else
  10814. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10815. #endif
  10816. source.Expression,
  10817. selector
  10818. )
  10819. );
  10820. }
  10821. /// <summary>
  10822. /// Projects each element of an observable sequence into a new form by incorporating the element's index.
  10823. /// </summary>
  10824. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10825. /// <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>
  10826. /// <param name="source">A sequence of elements to invoke a transform function on.</param>
  10827. /// <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>
  10828. /// <returns>An observable sequence whose elements are the result of invoking the transform function on each element of source.</returns>
  10829. /// <exception cref="ArgumentNullException">
  10830. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  10831. public static IQbservable<TResult> Select<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, TResult>> selector)
  10832. {
  10833. if (source == null)
  10834. throw new ArgumentNullException(nameof(source));
  10835. if (selector == null)
  10836. throw new ArgumentNullException(nameof(selector));
  10837. return source.Provider.CreateQuery<TResult>(
  10838. Expression.Call(
  10839. null,
  10840. #if CRIPPLED_REFLECTION
  10841. InfoOf(() => Qbservable.Select<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, TResult>>))),
  10842. #else
  10843. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  10844. #endif
  10845. source.Expression,
  10846. selector
  10847. )
  10848. );
  10849. }
  10850. /// <summary>
  10851. /// 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.
  10852. /// </summary>
  10853. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10854. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  10855. /// <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>
  10856. /// <param name="source">An observable sequence of elements to project.</param>
  10857. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  10858. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  10859. /// <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>
  10860. /// <exception cref="ArgumentNullException">
  10861. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  10862. /// <remarks>The projected sequences are enumerated synchonously 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="Observable.ToObservable{TSource}(IEnumerable{TSource})" /> conversion.</remarks>
  10863. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  10864. {
  10865. if (source == null)
  10866. throw new ArgumentNullException(nameof(source));
  10867. if (collectionSelector == null)
  10868. throw new ArgumentNullException(nameof(collectionSelector));
  10869. if (resultSelector == null)
  10870. throw new ArgumentNullException(nameof(resultSelector));
  10871. return source.Provider.CreateQuery<TResult>(
  10872. Expression.Call(
  10873. null,
  10874. #if CRIPPLED_REFLECTION
  10875. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  10876. #else
  10877. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  10878. #endif
  10879. source.Expression,
  10880. collectionSelector,
  10881. resultSelector
  10882. )
  10883. );
  10884. }
  10885. /// <summary>
  10886. /// 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.
  10887. /// </summary>
  10888. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10889. /// <typeparam name="TCollection">The type of the elements in the projected intermediate enumerable sequences.</typeparam>
  10890. /// <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>
  10891. /// <param name="source">An observable sequence of elements to project.</param>
  10892. /// <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>
  10893. /// <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>
  10894. /// <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>
  10895. /// <exception cref="ArgumentNullException">
  10896. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  10897. /// <remarks>The projected sequences are enumerated synchonously 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="Observable.ToObservable{TSource}(IEnumerable{TSource})" /> conversion.</remarks>
  10898. 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)
  10899. {
  10900. if (source == null)
  10901. throw new ArgumentNullException(nameof(source));
  10902. if (collectionSelector == null)
  10903. throw new ArgumentNullException(nameof(collectionSelector));
  10904. if (resultSelector == null)
  10905. throw new ArgumentNullException(nameof(resultSelector));
  10906. return source.Provider.CreateQuery<TResult>(
  10907. Expression.Call(
  10908. null,
  10909. #if CRIPPLED_REFLECTION
  10910. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  10911. #else
  10912. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  10913. #endif
  10914. source.Expression,
  10915. collectionSelector,
  10916. resultSelector
  10917. )
  10918. );
  10919. }
  10920. /// <summary>
  10921. /// 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.
  10922. /// </summary>
  10923. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10924. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  10925. /// <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>
  10926. /// <param name="source">An observable sequence of elements to project.</param>
  10927. /// <param name="collectionSelector">A transform function to apply to each element.</param>
  10928. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  10929. /// <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>
  10930. /// <exception cref="ArgumentNullException">
  10931. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  10932. public static IQbservable<TResult> SelectMany<TSource, TCollection, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TCollection>>> collectionSelector, Expression<Func<TSource, TCollection, TResult>> resultSelector)
  10933. {
  10934. if (source == null)
  10935. throw new ArgumentNullException(nameof(source));
  10936. if (collectionSelector == null)
  10937. throw new ArgumentNullException(nameof(collectionSelector));
  10938. if (resultSelector == null)
  10939. throw new ArgumentNullException(nameof(resultSelector));
  10940. return source.Provider.CreateQuery<TResult>(
  10941. Expression.Call(
  10942. null,
  10943. #if CRIPPLED_REFLECTION
  10944. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TCollection>>>), default(Expression<Func<TSource, TCollection, TResult>>))),
  10945. #else
  10946. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  10947. #endif
  10948. source.Expression,
  10949. collectionSelector,
  10950. resultSelector
  10951. )
  10952. );
  10953. }
  10954. /// <summary>
  10955. /// 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.
  10956. /// </summary>
  10957. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10958. /// <typeparam name="TCollection">The type of the elements in the projected intermediate sequences.</typeparam>
  10959. /// <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>
  10960. /// <param name="source">An observable sequence of elements to project.</param>
  10961. /// <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>
  10962. /// <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>
  10963. /// <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>
  10964. /// <exception cref="ArgumentNullException">
  10965. /// <paramref name="source" /> or <paramref name="collectionSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  10966. 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)
  10967. {
  10968. if (source == null)
  10969. throw new ArgumentNullException(nameof(source));
  10970. if (collectionSelector == null)
  10971. throw new ArgumentNullException(nameof(collectionSelector));
  10972. if (resultSelector == null)
  10973. throw new ArgumentNullException(nameof(resultSelector));
  10974. return source.Provider.CreateQuery<TResult>(
  10975. Expression.Call(
  10976. null,
  10977. #if CRIPPLED_REFLECTION
  10978. InfoOf(() => Qbservable.SelectMany<TSource, TCollection, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TCollection>>>), default(Expression<Func<TSource, int, TCollection, int, TResult>>))),
  10979. #else
  10980. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TCollection), typeof(TResult)),
  10981. #endif
  10982. source.Expression,
  10983. collectionSelector,
  10984. resultSelector
  10985. )
  10986. );
  10987. }
  10988. /// <summary>
  10989. /// Projects each element of the source observable sequence to the other observable sequence and merges the resulting observable sequences into one observable sequence.
  10990. /// </summary>
  10991. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  10992. /// <typeparam name="TOther">The type of the elements in the other sequence and the elements in the result sequence.</typeparam>
  10993. /// <param name="source">An observable sequence of elements to project.</param>
  10994. /// <param name="other">An observable sequence to project each element from the source sequence onto.</param>
  10995. /// <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>
  10996. /// <exception cref="ArgumentNullException">
  10997. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  10998. public static IQbservable<TOther> SelectMany<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  10999. {
  11000. if (source == null)
  11001. throw new ArgumentNullException(nameof(source));
  11002. if (other == null)
  11003. throw new ArgumentNullException(nameof(other));
  11004. return source.Provider.CreateQuery<TOther>(
  11005. Expression.Call(
  11006. null,
  11007. #if CRIPPLED_REFLECTION
  11008. InfoOf(() => Qbservable.SelectMany<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  11009. #else
  11010. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  11011. #endif
  11012. source.Expression,
  11013. GetSourceExpression(other)
  11014. )
  11015. );
  11016. }
  11017. /// <summary>
  11018. /// Projects each notification of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11019. /// </summary>
  11020. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11021. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11022. /// <param name="source">An observable sequence of notifications to project.</param>
  11023. /// <param name="onNext">A transform function to apply to each element.</param>
  11024. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11025. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11026. /// <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>
  11027. /// <exception cref="ArgumentNullException">
  11028. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11029. 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)
  11030. {
  11031. if (source == null)
  11032. throw new ArgumentNullException(nameof(source));
  11033. if (onNext == null)
  11034. throw new ArgumentNullException(nameof(onNext));
  11035. if (onError == null)
  11036. throw new ArgumentNullException(nameof(onError));
  11037. if (onCompleted == null)
  11038. throw new ArgumentNullException(nameof(onCompleted));
  11039. return source.Provider.CreateQuery<TResult>(
  11040. Expression.Call(
  11041. null,
  11042. #if CRIPPLED_REFLECTION
  11043. 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>>>))),
  11044. #else
  11045. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11046. #endif
  11047. source.Expression,
  11048. onNext,
  11049. onError,
  11050. onCompleted
  11051. )
  11052. );
  11053. }
  11054. /// <summary>
  11055. /// 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.
  11056. /// </summary>
  11057. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11058. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11059. /// <param name="source">An observable sequence of notifications to project.</param>
  11060. /// <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>
  11061. /// <param name="onError">A transform function to apply when an error occurs in the source sequence.</param>
  11062. /// <param name="onCompleted">A transform function to apply when the end of the source sequence is reached.</param>
  11063. /// <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>
  11064. /// <exception cref="ArgumentNullException">
  11065. /// <paramref name="source" /> or <paramref name="onNext" /> or <paramref name="onError" /> or <paramref name="onCompleted" /> is null.</exception>
  11066. 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)
  11067. {
  11068. if (source == null)
  11069. throw new ArgumentNullException(nameof(source));
  11070. if (onNext == null)
  11071. throw new ArgumentNullException(nameof(onNext));
  11072. if (onError == null)
  11073. throw new ArgumentNullException(nameof(onError));
  11074. if (onCompleted == null)
  11075. throw new ArgumentNullException(nameof(onCompleted));
  11076. return source.Provider.CreateQuery<TResult>(
  11077. Expression.Call(
  11078. null,
  11079. #if CRIPPLED_REFLECTION
  11080. 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>>>))),
  11081. #else
  11082. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11083. #endif
  11084. source.Expression,
  11085. onNext,
  11086. onError,
  11087. onCompleted
  11088. )
  11089. );
  11090. }
  11091. /// <summary>
  11092. /// Projects each element of an observable sequence to an enumerable sequence and concatenates the resulting enumerable sequences into one observable sequence.
  11093. /// </summary>
  11094. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11095. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11096. /// <param name="source">An observable sequence of elements to project.</param>
  11097. /// <param name="selector">A transform function to apply to each element.</param>
  11098. /// <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>
  11099. /// <exception cref="ArgumentNullException">
  11100. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11101. /// <remarks>The projected sequences are enumerated synchonously 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="Observable.ToObservable{TSource}(IEnumerable{TSource})" /> conversion.</remarks>
  11102. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IEnumerable<TResult>>> selector)
  11103. {
  11104. if (source == null)
  11105. throw new ArgumentNullException(nameof(source));
  11106. if (selector == null)
  11107. throw new ArgumentNullException(nameof(selector));
  11108. return source.Provider.CreateQuery<TResult>(
  11109. Expression.Call(
  11110. null,
  11111. #if CRIPPLED_REFLECTION
  11112. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IEnumerable<TResult>>>))),
  11113. #else
  11114. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11115. #endif
  11116. source.Expression,
  11117. selector
  11118. )
  11119. );
  11120. }
  11121. /// <summary>
  11122. /// 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.
  11123. /// </summary>
  11124. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11125. /// <typeparam name="TResult">The type of the elements in the projected inner enumerable sequences and the elements in the merged result sequence.</typeparam>
  11126. /// <param name="source">An observable sequence of elements to project.</param>
  11127. /// <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>
  11128. /// <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>
  11129. /// <exception cref="ArgumentNullException">
  11130. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11131. /// <remarks>The projected sequences are enumerated synchonously 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="Observable.ToObservable{TSource}(IEnumerable{TSource})" /> conversion.</remarks>
  11132. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IEnumerable<TResult>>> selector)
  11133. {
  11134. if (source == null)
  11135. throw new ArgumentNullException(nameof(source));
  11136. if (selector == null)
  11137. throw new ArgumentNullException(nameof(selector));
  11138. return source.Provider.CreateQuery<TResult>(
  11139. Expression.Call(
  11140. null,
  11141. #if CRIPPLED_REFLECTION
  11142. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IEnumerable<TResult>>>))),
  11143. #else
  11144. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11145. #endif
  11146. source.Expression,
  11147. selector
  11148. )
  11149. );
  11150. }
  11151. /// <summary>
  11152. /// Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence.
  11153. /// </summary>
  11154. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11155. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11156. /// <param name="source">An observable sequence of elements to project.</param>
  11157. /// <param name="selector">A transform function to apply to each element.</param>
  11158. /// <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>
  11159. /// <exception cref="ArgumentNullException">
  11160. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11161. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TResult>>> selector)
  11162. {
  11163. if (source == null)
  11164. throw new ArgumentNullException(nameof(source));
  11165. if (selector == null)
  11166. throw new ArgumentNullException(nameof(selector));
  11167. return source.Provider.CreateQuery<TResult>(
  11168. Expression.Call(
  11169. null,
  11170. #if CRIPPLED_REFLECTION
  11171. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TResult>>>))),
  11172. #else
  11173. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11174. #endif
  11175. source.Expression,
  11176. selector
  11177. )
  11178. );
  11179. }
  11180. /// <summary>
  11181. /// 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.
  11182. /// </summary>
  11183. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11184. /// <typeparam name="TResult">The type of the elements in the projected inner sequences and the elements in the merged result sequence.</typeparam>
  11185. /// <param name="source">An observable sequence of elements to project.</param>
  11186. /// <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>
  11187. /// <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>
  11188. /// <exception cref="ArgumentNullException">
  11189. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11190. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, IObservable<TResult>>> selector)
  11191. {
  11192. if (source == null)
  11193. throw new ArgumentNullException(nameof(source));
  11194. if (selector == null)
  11195. throw new ArgumentNullException(nameof(selector));
  11196. return source.Provider.CreateQuery<TResult>(
  11197. Expression.Call(
  11198. null,
  11199. #if CRIPPLED_REFLECTION
  11200. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, IObservable<TResult>>>))),
  11201. #else
  11202. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11203. #endif
  11204. source.Expression,
  11205. selector
  11206. )
  11207. );
  11208. }
  11209. /// <summary>
  11210. /// Projects each element of an observable sequence to a task and merges all of the task results into one observable sequence.
  11211. /// </summary>
  11212. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11213. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11214. /// <param name="source">An observable sequence of elements to project.</param>
  11215. /// <param name="selector">A transform function to apply to each element.</param>
  11216. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11217. /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable{TSource}(Task{TSource})" />.</remarks>
  11218. /// <exception cref="ArgumentNullException">
  11219. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11220. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TResult>>> selector)
  11221. {
  11222. if (source == null)
  11223. throw new ArgumentNullException(nameof(source));
  11224. if (selector == null)
  11225. throw new ArgumentNullException(nameof(selector));
  11226. return source.Provider.CreateQuery<TResult>(
  11227. Expression.Call(
  11228. null,
  11229. #if CRIPPLED_REFLECTION
  11230. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TResult>>>))),
  11231. #else
  11232. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11233. #endif
  11234. source.Expression,
  11235. selector
  11236. )
  11237. );
  11238. }
  11239. /// <summary>
  11240. /// 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.
  11241. /// </summary>
  11242. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11243. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11244. /// <param name="source">An observable sequence of elements to project.</param>
  11245. /// <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>
  11246. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11247. /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable{TSource}(Task{TSource})" />.</remarks>
  11248. /// <exception cref="ArgumentNullException">
  11249. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11250. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, Task<TResult>>> selector)
  11251. {
  11252. if (source == null)
  11253. throw new ArgumentNullException(nameof(source));
  11254. if (selector == null)
  11255. throw new ArgumentNullException(nameof(selector));
  11256. return source.Provider.CreateQuery<TResult>(
  11257. Expression.Call(
  11258. null,
  11259. #if CRIPPLED_REFLECTION
  11260. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TResult>>>))),
  11261. #else
  11262. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11263. #endif
  11264. source.Expression,
  11265. selector
  11266. )
  11267. );
  11268. }
  11269. /// <summary>
  11270. /// Projects each element of an observable sequence to a task with cancellation support and merges all of the task results into one observable sequence.
  11271. /// </summary>
  11272. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11273. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11274. /// <param name="source">An observable sequence of elements to project.</param>
  11275. /// <param name="selector">A transform function to apply to each element.</param>
  11276. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11277. /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable{TSource}(Task{TSource})" />.</remarks>
  11278. /// <exception cref="ArgumentNullException">
  11279. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11280. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, CancellationToken, Task<TResult>>> selector)
  11281. {
  11282. if (source == null)
  11283. throw new ArgumentNullException(nameof(source));
  11284. if (selector == null)
  11285. throw new ArgumentNullException(nameof(selector));
  11286. return source.Provider.CreateQuery<TResult>(
  11287. Expression.Call(
  11288. null,
  11289. #if CRIPPLED_REFLECTION
  11290. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TResult>>>))),
  11291. #else
  11292. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11293. #endif
  11294. source.Expression,
  11295. selector
  11296. )
  11297. );
  11298. }
  11299. /// <summary>
  11300. /// 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.
  11301. /// </summary>
  11302. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11303. /// <typeparam name="TResult">The type of the result produced by the projected tasks and the elements in the merged result sequence.</typeparam>
  11304. /// <param name="source">An observable sequence of elements to project.</param>
  11305. /// <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>
  11306. /// <returns>An observable sequence whose elements are the result of the tasks executed for each element of the input sequence.</returns>
  11307. /// <remarks>This overload supports composition of observable sequences and tasks, without requiring manual conversion of the tasks to observable sequences using <see cref="System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable{TSource}(Task{TSource})" />.</remarks>
  11308. /// <exception cref="ArgumentNullException">
  11309. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  11310. public static IQbservable<TResult> SelectMany<TSource, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, int, CancellationToken, Task<TResult>>> selector)
  11311. {
  11312. if (source == null)
  11313. throw new ArgumentNullException(nameof(source));
  11314. if (selector == null)
  11315. throw new ArgumentNullException(nameof(selector));
  11316. return source.Provider.CreateQuery<TResult>(
  11317. Expression.Call(
  11318. null,
  11319. #if CRIPPLED_REFLECTION
  11320. InfoOf(() => Qbservable.SelectMany<TSource, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TResult>>>))),
  11321. #else
  11322. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  11323. #endif
  11324. source.Expression,
  11325. selector
  11326. )
  11327. );
  11328. }
  11329. /// <summary>
  11330. /// 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.
  11331. /// </summary>
  11332. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11333. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11334. /// <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>
  11335. /// <param name="source">An observable sequence of elements to project.</param>
  11336. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11337. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11338. /// <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>
  11339. /// <exception cref="ArgumentNullException">
  11340. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11341. /// <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="System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable{TSource}(Task{TSource})" />.</remarks>
  11342. public static IQbservable<TResult> SelectMany<TSource, TTaskResult, TResult>(this IQbservable<TSource> source, Expression<Func<TSource, Task<TTaskResult>>> taskSelector, Expression<Func<TSource, TTaskResult, TResult>> resultSelector)
  11343. {
  11344. if (source == null)
  11345. throw new ArgumentNullException(nameof(source));
  11346. if (taskSelector == null)
  11347. throw new ArgumentNullException(nameof(taskSelector));
  11348. if (resultSelector == null)
  11349. throw new ArgumentNullException(nameof(resultSelector));
  11350. return source.Provider.CreateQuery<TResult>(
  11351. Expression.Call(
  11352. null,
  11353. #if CRIPPLED_REFLECTION
  11354. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11355. #else
  11356. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11357. #endif
  11358. source.Expression,
  11359. taskSelector,
  11360. resultSelector
  11361. )
  11362. );
  11363. }
  11364. /// <summary>
  11365. /// 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.
  11366. /// </summary>
  11367. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11368. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11369. /// <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>
  11370. /// <param name="source">An observable sequence of elements to project.</param>
  11371. /// <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>
  11372. /// <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>
  11373. /// <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>
  11374. /// <exception cref="ArgumentNullException">
  11375. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11376. /// <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="System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable{TSource}(Task{TSource})" />.</remarks>
  11377. 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)
  11378. {
  11379. if (source == null)
  11380. throw new ArgumentNullException(nameof(source));
  11381. if (taskSelector == null)
  11382. throw new ArgumentNullException(nameof(taskSelector));
  11383. if (resultSelector == null)
  11384. throw new ArgumentNullException(nameof(resultSelector));
  11385. return source.Provider.CreateQuery<TResult>(
  11386. Expression.Call(
  11387. null,
  11388. #if CRIPPLED_REFLECTION
  11389. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11390. #else
  11391. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11392. #endif
  11393. source.Expression,
  11394. taskSelector,
  11395. resultSelector
  11396. )
  11397. );
  11398. }
  11399. /// <summary>
  11400. /// 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.
  11401. /// </summary>
  11402. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11403. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11404. /// <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>
  11405. /// <param name="source">An observable sequence of elements to project.</param>
  11406. /// <param name="taskSelector">A transform function to apply to each element.</param>
  11407. /// <param name="resultSelector">A transform function to apply to each element of the intermediate sequence.</param>
  11408. /// <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>
  11409. /// <exception cref="ArgumentNullException">
  11410. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11411. /// <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="System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable{TSource}(Task{TSource})" />.</remarks>
  11412. 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)
  11413. {
  11414. if (source == null)
  11415. throw new ArgumentNullException(nameof(source));
  11416. if (taskSelector == null)
  11417. throw new ArgumentNullException(nameof(taskSelector));
  11418. if (resultSelector == null)
  11419. throw new ArgumentNullException(nameof(resultSelector));
  11420. return source.Provider.CreateQuery<TResult>(
  11421. Expression.Call(
  11422. null,
  11423. #if CRIPPLED_REFLECTION
  11424. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, TTaskResult, TResult>>))),
  11425. #else
  11426. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11427. #endif
  11428. source.Expression,
  11429. taskSelector,
  11430. resultSelector
  11431. )
  11432. );
  11433. }
  11434. /// <summary>
  11435. /// 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.
  11436. /// </summary>
  11437. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11438. /// <typeparam name="TTaskResult">The type of the results produced by the projected intermediate tasks.</typeparam>
  11439. /// <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>
  11440. /// <param name="source">An observable sequence of elements to project.</param>
  11441. /// <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>
  11442. /// <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>
  11443. /// <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>
  11444. /// <exception cref="ArgumentNullException">
  11445. /// <paramref name="source" /> or <paramref name="taskSelector" /> or <paramref name="resultSelector" /> is null.</exception>
  11446. /// <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="System.Reactive.Threading.Tasks.TaskObservableExtensions.ToObservable{TSource}(Task{TSource})" />.</remarks>
  11447. 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)
  11448. {
  11449. if (source == null)
  11450. throw new ArgumentNullException(nameof(source));
  11451. if (taskSelector == null)
  11452. throw new ArgumentNullException(nameof(taskSelector));
  11453. if (resultSelector == null)
  11454. throw new ArgumentNullException(nameof(resultSelector));
  11455. return source.Provider.CreateQuery<TResult>(
  11456. Expression.Call(
  11457. null,
  11458. #if CRIPPLED_REFLECTION
  11459. InfoOf(() => Qbservable.SelectMany<TSource, TTaskResult, TResult>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, CancellationToken, Task<TTaskResult>>>), default(Expression<Func<TSource, int, TTaskResult, TResult>>))),
  11460. #else
  11461. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTaskResult), typeof(TResult)),
  11462. #endif
  11463. source.Expression,
  11464. taskSelector,
  11465. resultSelector
  11466. )
  11467. );
  11468. }
  11469. /// <summary>
  11470. /// Determines whether two sequences are equal by comparing the elements pairwise.
  11471. /// </summary>
  11472. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11473. /// <param name="first">First observable sequence to compare.</param>
  11474. /// <param name="second">Second observable sequence to compare.</param>
  11475. /// <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>
  11476. /// <exception cref="ArgumentNullException">
  11477. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11478. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11479. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second)
  11480. {
  11481. if (first == null)
  11482. throw new ArgumentNullException(nameof(first));
  11483. if (second == null)
  11484. throw new ArgumentNullException(nameof(second));
  11485. return first.Provider.CreateQuery<bool>(
  11486. Expression.Call(
  11487. null,
  11488. #if CRIPPLED_REFLECTION
  11489. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>))),
  11490. #else
  11491. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11492. #endif
  11493. first.Expression,
  11494. GetSourceExpression(second)
  11495. )
  11496. );
  11497. }
  11498. /// <summary>
  11499. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise.
  11500. /// </summary>
  11501. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11502. /// <param name="first">First observable sequence to compare.</param>
  11503. /// <param name="second">Second observable sequence to compare.</param>
  11504. /// <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>
  11505. /// <exception cref="ArgumentNullException">
  11506. /// <paramref name="first" /> or <paramref name="second" /> is null.</exception>
  11507. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11508. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second)
  11509. {
  11510. if (first == null)
  11511. throw new ArgumentNullException(nameof(first));
  11512. if (second == null)
  11513. throw new ArgumentNullException(nameof(second));
  11514. return first.Provider.CreateQuery<bool>(
  11515. Expression.Call(
  11516. null,
  11517. #if CRIPPLED_REFLECTION
  11518. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  11519. #else
  11520. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11521. #endif
  11522. first.Expression,
  11523. GetSourceExpression(second)
  11524. )
  11525. );
  11526. }
  11527. /// <summary>
  11528. /// Determines whether two sequences are equal by comparing the elements pairwise using a specified equality comparer.
  11529. /// </summary>
  11530. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11531. /// <param name="first">First observable sequence to compare.</param>
  11532. /// <param name="second">Second observable sequence to compare.</param>
  11533. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11534. /// <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>
  11535. /// <exception cref="ArgumentNullException">
  11536. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11537. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11538. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IObservable<TSource> second, IEqualityComparer<TSource> comparer)
  11539. {
  11540. if (first == null)
  11541. throw new ArgumentNullException(nameof(first));
  11542. if (second == null)
  11543. throw new ArgumentNullException(nameof(second));
  11544. if (comparer == null)
  11545. throw new ArgumentNullException(nameof(comparer));
  11546. return first.Provider.CreateQuery<bool>(
  11547. Expression.Call(
  11548. null,
  11549. #if CRIPPLED_REFLECTION
  11550. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IObservable<TSource>), default(IEqualityComparer<TSource>))),
  11551. #else
  11552. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11553. #endif
  11554. first.Expression,
  11555. GetSourceExpression(second),
  11556. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11557. )
  11558. );
  11559. }
  11560. /// <summary>
  11561. /// Determines whether an observable and enumerable sequence are equal by comparing the elements pairwise using a specified equality comparer.
  11562. /// </summary>
  11563. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11564. /// <param name="first">First observable sequence to compare.</param>
  11565. /// <param name="second">Second observable sequence to compare.</param>
  11566. /// <param name="comparer">Comparer used to compare elements of both sequences.</param>
  11567. /// <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>
  11568. /// <exception cref="ArgumentNullException">
  11569. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="comparer" /> is null.</exception>
  11570. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  11571. public static IQbservable<bool> SequenceEqual<TSource>(this IQbservable<TSource> first, IEnumerable<TSource> second, IEqualityComparer<TSource> comparer)
  11572. {
  11573. if (first == null)
  11574. throw new ArgumentNullException(nameof(first));
  11575. if (second == null)
  11576. throw new ArgumentNullException(nameof(second));
  11577. if (comparer == null)
  11578. throw new ArgumentNullException(nameof(comparer));
  11579. return first.Provider.CreateQuery<bool>(
  11580. Expression.Call(
  11581. null,
  11582. #if CRIPPLED_REFLECTION
  11583. InfoOf(() => Qbservable.SequenceEqual<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>), default(IEqualityComparer<TSource>))),
  11584. #else
  11585. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11586. #endif
  11587. first.Expression,
  11588. GetSourceExpression(second),
  11589. Expression.Constant(comparer, typeof(IEqualityComparer<TSource>))
  11590. )
  11591. );
  11592. }
  11593. /// <summary>
  11594. /// Returns the only element of an observable sequence, and reports an exception if there is not exactly one element in the observable sequence.
  11595. /// </summary>
  11596. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11597. /// <param name="source">Source observable sequence.</param>
  11598. /// <returns>Sequence containing the single element in the observable sequence.</returns>
  11599. /// <exception cref="ArgumentNullException">
  11600. /// <paramref name="source" /> is null.</exception>
  11601. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence contains more than one element. -or- The source sequence is empty.</exception>
  11602. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source)
  11603. {
  11604. if (source == null)
  11605. throw new ArgumentNullException(nameof(source));
  11606. return source.Provider.CreateQuery<TSource>(
  11607. Expression.Call(
  11608. null,
  11609. #if CRIPPLED_REFLECTION
  11610. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>))),
  11611. #else
  11612. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11613. #endif
  11614. source.Expression
  11615. )
  11616. );
  11617. }
  11618. /// <summary>
  11619. /// 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.
  11620. /// </summary>
  11621. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11622. /// <param name="source">Source observable sequence.</param>
  11623. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  11624. /// <returns>Sequence containing the single element in the observable sequence that satisfies the condition in the predicate.</returns>
  11625. /// <exception cref="ArgumentNullException">
  11626. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  11627. /// <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>
  11628. public static IQbservable<TSource> SingleAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  11629. {
  11630. if (source == null)
  11631. throw new ArgumentNullException(nameof(source));
  11632. if (predicate == null)
  11633. throw new ArgumentNullException(nameof(predicate));
  11634. return source.Provider.CreateQuery<TSource>(
  11635. Expression.Call(
  11636. null,
  11637. #if CRIPPLED_REFLECTION
  11638. InfoOf(() => Qbservable.SingleAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  11639. #else
  11640. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11641. #endif
  11642. source.Expression,
  11643. predicate
  11644. )
  11645. );
  11646. }
  11647. /// <summary>
  11648. /// 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.
  11649. /// </summary>
  11650. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11651. /// <param name="source">Source observable sequence.</param>
  11652. /// <returns>Sequence containing the single element in the observable sequence, or a default value if no such element exists.</returns>
  11653. /// <exception cref="ArgumentNullException">
  11654. /// <paramref name="source" /> is null.</exception>
  11655. /// <exception cref="InvalidOperationException">(Asynchronous) The source sequence contains more than one element.</exception>
  11656. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source)
  11657. {
  11658. if (source == null)
  11659. throw new ArgumentNullException(nameof(source));
  11660. return source.Provider.CreateQuery<TSource>(
  11661. Expression.Call(
  11662. null,
  11663. #if CRIPPLED_REFLECTION
  11664. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>))),
  11665. #else
  11666. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11667. #endif
  11668. source.Expression
  11669. )
  11670. );
  11671. }
  11672. /// <summary>
  11673. /// 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.
  11674. /// </summary>
  11675. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11676. /// <param name="source">Source observable sequence.</param>
  11677. /// <param name="predicate">A predicate function to evaluate for elements in the source sequence.</param>
  11678. /// <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>
  11679. /// <exception cref="ArgumentNullException">
  11680. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  11681. /// <exception cref="InvalidOperationException">(Asynchronous) The sequence contains more than one element that satisfies the condition in the predicate.</exception>
  11682. public static IQbservable<TSource> SingleOrDefaultAsync<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  11683. {
  11684. if (source == null)
  11685. throw new ArgumentNullException(nameof(source));
  11686. if (predicate == null)
  11687. throw new ArgumentNullException(nameof(predicate));
  11688. return source.Provider.CreateQuery<TSource>(
  11689. Expression.Call(
  11690. null,
  11691. #if CRIPPLED_REFLECTION
  11692. InfoOf(() => Qbservable.SingleOrDefaultAsync<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  11693. #else
  11694. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11695. #endif
  11696. source.Expression,
  11697. predicate
  11698. )
  11699. );
  11700. }
  11701. /// <summary>
  11702. /// Bypasses a specified number of elements in an observable sequence and then returns the remaining elements.
  11703. /// </summary>
  11704. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11705. /// <param name="source">The sequence to take elements from.</param>
  11706. /// <param name="count">The number of elements to skip before returning the remaining elements.</param>
  11707. /// <returns>An observable sequence that contains the elements that occur after the specified index in the input sequence.</returns>
  11708. /// <exception cref="ArgumentNullException">
  11709. /// <paramref name="source" /> is null.</exception>
  11710. /// <exception cref="ArgumentOutOfRangeException">
  11711. /// <paramref name="count" /> is less than zero.</exception>
  11712. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, int count)
  11713. {
  11714. if (source == null)
  11715. throw new ArgumentNullException(nameof(source));
  11716. return source.Provider.CreateQuery<TSource>(
  11717. Expression.Call(
  11718. null,
  11719. #if CRIPPLED_REFLECTION
  11720. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(int))),
  11721. #else
  11722. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11723. #endif
  11724. source.Expression,
  11725. Expression.Constant(count, typeof(int))
  11726. )
  11727. );
  11728. }
  11729. /// <summary>
  11730. /// Skips elements for the specified duration from the start of the observable source sequence.
  11731. /// </summary>
  11732. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11733. /// <param name="source">Source sequence to skip elements for.</param>
  11734. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  11735. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  11736. /// <exception cref="ArgumentNullException">
  11737. /// <paramref name="source" /> is null.</exception>
  11738. /// <exception cref="ArgumentOutOfRangeException">
  11739. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  11740. /// <remarks>
  11741. /// <para>
  11742. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  11743. /// 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
  11744. /// may not execute immediately, despite the TimeSpan.Zero due time.
  11745. /// </para>
  11746. /// <para>
  11747. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  11748. /// </para>
  11749. /// </remarks>
  11750. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  11751. {
  11752. if (source == null)
  11753. throw new ArgumentNullException(nameof(source));
  11754. return source.Provider.CreateQuery<TSource>(
  11755. Expression.Call(
  11756. null,
  11757. #if CRIPPLED_REFLECTION
  11758. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  11759. #else
  11760. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11761. #endif
  11762. source.Expression,
  11763. Expression.Constant(duration, typeof(TimeSpan))
  11764. )
  11765. );
  11766. }
  11767. /// <summary>
  11768. /// Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  11769. /// </summary>
  11770. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11771. /// <param name="source">Source sequence to skip elements for.</param>
  11772. /// <param name="duration">Duration for skipping elements from the start of the sequence.</param>
  11773. /// <param name="scheduler">Scheduler to run the timer on.</param>
  11774. /// <returns>An observable sequence with the elements skipped during the specified duration from the start of the source sequence.</returns>
  11775. /// <exception cref="ArgumentNullException">
  11776. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  11777. /// <exception cref="ArgumentOutOfRangeException">
  11778. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  11779. /// <remarks>
  11780. /// <para>
  11781. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee no elements will be dropped from the start of the source sequence.
  11782. /// 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
  11783. /// may not execute immediately, despite the TimeSpan.Zero due time.
  11784. /// </para>
  11785. /// <para>
  11786. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="duration" />.
  11787. /// </para>
  11788. /// </remarks>
  11789. public static IQbservable<TSource> Skip<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  11790. {
  11791. if (source == null)
  11792. throw new ArgumentNullException(nameof(source));
  11793. if (scheduler == null)
  11794. throw new ArgumentNullException(nameof(scheduler));
  11795. return source.Provider.CreateQuery<TSource>(
  11796. Expression.Call(
  11797. null,
  11798. #if CRIPPLED_REFLECTION
  11799. InfoOf(() => Qbservable.Skip<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  11800. #else
  11801. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11802. #endif
  11803. source.Expression,
  11804. Expression.Constant(duration, typeof(TimeSpan)),
  11805. Expression.Constant(scheduler, typeof(IScheduler))
  11806. )
  11807. );
  11808. }
  11809. /// <summary>
  11810. /// Bypasses a specified number of elements at the end of an observable sequence.
  11811. /// </summary>
  11812. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11813. /// <param name="source">Source sequence.</param>
  11814. /// <param name="count">Number of elements to bypass at the end of the source sequence.</param>
  11815. /// <returns>An observable sequence containing the source sequence elements except for the bypassed ones at the end.</returns>
  11816. /// <exception cref="ArgumentNullException">
  11817. /// <paramref name="source" /> is null.</exception>
  11818. /// <exception cref="ArgumentOutOfRangeException">
  11819. /// <paramref name="count" /> is less than zero.</exception>
  11820. /// <remarks>
  11821. /// This operator accumulates a queue with a length enough to store the first <paramref name="count" /> elements. As more elements are
  11822. /// received, elements are taken from the front of the queue and produced on the result sequence. This causes elements to be delayed.
  11823. /// </remarks>
  11824. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, int count)
  11825. {
  11826. if (source == null)
  11827. throw new ArgumentNullException(nameof(source));
  11828. return source.Provider.CreateQuery<TSource>(
  11829. Expression.Call(
  11830. null,
  11831. #if CRIPPLED_REFLECTION
  11832. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(int))),
  11833. #else
  11834. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11835. #endif
  11836. source.Expression,
  11837. Expression.Constant(count, typeof(int))
  11838. )
  11839. );
  11840. }
  11841. /// <summary>
  11842. /// Skips elements for the specified duration from the end of the observable source sequence.
  11843. /// </summary>
  11844. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11845. /// <param name="source">Source sequence to skip elements for.</param>
  11846. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  11847. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  11848. /// <exception cref="ArgumentNullException">
  11849. /// <paramref name="source" /> is null.</exception>
  11850. /// <exception cref="ArgumentOutOfRangeException">
  11851. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  11852. /// <remarks>
  11853. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  11854. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  11855. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  11856. /// </remarks>
  11857. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  11858. {
  11859. if (source == null)
  11860. throw new ArgumentNullException(nameof(source));
  11861. return source.Provider.CreateQuery<TSource>(
  11862. Expression.Call(
  11863. null,
  11864. #if CRIPPLED_REFLECTION
  11865. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  11866. #else
  11867. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11868. #endif
  11869. source.Expression,
  11870. Expression.Constant(duration, typeof(TimeSpan))
  11871. )
  11872. );
  11873. }
  11874. /// <summary>
  11875. /// Skips elements for the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  11876. /// </summary>
  11877. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11878. /// <param name="source">Source sequence to skip elements for.</param>
  11879. /// <param name="duration">Duration for skipping elements from the end of the sequence.</param>
  11880. /// <param name="scheduler">Scheduler to run the timer on.</param>
  11881. /// <returns>An observable sequence with the elements skipped during the specified duration from the end of the source sequence.</returns>
  11882. /// <exception cref="ArgumentNullException">
  11883. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  11884. /// <exception cref="ArgumentOutOfRangeException">
  11885. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  11886. /// <remarks>
  11887. /// This operator accumulates a queue with a length enough to store elements received during the initial <paramref name="duration" /> window.
  11888. /// As more elements are received, elements older than the specified <paramref name="duration" /> are taken from the queue and produced on the
  11889. /// result sequence. This causes elements to be delayed with <paramref name="duration" />.
  11890. /// </remarks>
  11891. public static IQbservable<TSource> SkipLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  11892. {
  11893. if (source == null)
  11894. throw new ArgumentNullException(nameof(source));
  11895. if (scheduler == null)
  11896. throw new ArgumentNullException(nameof(scheduler));
  11897. return source.Provider.CreateQuery<TSource>(
  11898. Expression.Call(
  11899. null,
  11900. #if CRIPPLED_REFLECTION
  11901. InfoOf(() => Qbservable.SkipLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  11902. #else
  11903. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11904. #endif
  11905. source.Expression,
  11906. Expression.Constant(duration, typeof(TimeSpan)),
  11907. Expression.Constant(scheduler, typeof(IScheduler))
  11908. )
  11909. );
  11910. }
  11911. /// <summary>
  11912. /// Skips elements from the observable source sequence until the specified start time.
  11913. /// </summary>
  11914. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11915. /// <param name="source">Source sequence to skip elements for.</param>
  11916. /// <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>
  11917. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  11918. /// <exception cref="ArgumentNullException">
  11919. /// <paramref name="source" /> is null.</exception>
  11920. /// <remarks>
  11921. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  11922. /// </remarks>
  11923. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime)
  11924. {
  11925. if (source == null)
  11926. throw new ArgumentNullException(nameof(source));
  11927. return source.Provider.CreateQuery<TSource>(
  11928. Expression.Call(
  11929. null,
  11930. #if CRIPPLED_REFLECTION
  11931. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  11932. #else
  11933. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11934. #endif
  11935. source.Expression,
  11936. Expression.Constant(startTime, typeof(DateTimeOffset))
  11937. )
  11938. );
  11939. }
  11940. /// <summary>
  11941. /// Skips elements from the observable source sequence until the specified start time, using the specified scheduler to run timers.
  11942. /// </summary>
  11943. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11944. /// <param name="source">Source sequence to skip elements for.</param>
  11945. /// <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>
  11946. /// <param name="scheduler">Scheduler to run the timer on.</param>
  11947. /// <returns>An observable sequence with the elements skipped until the specified start time.</returns>
  11948. /// <exception cref="ArgumentNullException">
  11949. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  11950. /// <remarks>
  11951. /// Errors produced by the source sequence are always forwarded to the result sequence, even if the error occurs before the <paramref name="startTime" />.
  11952. /// </remarks>
  11953. public static IQbservable<TSource> SkipUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset startTime, IScheduler scheduler)
  11954. {
  11955. if (source == null)
  11956. throw new ArgumentNullException(nameof(source));
  11957. if (scheduler == null)
  11958. throw new ArgumentNullException(nameof(scheduler));
  11959. return source.Provider.CreateQuery<TSource>(
  11960. Expression.Call(
  11961. null,
  11962. #if CRIPPLED_REFLECTION
  11963. InfoOf(() => Qbservable.SkipUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  11964. #else
  11965. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  11966. #endif
  11967. source.Expression,
  11968. Expression.Constant(startTime, typeof(DateTimeOffset)),
  11969. Expression.Constant(scheduler, typeof(IScheduler))
  11970. )
  11971. );
  11972. }
  11973. /// <summary>
  11974. /// Returns the elements from the source observable sequence only after the other observable sequence produces an element.
  11975. /// </summary>
  11976. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  11977. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of skip behavior.</typeparam>
  11978. /// <param name="source">Source sequence to propagate elements for.</param>
  11979. /// <param name="other">Observable sequence that triggers propagation of elements of the source sequence.</param>
  11980. /// <returns>An observable sequence containing the elements of the source sequence starting from the point the other sequence triggered propagation.</returns>
  11981. /// <exception cref="ArgumentNullException">
  11982. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  11983. public static IQbservable<TSource> SkipUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  11984. {
  11985. if (source == null)
  11986. throw new ArgumentNullException(nameof(source));
  11987. if (other == null)
  11988. throw new ArgumentNullException(nameof(other));
  11989. return source.Provider.CreateQuery<TSource>(
  11990. Expression.Call(
  11991. null,
  11992. #if CRIPPLED_REFLECTION
  11993. InfoOf(() => Qbservable.SkipUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  11994. #else
  11995. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  11996. #endif
  11997. source.Expression,
  11998. GetSourceExpression(other)
  11999. )
  12000. );
  12001. }
  12002. /// <summary>
  12003. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12004. /// </summary>
  12005. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12006. /// <param name="source">An observable sequence to return elements from.</param>
  12007. /// <param name="predicate">A function to test each element for a condition.</param>
  12008. /// <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>
  12009. /// <exception cref="ArgumentNullException">
  12010. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12011. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  12012. {
  12013. if (source == null)
  12014. throw new ArgumentNullException(nameof(source));
  12015. if (predicate == null)
  12016. throw new ArgumentNullException(nameof(predicate));
  12017. return source.Provider.CreateQuery<TSource>(
  12018. Expression.Call(
  12019. null,
  12020. #if CRIPPLED_REFLECTION
  12021. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  12022. #else
  12023. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12024. #endif
  12025. source.Expression,
  12026. predicate
  12027. )
  12028. );
  12029. }
  12030. /// <summary>
  12031. /// Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements.
  12032. /// The element's index is used in the logic of the predicate function.
  12033. /// </summary>
  12034. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12035. /// <param name="source">An observable sequence to return elements from.</param>
  12036. /// <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>
  12037. /// <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>
  12038. /// <exception cref="ArgumentNullException">
  12039. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  12040. public static IQbservable<TSource> SkipWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  12041. {
  12042. if (source == null)
  12043. throw new ArgumentNullException(nameof(source));
  12044. if (predicate == null)
  12045. throw new ArgumentNullException(nameof(predicate));
  12046. return source.Provider.CreateQuery<TSource>(
  12047. Expression.Call(
  12048. null,
  12049. #if CRIPPLED_REFLECTION
  12050. InfoOf(() => Qbservable.SkipWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  12051. #else
  12052. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12053. #endif
  12054. source.Expression,
  12055. predicate
  12056. )
  12057. );
  12058. }
  12059. /// <summary>
  12060. /// Invokes the action asynchronously, surfacing the result through an observable sequence.
  12061. /// </summary>
  12062. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12063. /// <param name="action">Action to run asynchronously.</param>
  12064. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12065. /// <exception cref="ArgumentNullException">
  12066. /// <paramref name="action" /> is null.</exception>
  12067. /// <remarks>
  12068. /// <list type="bullet">
  12069. /// <item>
  12070. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12071. /// </item>
  12072. /// <item>
  12073. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12074. /// </item>
  12075. /// </list>
  12076. /// </remarks>
  12077. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action)
  12078. {
  12079. if (provider == null)
  12080. throw new ArgumentNullException(nameof(provider));
  12081. if (action == null)
  12082. throw new ArgumentNullException(nameof(action));
  12083. return provider.CreateQuery<Unit>(
  12084. Expression.Call(
  12085. null,
  12086. #if CRIPPLED_REFLECTION
  12087. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>))),
  12088. #else
  12089. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12090. #endif
  12091. Expression.Constant(provider, typeof(IQbservableProvider)),
  12092. action
  12093. )
  12094. );
  12095. }
  12096. /// <summary>
  12097. /// Invokes the action asynchronously on the specified scheduler, surfacing the result through an observable sequence.
  12098. /// </summary>
  12099. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12100. /// <param name="action">Action to run asynchronously.</param>
  12101. /// <param name="scheduler">Scheduler to run the action on.</param>
  12102. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12103. /// <exception cref="ArgumentNullException">
  12104. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  12105. /// <remarks>
  12106. /// <list type="bullet">
  12107. /// <item>
  12108. /// <description>The action is called immediately, not during the subscription of the resulting sequence.</description>
  12109. /// </item>
  12110. /// <item>
  12111. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12112. /// </item>
  12113. /// </list>
  12114. /// </remarks>
  12115. public static IQbservable<Unit> Start(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  12116. {
  12117. if (provider == null)
  12118. throw new ArgumentNullException(nameof(provider));
  12119. if (action == null)
  12120. throw new ArgumentNullException(nameof(action));
  12121. if (scheduler == null)
  12122. throw new ArgumentNullException(nameof(scheduler));
  12123. return provider.CreateQuery<Unit>(
  12124. Expression.Call(
  12125. null,
  12126. #if CRIPPLED_REFLECTION
  12127. InfoOf(() => Qbservable.Start(default(IQbservableProvider), default(Expression<Action>), default(IScheduler))),
  12128. #else
  12129. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12130. #endif
  12131. Expression.Constant(provider, typeof(IQbservableProvider)),
  12132. action,
  12133. Expression.Constant(scheduler, typeof(IScheduler))
  12134. )
  12135. );
  12136. }
  12137. /// <summary>
  12138. /// Invokes the specified function asynchronously, surfacing the result through an observable sequence.
  12139. /// </summary>
  12140. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12141. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12142. /// <param name="function">Function to run asynchronously.</param>
  12143. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12144. /// <exception cref="ArgumentNullException">
  12145. /// <paramref name="function" /> is null.</exception>
  12146. /// <remarks>
  12147. /// <list type="bullet">
  12148. /// <item>
  12149. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12150. /// </item>
  12151. /// <item>
  12152. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12153. /// </item>
  12154. /// </list>
  12155. /// </remarks>
  12156. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  12157. {
  12158. if (provider == null)
  12159. throw new ArgumentNullException(nameof(provider));
  12160. if (function == null)
  12161. throw new ArgumentNullException(nameof(function));
  12162. return provider.CreateQuery<TResult>(
  12163. Expression.Call(
  12164. null,
  12165. #if CRIPPLED_REFLECTION
  12166. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>))),
  12167. #else
  12168. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12169. #endif
  12170. Expression.Constant(provider, typeof(IQbservableProvider)),
  12171. function
  12172. )
  12173. );
  12174. }
  12175. /// <summary>
  12176. /// Invokes the specified function asynchronously on the specified scheduler, surfacing the result through an observable sequence
  12177. /// </summary>
  12178. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12179. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  12180. /// <param name="function">Function to run asynchronously.</param>
  12181. /// <param name="scheduler">Scheduler to run the function on.</param>
  12182. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12183. /// <exception cref="ArgumentNullException">
  12184. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  12185. /// <remarks>
  12186. /// <list type="bullet">
  12187. /// <item>
  12188. /// <description>The function is called immediately, not during the subscription of the resulting sequence.</description>
  12189. /// </item>
  12190. /// <item>
  12191. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12192. /// </item>
  12193. /// </list>
  12194. /// </remarks>
  12195. public static IQbservable<TResult> Start<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  12196. {
  12197. if (provider == null)
  12198. throw new ArgumentNullException(nameof(provider));
  12199. if (function == null)
  12200. throw new ArgumentNullException(nameof(function));
  12201. if (scheduler == null)
  12202. throw new ArgumentNullException(nameof(scheduler));
  12203. return provider.CreateQuery<TResult>(
  12204. Expression.Call(
  12205. null,
  12206. #if CRIPPLED_REFLECTION
  12207. InfoOf(() => Qbservable.Start<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler))),
  12208. #else
  12209. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12210. #endif
  12211. Expression.Constant(provider, typeof(IQbservableProvider)),
  12212. function,
  12213. Expression.Constant(scheduler, typeof(IScheduler))
  12214. )
  12215. );
  12216. }
  12217. /// <summary>
  12218. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12219. /// </summary>
  12220. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12221. /// <param name="actionAsync">Asynchronous action to run.</param>
  12222. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12223. /// <exception cref="ArgumentNullException">
  12224. /// <paramref name="actionAsync" /> is null.</exception>
  12225. /// <remarks>
  12226. /// <list type="bullet">
  12227. /// <item>
  12228. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12229. /// </item>
  12230. /// <item>
  12231. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12232. /// </item>
  12233. /// </list>
  12234. /// </remarks>
  12235. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync)
  12236. {
  12237. if (provider == null)
  12238. throw new ArgumentNullException(nameof(provider));
  12239. if (actionAsync == null)
  12240. throw new ArgumentNullException(nameof(actionAsync));
  12241. return provider.CreateQuery<Unit>(
  12242. Expression.Call(
  12243. null,
  12244. #if CRIPPLED_REFLECTION
  12245. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>))),
  12246. #else
  12247. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12248. #endif
  12249. Expression.Constant(provider, typeof(IQbservableProvider)),
  12250. actionAsync
  12251. )
  12252. );
  12253. }
  12254. /// <summary>
  12255. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12256. /// </summary>
  12257. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12258. /// <param name="actionAsync">Asynchronous action to run.</param>
  12259. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12260. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12261. /// <exception cref="ArgumentNullException">
  12262. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12263. /// <remarks>
  12264. /// <list type="bullet">
  12265. /// <item>
  12266. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12267. /// </item>
  12268. /// <item>
  12269. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12270. /// </item>
  12271. /// </list>
  12272. /// </remarks>
  12273. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<Task>> actionAsync, IScheduler scheduler)
  12274. {
  12275. if (provider == null)
  12276. throw new ArgumentNullException(nameof(provider));
  12277. if (actionAsync == null)
  12278. throw new ArgumentNullException(nameof(actionAsync));
  12279. if (scheduler == null)
  12280. throw new ArgumentNullException(nameof(scheduler));
  12281. return provider.CreateQuery<Unit>(
  12282. Expression.Call(
  12283. null,
  12284. #if CRIPPLED_REFLECTION
  12285. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<Task>>), default(IScheduler))),
  12286. #else
  12287. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12288. #endif
  12289. Expression.Constant(provider, typeof(IQbservableProvider)),
  12290. actionAsync,
  12291. Expression.Constant(scheduler, typeof(IScheduler))
  12292. )
  12293. );
  12294. }
  12295. /// <summary>
  12296. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12297. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12298. /// </summary>
  12299. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12300. /// <param name="actionAsync">Asynchronous action to run.</param>
  12301. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12302. /// <exception cref="ArgumentNullException">
  12303. /// <paramref name="actionAsync" /> is null.</exception>
  12304. /// <remarks>
  12305. /// <list type="bullet">
  12306. /// <item>
  12307. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12308. /// </item>
  12309. /// <item>
  12310. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12311. /// </item>
  12312. /// <item>
  12313. /// <description>
  12314. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12315. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12316. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12317. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12318. /// multicast operators.
  12319. /// </description>
  12320. /// </item>
  12321. /// </list>
  12322. /// </remarks>
  12323. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync)
  12324. {
  12325. if (provider == null)
  12326. throw new ArgumentNullException(nameof(provider));
  12327. if (actionAsync == null)
  12328. throw new ArgumentNullException(nameof(actionAsync));
  12329. return provider.CreateQuery<Unit>(
  12330. Expression.Call(
  12331. null,
  12332. #if CRIPPLED_REFLECTION
  12333. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>))),
  12334. #else
  12335. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12336. #endif
  12337. Expression.Constant(provider, typeof(IQbservableProvider)),
  12338. actionAsync
  12339. )
  12340. );
  12341. }
  12342. /// <summary>
  12343. /// Invokes the asynchronous action, surfacing the result through an observable sequence.
  12344. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12345. /// </summary>
  12346. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12347. /// <param name="actionAsync">Asynchronous action to run.</param>
  12348. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12349. /// <returns>An observable sequence exposing a Unit value upon completion of the action, or an exception.</returns>
  12350. /// <exception cref="ArgumentNullException">
  12351. /// <paramref name="actionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12352. /// <remarks>
  12353. /// <list type="bullet">
  12354. /// <item>
  12355. /// <description>The action is started immediately, not during the subscription of the resulting sequence.</description>
  12356. /// </item>
  12357. /// <item>
  12358. /// <description>Multiple subscriptions to the resulting sequence can observe the action's outcome.</description>
  12359. /// </item>
  12360. /// <item>
  12361. /// <description>
  12362. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12363. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12364. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12365. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12366. /// multicast operators.
  12367. /// </description>
  12368. /// </item>
  12369. /// </list>
  12370. /// </remarks>
  12371. public static IQbservable<Unit> StartAsync(this IQbservableProvider provider, Expression<Func<CancellationToken, Task>> actionAsync, IScheduler scheduler)
  12372. {
  12373. if (provider == null)
  12374. throw new ArgumentNullException(nameof(provider));
  12375. if (actionAsync == null)
  12376. throw new ArgumentNullException(nameof(actionAsync));
  12377. if (scheduler == null)
  12378. throw new ArgumentNullException(nameof(scheduler));
  12379. return provider.CreateQuery<Unit>(
  12380. Expression.Call(
  12381. null,
  12382. #if CRIPPLED_REFLECTION
  12383. InfoOf(() => Qbservable.StartAsync(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task>>), default(IScheduler))),
  12384. #else
  12385. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12386. #endif
  12387. Expression.Constant(provider, typeof(IQbservableProvider)),
  12388. actionAsync,
  12389. Expression.Constant(scheduler, typeof(IScheduler))
  12390. )
  12391. );
  12392. }
  12393. /// <summary>
  12394. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12395. /// </summary>
  12396. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12397. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12398. /// <param name="functionAsync">Asynchronous function to run.</param>
  12399. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12400. /// <exception cref="ArgumentNullException">
  12401. /// <paramref name="functionAsync" /> is null.</exception>
  12402. /// <remarks>
  12403. /// <list type="bullet">
  12404. /// <item>
  12405. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12406. /// </item>
  12407. /// <item>
  12408. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12409. /// </item>
  12410. /// </list>
  12411. /// </remarks>
  12412. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync)
  12413. {
  12414. if (provider == null)
  12415. throw new ArgumentNullException(nameof(provider));
  12416. if (functionAsync == null)
  12417. throw new ArgumentNullException(nameof(functionAsync));
  12418. return provider.CreateQuery<TResult>(
  12419. Expression.Call(
  12420. null,
  12421. #if CRIPPLED_REFLECTION
  12422. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>))),
  12423. #else
  12424. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12425. #endif
  12426. Expression.Constant(provider, typeof(IQbservableProvider)),
  12427. functionAsync
  12428. )
  12429. );
  12430. }
  12431. /// <summary>
  12432. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12433. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12434. /// </summary>
  12435. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12436. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12437. /// <param name="functionAsync">Asynchronous function to run.</param>
  12438. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12439. /// <exception cref="ArgumentNullException">
  12440. /// <paramref name="functionAsync" /> is null.</exception>
  12441. /// <remarks>
  12442. /// <list type="bullet">
  12443. /// <item>
  12444. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12445. /// </item>
  12446. /// <item>
  12447. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12448. /// </item>
  12449. /// <item>
  12450. /// <description>
  12451. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12452. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12453. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12454. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12455. /// multicast operators.
  12456. /// </description>
  12457. /// </item>
  12458. /// </list>
  12459. /// </remarks>
  12460. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync)
  12461. {
  12462. if (provider == null)
  12463. throw new ArgumentNullException(nameof(provider));
  12464. if (functionAsync == null)
  12465. throw new ArgumentNullException(nameof(functionAsync));
  12466. return provider.CreateQuery<TResult>(
  12467. Expression.Call(
  12468. null,
  12469. #if CRIPPLED_REFLECTION
  12470. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>))),
  12471. #else
  12472. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12473. #endif
  12474. Expression.Constant(provider, typeof(IQbservableProvider)),
  12475. functionAsync
  12476. )
  12477. );
  12478. }
  12479. /// <summary>
  12480. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12481. /// </summary>
  12482. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12483. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12484. /// <param name="functionAsync">Asynchronous function to run.</param>
  12485. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12486. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12487. /// <exception cref="ArgumentNullException">
  12488. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12489. /// <remarks>
  12490. /// <list type="bullet">
  12491. /// <item>
  12492. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12493. /// </item>
  12494. /// <item>
  12495. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12496. /// </item>
  12497. /// </list>
  12498. /// </remarks>
  12499. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<Task<TResult>>> functionAsync, IScheduler scheduler)
  12500. {
  12501. if (provider == null)
  12502. throw new ArgumentNullException(nameof(provider));
  12503. if (functionAsync == null)
  12504. throw new ArgumentNullException(nameof(functionAsync));
  12505. if (scheduler == null)
  12506. throw new ArgumentNullException(nameof(scheduler));
  12507. return provider.CreateQuery<TResult>(
  12508. Expression.Call(
  12509. null,
  12510. #if CRIPPLED_REFLECTION
  12511. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<Task<TResult>>>), default(IScheduler))),
  12512. #else
  12513. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12514. #endif
  12515. Expression.Constant(provider, typeof(IQbservableProvider)),
  12516. functionAsync,
  12517. Expression.Constant(scheduler, typeof(IScheduler))
  12518. )
  12519. );
  12520. }
  12521. /// <summary>
  12522. /// Invokes the asynchronous function, surfacing the result through an observable sequence.
  12523. /// The CancellationToken is shared by all subscriptions on the resulting observable sequence. See the remarks section for more information.
  12524. /// </summary>
  12525. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  12526. /// <typeparam name="TResult">The type of the result returned by the asynchronous function.</typeparam>
  12527. /// <param name="functionAsync">Asynchronous function to run.</param>
  12528. /// <param name="scheduler">Scheduler on which to notify observers.</param>
  12529. /// <returns>An observable sequence exposing the function's result value, or an exception.</returns>
  12530. /// <exception cref="ArgumentNullException">
  12531. /// <paramref name="functionAsync" /> is null or <paramref name="scheduler" /> is null.</exception>
  12532. /// <remarks>
  12533. /// <list type="bullet">
  12534. /// <item>
  12535. /// <description>The function is started immediately, not during the subscription of the resulting sequence.</description>
  12536. /// </item>
  12537. /// <item>
  12538. /// <description>Multiple subscriptions to the resulting sequence can observe the function's result.</description>
  12539. /// </item>
  12540. /// <item>
  12541. /// <description>
  12542. /// If any subscription to the resulting sequence is disposed, the CancellationToken is set. The observer associated to the disposed
  12543. /// subscription won't see the TaskCanceledException, but other observers will. You can protect against this using the Catch operator.
  12544. /// Be careful when handing out the resulting sequence because of this behavior. The most common use is to have a single subscription
  12545. /// to the resulting sequence, which controls the CancellationToken state. Alternatively, you can control subscription behavior using
  12546. /// multicast operators.
  12547. /// </description>
  12548. /// </item>
  12549. /// </list>
  12550. /// </remarks>
  12551. public static IQbservable<TResult> StartAsync<TResult>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResult>>> functionAsync, IScheduler scheduler)
  12552. {
  12553. if (provider == null)
  12554. throw new ArgumentNullException(nameof(provider));
  12555. if (functionAsync == null)
  12556. throw new ArgumentNullException(nameof(functionAsync));
  12557. if (scheduler == null)
  12558. throw new ArgumentNullException(nameof(scheduler));
  12559. return provider.CreateQuery<TResult>(
  12560. Expression.Call(
  12561. null,
  12562. #if CRIPPLED_REFLECTION
  12563. InfoOf(() => Qbservable.StartAsync<TResult>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResult>>>), default(IScheduler))),
  12564. #else
  12565. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  12566. #endif
  12567. Expression.Constant(provider, typeof(IQbservableProvider)),
  12568. functionAsync,
  12569. Expression.Constant(scheduler, typeof(IScheduler))
  12570. )
  12571. );
  12572. }
  12573. /// <summary>
  12574. /// Prepends a sequence of values to an observable sequence.
  12575. /// </summary>
  12576. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12577. /// <param name="source">Source sequence to prepend values to.</param>
  12578. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  12579. /// <param name="values">Values to prepend to the specified sequence.</param>
  12580. /// <returns>The source sequence prepended with the specified values.</returns>
  12581. /// <exception cref="ArgumentNullException">
  12582. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  12583. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, params TSource[] values)
  12584. {
  12585. if (source == null)
  12586. throw new ArgumentNullException(nameof(source));
  12587. if (scheduler == null)
  12588. throw new ArgumentNullException(nameof(scheduler));
  12589. if (values == null)
  12590. throw new ArgumentNullException(nameof(values));
  12591. return source.Provider.CreateQuery<TSource>(
  12592. Expression.Call(
  12593. null,
  12594. #if CRIPPLED_REFLECTION
  12595. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(TSource[]))),
  12596. #else
  12597. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12598. #endif
  12599. source.Expression,
  12600. Expression.Constant(scheduler, typeof(IScheduler)),
  12601. Expression.Constant(values, typeof(TSource[]))
  12602. )
  12603. );
  12604. }
  12605. /// <summary>
  12606. /// Prepends a sequence of values to an observable sequence.
  12607. /// </summary>
  12608. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12609. /// <param name="source">Source sequence to prepend values to.</param>
  12610. /// <param name="scheduler">Scheduler to emit the prepended values on.</param>
  12611. /// <param name="values">Values to prepend to the specified sequence.</param>
  12612. /// <returns>The source sequence prepended with the specified values.</returns>
  12613. /// <exception cref="ArgumentNullException">
  12614. /// <paramref name="source" /> or <paramref name="scheduler" /> or <paramref name="values" /> is null.</exception>
  12615. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IScheduler scheduler, IEnumerable<TSource> values)
  12616. {
  12617. if (source == null)
  12618. throw new ArgumentNullException(nameof(source));
  12619. if (scheduler == null)
  12620. throw new ArgumentNullException(nameof(scheduler));
  12621. if (values == null)
  12622. throw new ArgumentNullException(nameof(values));
  12623. return source.Provider.CreateQuery<TSource>(
  12624. Expression.Call(
  12625. null,
  12626. #if CRIPPLED_REFLECTION
  12627. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IScheduler), default(IEnumerable<TSource>))),
  12628. #else
  12629. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12630. #endif
  12631. source.Expression,
  12632. Expression.Constant(scheduler, typeof(IScheduler)),
  12633. GetSourceExpression(values)
  12634. )
  12635. );
  12636. }
  12637. /// <summary>
  12638. /// Prepends a sequence of values to an observable sequence.
  12639. /// </summary>
  12640. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12641. /// <param name="source">Source sequence to prepend values to.</param>
  12642. /// <param name="values">Values to prepend to the specified sequence.</param>
  12643. /// <returns>The source sequence prepended with the specified values.</returns>
  12644. /// <exception cref="ArgumentNullException">
  12645. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  12646. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, params TSource[] values)
  12647. {
  12648. if (source == null)
  12649. throw new ArgumentNullException(nameof(source));
  12650. if (values == null)
  12651. throw new ArgumentNullException(nameof(values));
  12652. return source.Provider.CreateQuery<TSource>(
  12653. Expression.Call(
  12654. null,
  12655. #if CRIPPLED_REFLECTION
  12656. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(TSource[]))),
  12657. #else
  12658. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12659. #endif
  12660. source.Expression,
  12661. Expression.Constant(values, typeof(TSource[]))
  12662. )
  12663. );
  12664. }
  12665. /// <summary>
  12666. /// Prepends a sequence of values to an observable sequence.
  12667. /// </summary>
  12668. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12669. /// <param name="source">Source sequence to prepend values to.</param>
  12670. /// <param name="values">Values to prepend to the specified sequence.</param>
  12671. /// <returns>The source sequence prepended with the specified values.</returns>
  12672. /// <exception cref="ArgumentNullException">
  12673. /// <paramref name="source" /> or <paramref name="values" /> is null.</exception>
  12674. public static IQbservable<TSource> StartWith<TSource>(this IQbservable<TSource> source, IEnumerable<TSource> values)
  12675. {
  12676. if (source == null)
  12677. throw new ArgumentNullException(nameof(source));
  12678. if (values == null)
  12679. throw new ArgumentNullException(nameof(values));
  12680. return source.Provider.CreateQuery<TSource>(
  12681. Expression.Call(
  12682. null,
  12683. #if CRIPPLED_REFLECTION
  12684. InfoOf(() => Qbservable.StartWith<TSource>(default(IQbservable<TSource>), default(IEnumerable<TSource>))),
  12685. #else
  12686. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12687. #endif
  12688. source.Expression,
  12689. GetSourceExpression(values)
  12690. )
  12691. );
  12692. }
  12693. /// <summary>
  12694. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified synchronization context. This operation is not commonly used;
  12695. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  12696. /// </summary>
  12697. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12698. /// <param name="source">Source sequence.</param>
  12699. /// <param name="context">Synchronization context to perform subscription and unsubscription actions on.</param>
  12700. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified synchronization context.</returns>
  12701. /// <exception cref="ArgumentNullException">
  12702. /// <paramref name="source" /> or <paramref name="context" /> is null.</exception>
  12703. /// <remarks>
  12704. /// This only performs the side-effects of subscription and unsubscription on the specified synchronization context. In order to invoke observer
  12705. /// callbacks on a synchronization context, use <see cref="Observable.ObserveOn{TSource}(IObservable{TSource},SynchronizationContext)" />.
  12706. /// </remarks>
  12707. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, SynchronizationContext context)
  12708. {
  12709. if (source == null)
  12710. throw new ArgumentNullException(nameof(source));
  12711. if (context == null)
  12712. throw new ArgumentNullException(nameof(context));
  12713. return source.Provider.CreateQuery<TSource>(
  12714. Expression.Call(
  12715. null,
  12716. #if CRIPPLED_REFLECTION
  12717. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(SynchronizationContext))),
  12718. #else
  12719. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12720. #endif
  12721. source.Expression,
  12722. Expression.Constant(context, typeof(SynchronizationContext))
  12723. )
  12724. );
  12725. }
  12726. /// <summary>
  12727. /// Wraps the source sequence in order to run its subscription and unsubscription logic on the specified scheduler. This operation is not commonly used;
  12728. /// see the remarks section for more information on the distinction between SubscribeOn and ObserveOn.
  12729. /// </summary>
  12730. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  12731. /// <param name="source">Source sequence.</param>
  12732. /// <param name="scheduler">Scheduler to perform subscription and unsubscription actions on.</param>
  12733. /// <returns>The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler.</returns>
  12734. /// <exception cref="ArgumentNullException">
  12735. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  12736. /// <remarks>
  12737. /// This only performs the side-effects of subscription and unsubscription on the specified scheduler. In order to invoke observer
  12738. /// callbacks on a scheduler, use <see cref="Observable.ObserveOn{TSource}(IObservable{TSource},IScheduler)" />.
  12739. /// </remarks>
  12740. public static IQbservable<TSource> SubscribeOn<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  12741. {
  12742. if (source == null)
  12743. throw new ArgumentNullException(nameof(source));
  12744. if (scheduler == null)
  12745. throw new ArgumentNullException(nameof(scheduler));
  12746. return source.Provider.CreateQuery<TSource>(
  12747. Expression.Call(
  12748. null,
  12749. #if CRIPPLED_REFLECTION
  12750. InfoOf(() => Qbservable.SubscribeOn<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  12751. #else
  12752. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  12753. #endif
  12754. source.Expression,
  12755. Expression.Constant(scheduler, typeof(IScheduler))
  12756. )
  12757. );
  12758. }
  12759. /// <summary>
  12760. /// Computes the sum of a sequence of <see cref="Decimal" /> values.
  12761. /// </summary>
  12762. /// <param name="source">A sequence of <see cref="Decimal" /> values to calculate the sum of.</param>
  12763. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12764. /// <exception cref="ArgumentNullException">
  12765. /// <paramref name="source" /> is null.</exception>
  12766. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Decimal.MaxValue" />.</exception>
  12767. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12768. public static IQbservable<decimal> Sum(this IQbservable<decimal> source)
  12769. {
  12770. if (source == null)
  12771. throw new ArgumentNullException(nameof(source));
  12772. return source.Provider.CreateQuery<decimal>(
  12773. Expression.Call(
  12774. null,
  12775. #if CRIPPLED_REFLECTION
  12776. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal>))),
  12777. #else
  12778. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12779. #endif
  12780. source.Expression
  12781. )
  12782. );
  12783. }
  12784. /// <summary>
  12785. /// Computes the sum of a sequence of <see cref="double" /> values.
  12786. /// </summary>
  12787. /// <param name="source">A sequence of <see cref="double" /> values to calculate the sum of.</param>
  12788. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12789. /// <exception cref="ArgumentNullException">
  12790. /// <paramref name="source" /> is null.</exception>
  12791. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12792. public static IQbservable<double> Sum(this IQbservable<double> source)
  12793. {
  12794. if (source == null)
  12795. throw new ArgumentNullException(nameof(source));
  12796. return source.Provider.CreateQuery<double>(
  12797. Expression.Call(
  12798. null,
  12799. #if CRIPPLED_REFLECTION
  12800. InfoOf(() => Qbservable.Sum(default(IQbservable<double>))),
  12801. #else
  12802. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12803. #endif
  12804. source.Expression
  12805. )
  12806. );
  12807. }
  12808. /// <summary>
  12809. /// Computes the sum of a sequence of <see cref="int" /> values.
  12810. /// </summary>
  12811. /// <param name="source">A sequence of <see cref="int" /> values to calculate the sum of.</param>
  12812. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12813. /// <exception cref="ArgumentNullException">
  12814. /// <paramref name="source" /> is null.</exception>
  12815. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Int32.MaxValue" />.</exception>
  12816. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12817. public static IQbservable<int> Sum(this IQbservable<int> source)
  12818. {
  12819. if (source == null)
  12820. throw new ArgumentNullException(nameof(source));
  12821. return source.Provider.CreateQuery<int>(
  12822. Expression.Call(
  12823. null,
  12824. #if CRIPPLED_REFLECTION
  12825. InfoOf(() => Qbservable.Sum(default(IQbservable<int>))),
  12826. #else
  12827. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12828. #endif
  12829. source.Expression
  12830. )
  12831. );
  12832. }
  12833. /// <summary>
  12834. /// Computes the sum of a sequence of <see cref="long" /> values.
  12835. /// </summary>
  12836. /// <param name="source">A sequence of <see cref="long" /> values to calculate the sum of.</param>
  12837. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12838. /// <exception cref="ArgumentNullException">
  12839. /// <paramref name="source" /> is null.</exception>
  12840. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  12841. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12842. public static IQbservable<long> Sum(this IQbservable<long> source)
  12843. {
  12844. if (source == null)
  12845. throw new ArgumentNullException(nameof(source));
  12846. return source.Provider.CreateQuery<long>(
  12847. Expression.Call(
  12848. null,
  12849. #if CRIPPLED_REFLECTION
  12850. InfoOf(() => Qbservable.Sum(default(IQbservable<long>))),
  12851. #else
  12852. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12853. #endif
  12854. source.Expression
  12855. )
  12856. );
  12857. }
  12858. /// <summary>
  12859. /// Computes the sum of a sequence of nullable <see cref="Decimal" /> values.
  12860. /// </summary>
  12861. /// <param name="source">A sequence of nullable <see cref="Decimal" /> values to calculate the sum of.</param>
  12862. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12863. /// <exception cref="ArgumentNullException">
  12864. /// <paramref name="source" /> is null.</exception>
  12865. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Decimal.MaxValue" />.</exception>
  12866. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12867. public static IQbservable<decimal?> Sum(this IQbservable<decimal?> source)
  12868. {
  12869. if (source == null)
  12870. throw new ArgumentNullException(nameof(source));
  12871. return source.Provider.CreateQuery<decimal?>(
  12872. Expression.Call(
  12873. null,
  12874. #if CRIPPLED_REFLECTION
  12875. InfoOf(() => Qbservable.Sum(default(IQbservable<decimal?>))),
  12876. #else
  12877. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12878. #endif
  12879. source.Expression
  12880. )
  12881. );
  12882. }
  12883. /// <summary>
  12884. /// Computes the sum of a sequence of nullable <see cref="double" /> values.
  12885. /// </summary>
  12886. /// <param name="source">A sequence of nullable <see cref="double" /> values to calculate the sum of.</param>
  12887. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12888. /// <exception cref="ArgumentNullException">
  12889. /// <paramref name="source" /> is null.</exception>
  12890. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12891. public static IQbservable<double?> Sum(this IQbservable<double?> source)
  12892. {
  12893. if (source == null)
  12894. throw new ArgumentNullException(nameof(source));
  12895. return source.Provider.CreateQuery<double?>(
  12896. Expression.Call(
  12897. null,
  12898. #if CRIPPLED_REFLECTION
  12899. InfoOf(() => Qbservable.Sum(default(IQbservable<double?>))),
  12900. #else
  12901. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12902. #endif
  12903. source.Expression
  12904. )
  12905. );
  12906. }
  12907. /// <summary>
  12908. /// Computes the sum of a sequence of nullable <see cref="int" /> values.
  12909. /// </summary>
  12910. /// <param name="source">A sequence of nullable <see cref="int" /> values to calculate the sum of.</param>
  12911. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12912. /// <exception cref="ArgumentNullException">
  12913. /// <paramref name="source" /> is null.</exception>
  12914. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Int32.MaxValue" />.</exception>
  12915. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12916. public static IQbservable<int?> Sum(this IQbservable<int?> source)
  12917. {
  12918. if (source == null)
  12919. throw new ArgumentNullException(nameof(source));
  12920. return source.Provider.CreateQuery<int?>(
  12921. Expression.Call(
  12922. null,
  12923. #if CRIPPLED_REFLECTION
  12924. InfoOf(() => Qbservable.Sum(default(IQbservable<int?>))),
  12925. #else
  12926. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12927. #endif
  12928. source.Expression
  12929. )
  12930. );
  12931. }
  12932. /// <summary>
  12933. /// Computes the sum of a sequence of nullable <see cref="long" /> values.
  12934. /// </summary>
  12935. /// <param name="source">A sequence of nullable <see cref="long" /> values to calculate the sum of.</param>
  12936. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12937. /// <exception cref="ArgumentNullException">
  12938. /// <paramref name="source" /> is null.</exception>
  12939. /// <exception cref="OverflowException">(Asynchronous) The sum of the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  12940. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12941. public static IQbservable<long?> Sum(this IQbservable<long?> source)
  12942. {
  12943. if (source == null)
  12944. throw new ArgumentNullException(nameof(source));
  12945. return source.Provider.CreateQuery<long?>(
  12946. Expression.Call(
  12947. null,
  12948. #if CRIPPLED_REFLECTION
  12949. InfoOf(() => Qbservable.Sum(default(IQbservable<long?>))),
  12950. #else
  12951. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12952. #endif
  12953. source.Expression
  12954. )
  12955. );
  12956. }
  12957. /// <summary>
  12958. /// Computes the sum of a sequence of nullable <see cref="Single" /> values.
  12959. /// </summary>
  12960. /// <param name="source">A sequence of nullable <see cref="Single" /> values to calculate the sum of.</param>
  12961. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12962. /// <exception cref="ArgumentNullException">
  12963. /// <paramref name="source" /> is null.</exception>
  12964. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12965. public static IQbservable<float?> Sum(this IQbservable<float?> source)
  12966. {
  12967. if (source == null)
  12968. throw new ArgumentNullException(nameof(source));
  12969. return source.Provider.CreateQuery<float?>(
  12970. Expression.Call(
  12971. null,
  12972. #if CRIPPLED_REFLECTION
  12973. InfoOf(() => Qbservable.Sum(default(IQbservable<float?>))),
  12974. #else
  12975. (MethodInfo)MethodInfo.GetCurrentMethod(),
  12976. #endif
  12977. source.Expression
  12978. )
  12979. );
  12980. }
  12981. /// <summary>
  12982. /// Computes the sum of a sequence of <see cref="Single" /> values.
  12983. /// </summary>
  12984. /// <param name="source">A sequence of <see cref="Single" /> values to calculate the sum of.</param>
  12985. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  12986. /// <exception cref="ArgumentNullException">
  12987. /// <paramref name="source" /> is null.</exception>
  12988. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  12989. public static IQbservable<float> Sum(this IQbservable<float> source)
  12990. {
  12991. if (source == null)
  12992. throw new ArgumentNullException(nameof(source));
  12993. return source.Provider.CreateQuery<float>(
  12994. Expression.Call(
  12995. null,
  12996. #if CRIPPLED_REFLECTION
  12997. InfoOf(() => Qbservable.Sum(default(IQbservable<float>))),
  12998. #else
  12999. (MethodInfo)MethodInfo.GetCurrentMethod(),
  13000. #endif
  13001. source.Expression
  13002. )
  13003. );
  13004. }
  13005. /// <summary>
  13006. /// 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.
  13007. /// </summary>
  13008. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13009. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13010. /// <param name="selector">A transform function to apply to each element.</param>
  13011. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13012. /// <exception cref="ArgumentNullException">
  13013. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13014. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13015. public static IQbservable<double?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double?>> selector)
  13016. {
  13017. if (source == null)
  13018. throw new ArgumentNullException(nameof(source));
  13019. if (selector == null)
  13020. throw new ArgumentNullException(nameof(selector));
  13021. return source.Provider.CreateQuery<double?>(
  13022. Expression.Call(
  13023. null,
  13024. #if CRIPPLED_REFLECTION
  13025. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double?>>))),
  13026. #else
  13027. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13028. #endif
  13029. source.Expression,
  13030. selector
  13031. )
  13032. );
  13033. }
  13034. /// <summary>
  13035. /// 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.
  13036. /// </summary>
  13037. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13038. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13039. /// <param name="selector">A transform function to apply to each element.</param>
  13040. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13041. /// <exception cref="ArgumentNullException">
  13042. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13043. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13044. public static IQbservable<float?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float?>> selector)
  13045. {
  13046. if (source == null)
  13047. throw new ArgumentNullException(nameof(source));
  13048. if (selector == null)
  13049. throw new ArgumentNullException(nameof(selector));
  13050. return source.Provider.CreateQuery<float?>(
  13051. Expression.Call(
  13052. null,
  13053. #if CRIPPLED_REFLECTION
  13054. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float?>>))),
  13055. #else
  13056. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13057. #endif
  13058. source.Expression,
  13059. selector
  13060. )
  13061. );
  13062. }
  13063. /// <summary>
  13064. /// 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.
  13065. /// </summary>
  13066. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13067. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13068. /// <param name="selector">A transform function to apply to each element.</param>
  13069. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13070. /// <exception cref="ArgumentNullException">
  13071. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13072. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Decimal.MaxValue" />.</exception>
  13073. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13074. public static IQbservable<decimal?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal?>> selector)
  13075. {
  13076. if (source == null)
  13077. throw new ArgumentNullException(nameof(source));
  13078. if (selector == null)
  13079. throw new ArgumentNullException(nameof(selector));
  13080. return source.Provider.CreateQuery<decimal?>(
  13081. Expression.Call(
  13082. null,
  13083. #if CRIPPLED_REFLECTION
  13084. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal?>>))),
  13085. #else
  13086. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13087. #endif
  13088. source.Expression,
  13089. selector
  13090. )
  13091. );
  13092. }
  13093. /// <summary>
  13094. /// 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.
  13095. /// </summary>
  13096. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13097. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13098. /// <param name="selector">A transform function to apply to each element.</param>
  13099. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13100. /// <exception cref="ArgumentNullException">
  13101. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13102. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Int32.MaxValue" />.</exception>
  13103. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13104. public static IQbservable<int?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int?>> selector)
  13105. {
  13106. if (source == null)
  13107. throw new ArgumentNullException(nameof(source));
  13108. if (selector == null)
  13109. throw new ArgumentNullException(nameof(selector));
  13110. return source.Provider.CreateQuery<int?>(
  13111. Expression.Call(
  13112. null,
  13113. #if CRIPPLED_REFLECTION
  13114. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int?>>))),
  13115. #else
  13116. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13117. #endif
  13118. source.Expression,
  13119. selector
  13120. )
  13121. );
  13122. }
  13123. /// <summary>
  13124. /// 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.
  13125. /// </summary>
  13126. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13127. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13128. /// <param name="selector">A transform function to apply to each element.</param>
  13129. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13130. /// <exception cref="ArgumentNullException">
  13131. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13132. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  13133. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13134. public static IQbservable<long?> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long?>> selector)
  13135. {
  13136. if (source == null)
  13137. throw new ArgumentNullException(nameof(source));
  13138. if (selector == null)
  13139. throw new ArgumentNullException(nameof(selector));
  13140. return source.Provider.CreateQuery<long?>(
  13141. Expression.Call(
  13142. null,
  13143. #if CRIPPLED_REFLECTION
  13144. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long?>>))),
  13145. #else
  13146. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13147. #endif
  13148. source.Expression,
  13149. selector
  13150. )
  13151. );
  13152. }
  13153. /// <summary>
  13154. /// 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.
  13155. /// </summary>
  13156. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13157. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13158. /// <param name="selector">A transform function to apply to each element.</param>
  13159. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13160. /// <exception cref="ArgumentNullException">
  13161. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13162. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13163. public static IQbservable<double> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, double>> selector)
  13164. {
  13165. if (source == null)
  13166. throw new ArgumentNullException(nameof(source));
  13167. if (selector == null)
  13168. throw new ArgumentNullException(nameof(selector));
  13169. return source.Provider.CreateQuery<double>(
  13170. Expression.Call(
  13171. null,
  13172. #if CRIPPLED_REFLECTION
  13173. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, double>>))),
  13174. #else
  13175. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13176. #endif
  13177. source.Expression,
  13178. selector
  13179. )
  13180. );
  13181. }
  13182. /// <summary>
  13183. /// 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.
  13184. /// </summary>
  13185. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13186. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13187. /// <param name="selector">A transform function to apply to each element.</param>
  13188. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13189. /// <exception cref="ArgumentNullException">
  13190. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13191. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13192. public static IQbservable<float> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, float>> selector)
  13193. {
  13194. if (source == null)
  13195. throw new ArgumentNullException(nameof(source));
  13196. if (selector == null)
  13197. throw new ArgumentNullException(nameof(selector));
  13198. return source.Provider.CreateQuery<float>(
  13199. Expression.Call(
  13200. null,
  13201. #if CRIPPLED_REFLECTION
  13202. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, float>>))),
  13203. #else
  13204. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13205. #endif
  13206. source.Expression,
  13207. selector
  13208. )
  13209. );
  13210. }
  13211. /// <summary>
  13212. /// 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.
  13213. /// </summary>
  13214. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13215. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13216. /// <param name="selector">A transform function to apply to each element.</param>
  13217. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13218. /// <exception cref="ArgumentNullException">
  13219. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13220. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Decimal.MaxValue" />.</exception>
  13221. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13222. public static IQbservable<decimal> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, decimal>> selector)
  13223. {
  13224. if (source == null)
  13225. throw new ArgumentNullException(nameof(source));
  13226. if (selector == null)
  13227. throw new ArgumentNullException(nameof(selector));
  13228. return source.Provider.CreateQuery<decimal>(
  13229. Expression.Call(
  13230. null,
  13231. #if CRIPPLED_REFLECTION
  13232. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, decimal>>))),
  13233. #else
  13234. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13235. #endif
  13236. source.Expression,
  13237. selector
  13238. )
  13239. );
  13240. }
  13241. /// <summary>
  13242. /// 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.
  13243. /// </summary>
  13244. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13245. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13246. /// <param name="selector">A transform function to apply to each element.</param>
  13247. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13248. /// <exception cref="ArgumentNullException">
  13249. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13250. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Int32.MaxValue" />.</exception>
  13251. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13252. public static IQbservable<int> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int>> selector)
  13253. {
  13254. if (source == null)
  13255. throw new ArgumentNullException(nameof(source));
  13256. if (selector == null)
  13257. throw new ArgumentNullException(nameof(selector));
  13258. return source.Provider.CreateQuery<int>(
  13259. Expression.Call(
  13260. null,
  13261. #if CRIPPLED_REFLECTION
  13262. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int>>))),
  13263. #else
  13264. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13265. #endif
  13266. source.Expression,
  13267. selector
  13268. )
  13269. );
  13270. }
  13271. /// <summary>
  13272. /// 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.
  13273. /// </summary>
  13274. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13275. /// <param name="source">A sequence of values that are used to calculate a sum.</param>
  13276. /// <param name="selector">A transform function to apply to each element.</param>
  13277. /// <returns>An observable sequence containing a single element with the sum of the values in the source sequence.</returns>
  13278. /// <exception cref="ArgumentNullException">
  13279. /// <paramref name="source" /> or <paramref name="selector" /> is null.</exception>
  13280. /// <exception cref="OverflowException">(Asynchronous) The sum of the projected values for the elements in the source sequence is larger than <see cref="Int64.MaxValue" />.</exception>
  13281. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  13282. public static IQbservable<long> Sum<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, long>> selector)
  13283. {
  13284. if (source == null)
  13285. throw new ArgumentNullException(nameof(source));
  13286. if (selector == null)
  13287. throw new ArgumentNullException(nameof(selector));
  13288. return source.Provider.CreateQuery<long>(
  13289. Expression.Call(
  13290. null,
  13291. #if CRIPPLED_REFLECTION
  13292. InfoOf(() => Qbservable.Sum<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, long>>))),
  13293. #else
  13294. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13295. #endif
  13296. source.Expression,
  13297. selector
  13298. )
  13299. );
  13300. }
  13301. /// <summary>
  13302. /// Transforms an observable sequence of observable sequences into an observable sequence
  13303. /// producing values only from the most recent observable sequence.
  13304. /// Each time a new inner observable sequence is received, unsubscribe from the
  13305. /// previous inner observable sequence.
  13306. /// </summary>
  13307. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  13308. /// <param name="sources">Observable sequence of inner observable sequences.</param>
  13309. /// <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>
  13310. /// <exception cref="ArgumentNullException">
  13311. /// <paramref name="sources" /> is null.</exception>
  13312. public static IQbservable<TSource> Switch<TSource>(this IQbservable<IObservable<TSource>> sources)
  13313. {
  13314. if (sources == null)
  13315. throw new ArgumentNullException(nameof(sources));
  13316. return sources.Provider.CreateQuery<TSource>(
  13317. Expression.Call(
  13318. null,
  13319. #if CRIPPLED_REFLECTION
  13320. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<IObservable<TSource>>))),
  13321. #else
  13322. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13323. #endif
  13324. sources.Expression
  13325. )
  13326. );
  13327. }
  13328. /// <summary>
  13329. /// Transforms an observable sequence of tasks into an observable sequence
  13330. /// producing values only from the most recent observable sequence.
  13331. /// Each time a new task is received, the previous task's result is ignored.
  13332. /// </summary>
  13333. /// <typeparam name="TSource">The type of the results produced by the source tasks.</typeparam>
  13334. /// <param name="sources">Observable sequence of tasks.</param>
  13335. /// <returns>The observable sequence that at any point in time produces the result of the most recent task that has been received.</returns>
  13336. /// <exception cref="ArgumentNullException">
  13337. /// <paramref name="sources" /> is null.</exception>
  13338. /// <remarks>If the tasks support cancellation, consider manual conversion of the tasks using <see cref="Observable.FromAsync{TSource}(Func{CancellationToken,Task{TSource}})" />, followed by a switch operation using <see cref="Observable.Switch{TSource}(IObservable{IObservable{TSource}})" />.</remarks>
  13339. public static IQbservable<TSource> Switch<TSource>(this IQbservable<Task<TSource>> sources)
  13340. {
  13341. if (sources == null)
  13342. throw new ArgumentNullException(nameof(sources));
  13343. return sources.Provider.CreateQuery<TSource>(
  13344. Expression.Call(
  13345. null,
  13346. #if CRIPPLED_REFLECTION
  13347. InfoOf(() => Qbservable.Switch<TSource>(default(IQbservable<Task<TSource>>))),
  13348. #else
  13349. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13350. #endif
  13351. sources.Expression
  13352. )
  13353. );
  13354. }
  13355. /// <summary>
  13356. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently.
  13357. /// This overload is useful to "fix" an observable sequence that exhibits concurrent callbacks on individual observers, which is invalid behavior for the query processor.
  13358. /// </summary>
  13359. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13360. /// <param name="source">Source sequence.</param>
  13361. /// <returns>The source sequence whose outgoing calls to observers are synchronized.</returns>
  13362. /// <exception cref="ArgumentNullException">
  13363. /// <paramref name="source" /> is null.</exception>
  13364. /// <remarks>
  13365. /// It's invalid behavior - according to the observer grammar - for a sequence to exhibit concurrent callbacks on a given observer.
  13366. /// This operator can be used to "fix" a source that doesn't conform to this rule.
  13367. /// </remarks>
  13368. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source)
  13369. {
  13370. if (source == null)
  13371. throw new ArgumentNullException(nameof(source));
  13372. return source.Provider.CreateQuery<TSource>(
  13373. Expression.Call(
  13374. null,
  13375. #if CRIPPLED_REFLECTION
  13376. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>))),
  13377. #else
  13378. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13379. #endif
  13380. source.Expression
  13381. )
  13382. );
  13383. }
  13384. /// <summary>
  13385. /// Synchronizes the observable sequence such that observer notifications cannot be delivered concurrently, using the specified gate object.
  13386. /// 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.
  13387. /// </summary>
  13388. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13389. /// <param name="source">Source sequence.</param>
  13390. /// <param name="gate">Gate object to synchronize each observer call on.</param>
  13391. /// <returns>The source sequence whose outgoing calls to observers are synchronized on the given gate object.</returns>
  13392. /// <exception cref="ArgumentNullException">
  13393. /// <paramref name="source" /> or <paramref name="gate" /> is null.</exception>
  13394. public static IQbservable<TSource> Synchronize<TSource>(this IQbservable<TSource> source, object gate)
  13395. {
  13396. if (source == null)
  13397. throw new ArgumentNullException(nameof(source));
  13398. if (gate == null)
  13399. throw new ArgumentNullException(nameof(gate));
  13400. return source.Provider.CreateQuery<TSource>(
  13401. Expression.Call(
  13402. null,
  13403. #if CRIPPLED_REFLECTION
  13404. InfoOf(() => Qbservable.Synchronize<TSource>(default(IQbservable<TSource>), default(object))),
  13405. #else
  13406. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13407. #endif
  13408. source.Expression,
  13409. Expression.Constant(gate, typeof(object))
  13410. )
  13411. );
  13412. }
  13413. /// <summary>
  13414. /// Returns a specified number of contiguous elements from the start of an observable sequence.
  13415. /// </summary>
  13416. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13417. /// <param name="source">The sequence to take elements from.</param>
  13418. /// <param name="count">The number of elements to return.</param>
  13419. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13420. /// <exception cref="ArgumentNullException">
  13421. /// <paramref name="source" /> is null.</exception>
  13422. /// <exception cref="ArgumentOutOfRangeException">
  13423. /// <paramref name="count" /> is less than zero.</exception>
  13424. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count)
  13425. {
  13426. if (source == null)
  13427. throw new ArgumentNullException(nameof(source));
  13428. return source.Provider.CreateQuery<TSource>(
  13429. Expression.Call(
  13430. null,
  13431. #if CRIPPLED_REFLECTION
  13432. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int))),
  13433. #else
  13434. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13435. #endif
  13436. source.Expression,
  13437. Expression.Constant(count, typeof(int))
  13438. )
  13439. );
  13440. }
  13441. /// <summary>
  13442. /// 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).
  13443. /// </summary>
  13444. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13445. /// <param name="source">The sequence to take elements from.</param>
  13446. /// <param name="count">The number of elements to return.</param>
  13447. /// <param name="scheduler">Scheduler used to produce an OnCompleted message in case <paramref name="count">count</paramref> is set to 0.</param>
  13448. /// <returns>An observable sequence that contains the specified number of elements from the start of the input sequence.</returns>
  13449. /// <exception cref="ArgumentNullException">
  13450. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13451. /// <exception cref="ArgumentOutOfRangeException">
  13452. /// <paramref name="count" /> is less than zero.</exception>
  13453. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13454. {
  13455. if (source == null)
  13456. throw new ArgumentNullException(nameof(source));
  13457. if (scheduler == null)
  13458. throw new ArgumentNullException(nameof(scheduler));
  13459. return source.Provider.CreateQuery<TSource>(
  13460. Expression.Call(
  13461. null,
  13462. #if CRIPPLED_REFLECTION
  13463. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13464. #else
  13465. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13466. #endif
  13467. source.Expression,
  13468. Expression.Constant(count, typeof(int)),
  13469. Expression.Constant(scheduler, typeof(IScheduler))
  13470. )
  13471. );
  13472. }
  13473. /// <summary>
  13474. /// Takes elements for the specified duration from the start of the observable source sequence.
  13475. /// </summary>
  13476. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13477. /// <param name="source">Source sequence to take elements from.</param>
  13478. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13479. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13480. /// <exception cref="ArgumentNullException">
  13481. /// <paramref name="source" /> is null.</exception>
  13482. /// <exception cref="ArgumentOutOfRangeException">
  13483. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13484. /// <remarks>
  13485. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13486. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13487. /// immediately, despite the TimeSpan.Zero due time.
  13488. /// </remarks>
  13489. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13490. {
  13491. if (source == null)
  13492. throw new ArgumentNullException(nameof(source));
  13493. return source.Provider.CreateQuery<TSource>(
  13494. Expression.Call(
  13495. null,
  13496. #if CRIPPLED_REFLECTION
  13497. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13498. #else
  13499. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13500. #endif
  13501. source.Expression,
  13502. Expression.Constant(duration, typeof(TimeSpan))
  13503. )
  13504. );
  13505. }
  13506. /// <summary>
  13507. /// Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers.
  13508. /// </summary>
  13509. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13510. /// <param name="source">Source sequence to take elements from.</param>
  13511. /// <param name="duration">Duration for taking elements from the start of the sequence.</param>
  13512. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13513. /// <returns>An observable sequence with the elements taken during the specified duration from the start of the source sequence.</returns>
  13514. /// <exception cref="ArgumentNullException">
  13515. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13516. /// <exception cref="ArgumentOutOfRangeException">
  13517. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13518. /// <remarks>
  13519. /// Specifying a TimeSpan.Zero value for <paramref name="duration" /> doesn't guarantee an empty sequence will be returned. This is a side-effect
  13520. /// of the asynchrony introduced by the scheduler, where the action that stops forwarding callbacks from the source sequence may not execute
  13521. /// immediately, despite the TimeSpan.Zero due time.
  13522. /// </remarks>
  13523. public static IQbservable<TSource> Take<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13524. {
  13525. if (source == null)
  13526. throw new ArgumentNullException(nameof(source));
  13527. if (scheduler == null)
  13528. throw new ArgumentNullException(nameof(scheduler));
  13529. return source.Provider.CreateQuery<TSource>(
  13530. Expression.Call(
  13531. null,
  13532. #if CRIPPLED_REFLECTION
  13533. InfoOf(() => Qbservable.Take<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13534. #else
  13535. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13536. #endif
  13537. source.Expression,
  13538. Expression.Constant(duration, typeof(TimeSpan)),
  13539. Expression.Constant(scheduler, typeof(IScheduler))
  13540. )
  13541. );
  13542. }
  13543. /// <summary>
  13544. /// Returns a specified number of contiguous elements from the end of an observable sequence.
  13545. /// </summary>
  13546. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13547. /// <param name="source">Source sequence.</param>
  13548. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13549. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13550. /// <exception cref="ArgumentNullException">
  13551. /// <paramref name="source" /> is null.</exception>
  13552. /// <exception cref="ArgumentOutOfRangeException">
  13553. /// <paramref name="count" /> is less than zero.</exception>
  13554. /// <remarks>
  13555. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13556. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13557. /// </remarks>
  13558. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count)
  13559. {
  13560. if (source == null)
  13561. throw new ArgumentNullException(nameof(source));
  13562. return source.Provider.CreateQuery<TSource>(
  13563. Expression.Call(
  13564. null,
  13565. #if CRIPPLED_REFLECTION
  13566. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int))),
  13567. #else
  13568. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13569. #endif
  13570. source.Expression,
  13571. Expression.Constant(count, typeof(int))
  13572. )
  13573. );
  13574. }
  13575. /// <summary>
  13576. /// Returns a specified number of contiguous elements from the end of an observable sequence, using the specified scheduler to drain the queue.
  13577. /// </summary>
  13578. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13579. /// <param name="source">Source sequence.</param>
  13580. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13581. /// <param name="scheduler">Scheduler used to drain the queue upon completion of the source sequence.</param>
  13582. /// <returns>An observable sequence containing the specified number of elements from the end of the source sequence.</returns>
  13583. /// <exception cref="ArgumentNullException">
  13584. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13585. /// <exception cref="ArgumentOutOfRangeException">
  13586. /// <paramref name="count" /> is less than zero.</exception>
  13587. /// <remarks>
  13588. /// This operator accumulates a buffer with a length enough to store elements <paramref name="count" /> elements. Upon completion of
  13589. /// the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.
  13590. /// </remarks>
  13591. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, int count, IScheduler scheduler)
  13592. {
  13593. if (source == null)
  13594. throw new ArgumentNullException(nameof(source));
  13595. if (scheduler == null)
  13596. throw new ArgumentNullException(nameof(scheduler));
  13597. return source.Provider.CreateQuery<TSource>(
  13598. Expression.Call(
  13599. null,
  13600. #if CRIPPLED_REFLECTION
  13601. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(int), default(IScheduler))),
  13602. #else
  13603. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13604. #endif
  13605. source.Expression,
  13606. Expression.Constant(count, typeof(int)),
  13607. Expression.Constant(scheduler, typeof(IScheduler))
  13608. )
  13609. );
  13610. }
  13611. /// <summary>
  13612. /// Returns elements within the specified duration from the end of the observable source sequence.
  13613. /// </summary>
  13614. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13615. /// <param name="source">Source sequence to take elements from.</param>
  13616. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13617. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13618. /// <exception cref="ArgumentNullException">
  13619. /// <paramref name="source" /> is null.</exception>
  13620. /// <exception cref="ArgumentOutOfRangeException">
  13621. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13622. /// <remarks>
  13623. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13624. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13625. /// to be delayed with <paramref name="duration" />.
  13626. /// </remarks>
  13627. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13628. {
  13629. if (source == null)
  13630. throw new ArgumentNullException(nameof(source));
  13631. return source.Provider.CreateQuery<TSource>(
  13632. Expression.Call(
  13633. null,
  13634. #if CRIPPLED_REFLECTION
  13635. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13636. #else
  13637. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13638. #endif
  13639. source.Expression,
  13640. Expression.Constant(duration, typeof(TimeSpan))
  13641. )
  13642. );
  13643. }
  13644. /// <summary>
  13645. /// Returns elements within the specified duration from the end of the observable source sequence, using the specified scheduler to run timers.
  13646. /// </summary>
  13647. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13648. /// <param name="source">Source sequence to take elements from.</param>
  13649. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13650. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13651. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13652. /// <exception cref="ArgumentNullException">
  13653. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13654. /// <exception cref="ArgumentOutOfRangeException">
  13655. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13656. /// <remarks>
  13657. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13658. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13659. /// to be delayed with <paramref name="duration" />.
  13660. /// </remarks>
  13661. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13662. {
  13663. if (source == null)
  13664. throw new ArgumentNullException(nameof(source));
  13665. if (scheduler == null)
  13666. throw new ArgumentNullException(nameof(scheduler));
  13667. return source.Provider.CreateQuery<TSource>(
  13668. Expression.Call(
  13669. null,
  13670. #if CRIPPLED_REFLECTION
  13671. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13672. #else
  13673. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13674. #endif
  13675. source.Expression,
  13676. Expression.Constant(duration, typeof(TimeSpan)),
  13677. Expression.Constant(scheduler, typeof(IScheduler))
  13678. )
  13679. );
  13680. }
  13681. /// <summary>
  13682. /// 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.
  13683. /// </summary>
  13684. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13685. /// <param name="source">Source sequence to take elements from.</param>
  13686. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13687. /// <param name="timerScheduler">Scheduler to run the timer on.</param>
  13688. /// <param name="loopScheduler">Scheduler to drain the collected elements.</param>
  13689. /// <returns>An observable sequence with the elements taken during the specified duration from the end of the source sequence.</returns>
  13690. /// <exception cref="ArgumentNullException">
  13691. /// <paramref name="source" /> or <paramref name="timerScheduler" /> or <paramref name="loopScheduler" /> is null.</exception>
  13692. /// <exception cref="ArgumentOutOfRangeException">
  13693. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13694. /// <remarks>
  13695. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13696. /// the source sequence. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the result elements
  13697. /// to be delayed with <paramref name="duration" />.
  13698. /// </remarks>
  13699. public static IQbservable<TSource> TakeLast<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler timerScheduler, IScheduler loopScheduler)
  13700. {
  13701. if (source == null)
  13702. throw new ArgumentNullException(nameof(source));
  13703. if (timerScheduler == null)
  13704. throw new ArgumentNullException(nameof(timerScheduler));
  13705. if (loopScheduler == null)
  13706. throw new ArgumentNullException(nameof(loopScheduler));
  13707. return source.Provider.CreateQuery<TSource>(
  13708. Expression.Call(
  13709. null,
  13710. #if CRIPPLED_REFLECTION
  13711. InfoOf(() => Qbservable.TakeLast<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler), default(IScheduler))),
  13712. #else
  13713. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13714. #endif
  13715. source.Expression,
  13716. Expression.Constant(duration, typeof(TimeSpan)),
  13717. Expression.Constant(timerScheduler, typeof(IScheduler)),
  13718. Expression.Constant(loopScheduler, typeof(IScheduler))
  13719. )
  13720. );
  13721. }
  13722. /// <summary>
  13723. /// Returns a list with the specified number of contiguous elements from the end of an observable sequence.
  13724. /// </summary>
  13725. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13726. /// <param name="source">Source sequence.</param>
  13727. /// <param name="count">Number of elements to take from the end of the source sequence.</param>
  13728. /// <returns>An observable sequence containing a single list with the specified number of elements from the end of the source sequence.</returns>
  13729. /// <exception cref="ArgumentNullException">
  13730. /// <paramref name="source" /> is null.</exception>
  13731. /// <exception cref="ArgumentOutOfRangeException">
  13732. /// <paramref name="count" /> is less than zero.</exception>
  13733. /// <remarks>
  13734. /// This operator accumulates a buffer with a length enough to store <paramref name="count" /> elements. Upon completion of the
  13735. /// source sequence, this buffer is produced on the result sequence.
  13736. /// </remarks>
  13737. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, int count)
  13738. {
  13739. if (source == null)
  13740. throw new ArgumentNullException(nameof(source));
  13741. return source.Provider.CreateQuery<IList<TSource>>(
  13742. Expression.Call(
  13743. null,
  13744. #if CRIPPLED_REFLECTION
  13745. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(int))),
  13746. #else
  13747. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13748. #endif
  13749. source.Expression,
  13750. Expression.Constant(count, typeof(int))
  13751. )
  13752. );
  13753. }
  13754. /// <summary>
  13755. /// Returns a list with the elements within the specified duration from the end of the observable source sequence.
  13756. /// </summary>
  13757. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13758. /// <param name="source">Source sequence to take elements from.</param>
  13759. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13760. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  13761. /// <exception cref="ArgumentNullException">
  13762. /// <paramref name="source" /> is null.</exception>
  13763. /// <exception cref="ArgumentOutOfRangeException">
  13764. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13765. /// <remarks>
  13766. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13767. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  13768. /// </remarks>
  13769. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration)
  13770. {
  13771. if (source == null)
  13772. throw new ArgumentNullException(nameof(source));
  13773. return source.Provider.CreateQuery<IList<TSource>>(
  13774. Expression.Call(
  13775. null,
  13776. #if CRIPPLED_REFLECTION
  13777. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13778. #else
  13779. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13780. #endif
  13781. source.Expression,
  13782. Expression.Constant(duration, typeof(TimeSpan))
  13783. )
  13784. );
  13785. }
  13786. /// <summary>
  13787. /// 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.
  13788. /// </summary>
  13789. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13790. /// <param name="source">Source sequence to take elements from.</param>
  13791. /// <param name="duration">Duration for taking elements from the end of the sequence.</param>
  13792. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13793. /// <returns>An observable sequence containing a single list with the elements taken during the specified duration from the end of the source sequence.</returns>
  13794. /// <exception cref="ArgumentNullException">
  13795. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13796. /// <exception cref="ArgumentOutOfRangeException">
  13797. /// <paramref name="duration" /> is less than TimeSpan.Zero.</exception>
  13798. /// <remarks>
  13799. /// This operator accumulates a buffer with a length enough to store elements for any <paramref name="duration" /> window during the lifetime of
  13800. /// the source sequence. Upon completion of the source sequence, this buffer is produced on the result sequence.
  13801. /// </remarks>
  13802. public static IQbservable<IList<TSource>> TakeLastBuffer<TSource>(this IQbservable<TSource> source, TimeSpan duration, IScheduler scheduler)
  13803. {
  13804. if (source == null)
  13805. throw new ArgumentNullException(nameof(source));
  13806. if (scheduler == null)
  13807. throw new ArgumentNullException(nameof(scheduler));
  13808. return source.Provider.CreateQuery<IList<TSource>>(
  13809. Expression.Call(
  13810. null,
  13811. #if CRIPPLED_REFLECTION
  13812. InfoOf(() => Qbservable.TakeLastBuffer<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  13813. #else
  13814. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13815. #endif
  13816. source.Expression,
  13817. Expression.Constant(duration, typeof(TimeSpan)),
  13818. Expression.Constant(scheduler, typeof(IScheduler))
  13819. )
  13820. );
  13821. }
  13822. /// <summary>
  13823. /// Takes elements for the specified duration until the specified end time.
  13824. /// </summary>
  13825. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13826. /// <param name="source">Source sequence to take elements from.</param>
  13827. /// <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>
  13828. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  13829. /// <exception cref="ArgumentNullException">
  13830. /// <paramref name="source" /> is null.</exception>
  13831. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime)
  13832. {
  13833. if (source == null)
  13834. throw new ArgumentNullException(nameof(source));
  13835. return source.Provider.CreateQuery<TSource>(
  13836. Expression.Call(
  13837. null,
  13838. #if CRIPPLED_REFLECTION
  13839. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  13840. #else
  13841. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13842. #endif
  13843. source.Expression,
  13844. Expression.Constant(endTime, typeof(DateTimeOffset))
  13845. )
  13846. );
  13847. }
  13848. /// <summary>
  13849. /// Takes elements for the specified duration until the specified end time, using the specified scheduler to run timers.
  13850. /// </summary>
  13851. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13852. /// <param name="source">Source sequence to take elements from.</param>
  13853. /// <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>
  13854. /// <param name="scheduler">Scheduler to run the timer on.</param>
  13855. /// <returns>An observable sequence with the elements taken until the specified end time.</returns>
  13856. /// <exception cref="ArgumentNullException">
  13857. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  13858. public static IQbservable<TSource> TakeUntil<TSource>(this IQbservable<TSource> source, DateTimeOffset endTime, IScheduler scheduler)
  13859. {
  13860. if (source == null)
  13861. throw new ArgumentNullException(nameof(source));
  13862. if (scheduler == null)
  13863. throw new ArgumentNullException(nameof(scheduler));
  13864. return source.Provider.CreateQuery<TSource>(
  13865. Expression.Call(
  13866. null,
  13867. #if CRIPPLED_REFLECTION
  13868. InfoOf(() => Qbservable.TakeUntil<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  13869. #else
  13870. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13871. #endif
  13872. source.Expression,
  13873. Expression.Constant(endTime, typeof(DateTimeOffset)),
  13874. Expression.Constant(scheduler, typeof(IScheduler))
  13875. )
  13876. );
  13877. }
  13878. /// <summary>
  13879. /// Returns the elements from the source observable sequence until the other observable sequence produces an element.
  13880. /// </summary>
  13881. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13882. /// <typeparam name="TOther">The type of the elements in the other sequence that indicates the end of take behavior.</typeparam>
  13883. /// <param name="source">Source sequence to propagate elements for.</param>
  13884. /// <param name="other">Observable sequence that terminates propagation of elements of the source sequence.</param>
  13885. /// <returns>An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation.</returns>
  13886. /// <exception cref="ArgumentNullException">
  13887. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  13888. public static IQbservable<TSource> TakeUntil<TSource, TOther>(this IQbservable<TSource> source, IObservable<TOther> other)
  13889. {
  13890. if (source == null)
  13891. throw new ArgumentNullException(nameof(source));
  13892. if (other == null)
  13893. throw new ArgumentNullException(nameof(other));
  13894. return source.Provider.CreateQuery<TSource>(
  13895. Expression.Call(
  13896. null,
  13897. #if CRIPPLED_REFLECTION
  13898. InfoOf(() => Qbservable.TakeUntil<TSource, TOther>(default(IQbservable<TSource>), default(IObservable<TOther>))),
  13899. #else
  13900. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TOther)),
  13901. #endif
  13902. source.Expression,
  13903. GetSourceExpression(other)
  13904. )
  13905. );
  13906. }
  13907. /// <summary>
  13908. /// Returns elements from an observable sequence as long as a specified condition is true.
  13909. /// </summary>
  13910. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13911. /// <param name="source">A sequence to return elements from.</param>
  13912. /// <param name="predicate">A function to test each element for a condition.</param>
  13913. /// <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>
  13914. /// <exception cref="ArgumentNullException">
  13915. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  13916. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  13917. {
  13918. if (source == null)
  13919. throw new ArgumentNullException(nameof(source));
  13920. if (predicate == null)
  13921. throw new ArgumentNullException(nameof(predicate));
  13922. return source.Provider.CreateQuery<TSource>(
  13923. Expression.Call(
  13924. null,
  13925. #if CRIPPLED_REFLECTION
  13926. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  13927. #else
  13928. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13929. #endif
  13930. source.Expression,
  13931. predicate
  13932. )
  13933. );
  13934. }
  13935. /// <summary>
  13936. /// Returns elements from an observable sequence as long as a specified condition is true.
  13937. /// The element's index is used in the logic of the predicate function.
  13938. /// </summary>
  13939. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13940. /// <param name="source">A sequence to return elements from.</param>
  13941. /// <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>
  13942. /// <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>
  13943. /// <exception cref="ArgumentNullException">
  13944. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  13945. public static IQbservable<TSource> TakeWhile<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  13946. {
  13947. if (source == null)
  13948. throw new ArgumentNullException(nameof(source));
  13949. if (predicate == null)
  13950. throw new ArgumentNullException(nameof(predicate));
  13951. return source.Provider.CreateQuery<TSource>(
  13952. Expression.Call(
  13953. null,
  13954. #if CRIPPLED_REFLECTION
  13955. InfoOf(() => Qbservable.TakeWhile<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  13956. #else
  13957. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  13958. #endif
  13959. source.Expression,
  13960. predicate
  13961. )
  13962. );
  13963. }
  13964. /// <summary>
  13965. /// Ignores elements from an observable sequence which are followed by another element within a specified relative time duration.
  13966. /// </summary>
  13967. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  13968. /// <param name="source">Source sequence to throttle.</param>
  13969. /// <param name="dueTime">Throttling duration for each element.</param>
  13970. /// <returns>The throttled sequence.</returns>
  13971. /// <exception cref="ArgumentNullException">
  13972. /// <paramref name="source" /> is null.</exception>
  13973. /// <exception cref="ArgumentOutOfRangeException">
  13974. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  13975. /// <remarks>
  13976. /// <para>
  13977. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  13978. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  13979. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  13980. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  13981. /// Observable.Sample set of operators.
  13982. /// </para>
  13983. /// <para>
  13984. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  13985. /// 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
  13986. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  13987. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  13988. /// </para>
  13989. /// </remarks>
  13990. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  13991. {
  13992. if (source == null)
  13993. throw new ArgumentNullException(nameof(source));
  13994. return source.Provider.CreateQuery<TSource>(
  13995. Expression.Call(
  13996. null,
  13997. #if CRIPPLED_REFLECTION
  13998. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  13999. #else
  14000. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14001. #endif
  14002. source.Expression,
  14003. Expression.Constant(dueTime, typeof(TimeSpan))
  14004. )
  14005. );
  14006. }
  14007. /// <summary>
  14008. /// 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.
  14009. /// </summary>
  14010. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14011. /// <param name="source">Source sequence to throttle.</param>
  14012. /// <param name="dueTime">Throttling duration for each element.</param>
  14013. /// <param name="scheduler">Scheduler to run the throttle timers on.</param>
  14014. /// <returns>The throttled sequence.</returns>
  14015. /// <exception cref="ArgumentNullException">
  14016. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14017. /// <exception cref="ArgumentOutOfRangeException">
  14018. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14019. /// <remarks>
  14020. /// <para>
  14021. /// This operator throttles the source sequence by holding on to each element for the duration specified in <paramref name="dueTime" />. If another
  14022. /// element is produced within this time window, the element is dropped and a new timer is started for the current element, repeating this whole
  14023. /// process. For streams that never have gaps larger than or equal to <paramref name="dueTime" /> between elements, the resulting stream won't
  14024. /// produce any elements. In order to reduce the volume of a stream whilst guaranteeing the periodic production of elements, consider using the
  14025. /// Observable.Sample set of operators.
  14026. /// </para>
  14027. /// <para>
  14028. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing throttling timers to be scheduled
  14029. /// 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
  14030. /// asynchrony introduced by the scheduler, where the action to forward the current element may not execute immediately, despite the TimeSpan.Zero
  14031. /// due time. In such cases, the next element may arrive before the scheduler gets a chance to run the throttling action.
  14032. /// </para>
  14033. /// </remarks>
  14034. public static IQbservable<TSource> Throttle<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14035. {
  14036. if (source == null)
  14037. throw new ArgumentNullException(nameof(source));
  14038. if (scheduler == null)
  14039. throw new ArgumentNullException(nameof(scheduler));
  14040. return source.Provider.CreateQuery<TSource>(
  14041. Expression.Call(
  14042. null,
  14043. #if CRIPPLED_REFLECTION
  14044. InfoOf(() => Qbservable.Throttle<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14045. #else
  14046. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14047. #endif
  14048. source.Expression,
  14049. Expression.Constant(dueTime, typeof(TimeSpan)),
  14050. Expression.Constant(scheduler, typeof(IScheduler))
  14051. )
  14052. );
  14053. }
  14054. /// <summary>
  14055. /// Ignores elements from an observable sequence which are followed by another value within a computed throttle duration.
  14056. /// </summary>
  14057. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14058. /// <typeparam name="TThrottle">The type of the elements in the throttle sequences selected for each element in the source sequence.</typeparam>
  14059. /// <param name="source">Source sequence to throttle.</param>
  14060. /// <param name="throttleDurationSelector">Selector function to retrieve a sequence indicating the throttle duration for each given element.</param>
  14061. /// <returns>The throttled sequence.</returns>
  14062. /// <exception cref="ArgumentNullException">
  14063. /// <paramref name="source" /> or <paramref name="throttleDurationSelector" /> is null.</exception>
  14064. /// <remarks>
  14065. /// This operator throttles the source sequence by holding on to each element for the duration denoted by <paramref name="throttleDurationSelector" />.
  14066. /// 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
  14067. /// whole process. For streams where the duration computed by applying the <paramref name="throttleDurationSelector" /> to each element overlaps with
  14068. /// the occurrence of the successor element, the resulting stream won't produce any elements. In order to reduce the volume of a stream whilst
  14069. /// guaranteeing the periodic production of elements, consider using the Observable.Sample set of operators.
  14070. /// </remarks>
  14071. public static IQbservable<TSource> Throttle<TSource, TThrottle>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TThrottle>>> throttleDurationSelector)
  14072. {
  14073. if (source == null)
  14074. throw new ArgumentNullException(nameof(source));
  14075. if (throttleDurationSelector == null)
  14076. throw new ArgumentNullException(nameof(throttleDurationSelector));
  14077. return source.Provider.CreateQuery<TSource>(
  14078. Expression.Call(
  14079. null,
  14080. #if CRIPPLED_REFLECTION
  14081. InfoOf(() => Qbservable.Throttle<TSource, TThrottle>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TThrottle>>>))),
  14082. #else
  14083. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TThrottle)),
  14084. #endif
  14085. source.Expression,
  14086. throttleDurationSelector
  14087. )
  14088. );
  14089. }
  14090. /// <summary>
  14091. /// Returns an observable sequence that terminates with an exception.
  14092. /// </summary>
  14093. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14094. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}"/> type parameter of the resulting sequence.</typeparam>
  14095. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14096. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14097. /// <exception cref="ArgumentNullException">
  14098. /// <paramref name="exception" /> is null.</exception>
  14099. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception)
  14100. {
  14101. if (provider == null)
  14102. throw new ArgumentNullException(nameof(provider));
  14103. if (exception == null)
  14104. throw new ArgumentNullException(nameof(exception));
  14105. return provider.CreateQuery<TResult>(
  14106. Expression.Call(
  14107. null,
  14108. #if CRIPPLED_REFLECTION
  14109. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception))),
  14110. #else
  14111. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14112. #endif
  14113. Expression.Constant(provider, typeof(IQbservableProvider)),
  14114. Expression.Constant(exception, typeof(Exception))
  14115. )
  14116. );
  14117. }
  14118. /// <summary>
  14119. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14120. /// </summary>
  14121. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14122. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}"/> type parameter of the resulting sequence.</typeparam>
  14123. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14124. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14125. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14126. /// <exception cref="ArgumentNullException">
  14127. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14128. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler)
  14129. {
  14130. if (provider == null)
  14131. throw new ArgumentNullException(nameof(provider));
  14132. if (exception == null)
  14133. throw new ArgumentNullException(nameof(exception));
  14134. if (scheduler == null)
  14135. throw new ArgumentNullException(nameof(scheduler));
  14136. return provider.CreateQuery<TResult>(
  14137. Expression.Call(
  14138. null,
  14139. #if CRIPPLED_REFLECTION
  14140. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler))),
  14141. #else
  14142. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14143. #endif
  14144. Expression.Constant(provider, typeof(IQbservableProvider)),
  14145. Expression.Constant(exception, typeof(Exception)),
  14146. Expression.Constant(scheduler, typeof(IScheduler))
  14147. )
  14148. );
  14149. }
  14150. /// <summary>
  14151. /// Returns an observable sequence that terminates with an exception, using the specified scheduler to send out the single OnError message.
  14152. /// </summary>
  14153. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14154. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}"/> type parameter of the resulting sequence.</typeparam>
  14155. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14156. /// <param name="scheduler">Scheduler to send the exceptional termination call on.</param>
  14157. /// <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>
  14158. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14159. /// <exception cref="ArgumentNullException">
  14160. /// <paramref name="exception" /> or <paramref name="scheduler" /> is null.</exception>
  14161. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, IScheduler scheduler, TResult witness)
  14162. {
  14163. if (provider == null)
  14164. throw new ArgumentNullException(nameof(provider));
  14165. if (exception == null)
  14166. throw new ArgumentNullException(nameof(exception));
  14167. if (scheduler == null)
  14168. throw new ArgumentNullException(nameof(scheduler));
  14169. return provider.CreateQuery<TResult>(
  14170. Expression.Call(
  14171. null,
  14172. #if CRIPPLED_REFLECTION
  14173. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(IScheduler), default(TResult))),
  14174. #else
  14175. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14176. #endif
  14177. Expression.Constant(provider, typeof(IQbservableProvider)),
  14178. Expression.Constant(exception, typeof(Exception)),
  14179. Expression.Constant(scheduler, typeof(IScheduler)),
  14180. Expression.Constant(witness, typeof(TResult))
  14181. )
  14182. );
  14183. }
  14184. /// <summary>
  14185. /// Returns an observable sequence that terminates with an exception.
  14186. /// </summary>
  14187. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14188. /// <typeparam name="TResult">The type used for the <see cref="IObservable{T}"/> type parameter of the resulting sequence.</typeparam>
  14189. /// <param name="exception">Exception object used for the sequence's termination.</param>
  14190. /// <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>
  14191. /// <returns>The observable sequence that terminates exceptionally with the specified exception object.</returns>
  14192. /// <exception cref="ArgumentNullException">
  14193. /// <paramref name="exception" /> is null.</exception>
  14194. public static IQbservable<TResult> Throw<TResult>(this IQbservableProvider provider, Exception exception, TResult witness)
  14195. {
  14196. if (provider == null)
  14197. throw new ArgumentNullException(nameof(provider));
  14198. if (exception == null)
  14199. throw new ArgumentNullException(nameof(exception));
  14200. return provider.CreateQuery<TResult>(
  14201. Expression.Call(
  14202. null,
  14203. #if CRIPPLED_REFLECTION
  14204. InfoOf(() => Qbservable.Throw<TResult>(default(IQbservableProvider), default(Exception), default(TResult))),
  14205. #else
  14206. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult)),
  14207. #endif
  14208. Expression.Constant(provider, typeof(IQbservableProvider)),
  14209. Expression.Constant(exception, typeof(Exception)),
  14210. Expression.Constant(witness, typeof(TResult))
  14211. )
  14212. );
  14213. }
  14214. /// <summary>
  14215. /// Records the time interval between consecutive elements in an observable sequence.
  14216. /// </summary>
  14217. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14218. /// <param name="source">Source sequence to record time intervals for.</param>
  14219. /// <returns>An observable sequence with time interval information on elements.</returns>
  14220. /// <exception cref="ArgumentNullException">
  14221. /// <paramref name="source" /> is null.</exception>
  14222. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source)
  14223. {
  14224. if (source == null)
  14225. throw new ArgumentNullException(nameof(source));
  14226. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14227. Expression.Call(
  14228. null,
  14229. #if CRIPPLED_REFLECTION
  14230. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>))),
  14231. #else
  14232. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14233. #endif
  14234. source.Expression
  14235. )
  14236. );
  14237. }
  14238. /// <summary>
  14239. /// Records the time interval between consecutive elements in an observable sequence, using the specified scheduler to compute time intervals.
  14240. /// </summary>
  14241. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14242. /// <param name="source">Source sequence to record time intervals for.</param>
  14243. /// <param name="scheduler">Scheduler used to compute time intervals.</param>
  14244. /// <returns>An observable sequence with time interval information on elements.</returns>
  14245. /// <exception cref="ArgumentNullException">
  14246. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14247. public static IQbservable<TimeInterval<TSource>> TimeInterval<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  14248. {
  14249. if (source == null)
  14250. throw new ArgumentNullException(nameof(source));
  14251. if (scheduler == null)
  14252. throw new ArgumentNullException(nameof(scheduler));
  14253. return source.Provider.CreateQuery<TimeInterval<TSource>>(
  14254. Expression.Call(
  14255. null,
  14256. #if CRIPPLED_REFLECTION
  14257. InfoOf(() => Qbservable.TimeInterval<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  14258. #else
  14259. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14260. #endif
  14261. source.Expression,
  14262. Expression.Constant(scheduler, typeof(IScheduler))
  14263. )
  14264. );
  14265. }
  14266. /// <summary>
  14267. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14268. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14269. /// </summary>
  14270. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14271. /// <param name="source">Source sequence to perform a timeout for.</param>
  14272. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14273. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14274. /// <exception cref="ArgumentNullException">
  14275. /// <paramref name="source" /> is null.</exception>
  14276. /// <exception cref="TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14277. /// <remarks>
  14278. /// In case you only want to timeout on the first element, consider using the <see cref="Observable.Amb{TSource}(IObservable{TSource},IObservable{TSource})" />
  14279. /// operator applied to the source sequence and a delayed <see cref="Observable.Throw{TSource}(Exception)" /> sequence. Alternatively, the general-purpose overload
  14280. /// of Timeout, <see cref="Observable.Timeout{TSource,TTimeout}(IObservable{TSource},IObservable{TTimeout},Func{TSource,IObservable{TTimeout}})" /> can be used.
  14281. /// </remarks>
  14282. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime)
  14283. {
  14284. if (source == null)
  14285. throw new ArgumentNullException(nameof(source));
  14286. return source.Provider.CreateQuery<TSource>(
  14287. Expression.Call(
  14288. null,
  14289. #if CRIPPLED_REFLECTION
  14290. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset))),
  14291. #else
  14292. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14293. #endif
  14294. source.Expression,
  14295. Expression.Constant(dueTime, typeof(DateTimeOffset))
  14296. )
  14297. );
  14298. }
  14299. /// <summary>
  14300. /// Applies a timeout policy to the observable sequence based on an absolute time.
  14301. /// 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.
  14302. /// </summary>
  14303. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14304. /// <param name="source">Source sequence to perform a timeout for.</param>
  14305. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14306. /// <param name="other">Sequence to return in case of a timeout.</param>
  14307. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14308. /// <exception cref="ArgumentNullException">
  14309. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14310. /// <remarks>
  14311. /// In case you only want to timeout on the first element, consider using the <see cref="Observable.Amb{TSource}(IObservable{TSource},IObservable{TSource})" />
  14312. /// operator applied to the source sequence and a delayed <see cref="Observable.Throw{TSource}(Exception)" /> sequence. Alternatively, the general-purpose overload
  14313. /// of Timeout, <see cref="Observable.Timeout{TSource,TTimeout}(IObservable{TSource},IObservable{TTimeout},Func{TSource,IObservable{TTimeout}})" /> can be used.
  14314. /// </remarks>
  14315. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other)
  14316. {
  14317. if (source == null)
  14318. throw new ArgumentNullException(nameof(source));
  14319. if (other == null)
  14320. throw new ArgumentNullException(nameof(other));
  14321. return source.Provider.CreateQuery<TSource>(
  14322. Expression.Call(
  14323. null,
  14324. #if CRIPPLED_REFLECTION
  14325. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>))),
  14326. #else
  14327. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14328. #endif
  14329. source.Expression,
  14330. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14331. GetSourceExpression(other)
  14332. )
  14333. );
  14334. }
  14335. /// <summary>
  14336. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14337. /// 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.
  14338. /// </summary>
  14339. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14340. /// <param name="source">Source sequence to perform a timeout for.</param>
  14341. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14342. /// <param name="other">Sequence to return in case of a timeout.</param>
  14343. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14344. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14345. /// <exception cref="ArgumentNullException">
  14346. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14347. /// <remarks>
  14348. /// In case you only want to timeout on the first element, consider using the <see cref="Observable.Amb{TSource}(IObservable{TSource},IObservable{TSource})" />
  14349. /// operator applied to the source sequence and a delayed <see cref="Observable.Throw{TSource}(Exception)" /> sequence. Alternatively, the general-purpose overload
  14350. /// of Timeout, <see cref="Observable.Timeout{TSource,TTimeout}(IObservable{TSource},IObservable{TTimeout},Func{TSource,IObservable{TTimeout}})" /> can be used.
  14351. /// </remarks>
  14352. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IObservable<TSource> other, IScheduler scheduler)
  14353. {
  14354. if (source == null)
  14355. throw new ArgumentNullException(nameof(source));
  14356. if (other == null)
  14357. throw new ArgumentNullException(nameof(other));
  14358. if (scheduler == null)
  14359. throw new ArgumentNullException(nameof(scheduler));
  14360. return source.Provider.CreateQuery<TSource>(
  14361. Expression.Call(
  14362. null,
  14363. #if CRIPPLED_REFLECTION
  14364. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IObservable<TSource>), default(IScheduler))),
  14365. #else
  14366. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14367. #endif
  14368. source.Expression,
  14369. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14370. GetSourceExpression(other),
  14371. Expression.Constant(scheduler, typeof(IScheduler))
  14372. )
  14373. );
  14374. }
  14375. /// <summary>
  14376. /// Applies a timeout policy to the observable sequence based on an absolute time, using the specified scheduler to run timeout timers.
  14377. /// If the sequence doesn't terminate before the specified absolute due time, a TimeoutException is propagated to the observer.
  14378. /// </summary>
  14379. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14380. /// <param name="source">Source sequence to perform a timeout for.</param>
  14381. /// <param name="dueTime">Time when a timeout occurs. If this value is less than or equal to DateTimeOffset.UtcNow, the timeout occurs immediately.</param>
  14382. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14383. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14384. /// <exception cref="ArgumentNullException">
  14385. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14386. /// <exception cref="TimeoutException">(Asynchronous) If the sequence hasn't terminated before <paramref name="dueTime" />.</exception>
  14387. /// <remarks>
  14388. /// In case you only want to timeout on the first element, consider using the <see cref="Observable.Amb{TSource}(IObservable{TSource},IObservable{TSource})" />
  14389. /// operator applied to the source sequence and a delayed <see cref="Observable.Throw{TSource}(Exception)" /> sequence. Alternatively, the general-purpose overload
  14390. /// of Timeout, <see cref="Observable.Timeout{TSource,TTimeout}(IObservable{TSource},IObservable{TTimeout},Func{TSource,IObservable{TTimeout}})" /> can be used.
  14391. /// </remarks>
  14392. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, DateTimeOffset dueTime, IScheduler scheduler)
  14393. {
  14394. if (source == null)
  14395. throw new ArgumentNullException(nameof(source));
  14396. if (scheduler == null)
  14397. throw new ArgumentNullException(nameof(scheduler));
  14398. return source.Provider.CreateQuery<TSource>(
  14399. Expression.Call(
  14400. null,
  14401. #if CRIPPLED_REFLECTION
  14402. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(DateTimeOffset), default(IScheduler))),
  14403. #else
  14404. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14405. #endif
  14406. source.Expression,
  14407. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14408. Expression.Constant(scheduler, typeof(IScheduler))
  14409. )
  14410. );
  14411. }
  14412. /// <summary>
  14413. /// Applies a timeout policy for each element in the observable sequence.
  14414. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14415. /// </summary>
  14416. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14417. /// <param name="source">Source sequence to perform a timeout for.</param>
  14418. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14419. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14420. /// <exception cref="ArgumentNullException">
  14421. /// <paramref name="source" /> is null.</exception>
  14422. /// <exception cref="ArgumentOutOfRangeException">
  14423. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14424. /// <exception cref="TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14425. /// <remarks>
  14426. /// <para>
  14427. /// In case you only want to timeout on the first element, consider using the <see cref="Observable.Amb{TSource}(IObservable{TSource},IObservable{TSource})" />
  14428. /// operator applied to the source sequence and a delayed <see cref="Observable.Throw{TSource}(Exception)" /> sequence. Alternatively, the general-purpose overload
  14429. /// of Timeout, <see cref="Observable.Timeout{TSource,TTimeout}(IObservable{TSource},IObservable{TTimeout},Func{TSource,IObservable{TTimeout}})" /> can be used.
  14430. /// </para>
  14431. /// <para>
  14432. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14433. /// 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
  14434. /// 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
  14435. /// arrive before the scheduler gets a chance to run the timeout action.
  14436. /// </para>
  14437. /// </remarks>
  14438. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime)
  14439. {
  14440. if (source == null)
  14441. throw new ArgumentNullException(nameof(source));
  14442. return source.Provider.CreateQuery<TSource>(
  14443. Expression.Call(
  14444. null,
  14445. #if CRIPPLED_REFLECTION
  14446. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  14447. #else
  14448. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14449. #endif
  14450. source.Expression,
  14451. Expression.Constant(dueTime, typeof(TimeSpan))
  14452. )
  14453. );
  14454. }
  14455. /// <summary>
  14456. /// Applies a timeout policy for each element in the observable sequence.
  14457. /// 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.
  14458. /// </summary>
  14459. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14460. /// <param name="source">Source sequence to perform a timeout for.</param>
  14461. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14462. /// <param name="other">Sequence to return in case of a timeout.</param>
  14463. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14464. /// <exception cref="ArgumentNullException">
  14465. /// <paramref name="source" /> or <paramref name="other" /> is null.</exception>
  14466. /// <exception cref="ArgumentOutOfRangeException">
  14467. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14468. /// <remarks>
  14469. /// <para>
  14470. /// In case you only want to timeout on the first element, consider using the <see cref="Observable.Amb{TSource}(IObservable{TSource},IObservable{TSource})" />
  14471. /// operator applied to the source sequence and a delayed <see cref="Observable.Throw{TSource}(Exception)" /> sequence. Alternatively, the general-purpose overload
  14472. /// of Timeout, <see cref="Observable.Timeout{TSource,TTimeout}(IObservable{TSource},IObservable{TTimeout},Func{TSource,IObservable{TTimeout}})" /> can be used.
  14473. /// </para>
  14474. /// <para>
  14475. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14476. /// 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
  14477. /// 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
  14478. /// arrive before the scheduler gets a chance to run the timeout action.
  14479. /// </para>
  14480. /// </remarks>
  14481. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other)
  14482. {
  14483. if (source == null)
  14484. throw new ArgumentNullException(nameof(source));
  14485. if (other == null)
  14486. throw new ArgumentNullException(nameof(other));
  14487. return source.Provider.CreateQuery<TSource>(
  14488. Expression.Call(
  14489. null,
  14490. #if CRIPPLED_REFLECTION
  14491. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>))),
  14492. #else
  14493. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14494. #endif
  14495. source.Expression,
  14496. Expression.Constant(dueTime, typeof(TimeSpan)),
  14497. GetSourceExpression(other)
  14498. )
  14499. );
  14500. }
  14501. /// <summary>
  14502. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14503. /// 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.
  14504. /// </summary>
  14505. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14506. /// <param name="source">Source sequence to perform a timeout for.</param>
  14507. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14508. /// <param name="other">Sequence to return in case of a timeout.</param>
  14509. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14510. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14511. /// <exception cref="ArgumentNullException">
  14512. /// <paramref name="source" /> or <paramref name="other" /> or <paramref name="scheduler" /> is null.</exception>
  14513. /// <exception cref="ArgumentOutOfRangeException">
  14514. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14515. /// <remarks>
  14516. /// <para>
  14517. /// In case you only want to timeout on the first element, consider using the <see cref="Observable.Amb{TSource}(IObservable{TSource},IObservable{TSource})" />
  14518. /// operator applied to the source sequence and a delayed <see cref="Observable.Throw{TSource}(Exception)" /> sequence. Alternatively, the general-purpose overload
  14519. /// of Timeout, <see cref="Observable.Timeout{TSource,TTimeout}(IObservable{TSource},IObservable{TTimeout},Func{TSource,IObservable{TTimeout}})" /> can be used.
  14520. /// </para>
  14521. /// <para>
  14522. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14523. /// 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
  14524. /// 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
  14525. /// arrive before the scheduler gets a chance to run the timeout action.
  14526. /// </para>
  14527. /// </remarks>
  14528. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IObservable<TSource> other, IScheduler scheduler)
  14529. {
  14530. if (source == null)
  14531. throw new ArgumentNullException(nameof(source));
  14532. if (other == null)
  14533. throw new ArgumentNullException(nameof(other));
  14534. if (scheduler == null)
  14535. throw new ArgumentNullException(nameof(scheduler));
  14536. return source.Provider.CreateQuery<TSource>(
  14537. Expression.Call(
  14538. null,
  14539. #if CRIPPLED_REFLECTION
  14540. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IObservable<TSource>), default(IScheduler))),
  14541. #else
  14542. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14543. #endif
  14544. source.Expression,
  14545. Expression.Constant(dueTime, typeof(TimeSpan)),
  14546. GetSourceExpression(other),
  14547. Expression.Constant(scheduler, typeof(IScheduler))
  14548. )
  14549. );
  14550. }
  14551. /// <summary>
  14552. /// Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers.
  14553. /// If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14554. /// </summary>
  14555. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14556. /// <param name="source">Source sequence to perform a timeout for.</param>
  14557. /// <param name="dueTime">Maximum duration between values before a timeout occurs.</param>
  14558. /// <param name="scheduler">Scheduler to run the timeout timers on.</param>
  14559. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14560. /// <exception cref="ArgumentNullException">
  14561. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14562. /// <exception cref="ArgumentOutOfRangeException">
  14563. /// <paramref name="dueTime" /> is less than TimeSpan.Zero.</exception>
  14564. /// <exception cref="TimeoutException">(Asynchronous) If no element is produced within <paramref name="dueTime" /> from the previous element.</exception>
  14565. /// <remarks>
  14566. /// <para>
  14567. /// In case you only want to timeout on the first element, consider using the <see cref="Observable.Amb{TSource}(IObservable{TSource},IObservable{TSource})" />
  14568. /// operator applied to the source sequence and a delayed <see cref="Observable.Throw{TSource}(Exception)" /> sequence. Alternatively, the general-purpose overload
  14569. /// of Timeout, <see cref="Observable.Timeout{TSource,TTimeout}(IObservable{TSource},IObservable{TTimeout},Func{TSource,IObservable{TTimeout}})" /> can be used.
  14570. /// </para>
  14571. /// <para>
  14572. /// Specifying a TimeSpan.Zero value for <paramref name="dueTime" /> is not recommended but supported, causing timeout timers to be scheduled that are due
  14573. /// 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
  14574. /// 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
  14575. /// arrive before the scheduler gets a chance to run the timeout action.
  14576. /// </para>
  14577. /// </remarks>
  14578. public static IQbservable<TSource> Timeout<TSource>(this IQbservable<TSource> source, TimeSpan dueTime, IScheduler scheduler)
  14579. {
  14580. if (source == null)
  14581. throw new ArgumentNullException(nameof(source));
  14582. if (scheduler == null)
  14583. throw new ArgumentNullException(nameof(scheduler));
  14584. return source.Provider.CreateQuery<TSource>(
  14585. Expression.Call(
  14586. null,
  14587. #if CRIPPLED_REFLECTION
  14588. InfoOf(() => Qbservable.Timeout<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  14589. #else
  14590. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14591. #endif
  14592. source.Expression,
  14593. Expression.Constant(dueTime, typeof(TimeSpan)),
  14594. Expression.Constant(scheduler, typeof(IScheduler))
  14595. )
  14596. );
  14597. }
  14598. /// <summary>
  14599. /// 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.
  14600. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14601. /// </summary>
  14602. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14603. /// <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>
  14604. /// <param name="source">Source sequence to perform a timeout for.</param>
  14605. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  14606. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14607. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14608. /// <exception cref="ArgumentNullException">
  14609. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  14610. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  14611. {
  14612. if (source == null)
  14613. throw new ArgumentNullException(nameof(source));
  14614. if (firstTimeout == null)
  14615. throw new ArgumentNullException(nameof(firstTimeout));
  14616. if (timeoutDurationSelector == null)
  14617. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  14618. return source.Provider.CreateQuery<TSource>(
  14619. Expression.Call(
  14620. null,
  14621. #if CRIPPLED_REFLECTION
  14622. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  14623. #else
  14624. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14625. #endif
  14626. source.Expression,
  14627. GetSourceExpression(firstTimeout),
  14628. timeoutDurationSelector
  14629. )
  14630. );
  14631. }
  14632. /// <summary>
  14633. /// 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.
  14634. /// 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.
  14635. /// </summary>
  14636. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14637. /// <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>
  14638. /// <param name="source">Source sequence to perform a timeout for.</param>
  14639. /// <param name="firstTimeout">Observable sequence that represents the timeout for the first element.</param>
  14640. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14641. /// <param name="other">Sequence to return in case of a timeout.</param>
  14642. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14643. /// <exception cref="ArgumentNullException">
  14644. /// <paramref name="source" /> or <paramref name="firstTimeout" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  14645. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, IObservable<TTimeout> firstTimeout, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  14646. {
  14647. if (source == null)
  14648. throw new ArgumentNullException(nameof(source));
  14649. if (firstTimeout == null)
  14650. throw new ArgumentNullException(nameof(firstTimeout));
  14651. if (timeoutDurationSelector == null)
  14652. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  14653. if (other == null)
  14654. throw new ArgumentNullException(nameof(other));
  14655. return source.Provider.CreateQuery<TSource>(
  14656. Expression.Call(
  14657. null,
  14658. #if CRIPPLED_REFLECTION
  14659. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(IObservable<TTimeout>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  14660. #else
  14661. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14662. #endif
  14663. source.Expression,
  14664. GetSourceExpression(firstTimeout),
  14665. timeoutDurationSelector,
  14666. GetSourceExpression(other)
  14667. )
  14668. );
  14669. }
  14670. /// <summary>
  14671. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  14672. /// If the next element isn't received within the computed duration starting from its predecessor, a TimeoutException is propagated to the observer.
  14673. /// </summary>
  14674. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14675. /// <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>
  14676. /// <param name="source">Source sequence to perform a timeout for.</param>
  14677. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14678. /// <returns>The source sequence with a TimeoutException in case of a timeout.</returns>
  14679. /// <exception cref="ArgumentNullException">
  14680. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> is null.</exception>
  14681. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector)
  14682. {
  14683. if (source == null)
  14684. throw new ArgumentNullException(nameof(source));
  14685. if (timeoutDurationSelector == null)
  14686. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  14687. return source.Provider.CreateQuery<TSource>(
  14688. Expression.Call(
  14689. null,
  14690. #if CRIPPLED_REFLECTION
  14691. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>))),
  14692. #else
  14693. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14694. #endif
  14695. source.Expression,
  14696. timeoutDurationSelector
  14697. )
  14698. );
  14699. }
  14700. /// <summary>
  14701. /// Applies a timeout policy to the observable sequence based on a timeout duration computed for each element.
  14702. /// 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.
  14703. /// </summary>
  14704. /// <typeparam name="TSource">The type of the elements in the source sequence and the other sequence used upon a timeout.</typeparam>
  14705. /// <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>
  14706. /// <param name="source">Source sequence to perform a timeout for.</param>
  14707. /// <param name="timeoutDurationSelector">Selector to retrieve an observable sequence that represents the timeout between the current element and the next element.</param>
  14708. /// <param name="other">Sequence to return in case of a timeout.</param>
  14709. /// <returns>The source sequence switching to the other sequence in case of a timeout.</returns>
  14710. /// <exception cref="ArgumentNullException">
  14711. /// <paramref name="source" /> or <paramref name="timeoutDurationSelector" /> or <paramref name="other" /> is null.</exception>
  14712. public static IQbservable<TSource> Timeout<TSource, TTimeout>(this IQbservable<TSource> source, Expression<Func<TSource, IObservable<TTimeout>>> timeoutDurationSelector, IObservable<TSource> other)
  14713. {
  14714. if (source == null)
  14715. throw new ArgumentNullException(nameof(source));
  14716. if (timeoutDurationSelector == null)
  14717. throw new ArgumentNullException(nameof(timeoutDurationSelector));
  14718. if (other == null)
  14719. throw new ArgumentNullException(nameof(other));
  14720. return source.Provider.CreateQuery<TSource>(
  14721. Expression.Call(
  14722. null,
  14723. #if CRIPPLED_REFLECTION
  14724. InfoOf(() => Qbservable.Timeout<TSource, TTimeout>(default(IQbservable<TSource>), default(Expression<Func<TSource, IObservable<TTimeout>>>), default(IObservable<TSource>))),
  14725. #else
  14726. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TTimeout)),
  14727. #endif
  14728. source.Expression,
  14729. timeoutDurationSelector,
  14730. GetSourceExpression(other)
  14731. )
  14732. );
  14733. }
  14734. /// <summary>
  14735. /// Returns an observable sequence that produces a single value at the specified absolute due time.
  14736. /// </summary>
  14737. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14738. /// <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>
  14739. /// <returns>An observable sequence that produces a value at due time.</returns>
  14740. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime)
  14741. {
  14742. if (provider == null)
  14743. throw new ArgumentNullException(nameof(provider));
  14744. return provider.CreateQuery<long>(
  14745. Expression.Call(
  14746. null,
  14747. #if CRIPPLED_REFLECTION
  14748. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset))),
  14749. #else
  14750. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14751. #endif
  14752. Expression.Constant(provider, typeof(IQbservableProvider)),
  14753. Expression.Constant(dueTime, typeof(DateTimeOffset))
  14754. )
  14755. );
  14756. }
  14757. /// <summary>
  14758. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time.
  14759. /// </summary>
  14760. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14761. /// <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>
  14762. /// <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>
  14763. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  14764. /// <exception cref="ArgumentOutOfRangeException">
  14765. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  14766. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period)
  14767. {
  14768. if (provider == null)
  14769. throw new ArgumentNullException(nameof(provider));
  14770. return provider.CreateQuery<long>(
  14771. Expression.Call(
  14772. null,
  14773. #if CRIPPLED_REFLECTION
  14774. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan))),
  14775. #else
  14776. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14777. #endif
  14778. Expression.Constant(provider, typeof(IQbservableProvider)),
  14779. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14780. Expression.Constant(period, typeof(TimeSpan))
  14781. )
  14782. );
  14783. }
  14784. /// <summary>
  14785. /// Returns an observable sequence that periodically produces a value starting at the specified initial absolute due time, using the specified scheduler to run timers.
  14786. /// </summary>
  14787. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14788. /// <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>
  14789. /// <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>
  14790. /// <param name="scheduler">Scheduler to run timers on.</param>
  14791. /// <returns>An observable sequence that produces a value at due time and then after each period.</returns>
  14792. /// <exception cref="ArgumentOutOfRangeException">
  14793. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  14794. /// <exception cref="ArgumentNullException">
  14795. /// <paramref name="scheduler" /> is null.</exception>
  14796. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, TimeSpan period, IScheduler scheduler)
  14797. {
  14798. if (provider == null)
  14799. throw new ArgumentNullException(nameof(provider));
  14800. if (scheduler == null)
  14801. throw new ArgumentNullException(nameof(scheduler));
  14802. return provider.CreateQuery<long>(
  14803. Expression.Call(
  14804. null,
  14805. #if CRIPPLED_REFLECTION
  14806. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(TimeSpan), default(IScheduler))),
  14807. #else
  14808. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14809. #endif
  14810. Expression.Constant(provider, typeof(IQbservableProvider)),
  14811. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14812. Expression.Constant(period, typeof(TimeSpan)),
  14813. Expression.Constant(scheduler, typeof(IScheduler))
  14814. )
  14815. );
  14816. }
  14817. /// <summary>
  14818. /// Returns an observable sequence that produces a single value at the specified absolute due time, using the specified scheduler to run the timer.
  14819. /// </summary>
  14820. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14821. /// <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>
  14822. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14823. /// <returns>An observable sequence that produces a value at due time.</returns>
  14824. /// <exception cref="ArgumentNullException">
  14825. /// <paramref name="scheduler" /> is null.</exception>
  14826. public static IQbservable<long> Timer(this IQbservableProvider provider, DateTimeOffset dueTime, IScheduler scheduler)
  14827. {
  14828. if (provider == null)
  14829. throw new ArgumentNullException(nameof(provider));
  14830. if (scheduler == null)
  14831. throw new ArgumentNullException(nameof(scheduler));
  14832. return provider.CreateQuery<long>(
  14833. Expression.Call(
  14834. null,
  14835. #if CRIPPLED_REFLECTION
  14836. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(DateTimeOffset), default(IScheduler))),
  14837. #else
  14838. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14839. #endif
  14840. Expression.Constant(provider, typeof(IQbservableProvider)),
  14841. Expression.Constant(dueTime, typeof(DateTimeOffset)),
  14842. Expression.Constant(scheduler, typeof(IScheduler))
  14843. )
  14844. );
  14845. }
  14846. /// <summary>
  14847. /// Returns an observable sequence that produces a single value after the specified relative due time has elapsed.
  14848. /// </summary>
  14849. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14850. /// <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>
  14851. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  14852. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime)
  14853. {
  14854. if (provider == null)
  14855. throw new ArgumentNullException(nameof(provider));
  14856. return provider.CreateQuery<long>(
  14857. Expression.Call(
  14858. null,
  14859. #if CRIPPLED_REFLECTION
  14860. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan))),
  14861. #else
  14862. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14863. #endif
  14864. Expression.Constant(provider, typeof(IQbservableProvider)),
  14865. Expression.Constant(dueTime, typeof(TimeSpan))
  14866. )
  14867. );
  14868. }
  14869. /// <summary>
  14870. /// Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed.
  14871. /// </summary>
  14872. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14873. /// <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>
  14874. /// <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>
  14875. /// <returns>An observable sequence that produces a value after due time has elapsed and then after each period.</returns>
  14876. /// <exception cref="ArgumentOutOfRangeException">
  14877. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  14878. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period)
  14879. {
  14880. if (provider == null)
  14881. throw new ArgumentNullException(nameof(provider));
  14882. return provider.CreateQuery<long>(
  14883. Expression.Call(
  14884. null,
  14885. #if CRIPPLED_REFLECTION
  14886. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan))),
  14887. #else
  14888. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14889. #endif
  14890. Expression.Constant(provider, typeof(IQbservableProvider)),
  14891. Expression.Constant(dueTime, typeof(TimeSpan)),
  14892. Expression.Constant(period, typeof(TimeSpan))
  14893. )
  14894. );
  14895. }
  14896. /// <summary>
  14897. /// 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.
  14898. /// </summary>
  14899. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14900. /// <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>
  14901. /// <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>
  14902. /// <param name="scheduler">Scheduler to run timers on.</param>
  14903. /// <returns>An observable sequence that produces a value after due time has elapsed and then each period.</returns>
  14904. /// <exception cref="ArgumentOutOfRangeException">
  14905. /// <paramref name="period" /> is less than TimeSpan.Zero.</exception>
  14906. /// <exception cref="ArgumentNullException">
  14907. /// <paramref name="scheduler" /> is null.</exception>
  14908. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, TimeSpan period, IScheduler scheduler)
  14909. {
  14910. if (provider == null)
  14911. throw new ArgumentNullException(nameof(provider));
  14912. if (scheduler == null)
  14913. throw new ArgumentNullException(nameof(scheduler));
  14914. return provider.CreateQuery<long>(
  14915. Expression.Call(
  14916. null,
  14917. #if CRIPPLED_REFLECTION
  14918. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  14919. #else
  14920. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14921. #endif
  14922. Expression.Constant(provider, typeof(IQbservableProvider)),
  14923. Expression.Constant(dueTime, typeof(TimeSpan)),
  14924. Expression.Constant(period, typeof(TimeSpan)),
  14925. Expression.Constant(scheduler, typeof(IScheduler))
  14926. )
  14927. );
  14928. }
  14929. /// <summary>
  14930. /// 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.
  14931. /// </summary>
  14932. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  14933. /// <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>
  14934. /// <param name="scheduler">Scheduler to run the timer on.</param>
  14935. /// <returns>An observable sequence that produces a value after the due time has elapsed.</returns>
  14936. /// <exception cref="ArgumentNullException">
  14937. /// <paramref name="scheduler" /> is null.</exception>
  14938. public static IQbservable<long> Timer(this IQbservableProvider provider, TimeSpan dueTime, IScheduler scheduler)
  14939. {
  14940. if (provider == null)
  14941. throw new ArgumentNullException(nameof(provider));
  14942. if (scheduler == null)
  14943. throw new ArgumentNullException(nameof(scheduler));
  14944. return provider.CreateQuery<long>(
  14945. Expression.Call(
  14946. null,
  14947. #if CRIPPLED_REFLECTION
  14948. InfoOf(() => Qbservable.Timer(default(IQbservableProvider), default(TimeSpan), default(IScheduler))),
  14949. #else
  14950. (MethodInfo)MethodInfo.GetCurrentMethod(),
  14951. #endif
  14952. Expression.Constant(provider, typeof(IQbservableProvider)),
  14953. Expression.Constant(dueTime, typeof(TimeSpan)),
  14954. Expression.Constant(scheduler, typeof(IScheduler))
  14955. )
  14956. );
  14957. }
  14958. /// <summary>
  14959. /// Timestamps each element in an observable sequence using the local system clock.
  14960. /// </summary>
  14961. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14962. /// <param name="source">Source sequence to timestamp elements for.</param>
  14963. /// <returns>An observable sequence with timestamp information on elements.</returns>
  14964. /// <exception cref="ArgumentNullException">
  14965. /// <paramref name="source" /> is null.</exception>
  14966. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source)
  14967. {
  14968. if (source == null)
  14969. throw new ArgumentNullException(nameof(source));
  14970. return source.Provider.CreateQuery<Timestamped<TSource>>(
  14971. Expression.Call(
  14972. null,
  14973. #if CRIPPLED_REFLECTION
  14974. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>))),
  14975. #else
  14976. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  14977. #endif
  14978. source.Expression
  14979. )
  14980. );
  14981. }
  14982. /// <summary>
  14983. /// Timestamp each element in an observable sequence using the clock of the specified scheduler.
  14984. /// </summary>
  14985. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  14986. /// <param name="source">Source sequence to timestamp elements for.</param>
  14987. /// <param name="scheduler">Scheduler used to compute timestamps.</param>
  14988. /// <returns>An observable sequence with timestamp information on elements.</returns>
  14989. /// <exception cref="ArgumentNullException">
  14990. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  14991. public static IQbservable<Timestamped<TSource>> Timestamp<TSource>(this IQbservable<TSource> source, IScheduler scheduler)
  14992. {
  14993. if (source == null)
  14994. throw new ArgumentNullException(nameof(source));
  14995. if (scheduler == null)
  14996. throw new ArgumentNullException(nameof(scheduler));
  14997. return source.Provider.CreateQuery<Timestamped<TSource>>(
  14998. Expression.Call(
  14999. null,
  15000. #if CRIPPLED_REFLECTION
  15001. InfoOf(() => Qbservable.Timestamp<TSource>(default(IQbservable<TSource>), default(IScheduler))),
  15002. #else
  15003. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15004. #endif
  15005. source.Expression,
  15006. Expression.Constant(scheduler, typeof(IScheduler))
  15007. )
  15008. );
  15009. }
  15010. /// <summary>
  15011. /// Creates an array from an observable sequence.
  15012. /// </summary>
  15013. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15014. /// <param name="source">The source observable sequence to get an array of elements for.</param>
  15015. /// <returns>An observable sequence containing a single element with an array containing all the elements of the source sequence.</returns>
  15016. /// <exception cref="ArgumentNullException">
  15017. /// <paramref name="source" /> is null.</exception>
  15018. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15019. public static IQbservable<TSource[]> ToArray<TSource>(this IQbservable<TSource> source)
  15020. {
  15021. if (source == null)
  15022. throw new ArgumentNullException(nameof(source));
  15023. return source.Provider.CreateQuery<TSource[]>(
  15024. Expression.Call(
  15025. null,
  15026. #if CRIPPLED_REFLECTION
  15027. InfoOf(() => Qbservable.ToArray<TSource>(default(IQbservable<TSource>))),
  15028. #else
  15029. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15030. #endif
  15031. source.Expression
  15032. )
  15033. );
  15034. }
  15035. /// <summary>
  15036. /// Creates a dictionary from an observable sequence according to a specified key selector function.
  15037. /// </summary>
  15038. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15039. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15040. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15041. /// <param name="keySelector">A function to extract a key from each element.</param>
  15042. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15043. /// <exception cref="ArgumentNullException">
  15044. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15045. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15046. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15047. {
  15048. if (source == null)
  15049. throw new ArgumentNullException(nameof(source));
  15050. if (keySelector == null)
  15051. throw new ArgumentNullException(nameof(keySelector));
  15052. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15053. Expression.Call(
  15054. null,
  15055. #if CRIPPLED_REFLECTION
  15056. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15057. #else
  15058. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15059. #endif
  15060. source.Expression,
  15061. keySelector
  15062. )
  15063. );
  15064. }
  15065. /// <summary>
  15066. /// Creates a dictionary from an observable sequence according to a specified key selector function, and a comparer.
  15067. /// </summary>
  15068. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15069. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15070. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15071. /// <param name="keySelector">A function to extract a key from each element.</param>
  15072. /// <param name="comparer">An equality comparer to compare keys.</param>
  15073. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15074. /// <exception cref="ArgumentNullException">
  15075. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15076. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15077. public static IQbservable<IDictionary<TKey, TSource>> ToDictionary<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15078. {
  15079. if (source == null)
  15080. throw new ArgumentNullException(nameof(source));
  15081. if (keySelector == null)
  15082. throw new ArgumentNullException(nameof(keySelector));
  15083. if (comparer == null)
  15084. throw new ArgumentNullException(nameof(comparer));
  15085. return source.Provider.CreateQuery<IDictionary<TKey, TSource>>(
  15086. Expression.Call(
  15087. null,
  15088. #if CRIPPLED_REFLECTION
  15089. InfoOf(() => Qbservable.ToDictionary<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15090. #else
  15091. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15092. #endif
  15093. source.Expression,
  15094. keySelector,
  15095. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15096. )
  15097. );
  15098. }
  15099. /// <summary>
  15100. /// Creates a dictionary from an observable sequence according to a specified key selector function, and an element selector function.
  15101. /// </summary>
  15102. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15103. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15104. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15105. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15106. /// <param name="keySelector">A function to extract a key from each element.</param>
  15107. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15108. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15109. /// <exception cref="ArgumentNullException">
  15110. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15111. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15112. public static IQbservable<IDictionary<TKey, TElement>> ToDictionary<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15113. {
  15114. if (source == null)
  15115. throw new ArgumentNullException(nameof(source));
  15116. if (keySelector == null)
  15117. throw new ArgumentNullException(nameof(keySelector));
  15118. if (elementSelector == null)
  15119. throw new ArgumentNullException(nameof(elementSelector));
  15120. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15121. Expression.Call(
  15122. null,
  15123. #if CRIPPLED_REFLECTION
  15124. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15125. #else
  15126. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15127. #endif
  15128. source.Expression,
  15129. keySelector,
  15130. elementSelector
  15131. )
  15132. );
  15133. }
  15134. /// <summary>
  15135. /// Creates a dictionary from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15136. /// </summary>
  15137. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15138. /// <typeparam name="TKey">The type of the dictionary key computed for each element in the source sequence.</typeparam>
  15139. /// <typeparam name="TElement">The type of the dictionary value computed for each element in the source sequence.</typeparam>
  15140. /// <param name="source">An observable sequence to create a dictionary for.</param>
  15141. /// <param name="keySelector">A function to extract a key from each element.</param>
  15142. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15143. /// <param name="comparer">An equality comparer to compare keys.</param>
  15144. /// <returns>An observable sequence containing a single element with a dictionary mapping unique key values onto the corresponding source sequence's element.</returns>
  15145. /// <exception cref="ArgumentNullException">
  15146. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15147. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15148. 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)
  15149. {
  15150. if (source == null)
  15151. throw new ArgumentNullException(nameof(source));
  15152. if (keySelector == null)
  15153. throw new ArgumentNullException(nameof(keySelector));
  15154. if (elementSelector == null)
  15155. throw new ArgumentNullException(nameof(elementSelector));
  15156. if (comparer == null)
  15157. throw new ArgumentNullException(nameof(comparer));
  15158. return source.Provider.CreateQuery<IDictionary<TKey, TElement>>(
  15159. Expression.Call(
  15160. null,
  15161. #if CRIPPLED_REFLECTION
  15162. InfoOf(() => Qbservable.ToDictionary<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15163. #else
  15164. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15165. #endif
  15166. source.Expression,
  15167. keySelector,
  15168. elementSelector,
  15169. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15170. )
  15171. );
  15172. }
  15173. /// <summary>
  15174. /// Converts an observable sequence to an enumerable sequence.
  15175. /// </summary>
  15176. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15177. /// <param name="source">An observable sequence to convert to an enumerable sequence.</param>
  15178. /// <returns>The enumerable sequence containing the elements in the observable sequence.</returns>
  15179. /// <exception cref="ArgumentNullException">
  15180. /// <paramref name="source" /> is null.</exception>
  15181. /// <remarks>This operator requires the source's <see cref="IQbservableProvider"/> object (see <see cref="IQbservable.Provider"/>) to implement <see cref="IQueryProvider"/>.</remarks>
  15182. public static IQueryable<TSource> ToQueryable<TSource>(this IQbservable<TSource> source)
  15183. {
  15184. if (source == null)
  15185. throw new ArgumentNullException(nameof(source));
  15186. return ((IQueryProvider)source.Provider).CreateQuery<TSource>(
  15187. Expression.Call(
  15188. null,
  15189. #if CRIPPLED_REFLECTION
  15190. InfoOf(() => Qbservable.ToQueryable<TSource>(default(IQbservable<TSource>))),
  15191. #else
  15192. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15193. #endif
  15194. source.Expression
  15195. )
  15196. );
  15197. }
  15198. /// <summary>
  15199. /// Creates a list from an observable sequence.
  15200. /// </summary>
  15201. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15202. /// <param name="source">The source observable sequence to get a list of elements for.</param>
  15203. /// <returns>An observable sequence containing a single element with a list containing all the elements of the source sequence.</returns>
  15204. /// <exception cref="ArgumentNullException">
  15205. /// <paramref name="source" /> is null.</exception>
  15206. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15207. public static IQbservable<IList<TSource>> ToList<TSource>(this IQbservable<TSource> source)
  15208. {
  15209. if (source == null)
  15210. throw new ArgumentNullException(nameof(source));
  15211. return source.Provider.CreateQuery<IList<TSource>>(
  15212. Expression.Call(
  15213. null,
  15214. #if CRIPPLED_REFLECTION
  15215. InfoOf(() => Qbservable.ToList<TSource>(default(IQbservable<TSource>))),
  15216. #else
  15217. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15218. #endif
  15219. source.Expression
  15220. )
  15221. );
  15222. }
  15223. /// <summary>
  15224. /// Creates a lookup from an observable sequence according to a specified key selector function.
  15225. /// </summary>
  15226. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15227. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15228. /// <param name="source">An observable sequence to create a lookup for.</param>
  15229. /// <param name="keySelector">A function to extract a key from each element.</param>
  15230. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15231. /// <exception cref="ArgumentNullException">
  15232. /// <paramref name="source" /> or <paramref name="keySelector" /> is null.</exception>
  15233. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15234. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector)
  15235. {
  15236. if (source == null)
  15237. throw new ArgumentNullException(nameof(source));
  15238. if (keySelector == null)
  15239. throw new ArgumentNullException(nameof(keySelector));
  15240. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15241. Expression.Call(
  15242. null,
  15243. #if CRIPPLED_REFLECTION
  15244. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>))),
  15245. #else
  15246. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15247. #endif
  15248. source.Expression,
  15249. keySelector
  15250. )
  15251. );
  15252. }
  15253. /// <summary>
  15254. /// Creates a lookup from an observable sequence according to a specified key selector function, and a comparer.
  15255. /// </summary>
  15256. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15257. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15258. /// <param name="source">An observable sequence to create a lookup for.</param>
  15259. /// <param name="keySelector">A function to extract a key from each element.</param>
  15260. /// <param name="comparer">An equality comparer to compare keys.</param>
  15261. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15262. /// <exception cref="ArgumentNullException">
  15263. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="comparer" /> is null.</exception>
  15264. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15265. public static IQbservable<ILookup<TKey, TSource>> ToLookup<TSource, TKey>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, IEqualityComparer<TKey> comparer)
  15266. {
  15267. if (source == null)
  15268. throw new ArgumentNullException(nameof(source));
  15269. if (keySelector == null)
  15270. throw new ArgumentNullException(nameof(keySelector));
  15271. if (comparer == null)
  15272. throw new ArgumentNullException(nameof(comparer));
  15273. return source.Provider.CreateQuery<ILookup<TKey, TSource>>(
  15274. Expression.Call(
  15275. null,
  15276. #if CRIPPLED_REFLECTION
  15277. InfoOf(() => Qbservable.ToLookup<TSource, TKey>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(IEqualityComparer<TKey>))),
  15278. #else
  15279. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey)),
  15280. #endif
  15281. source.Expression,
  15282. keySelector,
  15283. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15284. )
  15285. );
  15286. }
  15287. /// <summary>
  15288. /// Creates a lookup from an observable sequence according to a specified key selector function, and an element selector function.
  15289. /// </summary>
  15290. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15291. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15292. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15293. /// <param name="source">An observable sequence to create a lookup for.</param>
  15294. /// <param name="keySelector">A function to extract a key from each element.</param>
  15295. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15296. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15297. /// <exception cref="ArgumentNullException">
  15298. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> is null.</exception>
  15299. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15300. public static IQbservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector)
  15301. {
  15302. if (source == null)
  15303. throw new ArgumentNullException(nameof(source));
  15304. if (keySelector == null)
  15305. throw new ArgumentNullException(nameof(keySelector));
  15306. if (elementSelector == null)
  15307. throw new ArgumentNullException(nameof(elementSelector));
  15308. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15309. Expression.Call(
  15310. null,
  15311. #if CRIPPLED_REFLECTION
  15312. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>))),
  15313. #else
  15314. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15315. #endif
  15316. source.Expression,
  15317. keySelector,
  15318. elementSelector
  15319. )
  15320. );
  15321. }
  15322. /// <summary>
  15323. /// Creates a lookup from an observable sequence according to a specified key selector function, a comparer, and an element selector function.
  15324. /// </summary>
  15325. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15326. /// <typeparam name="TKey">The type of the lookup key computed for each element in the source sequence.</typeparam>
  15327. /// <typeparam name="TElement">The type of the lookup value computed for each element in the source sequence.</typeparam>
  15328. /// <param name="source">An observable sequence to create a lookup for.</param>
  15329. /// <param name="keySelector">A function to extract a key from each element.</param>
  15330. /// <param name="elementSelector">A transform function to produce a result element value from each element.</param>
  15331. /// <param name="comparer">An equality comparer to compare keys.</param>
  15332. /// <returns>An observable sequence containing a single element with a lookup mapping unique key values onto the corresponding source sequence's elements.</returns>
  15333. /// <exception cref="ArgumentNullException">
  15334. /// <paramref name="source" /> or <paramref name="keySelector" /> or <paramref name="elementSelector" /> or <paramref name="comparer" /> is null.</exception>
  15335. /// <remarks>The return type of this operator differs from the corresponding operator on IEnumerable in order to retain asynchronous behavior.</remarks>
  15336. public static IQbservable<ILookup<TKey, TElement>> ToLookup<TSource, TKey, TElement>(this IQbservable<TSource> source, Expression<Func<TSource, TKey>> keySelector, Expression<Func<TSource, TElement>> elementSelector, IEqualityComparer<TKey> comparer)
  15337. {
  15338. if (source == null)
  15339. throw new ArgumentNullException(nameof(source));
  15340. if (keySelector == null)
  15341. throw new ArgumentNullException(nameof(keySelector));
  15342. if (elementSelector == null)
  15343. throw new ArgumentNullException(nameof(elementSelector));
  15344. if (comparer == null)
  15345. throw new ArgumentNullException(nameof(comparer));
  15346. return source.Provider.CreateQuery<ILookup<TKey, TElement>>(
  15347. Expression.Call(
  15348. null,
  15349. #if CRIPPLED_REFLECTION
  15350. InfoOf(() => Qbservable.ToLookup<TSource, TKey, TElement>(default(IQbservable<TSource>), default(Expression<Func<TSource, TKey>>), default(Expression<Func<TSource, TElement>>), default(IEqualityComparer<TKey>))),
  15351. #else
  15352. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TKey), typeof(TElement)),
  15353. #endif
  15354. source.Expression,
  15355. keySelector,
  15356. elementSelector,
  15357. Expression.Constant(comparer, typeof(IEqualityComparer<TKey>))
  15358. )
  15359. );
  15360. }
  15361. /// <summary>
  15362. /// Converts an enumerable sequence to an observable sequence.
  15363. /// </summary>
  15364. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15365. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15366. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15367. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15368. /// <exception cref="ArgumentNullException">
  15369. /// <paramref name="source" /> is null.</exception>
  15370. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source)
  15371. {
  15372. if (provider == null)
  15373. throw new ArgumentNullException(nameof(provider));
  15374. if (source == null)
  15375. throw new ArgumentNullException(nameof(source));
  15376. return provider.CreateQuery<TSource>(
  15377. Expression.Call(
  15378. null,
  15379. #if CRIPPLED_REFLECTION
  15380. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>))),
  15381. #else
  15382. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15383. #endif
  15384. Expression.Constant(provider, typeof(IQbservableProvider)),
  15385. GetSourceExpression(source)
  15386. )
  15387. );
  15388. }
  15389. /// <summary>
  15390. /// Converts an enumerable sequence to an observable sequence, using the specified scheduler to run the enumeration loop.
  15391. /// </summary>
  15392. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15393. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15394. /// <param name="source">Enumerable sequence to convert to an observable sequence.</param>
  15395. /// <param name="scheduler">Scheduler to run the enumeration of the input sequence on.</param>
  15396. /// <returns>The observable sequence whose elements are pulled from the given enumerable sequence.</returns>
  15397. /// <exception cref="ArgumentNullException">
  15398. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15399. public static IQbservable<TSource> ToObservable<TSource>(this IQbservableProvider provider, IEnumerable<TSource> source, IScheduler scheduler)
  15400. {
  15401. if (provider == null)
  15402. throw new ArgumentNullException(nameof(provider));
  15403. if (source == null)
  15404. throw new ArgumentNullException(nameof(source));
  15405. if (scheduler == null)
  15406. throw new ArgumentNullException(nameof(scheduler));
  15407. return provider.CreateQuery<TSource>(
  15408. Expression.Call(
  15409. null,
  15410. #if CRIPPLED_REFLECTION
  15411. InfoOf(() => Qbservable.ToObservable<TSource>(default(IQbservableProvider), default(IEnumerable<TSource>), default(IScheduler))),
  15412. #else
  15413. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15414. #endif
  15415. Expression.Constant(provider, typeof(IQbservableProvider)),
  15416. GetSourceExpression(source),
  15417. Expression.Constant(scheduler, typeof(IScheduler))
  15418. )
  15419. );
  15420. }
  15421. /// <summary>
  15422. /// Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime.
  15423. /// </summary>
  15424. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15425. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15426. /// <typeparam name="TResource">The type of the resource used during the generation of the resulting sequence. Needs to implement <see cref="IDisposable" />.</typeparam>
  15427. /// <param name="resourceFactory">Factory function to obtain a resource object.</param>
  15428. /// <param name="observableFactory">Factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15429. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15430. /// <exception cref="ArgumentNullException">
  15431. /// <paramref name="resourceFactory" /> or <paramref name="observableFactory" /> is null.</exception>
  15432. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<TResource>> resourceFactory, Expression<Func<TResource, IObservable<TResult>>> observableFactory)
  15433. where TResource : IDisposable
  15434. {
  15435. if (provider == null)
  15436. throw new ArgumentNullException(nameof(provider));
  15437. if (resourceFactory == null)
  15438. throw new ArgumentNullException(nameof(resourceFactory));
  15439. if (observableFactory == null)
  15440. throw new ArgumentNullException(nameof(observableFactory));
  15441. return provider.CreateQuery<TResult>(
  15442. Expression.Call(
  15443. null,
  15444. #if CRIPPLED_REFLECTION
  15445. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<TResource>>), default(Expression<Func<TResource, IObservable<TResult>>>))),
  15446. #else
  15447. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15448. #endif
  15449. Expression.Constant(provider, typeof(IQbservableProvider)),
  15450. resourceFactory,
  15451. observableFactory
  15452. )
  15453. );
  15454. }
  15455. /// <summary>
  15456. /// 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.
  15457. /// 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.
  15458. /// </summary>
  15459. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15460. /// <typeparam name="TResult">The type of the elements in the produced sequence.</typeparam>
  15461. /// <typeparam name="TResource">The type of the resource used during the generation of the resulting sequence. Needs to implement <see cref="IDisposable" />.</typeparam>
  15462. /// <param name="resourceFactoryAsync">Asynchronous factory function to obtain a resource object.</param>
  15463. /// <param name="observableFactoryAsync">Asynchronous factory function to obtain an observable sequence that depends on the obtained resource.</param>
  15464. /// <returns>An observable sequence whose lifetime controls the lifetime of the dependent resource object.</returns>
  15465. /// <exception cref="ArgumentNullException">
  15466. /// <paramref name="resourceFactoryAsync" /> or <paramref name="observableFactoryAsync" /> is null.</exception>
  15467. /// <remarks>This operator is especially useful in conjunction with the asynchronous programming features introduced in C# 5.0 and Visual Basic 11.</remarks>
  15468. /// <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>
  15469. public static IQbservable<TResult> Using<TResult, TResource>(this IQbservableProvider provider, Expression<Func<CancellationToken, Task<TResource>>> resourceFactoryAsync, Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>> observableFactoryAsync)
  15470. where TResource : IDisposable
  15471. {
  15472. if (provider == null)
  15473. throw new ArgumentNullException(nameof(provider));
  15474. if (resourceFactoryAsync == null)
  15475. throw new ArgumentNullException(nameof(resourceFactoryAsync));
  15476. if (observableFactoryAsync == null)
  15477. throw new ArgumentNullException(nameof(observableFactoryAsync));
  15478. return provider.CreateQuery<TResult>(
  15479. Expression.Call(
  15480. null,
  15481. #if CRIPPLED_REFLECTION
  15482. InfoOf(() => Qbservable.Using<TResult, TResource>(default(IQbservableProvider), default(Expression<Func<CancellationToken, Task<TResource>>>), default(Expression<Func<TResource, CancellationToken, Task<IObservable<TResult>>>>))),
  15483. #else
  15484. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult), typeof(TResource)),
  15485. #endif
  15486. Expression.Constant(provider, typeof(IQbservableProvider)),
  15487. resourceFactoryAsync,
  15488. observableFactoryAsync
  15489. )
  15490. );
  15491. }
  15492. /// <summary>
  15493. /// Filters the elements of an observable sequence based on a predicate.
  15494. /// </summary>
  15495. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15496. /// <param name="source">An observable sequence whose elements to filter.</param>
  15497. /// <param name="predicate">A function to test each source element for a condition.</param>
  15498. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15499. /// <exception cref="ArgumentNullException">
  15500. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15501. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, bool>> predicate)
  15502. {
  15503. if (source == null)
  15504. throw new ArgumentNullException(nameof(source));
  15505. if (predicate == null)
  15506. throw new ArgumentNullException(nameof(predicate));
  15507. return source.Provider.CreateQuery<TSource>(
  15508. Expression.Call(
  15509. null,
  15510. #if CRIPPLED_REFLECTION
  15511. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, bool>>))),
  15512. #else
  15513. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15514. #endif
  15515. source.Expression,
  15516. predicate
  15517. )
  15518. );
  15519. }
  15520. /// <summary>
  15521. /// Filters the elements of an observable sequence based on a predicate by incorporating the element's index.
  15522. /// </summary>
  15523. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15524. /// <param name="source">An observable sequence whose elements to filter.</param>
  15525. /// <param name="predicate">A function to test each source element for a conditio; the second parameter of the function represents the index of the source element.</param>
  15526. /// <returns>An observable sequence that contains elements from the input sequence that satisfy the condition.</returns>
  15527. /// <exception cref="ArgumentNullException">
  15528. /// <paramref name="source" /> or <paramref name="predicate" /> is null.</exception>
  15529. public static IQbservable<TSource> Where<TSource>(this IQbservable<TSource> source, Expression<Func<TSource, int, bool>> predicate)
  15530. {
  15531. if (source == null)
  15532. throw new ArgumentNullException(nameof(source));
  15533. if (predicate == null)
  15534. throw new ArgumentNullException(nameof(predicate));
  15535. return source.Provider.CreateQuery<TSource>(
  15536. Expression.Call(
  15537. null,
  15538. #if CRIPPLED_REFLECTION
  15539. InfoOf(() => Qbservable.Where<TSource>(default(IQbservable<TSource>), default(Expression<Func<TSource, int, bool>>))),
  15540. #else
  15541. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15542. #endif
  15543. source.Expression,
  15544. predicate
  15545. )
  15546. );
  15547. }
  15548. /// <summary>
  15549. /// 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.
  15550. /// </summary>
  15551. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  15552. /// <typeparam name="TSource">The type of the elements in the source sequence.</typeparam>
  15553. /// <param name="source">Source to repeat as long as the <paramref name="condition" /> function evaluates to true.</param>
  15554. /// <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>
  15555. /// <returns>The observable sequence obtained by concatenating the <paramref name="source" /> sequence as long as the <paramref name="condition" /> holds.</returns>
  15556. /// <exception cref="ArgumentNullException">
  15557. /// <paramref name="condition" /> or <paramref name="source" /> is null.</exception>
  15558. public static IQbservable<TSource> While<TSource>(this IQbservableProvider provider, Expression<Func<bool>> condition, IObservable<TSource> source)
  15559. {
  15560. if (provider == null)
  15561. throw new ArgumentNullException(nameof(provider));
  15562. if (condition == null)
  15563. throw new ArgumentNullException(nameof(condition));
  15564. if (source == null)
  15565. throw new ArgumentNullException(nameof(source));
  15566. return provider.CreateQuery<TSource>(
  15567. Expression.Call(
  15568. null,
  15569. #if CRIPPLED_REFLECTION
  15570. InfoOf(() => Qbservable.While<TSource>(default(IQbservableProvider), default(Expression<Func<bool>>), default(IObservable<TSource>))),
  15571. #else
  15572. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15573. #endif
  15574. Expression.Constant(provider, typeof(IQbservableProvider)),
  15575. condition,
  15576. GetSourceExpression(source)
  15577. )
  15578. );
  15579. }
  15580. /// <summary>
  15581. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on element count information.
  15582. /// </summary>
  15583. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15584. /// <param name="source">Source sequence to produce windows over.</param>
  15585. /// <param name="count">Length of each window.</param>
  15586. /// <returns>An observable sequence of windows.</returns>
  15587. /// <exception cref="ArgumentNullException">
  15588. /// <paramref name="source" /> is null.</exception>
  15589. /// <exception cref="ArgumentOutOfRangeException">
  15590. /// <paramref name="count" /> is less than or equal to zero.</exception>
  15591. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count)
  15592. {
  15593. if (source == null)
  15594. throw new ArgumentNullException(nameof(source));
  15595. return source.Provider.CreateQuery<IObservable<TSource>>(
  15596. Expression.Call(
  15597. null,
  15598. #if CRIPPLED_REFLECTION
  15599. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int))),
  15600. #else
  15601. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15602. #endif
  15603. source.Expression,
  15604. Expression.Constant(count, typeof(int))
  15605. )
  15606. );
  15607. }
  15608. /// <summary>
  15609. /// Projects each element of an observable sequence into zero or more windows which are produced based on element count information.
  15610. /// </summary>
  15611. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15612. /// <param name="source">Source sequence to produce windows over.</param>
  15613. /// <param name="count">Length of each window.</param>
  15614. /// <param name="skip">Number of elements to skip between creation of consecutive windows.</param>
  15615. /// <returns>An observable sequence of windows.</returns>
  15616. /// <exception cref="ArgumentNullException">
  15617. /// <paramref name="source" /> is null.</exception>
  15618. /// <exception cref="ArgumentOutOfRangeException">
  15619. /// <paramref name="count" /> or <paramref name="skip" /> is less than or equal to zero.</exception>
  15620. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, int count, int skip)
  15621. {
  15622. if (source == null)
  15623. throw new ArgumentNullException(nameof(source));
  15624. return source.Provider.CreateQuery<IObservable<TSource>>(
  15625. Expression.Call(
  15626. null,
  15627. #if CRIPPLED_REFLECTION
  15628. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(int), default(int))),
  15629. #else
  15630. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15631. #endif
  15632. source.Expression,
  15633. Expression.Constant(count, typeof(int)),
  15634. Expression.Constant(skip, typeof(int))
  15635. )
  15636. );
  15637. }
  15638. /// <summary>
  15639. /// Projects each element of an observable sequence into consecutive non-overlapping windows which are produced based on timing information.
  15640. /// </summary>
  15641. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15642. /// <param name="source">Source sequence to produce windows over.</param>
  15643. /// <param name="timeSpan">Length of each window.</param>
  15644. /// <returns>The sequence of windows.</returns>
  15645. /// <exception cref="ArgumentNullException">
  15646. /// <paramref name="source" /> is null.</exception>
  15647. /// <exception cref="ArgumentOutOfRangeException">
  15648. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15649. /// <remarks>
  15650. /// 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.
  15651. /// 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
  15652. /// 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.
  15653. /// </remarks>
  15654. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan)
  15655. {
  15656. if (source == null)
  15657. throw new ArgumentNullException(nameof(source));
  15658. return source.Provider.CreateQuery<IObservable<TSource>>(
  15659. Expression.Call(
  15660. null,
  15661. #if CRIPPLED_REFLECTION
  15662. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan))),
  15663. #else
  15664. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15665. #endif
  15666. source.Expression,
  15667. Expression.Constant(timeSpan, typeof(TimeSpan))
  15668. )
  15669. );
  15670. }
  15671. /// <summary>
  15672. /// 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.
  15673. /// 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.
  15674. /// </summary>
  15675. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15676. /// <param name="source">Source sequence to produce windows over.</param>
  15677. /// <param name="timeSpan">Maximum time length of a window.</param>
  15678. /// <param name="count">Maximum element count of a window.</param>
  15679. /// <returns>An observable sequence of windows.</returns>
  15680. /// <exception cref="ArgumentNullException">
  15681. /// <paramref name="source" /> is null.</exception>
  15682. /// <exception cref="ArgumentOutOfRangeException">
  15683. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  15684. /// <remarks>
  15685. /// 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.
  15686. /// 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
  15687. /// 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.
  15688. /// </remarks>
  15689. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count)
  15690. {
  15691. if (source == null)
  15692. throw new ArgumentNullException(nameof(source));
  15693. return source.Provider.CreateQuery<IObservable<TSource>>(
  15694. Expression.Call(
  15695. null,
  15696. #if CRIPPLED_REFLECTION
  15697. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int))),
  15698. #else
  15699. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15700. #endif
  15701. source.Expression,
  15702. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15703. Expression.Constant(count, typeof(int))
  15704. )
  15705. );
  15706. }
  15707. /// <summary>
  15708. /// 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.
  15709. /// 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.
  15710. /// </summary>
  15711. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15712. /// <param name="source">Source sequence to produce windows over.</param>
  15713. /// <param name="timeSpan">Maximum time length of a window.</param>
  15714. /// <param name="count">Maximum element count of a window.</param>
  15715. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  15716. /// <returns>An observable sequence of windows.</returns>
  15717. /// <exception cref="ArgumentNullException">
  15718. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15719. /// <exception cref="ArgumentOutOfRangeException">
  15720. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero. -or- <paramref name="count" /> is less than or equal to zero.</exception>
  15721. /// <remarks>
  15722. /// 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.
  15723. /// 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
  15724. /// 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.
  15725. /// </remarks>
  15726. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, int count, IScheduler scheduler)
  15727. {
  15728. if (source == null)
  15729. throw new ArgumentNullException(nameof(source));
  15730. if (scheduler == null)
  15731. throw new ArgumentNullException(nameof(scheduler));
  15732. return source.Provider.CreateQuery<IObservable<TSource>>(
  15733. Expression.Call(
  15734. null,
  15735. #if CRIPPLED_REFLECTION
  15736. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(int), default(IScheduler))),
  15737. #else
  15738. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15739. #endif
  15740. source.Expression,
  15741. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15742. Expression.Constant(count, typeof(int)),
  15743. Expression.Constant(scheduler, typeof(IScheduler))
  15744. )
  15745. );
  15746. }
  15747. /// <summary>
  15748. /// 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.
  15749. /// </summary>
  15750. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15751. /// <param name="source">Source sequence to produce windows over.</param>
  15752. /// <param name="timeSpan">Length of each window.</param>
  15753. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  15754. /// <returns>An observable sequence of windows.</returns>
  15755. /// <exception cref="ArgumentNullException">
  15756. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15757. /// <exception cref="ArgumentOutOfRangeException">
  15758. /// <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15759. /// <remarks>
  15760. /// 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.
  15761. /// 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
  15762. /// 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.
  15763. /// </remarks>
  15764. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, IScheduler scheduler)
  15765. {
  15766. if (source == null)
  15767. throw new ArgumentNullException(nameof(source));
  15768. if (scheduler == null)
  15769. throw new ArgumentNullException(nameof(scheduler));
  15770. return source.Provider.CreateQuery<IObservable<TSource>>(
  15771. Expression.Call(
  15772. null,
  15773. #if CRIPPLED_REFLECTION
  15774. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(IScheduler))),
  15775. #else
  15776. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15777. #endif
  15778. source.Expression,
  15779. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15780. Expression.Constant(scheduler, typeof(IScheduler))
  15781. )
  15782. );
  15783. }
  15784. /// <summary>
  15785. /// Projects each element of an observable sequence into zero or more windows which are produced based on timing information.
  15786. /// </summary>
  15787. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15788. /// <param name="source">Source sequence to produce windows over.</param>
  15789. /// <param name="timeSpan">Length of each window.</param>
  15790. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  15791. /// <returns>An observable sequence of windows.</returns>
  15792. /// <exception cref="ArgumentNullException">
  15793. /// <paramref name="source" /> is null.</exception>
  15794. /// <exception cref="ArgumentOutOfRangeException">
  15795. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15796. /// <remarks>
  15797. /// <para>
  15798. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  15799. /// 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
  15800. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  15801. /// </para>
  15802. /// <para>
  15803. /// 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.
  15804. /// 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,
  15805. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  15806. /// </para>
  15807. /// </remarks>
  15808. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift)
  15809. {
  15810. if (source == null)
  15811. throw new ArgumentNullException(nameof(source));
  15812. return source.Provider.CreateQuery<IObservable<TSource>>(
  15813. Expression.Call(
  15814. null,
  15815. #if CRIPPLED_REFLECTION
  15816. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan))),
  15817. #else
  15818. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15819. #endif
  15820. source.Expression,
  15821. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15822. Expression.Constant(timeShift, typeof(TimeSpan))
  15823. )
  15824. );
  15825. }
  15826. /// <summary>
  15827. /// 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.
  15828. /// </summary>
  15829. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15830. /// <param name="source">Source sequence to produce windows over.</param>
  15831. /// <param name="timeSpan">Length of each window.</param>
  15832. /// <param name="timeShift">Interval between creation of consecutive windows.</param>
  15833. /// <param name="scheduler">Scheduler to run windowing timers on.</param>
  15834. /// <returns>An observable sequence of windows.</returns>
  15835. /// <exception cref="ArgumentNullException">
  15836. /// <paramref name="source" /> or <paramref name="scheduler" /> is null.</exception>
  15837. /// <exception cref="ArgumentOutOfRangeException">
  15838. /// <paramref name="timeSpan" /> or <paramref name="timeSpan" /> is less than TimeSpan.Zero.</exception>
  15839. /// <remarks>
  15840. /// <para>
  15841. /// Specifying a TimeSpan.Zero value for <paramref name="timeSpan" /> is not recommended but supported, causing the scheduler to create windows with minimum duration
  15842. /// 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
  15843. /// current window may not execute immediately, despite the TimeSpan.Zero due time.
  15844. /// </para>
  15845. /// <para>
  15846. /// 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.
  15847. /// 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,
  15848. /// where the action to create a new window may not execute immediately, despite the TimeSpan.Zero due time.
  15849. /// </para>
  15850. /// </remarks>
  15851. public static IQbservable<IObservable<TSource>> Window<TSource>(this IQbservable<TSource> source, TimeSpan timeSpan, TimeSpan timeShift, IScheduler scheduler)
  15852. {
  15853. if (source == null)
  15854. throw new ArgumentNullException(nameof(source));
  15855. if (scheduler == null)
  15856. throw new ArgumentNullException(nameof(scheduler));
  15857. return source.Provider.CreateQuery<IObservable<TSource>>(
  15858. Expression.Call(
  15859. null,
  15860. #if CRIPPLED_REFLECTION
  15861. InfoOf(() => Qbservable.Window<TSource>(default(IQbservable<TSource>), default(TimeSpan), default(TimeSpan), default(IScheduler))),
  15862. #else
  15863. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  15864. #endif
  15865. source.Expression,
  15866. Expression.Constant(timeSpan, typeof(TimeSpan)),
  15867. Expression.Constant(timeShift, typeof(TimeSpan)),
  15868. Expression.Constant(scheduler, typeof(IScheduler))
  15869. )
  15870. );
  15871. }
  15872. /// <summary>
  15873. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  15874. /// </summary>
  15875. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15876. /// <typeparam name="TWindowBoundary">The type of the elements in the sequences indicating window boundary events.</typeparam>
  15877. /// <param name="source">Source sequence to produce windows over.</param>
  15878. /// <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>
  15879. /// <returns>An observable sequence of windows.</returns>
  15880. /// <exception cref="ArgumentNullException">
  15881. /// <paramref name="source" /> or <paramref name="windowBoundaries" /> is null.</exception>
  15882. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowBoundary>(this IQbservable<TSource> source, IObservable<TWindowBoundary> windowBoundaries)
  15883. {
  15884. if (source == null)
  15885. throw new ArgumentNullException(nameof(source));
  15886. if (windowBoundaries == null)
  15887. throw new ArgumentNullException(nameof(windowBoundaries));
  15888. return source.Provider.CreateQuery<IObservable<TSource>>(
  15889. Expression.Call(
  15890. null,
  15891. #if CRIPPLED_REFLECTION
  15892. InfoOf(() => Qbservable.Window<TSource, TWindowBoundary>(default(IQbservable<TSource>), default(IObservable<TWindowBoundary>))),
  15893. #else
  15894. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowBoundary)),
  15895. #endif
  15896. source.Expression,
  15897. GetSourceExpression(windowBoundaries)
  15898. )
  15899. );
  15900. }
  15901. /// <summary>
  15902. /// Projects each element of an observable sequence into consecutive non-overlapping windows.
  15903. /// </summary>
  15904. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15905. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  15906. /// <param name="source">Source sequence to produce windows over.</param>
  15907. /// <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>
  15908. /// <returns>An observable sequence of windows.</returns>
  15909. /// <exception cref="ArgumentNullException">
  15910. /// <paramref name="source" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  15911. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowClosing>(this IQbservable<TSource> source, Expression<Func<IObservable<TWindowClosing>>> windowClosingSelector)
  15912. {
  15913. if (source == null)
  15914. throw new ArgumentNullException(nameof(source));
  15915. if (windowClosingSelector == null)
  15916. throw new ArgumentNullException(nameof(windowClosingSelector));
  15917. return source.Provider.CreateQuery<IObservable<TSource>>(
  15918. Expression.Call(
  15919. null,
  15920. #if CRIPPLED_REFLECTION
  15921. InfoOf(() => Qbservable.Window<TSource, TWindowClosing>(default(IQbservable<TSource>), default(Expression<Func<IObservable<TWindowClosing>>>))),
  15922. #else
  15923. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowClosing)),
  15924. #endif
  15925. source.Expression,
  15926. windowClosingSelector
  15927. )
  15928. );
  15929. }
  15930. /// <summary>
  15931. /// Projects each element of an observable sequence into zero or more windows.
  15932. /// </summary>
  15933. /// <typeparam name="TSource">The type of the elements in the source sequence, and in the windows in the result sequence.</typeparam>
  15934. /// <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>
  15935. /// <typeparam name="TWindowClosing">The type of the elements in the sequences indicating window closing events.</typeparam>
  15936. /// <param name="source">Source sequence to produce windows over.</param>
  15937. /// <param name="windowOpenings">Observable sequence whose elements denote the creation of new windows.</param>
  15938. /// <param name="windowClosingSelector">A function invoked to define the closing of each produced window.</param>
  15939. /// <returns>An observable sequence of windows.</returns>
  15940. /// <exception cref="ArgumentNullException">
  15941. /// <paramref name="source" /> or <paramref name="windowOpenings" /> or <paramref name="windowClosingSelector" /> is null.</exception>
  15942. public static IQbservable<IObservable<TSource>> Window<TSource, TWindowOpening, TWindowClosing>(this IQbservable<TSource> source, IObservable<TWindowOpening> windowOpenings, Expression<Func<TWindowOpening, IObservable<TWindowClosing>>> windowClosingSelector)
  15943. {
  15944. if (source == null)
  15945. throw new ArgumentNullException(nameof(source));
  15946. if (windowOpenings == null)
  15947. throw new ArgumentNullException(nameof(windowOpenings));
  15948. if (windowClosingSelector == null)
  15949. throw new ArgumentNullException(nameof(windowClosingSelector));
  15950. return source.Provider.CreateQuery<IObservable<TSource>>(
  15951. Expression.Call(
  15952. null,
  15953. #if CRIPPLED_REFLECTION
  15954. InfoOf(() => Qbservable.Window<TSource, TWindowOpening, TWindowClosing>(default(IQbservable<TSource>), default(IObservable<TWindowOpening>), default(Expression<Func<TWindowOpening, IObservable<TWindowClosing>>>))),
  15955. #else
  15956. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TWindowOpening), typeof(TWindowClosing)),
  15957. #endif
  15958. source.Expression,
  15959. GetSourceExpression(windowOpenings),
  15960. windowClosingSelector
  15961. )
  15962. );
  15963. }
  15964. /// <summary>
  15965. /// 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.
  15966. /// </summary>
  15967. /// <typeparam name="TFirst">The type of the elements in the first source sequence.</typeparam>
  15968. /// <typeparam name="TSecond">The type of the elements in the second source sequence.</typeparam>
  15969. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  15970. /// <param name="first">First observable source.</param>
  15971. /// <param name="second">Second observable source.</param>
  15972. /// <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>
  15973. /// <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>
  15974. /// <exception cref="ArgumentNullException">
  15975. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  15976. public static IQbservable<TResult> WithLatestFrom<TFirst, TSecond, TResult>(this IQbservable<TFirst> first, IObservable<TSecond> second, Expression<Func<TFirst, TSecond, TResult>> resultSelector)
  15977. {
  15978. if (first == null)
  15979. throw new ArgumentNullException(nameof(first));
  15980. if (second == null)
  15981. throw new ArgumentNullException(nameof(second));
  15982. if (resultSelector == null)
  15983. throw new ArgumentNullException(nameof(resultSelector));
  15984. return first.Provider.CreateQuery<TResult>(
  15985. Expression.Call(
  15986. null,
  15987. #if CRIPPLED_REFLECTION
  15988. InfoOf(() => Qbservable.WithLatestFrom<TFirst, TSecond, TResult>(default(IQbservable<TFirst>), default(IObservable<TSecond>), default(Expression<Func<TFirst, TSecond, TResult>>))),
  15989. #else
  15990. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TFirst), typeof(TSecond), typeof(TResult)),
  15991. #endif
  15992. first.Expression,
  15993. GetSourceExpression(second),
  15994. resultSelector
  15995. )
  15996. );
  15997. }
  15998. /// <summary>
  15999. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  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 sequences, and in the lists in the result sequence.</typeparam>
  16003. /// <param name="sources">Observable sources.</param>
  16004. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16005. /// <exception cref="ArgumentNullException">
  16006. /// <paramref name="sources" /> is null.</exception>
  16007. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources)
  16008. {
  16009. if (provider == null)
  16010. throw new ArgumentNullException(nameof(provider));
  16011. if (sources == null)
  16012. throw new ArgumentNullException(nameof(sources));
  16013. return provider.CreateQuery<IList<TSource>>(
  16014. Expression.Call(
  16015. null,
  16016. #if CRIPPLED_REFLECTION
  16017. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>))),
  16018. #else
  16019. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16020. #endif
  16021. Expression.Constant(provider, typeof(IQbservableProvider)),
  16022. GetSourceExpression(sources)
  16023. )
  16024. );
  16025. }
  16026. /// <summary>
  16027. /// Merges the specified observable sequences into one observable sequence by emitting a list with the elements of the observable sequences at corresponding indexes.
  16028. /// </summary>
  16029. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16030. /// <typeparam name="TSource">The type of the elements in the source sequences, and in the lists in the result sequence.</typeparam>
  16031. /// <param name="sources">Observable sources.</param>
  16032. /// <returns>An observable sequence containing lists of elements at corresponding indexes.</returns>
  16033. /// <exception cref="ArgumentNullException">
  16034. /// <paramref name="sources" /> is null.</exception>
  16035. public static IQbservable<IList<TSource>> Zip<TSource>(this IQbservableProvider provider, params IObservable<TSource>[] sources)
  16036. {
  16037. if (provider == null)
  16038. throw new ArgumentNullException(nameof(provider));
  16039. if (sources == null)
  16040. throw new ArgumentNullException(nameof(sources));
  16041. return provider.CreateQuery<IList<TSource>>(
  16042. Expression.Call(
  16043. null,
  16044. #if CRIPPLED_REFLECTION
  16045. InfoOf(() => Qbservable.Zip<TSource>(default(IQbservableProvider), default(IObservable<TSource>[]))),
  16046. #else
  16047. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource)),
  16048. #endif
  16049. Expression.Constant(provider, typeof(IQbservableProvider)),
  16050. GetSourceExpression(sources)
  16051. )
  16052. );
  16053. }
  16054. /// <summary>
  16055. /// 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.
  16056. /// </summary>
  16057. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  16058. /// <typeparam name="TSource">The type of the elements in the source sequences.</typeparam>
  16059. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16060. /// <param name="sources">Observable sources.</param>
  16061. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16062. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16063. /// <exception cref="ArgumentNullException">
  16064. /// <paramref name="sources" /> or <paramref name="resultSelector" /> is null.</exception>
  16065. public static IQbservable<TResult> Zip<TSource, TResult>(this IQbservableProvider provider, IEnumerable<IObservable<TSource>> sources, Expression<Func<IList<TSource>, TResult>> resultSelector)
  16066. {
  16067. if (provider == null)
  16068. throw new ArgumentNullException(nameof(provider));
  16069. if (sources == null)
  16070. throw new ArgumentNullException(nameof(sources));
  16071. if (resultSelector == null)
  16072. throw new ArgumentNullException(nameof(resultSelector));
  16073. return provider.CreateQuery<TResult>(
  16074. Expression.Call(
  16075. null,
  16076. #if CRIPPLED_REFLECTION
  16077. InfoOf(() => Qbservable.Zip<TSource, TResult>(default(IQbservableProvider), default(IEnumerable<IObservable<TSource>>), default(Expression<Func<IList<TSource>, TResult>>))),
  16078. #else
  16079. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource), typeof(TResult)),
  16080. #endif
  16081. Expression.Constant(provider, typeof(IQbservableProvider)),
  16082. GetSourceExpression(sources),
  16083. resultSelector
  16084. )
  16085. );
  16086. }
  16087. /// <summary>
  16088. /// Merges two observable sequences into one observable sequence by combining their elements in a pairwise fashion.
  16089. /// </summary>
  16090. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16091. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16092. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16093. /// <param name="first">First observable source.</param>
  16094. /// <param name="second">Second observable source.</param>
  16095. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16096. /// <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>
  16097. /// <exception cref="ArgumentNullException">
  16098. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16099. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IObservable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16100. {
  16101. if (first == null)
  16102. throw new ArgumentNullException(nameof(first));
  16103. if (second == null)
  16104. throw new ArgumentNullException(nameof(second));
  16105. if (resultSelector == null)
  16106. throw new ArgumentNullException(nameof(resultSelector));
  16107. return first.Provider.CreateQuery<TResult>(
  16108. Expression.Call(
  16109. null,
  16110. #if CRIPPLED_REFLECTION
  16111. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16112. #else
  16113. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16114. #endif
  16115. first.Expression,
  16116. GetSourceExpression(second),
  16117. resultSelector
  16118. )
  16119. );
  16120. }
  16121. /// <summary>
  16122. /// Merges an observable sequence and an enumerable sequence into one observable sequence by using the selector function.
  16123. /// </summary>
  16124. /// <typeparam name="TSource1">The type of the elements in the first observable source sequence.</typeparam>
  16125. /// <typeparam name="TSource2">The type of the elements in the second enumerable source sequence.</typeparam>
  16126. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16127. /// <param name="first">First observable source.</param>
  16128. /// <param name="second">Second enumerable source.</param>
  16129. /// <param name="resultSelector">Function to invoke for each consecutive pair of elements from the first and second source.</param>
  16130. /// <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>
  16131. /// <exception cref="ArgumentNullException">
  16132. /// <paramref name="first" /> or <paramref name="second" /> or <paramref name="resultSelector" /> is null.</exception>
  16133. public static IQbservable<TResult> Zip<TSource1, TSource2, TResult>(this IQbservable<TSource1> first, IEnumerable<TSource2> second, Expression<Func<TSource1, TSource2, TResult>> resultSelector)
  16134. {
  16135. if (first == null)
  16136. throw new ArgumentNullException(nameof(first));
  16137. if (second == null)
  16138. throw new ArgumentNullException(nameof(second));
  16139. if (resultSelector == null)
  16140. throw new ArgumentNullException(nameof(resultSelector));
  16141. return first.Provider.CreateQuery<TResult>(
  16142. Expression.Call(
  16143. null,
  16144. #if CRIPPLED_REFLECTION
  16145. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TResult>(default(IQbservable<TSource1>), default(IEnumerable<TSource2>), default(Expression<Func<TSource1, TSource2, TResult>>))),
  16146. #else
  16147. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TResult)),
  16148. #endif
  16149. first.Expression,
  16150. GetSourceExpression(second),
  16151. resultSelector
  16152. )
  16153. );
  16154. }
  16155. /// <summary>
  16156. /// 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.
  16157. /// </summary>
  16158. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16159. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16160. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16161. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16162. /// <param name="source1">First observable source.</param>
  16163. /// <param name="source2">Second observable source.</param>
  16164. /// <param name="source3">Third observable source.</param>
  16165. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16166. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16167. /// <exception cref="ArgumentNullException">
  16168. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="resultSelector" /> is null.</exception>
  16169. 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)
  16170. {
  16171. if (source1 == null)
  16172. throw new ArgumentNullException(nameof(source1));
  16173. if (source2 == null)
  16174. throw new ArgumentNullException(nameof(source2));
  16175. if (source3 == null)
  16176. throw new ArgumentNullException(nameof(source3));
  16177. if (resultSelector == null)
  16178. throw new ArgumentNullException(nameof(resultSelector));
  16179. return source1.Provider.CreateQuery<TResult>(
  16180. Expression.Call(
  16181. null,
  16182. #if CRIPPLED_REFLECTION
  16183. InfoOf(() => Qbservable.Zip<TSource1, TSource2, TSource3, TResult>(default(IQbservable<TSource1>), default(IObservable<TSource2>), default(IObservable<TSource3>), default(Expression<Func<TSource1, TSource2, TSource3, TResult>>))),
  16184. #else
  16185. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TResult)),
  16186. #endif
  16187. source1.Expression,
  16188. GetSourceExpression(source2),
  16189. GetSourceExpression(source3),
  16190. resultSelector
  16191. )
  16192. );
  16193. }
  16194. /// <summary>
  16195. /// 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.
  16196. /// </summary>
  16197. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16198. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16199. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16200. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16201. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16202. /// <param name="source1">First observable source.</param>
  16203. /// <param name="source2">Second observable source.</param>
  16204. /// <param name="source3">Third observable source.</param>
  16205. /// <param name="source4">Fourth observable source.</param>
  16206. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16207. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16208. /// <exception cref="ArgumentNullException">
  16209. /// <paramref name="source1" /> or <paramref name="source2" /> or <paramref name="source3" /> or <paramref name="source4" /> or <paramref name="resultSelector" /> is null.</exception>
  16210. 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)
  16211. {
  16212. if (source1 == null)
  16213. throw new ArgumentNullException(nameof(source1));
  16214. if (source2 == null)
  16215. throw new ArgumentNullException(nameof(source2));
  16216. if (source3 == null)
  16217. throw new ArgumentNullException(nameof(source3));
  16218. if (source4 == null)
  16219. throw new ArgumentNullException(nameof(source4));
  16220. if (resultSelector == null)
  16221. throw new ArgumentNullException(nameof(resultSelector));
  16222. return source1.Provider.CreateQuery<TResult>(
  16223. Expression.Call(
  16224. null,
  16225. #if CRIPPLED_REFLECTION
  16226. 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>>))),
  16227. #else
  16228. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TResult)),
  16229. #endif
  16230. source1.Expression,
  16231. GetSourceExpression(source2),
  16232. GetSourceExpression(source3),
  16233. GetSourceExpression(source4),
  16234. resultSelector
  16235. )
  16236. );
  16237. }
  16238. /// <summary>
  16239. /// 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.
  16240. /// </summary>
  16241. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16242. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16243. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16244. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16245. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16246. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16247. /// <param name="source1">First observable source.</param>
  16248. /// <param name="source2">Second observable source.</param>
  16249. /// <param name="source3">Third observable source.</param>
  16250. /// <param name="source4">Fourth observable source.</param>
  16251. /// <param name="source5">Fifth observable source.</param>
  16252. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16253. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16254. /// <exception cref="ArgumentNullException">
  16255. /// <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>
  16256. 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)
  16257. {
  16258. if (source1 == null)
  16259. throw new ArgumentNullException(nameof(source1));
  16260. if (source2 == null)
  16261. throw new ArgumentNullException(nameof(source2));
  16262. if (source3 == null)
  16263. throw new ArgumentNullException(nameof(source3));
  16264. if (source4 == null)
  16265. throw new ArgumentNullException(nameof(source4));
  16266. if (source5 == null)
  16267. throw new ArgumentNullException(nameof(source5));
  16268. if (resultSelector == null)
  16269. throw new ArgumentNullException(nameof(resultSelector));
  16270. return source1.Provider.CreateQuery<TResult>(
  16271. Expression.Call(
  16272. null,
  16273. #if CRIPPLED_REFLECTION
  16274. 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>>))),
  16275. #else
  16276. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TResult)),
  16277. #endif
  16278. source1.Expression,
  16279. GetSourceExpression(source2),
  16280. GetSourceExpression(source3),
  16281. GetSourceExpression(source4),
  16282. GetSourceExpression(source5),
  16283. resultSelector
  16284. )
  16285. );
  16286. }
  16287. /// <summary>
  16288. /// 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.
  16289. /// </summary>
  16290. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16291. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16292. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16293. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16294. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16295. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16296. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16297. /// <param name="source1">First observable source.</param>
  16298. /// <param name="source2">Second observable source.</param>
  16299. /// <param name="source3">Third observable source.</param>
  16300. /// <param name="source4">Fourth observable source.</param>
  16301. /// <param name="source5">Fifth observable source.</param>
  16302. /// <param name="source6">Sixth observable source.</param>
  16303. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16304. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16305. /// <exception cref="ArgumentNullException">
  16306. /// <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>
  16307. 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)
  16308. {
  16309. if (source1 == null)
  16310. throw new ArgumentNullException(nameof(source1));
  16311. if (source2 == null)
  16312. throw new ArgumentNullException(nameof(source2));
  16313. if (source3 == null)
  16314. throw new ArgumentNullException(nameof(source3));
  16315. if (source4 == null)
  16316. throw new ArgumentNullException(nameof(source4));
  16317. if (source5 == null)
  16318. throw new ArgumentNullException(nameof(source5));
  16319. if (source6 == null)
  16320. throw new ArgumentNullException(nameof(source6));
  16321. if (resultSelector == null)
  16322. throw new ArgumentNullException(nameof(resultSelector));
  16323. return source1.Provider.CreateQuery<TResult>(
  16324. Expression.Call(
  16325. null,
  16326. #if CRIPPLED_REFLECTION
  16327. 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>>))),
  16328. #else
  16329. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TResult)),
  16330. #endif
  16331. source1.Expression,
  16332. GetSourceExpression(source2),
  16333. GetSourceExpression(source3),
  16334. GetSourceExpression(source4),
  16335. GetSourceExpression(source5),
  16336. GetSourceExpression(source6),
  16337. resultSelector
  16338. )
  16339. );
  16340. }
  16341. /// <summary>
  16342. /// 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.
  16343. /// </summary>
  16344. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16345. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16346. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16347. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16348. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16349. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16350. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16351. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16352. /// <param name="source1">First observable source.</param>
  16353. /// <param name="source2">Second observable source.</param>
  16354. /// <param name="source3">Third observable source.</param>
  16355. /// <param name="source4">Fourth observable source.</param>
  16356. /// <param name="source5">Fifth observable source.</param>
  16357. /// <param name="source6">Sixth observable source.</param>
  16358. /// <param name="source7">Seventh observable source.</param>
  16359. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16360. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16361. /// <exception cref="ArgumentNullException">
  16362. /// <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>
  16363. 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)
  16364. {
  16365. if (source1 == null)
  16366. throw new ArgumentNullException(nameof(source1));
  16367. if (source2 == null)
  16368. throw new ArgumentNullException(nameof(source2));
  16369. if (source3 == null)
  16370. throw new ArgumentNullException(nameof(source3));
  16371. if (source4 == null)
  16372. throw new ArgumentNullException(nameof(source4));
  16373. if (source5 == null)
  16374. throw new ArgumentNullException(nameof(source5));
  16375. if (source6 == null)
  16376. throw new ArgumentNullException(nameof(source6));
  16377. if (source7 == null)
  16378. throw new ArgumentNullException(nameof(source7));
  16379. if (resultSelector == null)
  16380. throw new ArgumentNullException(nameof(resultSelector));
  16381. return source1.Provider.CreateQuery<TResult>(
  16382. Expression.Call(
  16383. null,
  16384. #if CRIPPLED_REFLECTION
  16385. 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>>))),
  16386. #else
  16387. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TResult)),
  16388. #endif
  16389. source1.Expression,
  16390. GetSourceExpression(source2),
  16391. GetSourceExpression(source3),
  16392. GetSourceExpression(source4),
  16393. GetSourceExpression(source5),
  16394. GetSourceExpression(source6),
  16395. GetSourceExpression(source7),
  16396. resultSelector
  16397. )
  16398. );
  16399. }
  16400. /// <summary>
  16401. /// 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.
  16402. /// </summary>
  16403. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16404. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16405. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16406. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16407. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16408. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16409. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16410. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16411. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16412. /// <param name="source1">First observable source.</param>
  16413. /// <param name="source2">Second observable source.</param>
  16414. /// <param name="source3">Third observable source.</param>
  16415. /// <param name="source4">Fourth observable source.</param>
  16416. /// <param name="source5">Fifth observable source.</param>
  16417. /// <param name="source6">Sixth observable source.</param>
  16418. /// <param name="source7">Seventh observable source.</param>
  16419. /// <param name="source8">Eighth observable source.</param>
  16420. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16421. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16422. /// <exception cref="ArgumentNullException">
  16423. /// <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>
  16424. 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)
  16425. {
  16426. if (source1 == null)
  16427. throw new ArgumentNullException(nameof(source1));
  16428. if (source2 == null)
  16429. throw new ArgumentNullException(nameof(source2));
  16430. if (source3 == null)
  16431. throw new ArgumentNullException(nameof(source3));
  16432. if (source4 == null)
  16433. throw new ArgumentNullException(nameof(source4));
  16434. if (source5 == null)
  16435. throw new ArgumentNullException(nameof(source5));
  16436. if (source6 == null)
  16437. throw new ArgumentNullException(nameof(source6));
  16438. if (source7 == null)
  16439. throw new ArgumentNullException(nameof(source7));
  16440. if (source8 == null)
  16441. throw new ArgumentNullException(nameof(source8));
  16442. if (resultSelector == null)
  16443. throw new ArgumentNullException(nameof(resultSelector));
  16444. return source1.Provider.CreateQuery<TResult>(
  16445. Expression.Call(
  16446. null,
  16447. #if CRIPPLED_REFLECTION
  16448. 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>>))),
  16449. #else
  16450. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TResult)),
  16451. #endif
  16452. source1.Expression,
  16453. GetSourceExpression(source2),
  16454. GetSourceExpression(source3),
  16455. GetSourceExpression(source4),
  16456. GetSourceExpression(source5),
  16457. GetSourceExpression(source6),
  16458. GetSourceExpression(source7),
  16459. GetSourceExpression(source8),
  16460. resultSelector
  16461. )
  16462. );
  16463. }
  16464. /// <summary>
  16465. /// 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.
  16466. /// </summary>
  16467. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16468. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16469. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16470. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16471. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16472. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16473. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16474. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16475. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16476. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16477. /// <param name="source1">First observable source.</param>
  16478. /// <param name="source2">Second observable source.</param>
  16479. /// <param name="source3">Third observable source.</param>
  16480. /// <param name="source4">Fourth observable source.</param>
  16481. /// <param name="source5">Fifth observable source.</param>
  16482. /// <param name="source6">Sixth observable source.</param>
  16483. /// <param name="source7">Seventh observable source.</param>
  16484. /// <param name="source8">Eighth observable source.</param>
  16485. /// <param name="source9">Ninth observable source.</param>
  16486. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16487. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16488. /// <exception cref="ArgumentNullException">
  16489. /// <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>
  16490. 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)
  16491. {
  16492. if (source1 == null)
  16493. throw new ArgumentNullException(nameof(source1));
  16494. if (source2 == null)
  16495. throw new ArgumentNullException(nameof(source2));
  16496. if (source3 == null)
  16497. throw new ArgumentNullException(nameof(source3));
  16498. if (source4 == null)
  16499. throw new ArgumentNullException(nameof(source4));
  16500. if (source5 == null)
  16501. throw new ArgumentNullException(nameof(source5));
  16502. if (source6 == null)
  16503. throw new ArgumentNullException(nameof(source6));
  16504. if (source7 == null)
  16505. throw new ArgumentNullException(nameof(source7));
  16506. if (source8 == null)
  16507. throw new ArgumentNullException(nameof(source8));
  16508. if (source9 == null)
  16509. throw new ArgumentNullException(nameof(source9));
  16510. if (resultSelector == null)
  16511. throw new ArgumentNullException(nameof(resultSelector));
  16512. return source1.Provider.CreateQuery<TResult>(
  16513. Expression.Call(
  16514. null,
  16515. #if CRIPPLED_REFLECTION
  16516. 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>>))),
  16517. #else
  16518. ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TSource1), typeof(TSource2), typeof(TSource3), typeof(TSource4), typeof(TSource5), typeof(TSource6), typeof(TSource7), typeof(TSource8), typeof(TSource9), typeof(TResult)),
  16519. #endif
  16520. source1.Expression,
  16521. GetSourceExpression(source2),
  16522. GetSourceExpression(source3),
  16523. GetSourceExpression(source4),
  16524. GetSourceExpression(source5),
  16525. GetSourceExpression(source6),
  16526. GetSourceExpression(source7),
  16527. GetSourceExpression(source8),
  16528. GetSourceExpression(source9),
  16529. resultSelector
  16530. )
  16531. );
  16532. }
  16533. /// <summary>
  16534. /// 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.
  16535. /// </summary>
  16536. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16537. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16538. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16539. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16540. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16541. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16542. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16543. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16544. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16545. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16546. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16547. /// <param name="source1">First observable source.</param>
  16548. /// <param name="source2">Second observable source.</param>
  16549. /// <param name="source3">Third observable source.</param>
  16550. /// <param name="source4">Fourth observable source.</param>
  16551. /// <param name="source5">Fifth observable source.</param>
  16552. /// <param name="source6">Sixth observable source.</param>
  16553. /// <param name="source7">Seventh observable source.</param>
  16554. /// <param name="source8">Eighth observable source.</param>
  16555. /// <param name="source9">Ninth observable source.</param>
  16556. /// <param name="source10">Tenth observable source.</param>
  16557. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16558. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16559. /// <exception cref="ArgumentNullException">
  16560. /// <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>
  16561. 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)
  16562. {
  16563. if (source1 == null)
  16564. throw new ArgumentNullException(nameof(source1));
  16565. if (source2 == null)
  16566. throw new ArgumentNullException(nameof(source2));
  16567. if (source3 == null)
  16568. throw new ArgumentNullException(nameof(source3));
  16569. if (source4 == null)
  16570. throw new ArgumentNullException(nameof(source4));
  16571. if (source5 == null)
  16572. throw new ArgumentNullException(nameof(source5));
  16573. if (source6 == null)
  16574. throw new ArgumentNullException(nameof(source6));
  16575. if (source7 == null)
  16576. throw new ArgumentNullException(nameof(source7));
  16577. if (source8 == null)
  16578. throw new ArgumentNullException(nameof(source8));
  16579. if (source9 == null)
  16580. throw new ArgumentNullException(nameof(source9));
  16581. if (source10 == null)
  16582. throw new ArgumentNullException(nameof(source10));
  16583. if (resultSelector == null)
  16584. throw new ArgumentNullException(nameof(resultSelector));
  16585. return source1.Provider.CreateQuery<TResult>(
  16586. Expression.Call(
  16587. null,
  16588. #if CRIPPLED_REFLECTION
  16589. 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>>))),
  16590. #else
  16591. ((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)),
  16592. #endif
  16593. source1.Expression,
  16594. GetSourceExpression(source2),
  16595. GetSourceExpression(source3),
  16596. GetSourceExpression(source4),
  16597. GetSourceExpression(source5),
  16598. GetSourceExpression(source6),
  16599. GetSourceExpression(source7),
  16600. GetSourceExpression(source8),
  16601. GetSourceExpression(source9),
  16602. GetSourceExpression(source10),
  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="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16614. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16615. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16616. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16617. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16618. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16619. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16620. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16621. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16622. /// <param name="source1">First observable source.</param>
  16623. /// <param name="source2">Second observable source.</param>
  16624. /// <param name="source3">Third observable source.</param>
  16625. /// <param name="source4">Fourth observable source.</param>
  16626. /// <param name="source5">Fifth observable source.</param>
  16627. /// <param name="source6">Sixth observable source.</param>
  16628. /// <param name="source7">Seventh observable source.</param>
  16629. /// <param name="source8">Eighth observable source.</param>
  16630. /// <param name="source9">Ninth observable source.</param>
  16631. /// <param name="source10">Tenth observable source.</param>
  16632. /// <param name="source11">Eleventh observable source.</param>
  16633. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16634. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16635. /// <exception cref="ArgumentNullException">
  16636. /// <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>
  16637. 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)
  16638. {
  16639. if (source1 == null)
  16640. throw new ArgumentNullException(nameof(source1));
  16641. if (source2 == null)
  16642. throw new ArgumentNullException(nameof(source2));
  16643. if (source3 == null)
  16644. throw new ArgumentNullException(nameof(source3));
  16645. if (source4 == null)
  16646. throw new ArgumentNullException(nameof(source4));
  16647. if (source5 == null)
  16648. throw new ArgumentNullException(nameof(source5));
  16649. if (source6 == null)
  16650. throw new ArgumentNullException(nameof(source6));
  16651. if (source7 == null)
  16652. throw new ArgumentNullException(nameof(source7));
  16653. if (source8 == null)
  16654. throw new ArgumentNullException(nameof(source8));
  16655. if (source9 == null)
  16656. throw new ArgumentNullException(nameof(source9));
  16657. if (source10 == null)
  16658. throw new ArgumentNullException(nameof(source10));
  16659. if (source11 == null)
  16660. throw new ArgumentNullException(nameof(source11));
  16661. if (resultSelector == null)
  16662. throw new ArgumentNullException(nameof(resultSelector));
  16663. return source1.Provider.CreateQuery<TResult>(
  16664. Expression.Call(
  16665. null,
  16666. #if CRIPPLED_REFLECTION
  16667. 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>>))),
  16668. #else
  16669. ((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)),
  16670. #endif
  16671. source1.Expression,
  16672. GetSourceExpression(source2),
  16673. GetSourceExpression(source3),
  16674. GetSourceExpression(source4),
  16675. GetSourceExpression(source5),
  16676. GetSourceExpression(source6),
  16677. GetSourceExpression(source7),
  16678. GetSourceExpression(source8),
  16679. GetSourceExpression(source9),
  16680. GetSourceExpression(source10),
  16681. GetSourceExpression(source11),
  16682. resultSelector
  16683. )
  16684. );
  16685. }
  16686. /// <summary>
  16687. /// 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.
  16688. /// </summary>
  16689. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16690. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16691. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16692. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16693. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16694. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16695. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16696. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16697. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16698. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16699. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16700. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  16701. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16702. /// <param name="source1">First observable source.</param>
  16703. /// <param name="source2">Second observable source.</param>
  16704. /// <param name="source3">Third observable source.</param>
  16705. /// <param name="source4">Fourth observable source.</param>
  16706. /// <param name="source5">Fifth observable source.</param>
  16707. /// <param name="source6">Sixth observable source.</param>
  16708. /// <param name="source7">Seventh observable source.</param>
  16709. /// <param name="source8">Eighth observable source.</param>
  16710. /// <param name="source9">Ninth observable source.</param>
  16711. /// <param name="source10">Tenth observable source.</param>
  16712. /// <param name="source11">Eleventh observable source.</param>
  16713. /// <param name="source12">Twelfth observable source.</param>
  16714. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16715. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16716. /// <exception cref="ArgumentNullException">
  16717. /// <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>
  16718. 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)
  16719. {
  16720. if (source1 == null)
  16721. throw new ArgumentNullException(nameof(source1));
  16722. if (source2 == null)
  16723. throw new ArgumentNullException(nameof(source2));
  16724. if (source3 == null)
  16725. throw new ArgumentNullException(nameof(source3));
  16726. if (source4 == null)
  16727. throw new ArgumentNullException(nameof(source4));
  16728. if (source5 == null)
  16729. throw new ArgumentNullException(nameof(source5));
  16730. if (source6 == null)
  16731. throw new ArgumentNullException(nameof(source6));
  16732. if (source7 == null)
  16733. throw new ArgumentNullException(nameof(source7));
  16734. if (source8 == null)
  16735. throw new ArgumentNullException(nameof(source8));
  16736. if (source9 == null)
  16737. throw new ArgumentNullException(nameof(source9));
  16738. if (source10 == null)
  16739. throw new ArgumentNullException(nameof(source10));
  16740. if (source11 == null)
  16741. throw new ArgumentNullException(nameof(source11));
  16742. if (source12 == null)
  16743. throw new ArgumentNullException(nameof(source12));
  16744. if (resultSelector == null)
  16745. throw new ArgumentNullException(nameof(resultSelector));
  16746. return source1.Provider.CreateQuery<TResult>(
  16747. Expression.Call(
  16748. null,
  16749. #if CRIPPLED_REFLECTION
  16750. 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>>))),
  16751. #else
  16752. ((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)),
  16753. #endif
  16754. source1.Expression,
  16755. GetSourceExpression(source2),
  16756. GetSourceExpression(source3),
  16757. GetSourceExpression(source4),
  16758. GetSourceExpression(source5),
  16759. GetSourceExpression(source6),
  16760. GetSourceExpression(source7),
  16761. GetSourceExpression(source8),
  16762. GetSourceExpression(source9),
  16763. GetSourceExpression(source10),
  16764. GetSourceExpression(source11),
  16765. GetSourceExpression(source12),
  16766. resultSelector
  16767. )
  16768. );
  16769. }
  16770. /// <summary>
  16771. /// 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.
  16772. /// </summary>
  16773. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16774. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16775. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16776. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16777. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16778. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16779. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16780. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16781. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16782. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16783. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16784. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  16785. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  16786. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16787. /// <param name="source1">First observable source.</param>
  16788. /// <param name="source2">Second observable source.</param>
  16789. /// <param name="source3">Third observable source.</param>
  16790. /// <param name="source4">Fourth observable source.</param>
  16791. /// <param name="source5">Fifth observable source.</param>
  16792. /// <param name="source6">Sixth observable source.</param>
  16793. /// <param name="source7">Seventh observable source.</param>
  16794. /// <param name="source8">Eighth observable source.</param>
  16795. /// <param name="source9">Ninth observable source.</param>
  16796. /// <param name="source10">Tenth observable source.</param>
  16797. /// <param name="source11">Eleventh observable source.</param>
  16798. /// <param name="source12">Twelfth observable source.</param>
  16799. /// <param name="source13">Thirteenth observable source.</param>
  16800. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16801. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16802. /// <exception cref="ArgumentNullException">
  16803. /// <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>
  16804. 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)
  16805. {
  16806. if (source1 == null)
  16807. throw new ArgumentNullException(nameof(source1));
  16808. if (source2 == null)
  16809. throw new ArgumentNullException(nameof(source2));
  16810. if (source3 == null)
  16811. throw new ArgumentNullException(nameof(source3));
  16812. if (source4 == null)
  16813. throw new ArgumentNullException(nameof(source4));
  16814. if (source5 == null)
  16815. throw new ArgumentNullException(nameof(source5));
  16816. if (source6 == null)
  16817. throw new ArgumentNullException(nameof(source6));
  16818. if (source7 == null)
  16819. throw new ArgumentNullException(nameof(source7));
  16820. if (source8 == null)
  16821. throw new ArgumentNullException(nameof(source8));
  16822. if (source9 == null)
  16823. throw new ArgumentNullException(nameof(source9));
  16824. if (source10 == null)
  16825. throw new ArgumentNullException(nameof(source10));
  16826. if (source11 == null)
  16827. throw new ArgumentNullException(nameof(source11));
  16828. if (source12 == null)
  16829. throw new ArgumentNullException(nameof(source12));
  16830. if (source13 == null)
  16831. throw new ArgumentNullException(nameof(source13));
  16832. if (resultSelector == null)
  16833. throw new ArgumentNullException(nameof(resultSelector));
  16834. return source1.Provider.CreateQuery<TResult>(
  16835. Expression.Call(
  16836. null,
  16837. #if CRIPPLED_REFLECTION
  16838. 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>>))),
  16839. #else
  16840. ((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)),
  16841. #endif
  16842. source1.Expression,
  16843. GetSourceExpression(source2),
  16844. GetSourceExpression(source3),
  16845. GetSourceExpression(source4),
  16846. GetSourceExpression(source5),
  16847. GetSourceExpression(source6),
  16848. GetSourceExpression(source7),
  16849. GetSourceExpression(source8),
  16850. GetSourceExpression(source9),
  16851. GetSourceExpression(source10),
  16852. GetSourceExpression(source11),
  16853. GetSourceExpression(source12),
  16854. GetSourceExpression(source13),
  16855. resultSelector
  16856. )
  16857. );
  16858. }
  16859. /// <summary>
  16860. /// 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.
  16861. /// </summary>
  16862. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16863. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16864. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16865. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16866. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16867. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16868. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16869. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16870. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16871. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16872. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16873. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  16874. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  16875. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  16876. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16877. /// <param name="source1">First observable source.</param>
  16878. /// <param name="source2">Second observable source.</param>
  16879. /// <param name="source3">Third observable source.</param>
  16880. /// <param name="source4">Fourth observable source.</param>
  16881. /// <param name="source5">Fifth observable source.</param>
  16882. /// <param name="source6">Sixth observable source.</param>
  16883. /// <param name="source7">Seventh observable source.</param>
  16884. /// <param name="source8">Eighth observable source.</param>
  16885. /// <param name="source9">Ninth observable source.</param>
  16886. /// <param name="source10">Tenth observable source.</param>
  16887. /// <param name="source11">Eleventh observable source.</param>
  16888. /// <param name="source12">Twelfth observable source.</param>
  16889. /// <param name="source13">Thirteenth observable source.</param>
  16890. /// <param name="source14">Fourteenth observable source.</param>
  16891. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16892. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16893. /// <exception cref="ArgumentNullException">
  16894. /// <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>
  16895. 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)
  16896. {
  16897. if (source1 == null)
  16898. throw new ArgumentNullException(nameof(source1));
  16899. if (source2 == null)
  16900. throw new ArgumentNullException(nameof(source2));
  16901. if (source3 == null)
  16902. throw new ArgumentNullException(nameof(source3));
  16903. if (source4 == null)
  16904. throw new ArgumentNullException(nameof(source4));
  16905. if (source5 == null)
  16906. throw new ArgumentNullException(nameof(source5));
  16907. if (source6 == null)
  16908. throw new ArgumentNullException(nameof(source6));
  16909. if (source7 == null)
  16910. throw new ArgumentNullException(nameof(source7));
  16911. if (source8 == null)
  16912. throw new ArgumentNullException(nameof(source8));
  16913. if (source9 == null)
  16914. throw new ArgumentNullException(nameof(source9));
  16915. if (source10 == null)
  16916. throw new ArgumentNullException(nameof(source10));
  16917. if (source11 == null)
  16918. throw new ArgumentNullException(nameof(source11));
  16919. if (source12 == null)
  16920. throw new ArgumentNullException(nameof(source12));
  16921. if (source13 == null)
  16922. throw new ArgumentNullException(nameof(source13));
  16923. if (source14 == null)
  16924. throw new ArgumentNullException(nameof(source14));
  16925. if (resultSelector == null)
  16926. throw new ArgumentNullException(nameof(resultSelector));
  16927. return source1.Provider.CreateQuery<TResult>(
  16928. Expression.Call(
  16929. null,
  16930. #if CRIPPLED_REFLECTION
  16931. 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>>))),
  16932. #else
  16933. ((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)),
  16934. #endif
  16935. source1.Expression,
  16936. GetSourceExpression(source2),
  16937. GetSourceExpression(source3),
  16938. GetSourceExpression(source4),
  16939. GetSourceExpression(source5),
  16940. GetSourceExpression(source6),
  16941. GetSourceExpression(source7),
  16942. GetSourceExpression(source8),
  16943. GetSourceExpression(source9),
  16944. GetSourceExpression(source10),
  16945. GetSourceExpression(source11),
  16946. GetSourceExpression(source12),
  16947. GetSourceExpression(source13),
  16948. GetSourceExpression(source14),
  16949. resultSelector
  16950. )
  16951. );
  16952. }
  16953. /// <summary>
  16954. /// 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.
  16955. /// </summary>
  16956. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  16957. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  16958. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  16959. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  16960. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  16961. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  16962. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  16963. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  16964. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  16965. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  16966. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  16967. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  16968. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  16969. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  16970. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  16971. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  16972. /// <param name="source1">First observable source.</param>
  16973. /// <param name="source2">Second observable source.</param>
  16974. /// <param name="source3">Third observable source.</param>
  16975. /// <param name="source4">Fourth observable source.</param>
  16976. /// <param name="source5">Fifth observable source.</param>
  16977. /// <param name="source6">Sixth observable source.</param>
  16978. /// <param name="source7">Seventh observable source.</param>
  16979. /// <param name="source8">Eighth observable source.</param>
  16980. /// <param name="source9">Ninth observable source.</param>
  16981. /// <param name="source10">Tenth observable source.</param>
  16982. /// <param name="source11">Eleventh observable source.</param>
  16983. /// <param name="source12">Twelfth observable source.</param>
  16984. /// <param name="source13">Thirteenth observable source.</param>
  16985. /// <param name="source14">Fourteenth observable source.</param>
  16986. /// <param name="source15">Fifteenth observable source.</param>
  16987. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  16988. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  16989. /// <exception cref="ArgumentNullException">
  16990. /// <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>
  16991. 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)
  16992. {
  16993. if (source1 == null)
  16994. throw new ArgumentNullException(nameof(source1));
  16995. if (source2 == null)
  16996. throw new ArgumentNullException(nameof(source2));
  16997. if (source3 == null)
  16998. throw new ArgumentNullException(nameof(source3));
  16999. if (source4 == null)
  17000. throw new ArgumentNullException(nameof(source4));
  17001. if (source5 == null)
  17002. throw new ArgumentNullException(nameof(source5));
  17003. if (source6 == null)
  17004. throw new ArgumentNullException(nameof(source6));
  17005. if (source7 == null)
  17006. throw new ArgumentNullException(nameof(source7));
  17007. if (source8 == null)
  17008. throw new ArgumentNullException(nameof(source8));
  17009. if (source9 == null)
  17010. throw new ArgumentNullException(nameof(source9));
  17011. if (source10 == null)
  17012. throw new ArgumentNullException(nameof(source10));
  17013. if (source11 == null)
  17014. throw new ArgumentNullException(nameof(source11));
  17015. if (source12 == null)
  17016. throw new ArgumentNullException(nameof(source12));
  17017. if (source13 == null)
  17018. throw new ArgumentNullException(nameof(source13));
  17019. if (source14 == null)
  17020. throw new ArgumentNullException(nameof(source14));
  17021. if (source15 == null)
  17022. throw new ArgumentNullException(nameof(source15));
  17023. if (resultSelector == null)
  17024. throw new ArgumentNullException(nameof(resultSelector));
  17025. return source1.Provider.CreateQuery<TResult>(
  17026. Expression.Call(
  17027. null,
  17028. #if CRIPPLED_REFLECTION
  17029. 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>>))),
  17030. #else
  17031. ((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)),
  17032. #endif
  17033. source1.Expression,
  17034. GetSourceExpression(source2),
  17035. GetSourceExpression(source3),
  17036. GetSourceExpression(source4),
  17037. GetSourceExpression(source5),
  17038. GetSourceExpression(source6),
  17039. GetSourceExpression(source7),
  17040. GetSourceExpression(source8),
  17041. GetSourceExpression(source9),
  17042. GetSourceExpression(source10),
  17043. GetSourceExpression(source11),
  17044. GetSourceExpression(source12),
  17045. GetSourceExpression(source13),
  17046. GetSourceExpression(source14),
  17047. GetSourceExpression(source15),
  17048. resultSelector
  17049. )
  17050. );
  17051. }
  17052. /// <summary>
  17053. /// 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.
  17054. /// </summary>
  17055. /// <typeparam name="TSource1">The type of the elements in the first source sequence.</typeparam>
  17056. /// <typeparam name="TSource2">The type of the elements in the second source sequence.</typeparam>
  17057. /// <typeparam name="TSource3">The type of the elements in the third source sequence.</typeparam>
  17058. /// <typeparam name="TSource4">The type of the elements in the fourth source sequence.</typeparam>
  17059. /// <typeparam name="TSource5">The type of the elements in the fifth source sequence.</typeparam>
  17060. /// <typeparam name="TSource6">The type of the elements in the sixth source sequence.</typeparam>
  17061. /// <typeparam name="TSource7">The type of the elements in the seventh source sequence.</typeparam>
  17062. /// <typeparam name="TSource8">The type of the elements in the eighth source sequence.</typeparam>
  17063. /// <typeparam name="TSource9">The type of the elements in the ninth source sequence.</typeparam>
  17064. /// <typeparam name="TSource10">The type of the elements in the tenth source sequence.</typeparam>
  17065. /// <typeparam name="TSource11">The type of the elements in the eleventh source sequence.</typeparam>
  17066. /// <typeparam name="TSource12">The type of the elements in the twelfth source sequence.</typeparam>
  17067. /// <typeparam name="TSource13">The type of the elements in the thirteenth source sequence.</typeparam>
  17068. /// <typeparam name="TSource14">The type of the elements in the fourteenth source sequence.</typeparam>
  17069. /// <typeparam name="TSource15">The type of the elements in the fifteenth source sequence.</typeparam>
  17070. /// <typeparam name="TSource16">The type of the elements in the sixteenth source sequence.</typeparam>
  17071. /// <typeparam name="TResult">The type of the elements in the result sequence, returned by the selector function.</typeparam>
  17072. /// <param name="source1">First observable source.</param>
  17073. /// <param name="source2">Second observable source.</param>
  17074. /// <param name="source3">Third observable source.</param>
  17075. /// <param name="source4">Fourth observable source.</param>
  17076. /// <param name="source5">Fifth observable source.</param>
  17077. /// <param name="source6">Sixth observable source.</param>
  17078. /// <param name="source7">Seventh observable source.</param>
  17079. /// <param name="source8">Eighth observable source.</param>
  17080. /// <param name="source9">Ninth observable source.</param>
  17081. /// <param name="source10">Tenth observable source.</param>
  17082. /// <param name="source11">Eleventh observable source.</param>
  17083. /// <param name="source12">Twelfth observable source.</param>
  17084. /// <param name="source13">Thirteenth observable source.</param>
  17085. /// <param name="source14">Fourteenth observable source.</param>
  17086. /// <param name="source15">Fifteenth observable source.</param>
  17087. /// <param name="source16">Sixteenth observable source.</param>
  17088. /// <param name="resultSelector">Function to invoke for each series of elements at corresponding indexes in the sources.</param>
  17089. /// <returns>An observable sequence containing the result of combining elements of the sources using the specified result selector function.</returns>
  17090. /// <exception cref="ArgumentNullException">
  17091. /// <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>
  17092. 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)
  17093. {
  17094. if (source1 == null)
  17095. throw new ArgumentNullException(nameof(source1));
  17096. if (source2 == null)
  17097. throw new ArgumentNullException(nameof(source2));
  17098. if (source3 == null)
  17099. throw new ArgumentNullException(nameof(source3));
  17100. if (source4 == null)
  17101. throw new ArgumentNullException(nameof(source4));
  17102. if (source5 == null)
  17103. throw new ArgumentNullException(nameof(source5));
  17104. if (source6 == null)
  17105. throw new ArgumentNullException(nameof(source6));
  17106. if (source7 == null)
  17107. throw new ArgumentNullException(nameof(source7));
  17108. if (source8 == null)
  17109. throw new ArgumentNullException(nameof(source8));
  17110. if (source9 == null)
  17111. throw new ArgumentNullException(nameof(source9));
  17112. if (source10 == null)
  17113. throw new ArgumentNullException(nameof(source10));
  17114. if (source11 == null)
  17115. throw new ArgumentNullException(nameof(source11));
  17116. if (source12 == null)
  17117. throw new ArgumentNullException(nameof(source12));
  17118. if (source13 == null)
  17119. throw new ArgumentNullException(nameof(source13));
  17120. if (source14 == null)
  17121. throw new ArgumentNullException(nameof(source14));
  17122. if (source15 == null)
  17123. throw new ArgumentNullException(nameof(source15));
  17124. if (source16 == null)
  17125. throw new ArgumentNullException(nameof(source16));
  17126. if (resultSelector == null)
  17127. throw new ArgumentNullException(nameof(resultSelector));
  17128. return source1.Provider.CreateQuery<TResult>(
  17129. Expression.Call(
  17130. null,
  17131. #if CRIPPLED_REFLECTION
  17132. 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>>))),
  17133. #else
  17134. ((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)),
  17135. #endif
  17136. source1.Expression,
  17137. GetSourceExpression(source2),
  17138. GetSourceExpression(source3),
  17139. GetSourceExpression(source4),
  17140. GetSourceExpression(source5),
  17141. GetSourceExpression(source6),
  17142. GetSourceExpression(source7),
  17143. GetSourceExpression(source8),
  17144. GetSourceExpression(source9),
  17145. GetSourceExpression(source10),
  17146. GetSourceExpression(source11),
  17147. GetSourceExpression(source12),
  17148. GetSourceExpression(source13),
  17149. GetSourceExpression(source14),
  17150. GetSourceExpression(source15),
  17151. GetSourceExpression(source16),
  17152. resultSelector
  17153. )
  17154. );
  17155. }
  17156. /// <summary>
  17157. /// 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.
  17158. /// </summary>
  17159. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17160. /// <param name="action">Action to convert to an asynchronous action.</param>
  17161. /// <returns>Asynchronous action.</returns>
  17162. /// <exception cref="ArgumentNullException">
  17163. /// <paramref name="action" /> is null.</exception>
  17164. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action)
  17165. {
  17166. if (provider == null)
  17167. throw new ArgumentNullException(nameof(provider));
  17168. if (action == null)
  17169. throw new ArgumentNullException(nameof(action));
  17170. #if CRIPPLED_REFLECTION
  17171. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>)));
  17172. #else
  17173. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17174. #endif
  17175. return () => provider.CreateQuery<Unit>(
  17176. Expression.Invoke(
  17177. Expression.Call(
  17178. null,
  17179. m,
  17180. Expression.Constant(provider, typeof(IQbservableProvider)),
  17181. action
  17182. )
  17183. )
  17184. );
  17185. }
  17186. /// <summary>
  17187. /// 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.
  17188. /// </summary>
  17189. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17190. /// <param name="action">Action to convert to an asynchronous action.</param>
  17191. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17192. /// <returns>Asynchronous action.</returns>
  17193. /// <exception cref="ArgumentNullException">
  17194. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17195. public static Func<IQbservable<Unit>> ToAsync(this IQbservableProvider provider, Expression<Action> action, IScheduler scheduler)
  17196. {
  17197. if (provider == null)
  17198. throw new ArgumentNullException(nameof(provider));
  17199. if (action == null)
  17200. throw new ArgumentNullException(nameof(action));
  17201. if (scheduler == null)
  17202. throw new ArgumentNullException(nameof(scheduler));
  17203. #if CRIPPLED_REFLECTION
  17204. var m = InfoOf(() => Qbservable.ToAsync(default(IQbservableProvider), default(Expression<Action>), default(IScheduler)));
  17205. #else
  17206. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  17207. #endif
  17208. return () => provider.CreateQuery<Unit>(
  17209. Expression.Invoke(
  17210. Expression.Call(
  17211. null,
  17212. m,
  17213. Expression.Constant(provider, typeof(IQbservableProvider)),
  17214. action,
  17215. Expression.Constant(scheduler, typeof(IScheduler))
  17216. )
  17217. )
  17218. );
  17219. }
  17220. /// <summary>
  17221. /// 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.
  17222. /// </summary>
  17223. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17224. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17225. /// <param name="action">Action to convert to an asynchronous action.</param>
  17226. /// <returns>Asynchronous action.</returns>
  17227. /// <exception cref="ArgumentNullException">
  17228. /// <paramref name="action" /> is null.</exception>
  17229. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action)
  17230. {
  17231. if (provider == null)
  17232. throw new ArgumentNullException(nameof(provider));
  17233. if (action == null)
  17234. throw new ArgumentNullException(nameof(action));
  17235. #if CRIPPLED_REFLECTION
  17236. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>)));
  17237. #else
  17238. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17239. #endif
  17240. return (t1) => provider.CreateQuery<Unit>(
  17241. Expression.Invoke(
  17242. Expression.Call(
  17243. null,
  17244. m,
  17245. Expression.Constant(provider, typeof(IQbservableProvider)),
  17246. action
  17247. ),
  17248. Expression.Constant(t1, typeof(TArg1))
  17249. )
  17250. );
  17251. }
  17252. /// <summary>
  17253. /// 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.
  17254. /// </summary>
  17255. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17256. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17257. /// <param name="action">Action to convert to an asynchronous action.</param>
  17258. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17259. /// <returns>Asynchronous action.</returns>
  17260. /// <exception cref="ArgumentNullException">
  17261. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17262. public static Func<TArg1, IQbservable<Unit>> ToAsync<TArg1>(this IQbservableProvider provider, Expression<Action<TArg1>> action, IScheduler scheduler)
  17263. {
  17264. if (provider == null)
  17265. throw new ArgumentNullException(nameof(provider));
  17266. if (action == null)
  17267. throw new ArgumentNullException(nameof(action));
  17268. if (scheduler == null)
  17269. throw new ArgumentNullException(nameof(scheduler));
  17270. #if CRIPPLED_REFLECTION
  17271. var m = InfoOf(() => Qbservable.ToAsync<TArg1>(default(IQbservableProvider), default(Expression<Action<TArg1>>), default(IScheduler)));
  17272. #else
  17273. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  17274. #endif
  17275. return (t1) => provider.CreateQuery<Unit>(
  17276. Expression.Invoke(
  17277. Expression.Call(
  17278. null,
  17279. m,
  17280. Expression.Constant(provider, typeof(IQbservableProvider)),
  17281. action,
  17282. Expression.Constant(scheduler, typeof(IScheduler))
  17283. ),
  17284. Expression.Constant(t1, typeof(TArg1))
  17285. )
  17286. );
  17287. }
  17288. /// <summary>
  17289. /// 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.
  17290. /// </summary>
  17291. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17292. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17293. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17294. /// <param name="action">Action to convert to an asynchronous action.</param>
  17295. /// <returns>Asynchronous action.</returns>
  17296. /// <exception cref="ArgumentNullException">
  17297. /// <paramref name="action" /> is null.</exception>
  17298. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action)
  17299. {
  17300. if (provider == null)
  17301. throw new ArgumentNullException(nameof(provider));
  17302. if (action == null)
  17303. throw new ArgumentNullException(nameof(action));
  17304. #if CRIPPLED_REFLECTION
  17305. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>)));
  17306. #else
  17307. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17308. #endif
  17309. return (t1, t2) => provider.CreateQuery<Unit>(
  17310. Expression.Invoke(
  17311. Expression.Call(
  17312. null,
  17313. m,
  17314. Expression.Constant(provider, typeof(IQbservableProvider)),
  17315. action
  17316. ),
  17317. Expression.Constant(t1, typeof(TArg1)),
  17318. Expression.Constant(t2, typeof(TArg2))
  17319. )
  17320. );
  17321. }
  17322. /// <summary>
  17323. /// 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.
  17324. /// </summary>
  17325. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17326. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17327. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17328. /// <param name="action">Action to convert to an asynchronous action.</param>
  17329. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17330. /// <returns>Asynchronous action.</returns>
  17331. /// <exception cref="ArgumentNullException">
  17332. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17333. public static Func<TArg1, TArg2, IQbservable<Unit>> ToAsync<TArg1, TArg2>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2>> action, IScheduler scheduler)
  17334. {
  17335. if (provider == null)
  17336. throw new ArgumentNullException(nameof(provider));
  17337. if (action == null)
  17338. throw new ArgumentNullException(nameof(action));
  17339. if (scheduler == null)
  17340. throw new ArgumentNullException(nameof(scheduler));
  17341. #if CRIPPLED_REFLECTION
  17342. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2>>), default(IScheduler)));
  17343. #else
  17344. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  17345. #endif
  17346. return (t1, t2) => provider.CreateQuery<Unit>(
  17347. Expression.Invoke(
  17348. Expression.Call(
  17349. null,
  17350. m,
  17351. Expression.Constant(provider, typeof(IQbservableProvider)),
  17352. action,
  17353. Expression.Constant(scheduler, typeof(IScheduler))
  17354. ),
  17355. Expression.Constant(t1, typeof(TArg1)),
  17356. Expression.Constant(t2, typeof(TArg2))
  17357. )
  17358. );
  17359. }
  17360. /// <summary>
  17361. /// 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.
  17362. /// </summary>
  17363. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17364. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17365. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17366. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17367. /// <param name="action">Action to convert to an asynchronous action.</param>
  17368. /// <returns>Asynchronous action.</returns>
  17369. /// <exception cref="ArgumentNullException">
  17370. /// <paramref name="action" /> is null.</exception>
  17371. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action)
  17372. {
  17373. if (provider == null)
  17374. throw new ArgumentNullException(nameof(provider));
  17375. if (action == null)
  17376. throw new ArgumentNullException(nameof(action));
  17377. #if CRIPPLED_REFLECTION
  17378. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>)));
  17379. #else
  17380. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17381. #endif
  17382. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17383. Expression.Invoke(
  17384. Expression.Call(
  17385. null,
  17386. m,
  17387. Expression.Constant(provider, typeof(IQbservableProvider)),
  17388. action
  17389. ),
  17390. Expression.Constant(t1, typeof(TArg1)),
  17391. Expression.Constant(t2, typeof(TArg2)),
  17392. Expression.Constant(t3, typeof(TArg3))
  17393. )
  17394. );
  17395. }
  17396. /// <summary>
  17397. /// 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.
  17398. /// </summary>
  17399. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17400. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17401. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17402. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17403. /// <param name="action">Action to convert to an asynchronous action.</param>
  17404. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17405. /// <returns>Asynchronous action.</returns>
  17406. /// <exception cref="ArgumentNullException">
  17407. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17408. public static Func<TArg1, TArg2, TArg3, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3>> action, IScheduler scheduler)
  17409. {
  17410. if (provider == null)
  17411. throw new ArgumentNullException(nameof(provider));
  17412. if (action == null)
  17413. throw new ArgumentNullException(nameof(action));
  17414. if (scheduler == null)
  17415. throw new ArgumentNullException(nameof(scheduler));
  17416. #if CRIPPLED_REFLECTION
  17417. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3>>), default(IScheduler)));
  17418. #else
  17419. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  17420. #endif
  17421. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  17422. Expression.Invoke(
  17423. Expression.Call(
  17424. null,
  17425. m,
  17426. Expression.Constant(provider, typeof(IQbservableProvider)),
  17427. action,
  17428. Expression.Constant(scheduler, typeof(IScheduler))
  17429. ),
  17430. Expression.Constant(t1, typeof(TArg1)),
  17431. Expression.Constant(t2, typeof(TArg2)),
  17432. Expression.Constant(t3, typeof(TArg3))
  17433. )
  17434. );
  17435. }
  17436. /// <summary>
  17437. /// 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.
  17438. /// </summary>
  17439. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17440. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17441. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17442. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17443. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17444. /// <param name="action">Action to convert to an asynchronous action.</param>
  17445. /// <returns>Asynchronous action.</returns>
  17446. /// <exception cref="ArgumentNullException">
  17447. /// <paramref name="action" /> is null.</exception>
  17448. public static Func<TArg1, TArg2, TArg3, TArg4, IQbservable<Unit>> ToAsync<TArg1, TArg2, TArg3, TArg4>(this IQbservableProvider provider, Expression<Action<TArg1, TArg2, TArg3, TArg4>> action)
  17449. {
  17450. if (provider == null)
  17451. throw new ArgumentNullException(nameof(provider));
  17452. if (action == null)
  17453. throw new ArgumentNullException(nameof(action));
  17454. #if CRIPPLED_REFLECTION
  17455. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>)));
  17456. #else
  17457. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17458. #endif
  17459. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17460. Expression.Invoke(
  17461. Expression.Call(
  17462. null,
  17463. m,
  17464. Expression.Constant(provider, typeof(IQbservableProvider)),
  17465. action
  17466. ),
  17467. Expression.Constant(t1, typeof(TArg1)),
  17468. Expression.Constant(t2, typeof(TArg2)),
  17469. Expression.Constant(t3, typeof(TArg3)),
  17470. Expression.Constant(t4, typeof(TArg4))
  17471. )
  17472. );
  17473. }
  17474. /// <summary>
  17475. /// 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.
  17476. /// </summary>
  17477. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17478. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17479. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17480. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17481. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17482. /// <param name="action">Action to convert to an asynchronous action.</param>
  17483. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17484. /// <returns>Asynchronous action.</returns>
  17485. /// <exception cref="ArgumentNullException">
  17486. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17487. 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)
  17488. {
  17489. if (provider == null)
  17490. throw new ArgumentNullException(nameof(provider));
  17491. if (action == null)
  17492. throw new ArgumentNullException(nameof(action));
  17493. if (scheduler == null)
  17494. throw new ArgumentNullException(nameof(scheduler));
  17495. #if CRIPPLED_REFLECTION
  17496. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4>>), default(IScheduler)));
  17497. #else
  17498. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  17499. #endif
  17500. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  17501. Expression.Invoke(
  17502. Expression.Call(
  17503. null,
  17504. m,
  17505. Expression.Constant(provider, typeof(IQbservableProvider)),
  17506. action,
  17507. Expression.Constant(scheduler, typeof(IScheduler))
  17508. ),
  17509. Expression.Constant(t1, typeof(TArg1)),
  17510. Expression.Constant(t2, typeof(TArg2)),
  17511. Expression.Constant(t3, typeof(TArg3)),
  17512. Expression.Constant(t4, typeof(TArg4))
  17513. )
  17514. );
  17515. }
  17516. /// <summary>
  17517. /// 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.
  17518. /// </summary>
  17519. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17520. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17521. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17522. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17523. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17524. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17525. /// <param name="action">Action to convert to an asynchronous action.</param>
  17526. /// <returns>Asynchronous action.</returns>
  17527. /// <exception cref="ArgumentNullException">
  17528. /// <paramref name="action" /> is null.</exception>
  17529. 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)
  17530. {
  17531. if (provider == null)
  17532. throw new ArgumentNullException(nameof(provider));
  17533. if (action == null)
  17534. throw new ArgumentNullException(nameof(action));
  17535. #if CRIPPLED_REFLECTION
  17536. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>)));
  17537. #else
  17538. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  17539. #endif
  17540. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  17541. Expression.Invoke(
  17542. Expression.Call(
  17543. null,
  17544. m,
  17545. Expression.Constant(provider, typeof(IQbservableProvider)),
  17546. action
  17547. ),
  17548. Expression.Constant(t1, typeof(TArg1)),
  17549. Expression.Constant(t2, typeof(TArg2)),
  17550. Expression.Constant(t3, typeof(TArg3)),
  17551. Expression.Constant(t4, typeof(TArg4)),
  17552. Expression.Constant(t5, typeof(TArg5))
  17553. )
  17554. );
  17555. }
  17556. /// <summary>
  17557. /// 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.
  17558. /// </summary>
  17559. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17560. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17561. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17562. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17563. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17564. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17565. /// <param name="action">Action to convert to an asynchronous action.</param>
  17566. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17567. /// <returns>Asynchronous action.</returns>
  17568. /// <exception cref="ArgumentNullException">
  17569. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17570. 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)
  17571. {
  17572. if (provider == null)
  17573. throw new ArgumentNullException(nameof(provider));
  17574. if (action == null)
  17575. throw new ArgumentNullException(nameof(action));
  17576. if (scheduler == null)
  17577. throw new ArgumentNullException(nameof(scheduler));
  17578. #if CRIPPLED_REFLECTION
  17579. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5>>), default(IScheduler)));
  17580. #else
  17581. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  17582. #endif
  17583. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  17584. Expression.Invoke(
  17585. Expression.Call(
  17586. null,
  17587. m,
  17588. Expression.Constant(provider, typeof(IQbservableProvider)),
  17589. action,
  17590. Expression.Constant(scheduler, typeof(IScheduler))
  17591. ),
  17592. Expression.Constant(t1, typeof(TArg1)),
  17593. Expression.Constant(t2, typeof(TArg2)),
  17594. Expression.Constant(t3, typeof(TArg3)),
  17595. Expression.Constant(t4, typeof(TArg4)),
  17596. Expression.Constant(t5, typeof(TArg5))
  17597. )
  17598. );
  17599. }
  17600. /// <summary>
  17601. /// 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.
  17602. /// </summary>
  17603. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17604. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17605. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17606. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17607. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17608. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17609. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17610. /// <param name="action">Action to convert to an asynchronous action.</param>
  17611. /// <returns>Asynchronous action.</returns>
  17612. /// <exception cref="ArgumentNullException">
  17613. /// <paramref name="action" /> is null.</exception>
  17614. 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)
  17615. {
  17616. if (provider == null)
  17617. throw new ArgumentNullException(nameof(provider));
  17618. if (action == null)
  17619. throw new ArgumentNullException(nameof(action));
  17620. #if CRIPPLED_REFLECTION
  17621. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>)));
  17622. #else
  17623. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  17624. #endif
  17625. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  17626. Expression.Invoke(
  17627. Expression.Call(
  17628. null,
  17629. m,
  17630. Expression.Constant(provider, typeof(IQbservableProvider)),
  17631. action
  17632. ),
  17633. Expression.Constant(t1, typeof(TArg1)),
  17634. Expression.Constant(t2, typeof(TArg2)),
  17635. Expression.Constant(t3, typeof(TArg3)),
  17636. Expression.Constant(t4, typeof(TArg4)),
  17637. Expression.Constant(t5, typeof(TArg5)),
  17638. Expression.Constant(t6, typeof(TArg6))
  17639. )
  17640. );
  17641. }
  17642. /// <summary>
  17643. /// 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.
  17644. /// </summary>
  17645. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17646. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17647. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17648. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17649. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17650. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17651. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17652. /// <param name="action">Action to convert to an asynchronous action.</param>
  17653. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17654. /// <returns>Asynchronous action.</returns>
  17655. /// <exception cref="ArgumentNullException">
  17656. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17657. 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)
  17658. {
  17659. if (provider == null)
  17660. throw new ArgumentNullException(nameof(provider));
  17661. if (action == null)
  17662. throw new ArgumentNullException(nameof(action));
  17663. if (scheduler == null)
  17664. throw new ArgumentNullException(nameof(scheduler));
  17665. #if CRIPPLED_REFLECTION
  17666. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6>>), default(IScheduler)));
  17667. #else
  17668. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  17669. #endif
  17670. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  17671. Expression.Invoke(
  17672. Expression.Call(
  17673. null,
  17674. m,
  17675. Expression.Constant(provider, typeof(IQbservableProvider)),
  17676. action,
  17677. Expression.Constant(scheduler, typeof(IScheduler))
  17678. ),
  17679. Expression.Constant(t1, typeof(TArg1)),
  17680. Expression.Constant(t2, typeof(TArg2)),
  17681. Expression.Constant(t3, typeof(TArg3)),
  17682. Expression.Constant(t4, typeof(TArg4)),
  17683. Expression.Constant(t5, typeof(TArg5)),
  17684. Expression.Constant(t6, typeof(TArg6))
  17685. )
  17686. );
  17687. }
  17688. /// <summary>
  17689. /// 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.
  17690. /// </summary>
  17691. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17692. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17693. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17694. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17695. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17696. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17697. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17698. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17699. /// <param name="action">Action to convert to an asynchronous action.</param>
  17700. /// <returns>Asynchronous action.</returns>
  17701. /// <exception cref="ArgumentNullException">
  17702. /// <paramref name="action" /> is null.</exception>
  17703. 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)
  17704. {
  17705. if (provider == null)
  17706. throw new ArgumentNullException(nameof(provider));
  17707. if (action == null)
  17708. throw new ArgumentNullException(nameof(action));
  17709. #if CRIPPLED_REFLECTION
  17710. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>(default(IQbservableProvider), default(Expression<Action<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TArg7>>)));
  17711. #else
  17712. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  17713. #endif
  17714. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  17715. Expression.Invoke(
  17716. Expression.Call(
  17717. null,
  17718. m,
  17719. Expression.Constant(provider, typeof(IQbservableProvider)),
  17720. action
  17721. ),
  17722. Expression.Constant(t1, typeof(TArg1)),
  17723. Expression.Constant(t2, typeof(TArg2)),
  17724. Expression.Constant(t3, typeof(TArg3)),
  17725. Expression.Constant(t4, typeof(TArg4)),
  17726. Expression.Constant(t5, typeof(TArg5)),
  17727. Expression.Constant(t6, typeof(TArg6)),
  17728. Expression.Constant(t7, typeof(TArg7))
  17729. )
  17730. );
  17731. }
  17732. /// <summary>
  17733. /// 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.
  17734. /// </summary>
  17735. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17736. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17737. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17738. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17739. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17740. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17741. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17742. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17743. /// <param name="action">Action to convert to an asynchronous action.</param>
  17744. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17745. /// <returns>Asynchronous action.</returns>
  17746. /// <exception cref="ArgumentNullException">
  17747. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17748. 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)
  17749. {
  17750. if (provider == null)
  17751. throw new ArgumentNullException(nameof(provider));
  17752. if (action == null)
  17753. throw new ArgumentNullException(nameof(action));
  17754. if (scheduler == null)
  17755. throw new ArgumentNullException(nameof(scheduler));
  17756. #if CRIPPLED_REFLECTION
  17757. 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)));
  17758. #else
  17759. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  17760. #endif
  17761. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  17762. Expression.Invoke(
  17763. Expression.Call(
  17764. null,
  17765. m,
  17766. Expression.Constant(provider, typeof(IQbservableProvider)),
  17767. action,
  17768. Expression.Constant(scheduler, typeof(IScheduler))
  17769. ),
  17770. Expression.Constant(t1, typeof(TArg1)),
  17771. Expression.Constant(t2, typeof(TArg2)),
  17772. Expression.Constant(t3, typeof(TArg3)),
  17773. Expression.Constant(t4, typeof(TArg4)),
  17774. Expression.Constant(t5, typeof(TArg5)),
  17775. Expression.Constant(t6, typeof(TArg6)),
  17776. Expression.Constant(t7, typeof(TArg7))
  17777. )
  17778. );
  17779. }
  17780. /// <summary>
  17781. /// 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.
  17782. /// </summary>
  17783. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17784. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17785. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17786. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17787. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17788. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17789. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17790. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17791. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17792. /// <param name="action">Action to convert to an asynchronous action.</param>
  17793. /// <returns>Asynchronous action.</returns>
  17794. /// <exception cref="ArgumentNullException">
  17795. /// <paramref name="action" /> is null.</exception>
  17796. 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)
  17797. {
  17798. if (provider == null)
  17799. throw new ArgumentNullException(nameof(provider));
  17800. if (action == null)
  17801. throw new ArgumentNullException(nameof(action));
  17802. #if CRIPPLED_REFLECTION
  17803. 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>>)));
  17804. #else
  17805. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  17806. #endif
  17807. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  17808. Expression.Invoke(
  17809. Expression.Call(
  17810. null,
  17811. m,
  17812. Expression.Constant(provider, typeof(IQbservableProvider)),
  17813. action
  17814. ),
  17815. Expression.Constant(t1, typeof(TArg1)),
  17816. Expression.Constant(t2, typeof(TArg2)),
  17817. Expression.Constant(t3, typeof(TArg3)),
  17818. Expression.Constant(t4, typeof(TArg4)),
  17819. Expression.Constant(t5, typeof(TArg5)),
  17820. Expression.Constant(t6, typeof(TArg6)),
  17821. Expression.Constant(t7, typeof(TArg7)),
  17822. Expression.Constant(t8, typeof(TArg8))
  17823. )
  17824. );
  17825. }
  17826. /// <summary>
  17827. /// 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.
  17828. /// </summary>
  17829. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17830. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17831. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17832. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17833. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17834. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17835. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17836. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17837. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17838. /// <param name="action">Action to convert to an asynchronous action.</param>
  17839. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17840. /// <returns>Asynchronous action.</returns>
  17841. /// <exception cref="ArgumentNullException">
  17842. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17843. 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)
  17844. {
  17845. if (provider == null)
  17846. throw new ArgumentNullException(nameof(provider));
  17847. if (action == null)
  17848. throw new ArgumentNullException(nameof(action));
  17849. if (scheduler == null)
  17850. throw new ArgumentNullException(nameof(scheduler));
  17851. #if CRIPPLED_REFLECTION
  17852. 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)));
  17853. #else
  17854. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  17855. #endif
  17856. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  17857. Expression.Invoke(
  17858. Expression.Call(
  17859. null,
  17860. m,
  17861. Expression.Constant(provider, typeof(IQbservableProvider)),
  17862. action,
  17863. Expression.Constant(scheduler, typeof(IScheduler))
  17864. ),
  17865. Expression.Constant(t1, typeof(TArg1)),
  17866. Expression.Constant(t2, typeof(TArg2)),
  17867. Expression.Constant(t3, typeof(TArg3)),
  17868. Expression.Constant(t4, typeof(TArg4)),
  17869. Expression.Constant(t5, typeof(TArg5)),
  17870. Expression.Constant(t6, typeof(TArg6)),
  17871. Expression.Constant(t7, typeof(TArg7)),
  17872. Expression.Constant(t8, typeof(TArg8))
  17873. )
  17874. );
  17875. }
  17876. /// <summary>
  17877. /// 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.
  17878. /// </summary>
  17879. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17880. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17881. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17882. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17883. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17884. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17885. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17886. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17887. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17888. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17889. /// <param name="action">Action to convert to an asynchronous action.</param>
  17890. /// <returns>Asynchronous action.</returns>
  17891. /// <exception cref="ArgumentNullException">
  17892. /// <paramref name="action" /> is null.</exception>
  17893. 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)
  17894. {
  17895. if (provider == null)
  17896. throw new ArgumentNullException(nameof(provider));
  17897. if (action == null)
  17898. throw new ArgumentNullException(nameof(action));
  17899. #if CRIPPLED_REFLECTION
  17900. 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>>)));
  17901. #else
  17902. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  17903. #endif
  17904. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  17905. Expression.Invoke(
  17906. Expression.Call(
  17907. null,
  17908. m,
  17909. Expression.Constant(provider, typeof(IQbservableProvider)),
  17910. action
  17911. ),
  17912. Expression.Constant(t1, typeof(TArg1)),
  17913. Expression.Constant(t2, typeof(TArg2)),
  17914. Expression.Constant(t3, typeof(TArg3)),
  17915. Expression.Constant(t4, typeof(TArg4)),
  17916. Expression.Constant(t5, typeof(TArg5)),
  17917. Expression.Constant(t6, typeof(TArg6)),
  17918. Expression.Constant(t7, typeof(TArg7)),
  17919. Expression.Constant(t8, typeof(TArg8)),
  17920. Expression.Constant(t9, typeof(TArg9))
  17921. )
  17922. );
  17923. }
  17924. /// <summary>
  17925. /// 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.
  17926. /// </summary>
  17927. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17928. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17929. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17930. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17931. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17932. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17933. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17934. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17935. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17936. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17937. /// <param name="action">Action to convert to an asynchronous action.</param>
  17938. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  17939. /// <returns>Asynchronous action.</returns>
  17940. /// <exception cref="ArgumentNullException">
  17941. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  17942. 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)
  17943. {
  17944. if (provider == null)
  17945. throw new ArgumentNullException(nameof(provider));
  17946. if (action == null)
  17947. throw new ArgumentNullException(nameof(action));
  17948. if (scheduler == null)
  17949. throw new ArgumentNullException(nameof(scheduler));
  17950. #if CRIPPLED_REFLECTION
  17951. 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)));
  17952. #else
  17953. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  17954. #endif
  17955. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  17956. Expression.Invoke(
  17957. Expression.Call(
  17958. null,
  17959. m,
  17960. Expression.Constant(provider, typeof(IQbservableProvider)),
  17961. action,
  17962. Expression.Constant(scheduler, typeof(IScheduler))
  17963. ),
  17964. Expression.Constant(t1, typeof(TArg1)),
  17965. Expression.Constant(t2, typeof(TArg2)),
  17966. Expression.Constant(t3, typeof(TArg3)),
  17967. Expression.Constant(t4, typeof(TArg4)),
  17968. Expression.Constant(t5, typeof(TArg5)),
  17969. Expression.Constant(t6, typeof(TArg6)),
  17970. Expression.Constant(t7, typeof(TArg7)),
  17971. Expression.Constant(t8, typeof(TArg8)),
  17972. Expression.Constant(t9, typeof(TArg9))
  17973. )
  17974. );
  17975. }
  17976. /// <summary>
  17977. /// 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.
  17978. /// </summary>
  17979. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  17980. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  17981. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  17982. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  17983. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  17984. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  17985. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  17986. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  17987. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  17988. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  17989. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  17990. /// <param name="action">Action to convert to an asynchronous action.</param>
  17991. /// <returns>Asynchronous action.</returns>
  17992. /// <exception cref="ArgumentNullException">
  17993. /// <paramref name="action" /> is null.</exception>
  17994. 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)
  17995. {
  17996. if (provider == null)
  17997. throw new ArgumentNullException(nameof(provider));
  17998. if (action == null)
  17999. throw new ArgumentNullException(nameof(action));
  18000. #if CRIPPLED_REFLECTION
  18001. 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>>)));
  18002. #else
  18003. 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));
  18004. #endif
  18005. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18006. Expression.Invoke(
  18007. Expression.Call(
  18008. null,
  18009. m,
  18010. Expression.Constant(provider, typeof(IQbservableProvider)),
  18011. action
  18012. ),
  18013. Expression.Constant(t1, typeof(TArg1)),
  18014. Expression.Constant(t2, typeof(TArg2)),
  18015. Expression.Constant(t3, typeof(TArg3)),
  18016. Expression.Constant(t4, typeof(TArg4)),
  18017. Expression.Constant(t5, typeof(TArg5)),
  18018. Expression.Constant(t6, typeof(TArg6)),
  18019. Expression.Constant(t7, typeof(TArg7)),
  18020. Expression.Constant(t8, typeof(TArg8)),
  18021. Expression.Constant(t9, typeof(TArg9)),
  18022. Expression.Constant(t10, typeof(TArg10))
  18023. )
  18024. );
  18025. }
  18026. /// <summary>
  18027. /// 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.
  18028. /// </summary>
  18029. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18030. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18031. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18032. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18033. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18034. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18035. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18036. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18037. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18038. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18039. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18040. /// <param name="action">Action to convert to an asynchronous action.</param>
  18041. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18042. /// <returns>Asynchronous action.</returns>
  18043. /// <exception cref="ArgumentNullException">
  18044. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18045. 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)
  18046. {
  18047. if (provider == null)
  18048. throw new ArgumentNullException(nameof(provider));
  18049. if (action == null)
  18050. throw new ArgumentNullException(nameof(action));
  18051. if (scheduler == null)
  18052. throw new ArgumentNullException(nameof(scheduler));
  18053. #if CRIPPLED_REFLECTION
  18054. 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)));
  18055. #else
  18056. 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));
  18057. #endif
  18058. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  18059. Expression.Invoke(
  18060. Expression.Call(
  18061. null,
  18062. m,
  18063. Expression.Constant(provider, typeof(IQbservableProvider)),
  18064. action,
  18065. Expression.Constant(scheduler, typeof(IScheduler))
  18066. ),
  18067. Expression.Constant(t1, typeof(TArg1)),
  18068. Expression.Constant(t2, typeof(TArg2)),
  18069. Expression.Constant(t3, typeof(TArg3)),
  18070. Expression.Constant(t4, typeof(TArg4)),
  18071. Expression.Constant(t5, typeof(TArg5)),
  18072. Expression.Constant(t6, typeof(TArg6)),
  18073. Expression.Constant(t7, typeof(TArg7)),
  18074. Expression.Constant(t8, typeof(TArg8)),
  18075. Expression.Constant(t9, typeof(TArg9)),
  18076. Expression.Constant(t10, typeof(TArg10))
  18077. )
  18078. );
  18079. }
  18080. /// <summary>
  18081. /// 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.
  18082. /// </summary>
  18083. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18084. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18085. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18086. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18087. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18088. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18089. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18090. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18091. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18092. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18093. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18094. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18095. /// <param name="action">Action to convert to an asynchronous action.</param>
  18096. /// <returns>Asynchronous action.</returns>
  18097. /// <exception cref="ArgumentNullException">
  18098. /// <paramref name="action" /> is null.</exception>
  18099. 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)
  18100. {
  18101. if (provider == null)
  18102. throw new ArgumentNullException(nameof(provider));
  18103. if (action == null)
  18104. throw new ArgumentNullException(nameof(action));
  18105. #if CRIPPLED_REFLECTION
  18106. 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>>)));
  18107. #else
  18108. 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));
  18109. #endif
  18110. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18111. Expression.Invoke(
  18112. Expression.Call(
  18113. null,
  18114. m,
  18115. Expression.Constant(provider, typeof(IQbservableProvider)),
  18116. action
  18117. ),
  18118. Expression.Constant(t1, typeof(TArg1)),
  18119. Expression.Constant(t2, typeof(TArg2)),
  18120. Expression.Constant(t3, typeof(TArg3)),
  18121. Expression.Constant(t4, typeof(TArg4)),
  18122. Expression.Constant(t5, typeof(TArg5)),
  18123. Expression.Constant(t6, typeof(TArg6)),
  18124. Expression.Constant(t7, typeof(TArg7)),
  18125. Expression.Constant(t8, typeof(TArg8)),
  18126. Expression.Constant(t9, typeof(TArg9)),
  18127. Expression.Constant(t10, typeof(TArg10)),
  18128. Expression.Constant(t11, typeof(TArg11))
  18129. )
  18130. );
  18131. }
  18132. /// <summary>
  18133. /// 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.
  18134. /// </summary>
  18135. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18136. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18137. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18138. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18139. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18140. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18141. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18142. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18143. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18144. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18145. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18146. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18147. /// <param name="action">Action to convert to an asynchronous action.</param>
  18148. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18149. /// <returns>Asynchronous action.</returns>
  18150. /// <exception cref="ArgumentNullException">
  18151. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18152. 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)
  18153. {
  18154. if (provider == null)
  18155. throw new ArgumentNullException(nameof(provider));
  18156. if (action == null)
  18157. throw new ArgumentNullException(nameof(action));
  18158. if (scheduler == null)
  18159. throw new ArgumentNullException(nameof(scheduler));
  18160. #if CRIPPLED_REFLECTION
  18161. 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)));
  18162. #else
  18163. 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));
  18164. #endif
  18165. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  18166. Expression.Invoke(
  18167. Expression.Call(
  18168. null,
  18169. m,
  18170. Expression.Constant(provider, typeof(IQbservableProvider)),
  18171. action,
  18172. Expression.Constant(scheduler, typeof(IScheduler))
  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. Expression.Constant(t8, typeof(TArg8)),
  18182. Expression.Constant(t9, typeof(TArg9)),
  18183. Expression.Constant(t10, typeof(TArg10)),
  18184. Expression.Constant(t11, typeof(TArg11))
  18185. )
  18186. );
  18187. }
  18188. /// <summary>
  18189. /// 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.
  18190. /// </summary>
  18191. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18192. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18193. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18194. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18195. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18196. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18197. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18198. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18199. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18200. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18201. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18202. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18203. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18204. /// <param name="action">Action to convert to an asynchronous action.</param>
  18205. /// <returns>Asynchronous action.</returns>
  18206. /// <exception cref="ArgumentNullException">
  18207. /// <paramref name="action" /> is null.</exception>
  18208. 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)
  18209. {
  18210. if (provider == null)
  18211. throw new ArgumentNullException(nameof(provider));
  18212. if (action == null)
  18213. throw new ArgumentNullException(nameof(action));
  18214. #if CRIPPLED_REFLECTION
  18215. 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>>)));
  18216. #else
  18217. 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));
  18218. #endif
  18219. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18220. Expression.Invoke(
  18221. Expression.Call(
  18222. null,
  18223. m,
  18224. Expression.Constant(provider, typeof(IQbservableProvider)),
  18225. action
  18226. ),
  18227. Expression.Constant(t1, typeof(TArg1)),
  18228. Expression.Constant(t2, typeof(TArg2)),
  18229. Expression.Constant(t3, typeof(TArg3)),
  18230. Expression.Constant(t4, typeof(TArg4)),
  18231. Expression.Constant(t5, typeof(TArg5)),
  18232. Expression.Constant(t6, typeof(TArg6)),
  18233. Expression.Constant(t7, typeof(TArg7)),
  18234. Expression.Constant(t8, typeof(TArg8)),
  18235. Expression.Constant(t9, typeof(TArg9)),
  18236. Expression.Constant(t10, typeof(TArg10)),
  18237. Expression.Constant(t11, typeof(TArg11)),
  18238. Expression.Constant(t12, typeof(TArg12))
  18239. )
  18240. );
  18241. }
  18242. /// <summary>
  18243. /// 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.
  18244. /// </summary>
  18245. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18246. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18247. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18248. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18249. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18250. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18251. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18252. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18253. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18254. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18255. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18256. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18257. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18258. /// <param name="action">Action to convert to an asynchronous action.</param>
  18259. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18260. /// <returns>Asynchronous action.</returns>
  18261. /// <exception cref="ArgumentNullException">
  18262. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18263. 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)
  18264. {
  18265. if (provider == null)
  18266. throw new ArgumentNullException(nameof(provider));
  18267. if (action == null)
  18268. throw new ArgumentNullException(nameof(action));
  18269. if (scheduler == null)
  18270. throw new ArgumentNullException(nameof(scheduler));
  18271. #if CRIPPLED_REFLECTION
  18272. 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)));
  18273. #else
  18274. 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));
  18275. #endif
  18276. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  18277. Expression.Invoke(
  18278. Expression.Call(
  18279. null,
  18280. m,
  18281. Expression.Constant(provider, typeof(IQbservableProvider)),
  18282. action,
  18283. Expression.Constant(scheduler, typeof(IScheduler))
  18284. ),
  18285. Expression.Constant(t1, typeof(TArg1)),
  18286. Expression.Constant(t2, typeof(TArg2)),
  18287. Expression.Constant(t3, typeof(TArg3)),
  18288. Expression.Constant(t4, typeof(TArg4)),
  18289. Expression.Constant(t5, typeof(TArg5)),
  18290. Expression.Constant(t6, typeof(TArg6)),
  18291. Expression.Constant(t7, typeof(TArg7)),
  18292. Expression.Constant(t8, typeof(TArg8)),
  18293. Expression.Constant(t9, typeof(TArg9)),
  18294. Expression.Constant(t10, typeof(TArg10)),
  18295. Expression.Constant(t11, typeof(TArg11)),
  18296. Expression.Constant(t12, typeof(TArg12))
  18297. )
  18298. );
  18299. }
  18300. /// <summary>
  18301. /// 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.
  18302. /// </summary>
  18303. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18304. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18305. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18306. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18307. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18308. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18309. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18310. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18311. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18312. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18313. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18314. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18315. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18316. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18317. /// <param name="action">Action to convert to an asynchronous action.</param>
  18318. /// <returns>Asynchronous action.</returns>
  18319. /// <exception cref="ArgumentNullException">
  18320. /// <paramref name="action" /> is null.</exception>
  18321. 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)
  18322. {
  18323. if (provider == null)
  18324. throw new ArgumentNullException(nameof(provider));
  18325. if (action == null)
  18326. throw new ArgumentNullException(nameof(action));
  18327. #if CRIPPLED_REFLECTION
  18328. 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>>)));
  18329. #else
  18330. 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));
  18331. #endif
  18332. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18333. Expression.Invoke(
  18334. Expression.Call(
  18335. null,
  18336. m,
  18337. Expression.Constant(provider, typeof(IQbservableProvider)),
  18338. action
  18339. ),
  18340. Expression.Constant(t1, typeof(TArg1)),
  18341. Expression.Constant(t2, typeof(TArg2)),
  18342. Expression.Constant(t3, typeof(TArg3)),
  18343. Expression.Constant(t4, typeof(TArg4)),
  18344. Expression.Constant(t5, typeof(TArg5)),
  18345. Expression.Constant(t6, typeof(TArg6)),
  18346. Expression.Constant(t7, typeof(TArg7)),
  18347. Expression.Constant(t8, typeof(TArg8)),
  18348. Expression.Constant(t9, typeof(TArg9)),
  18349. Expression.Constant(t10, typeof(TArg10)),
  18350. Expression.Constant(t11, typeof(TArg11)),
  18351. Expression.Constant(t12, typeof(TArg12)),
  18352. Expression.Constant(t13, typeof(TArg13))
  18353. )
  18354. );
  18355. }
  18356. /// <summary>
  18357. /// 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.
  18358. /// </summary>
  18359. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18360. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18361. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18362. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18363. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18364. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18365. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18366. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18367. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18368. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18369. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18370. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18371. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18372. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18373. /// <param name="action">Action to convert to an asynchronous action.</param>
  18374. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18375. /// <returns>Asynchronous action.</returns>
  18376. /// <exception cref="ArgumentNullException">
  18377. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18378. 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)
  18379. {
  18380. if (provider == null)
  18381. throw new ArgumentNullException(nameof(provider));
  18382. if (action == null)
  18383. throw new ArgumentNullException(nameof(action));
  18384. if (scheduler == null)
  18385. throw new ArgumentNullException(nameof(scheduler));
  18386. #if CRIPPLED_REFLECTION
  18387. 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)));
  18388. #else
  18389. 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));
  18390. #endif
  18391. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  18392. Expression.Invoke(
  18393. Expression.Call(
  18394. null,
  18395. m,
  18396. Expression.Constant(provider, typeof(IQbservableProvider)),
  18397. action,
  18398. Expression.Constant(scheduler, typeof(IScheduler))
  18399. ),
  18400. Expression.Constant(t1, typeof(TArg1)),
  18401. Expression.Constant(t2, typeof(TArg2)),
  18402. Expression.Constant(t3, typeof(TArg3)),
  18403. Expression.Constant(t4, typeof(TArg4)),
  18404. Expression.Constant(t5, typeof(TArg5)),
  18405. Expression.Constant(t6, typeof(TArg6)),
  18406. Expression.Constant(t7, typeof(TArg7)),
  18407. Expression.Constant(t8, typeof(TArg8)),
  18408. Expression.Constant(t9, typeof(TArg9)),
  18409. Expression.Constant(t10, typeof(TArg10)),
  18410. Expression.Constant(t11, typeof(TArg11)),
  18411. Expression.Constant(t12, typeof(TArg12)),
  18412. Expression.Constant(t13, typeof(TArg13))
  18413. )
  18414. );
  18415. }
  18416. /// <summary>
  18417. /// 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.
  18418. /// </summary>
  18419. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18420. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18421. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18422. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18423. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18424. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18425. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18426. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18427. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18428. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18429. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18430. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18431. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18432. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18433. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18434. /// <param name="action">Action to convert to an asynchronous action.</param>
  18435. /// <returns>Asynchronous action.</returns>
  18436. /// <exception cref="ArgumentNullException">
  18437. /// <paramref name="action" /> is null.</exception>
  18438. 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)
  18439. {
  18440. if (provider == null)
  18441. throw new ArgumentNullException(nameof(provider));
  18442. if (action == null)
  18443. throw new ArgumentNullException(nameof(action));
  18444. #if CRIPPLED_REFLECTION
  18445. 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>>)));
  18446. #else
  18447. 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));
  18448. #endif
  18449. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  18450. Expression.Invoke(
  18451. Expression.Call(
  18452. null,
  18453. m,
  18454. Expression.Constant(provider, typeof(IQbservableProvider)),
  18455. action
  18456. ),
  18457. Expression.Constant(t1, typeof(TArg1)),
  18458. Expression.Constant(t2, typeof(TArg2)),
  18459. Expression.Constant(t3, typeof(TArg3)),
  18460. Expression.Constant(t4, typeof(TArg4)),
  18461. Expression.Constant(t5, typeof(TArg5)),
  18462. Expression.Constant(t6, typeof(TArg6)),
  18463. Expression.Constant(t7, typeof(TArg7)),
  18464. Expression.Constant(t8, typeof(TArg8)),
  18465. Expression.Constant(t9, typeof(TArg9)),
  18466. Expression.Constant(t10, typeof(TArg10)),
  18467. Expression.Constant(t11, typeof(TArg11)),
  18468. Expression.Constant(t12, typeof(TArg12)),
  18469. Expression.Constant(t13, typeof(TArg13)),
  18470. Expression.Constant(t14, typeof(TArg14))
  18471. )
  18472. );
  18473. }
  18474. /// <summary>
  18475. /// 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.
  18476. /// </summary>
  18477. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18478. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18479. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18480. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18481. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18482. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18483. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18484. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18485. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18486. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18487. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18488. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18489. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18490. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18491. /// <typeparam name="TArg14">The type of the fourteenth 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, 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)
  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, 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)));
  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), typeof(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14));
  18509. #endif
  18510. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => 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. Expression.Constant(t11, typeof(TArg11)),
  18530. Expression.Constant(t12, typeof(TArg12)),
  18531. Expression.Constant(t13, typeof(TArg13)),
  18532. Expression.Constant(t14, typeof(TArg14))
  18533. )
  18534. );
  18535. }
  18536. /// <summary>
  18537. /// 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.
  18538. /// </summary>
  18539. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18540. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18541. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18542. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18543. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18544. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18545. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18546. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18547. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18548. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18549. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18550. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18551. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18552. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18553. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18554. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18555. /// <param name="action">Action to convert to an asynchronous action.</param>
  18556. /// <returns>Asynchronous action.</returns>
  18557. /// <exception cref="ArgumentNullException">
  18558. /// <paramref name="action" /> is null.</exception>
  18559. 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)
  18560. {
  18561. if (provider == null)
  18562. throw new ArgumentNullException(nameof(provider));
  18563. if (action == null)
  18564. throw new ArgumentNullException(nameof(action));
  18565. #if CRIPPLED_REFLECTION
  18566. 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>>)));
  18567. #else
  18568. 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));
  18569. #endif
  18570. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  18571. Expression.Invoke(
  18572. Expression.Call(
  18573. null,
  18574. m,
  18575. Expression.Constant(provider, typeof(IQbservableProvider)),
  18576. action
  18577. ),
  18578. Expression.Constant(t1, typeof(TArg1)),
  18579. Expression.Constant(t2, typeof(TArg2)),
  18580. Expression.Constant(t3, typeof(TArg3)),
  18581. Expression.Constant(t4, typeof(TArg4)),
  18582. Expression.Constant(t5, typeof(TArg5)),
  18583. Expression.Constant(t6, typeof(TArg6)),
  18584. Expression.Constant(t7, typeof(TArg7)),
  18585. Expression.Constant(t8, typeof(TArg8)),
  18586. Expression.Constant(t9, typeof(TArg9)),
  18587. Expression.Constant(t10, typeof(TArg10)),
  18588. Expression.Constant(t11, typeof(TArg11)),
  18589. Expression.Constant(t12, typeof(TArg12)),
  18590. Expression.Constant(t13, typeof(TArg13)),
  18591. Expression.Constant(t14, typeof(TArg14)),
  18592. Expression.Constant(t15, typeof(TArg15))
  18593. )
  18594. );
  18595. }
  18596. /// <summary>
  18597. /// 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.
  18598. /// </summary>
  18599. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18600. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18601. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18602. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18603. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18604. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18605. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18606. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18607. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18608. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18609. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18610. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18611. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18612. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18613. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18614. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18615. /// <param name="action">Action to convert to an asynchronous action.</param>
  18616. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18617. /// <returns>Asynchronous action.</returns>
  18618. /// <exception cref="ArgumentNullException">
  18619. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18620. 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)
  18621. {
  18622. if (provider == null)
  18623. throw new ArgumentNullException(nameof(provider));
  18624. if (action == null)
  18625. throw new ArgumentNullException(nameof(action));
  18626. if (scheduler == null)
  18627. throw new ArgumentNullException(nameof(scheduler));
  18628. #if CRIPPLED_REFLECTION
  18629. 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)));
  18630. #else
  18631. 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));
  18632. #endif
  18633. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<Unit>(
  18634. Expression.Invoke(
  18635. Expression.Call(
  18636. null,
  18637. m,
  18638. Expression.Constant(provider, typeof(IQbservableProvider)),
  18639. action,
  18640. Expression.Constant(scheduler, typeof(IScheduler))
  18641. ),
  18642. Expression.Constant(t1, typeof(TArg1)),
  18643. Expression.Constant(t2, typeof(TArg2)),
  18644. Expression.Constant(t3, typeof(TArg3)),
  18645. Expression.Constant(t4, typeof(TArg4)),
  18646. Expression.Constant(t5, typeof(TArg5)),
  18647. Expression.Constant(t6, typeof(TArg6)),
  18648. Expression.Constant(t7, typeof(TArg7)),
  18649. Expression.Constant(t8, typeof(TArg8)),
  18650. Expression.Constant(t9, typeof(TArg9)),
  18651. Expression.Constant(t10, typeof(TArg10)),
  18652. Expression.Constant(t11, typeof(TArg11)),
  18653. Expression.Constant(t12, typeof(TArg12)),
  18654. Expression.Constant(t13, typeof(TArg13)),
  18655. Expression.Constant(t14, typeof(TArg14)),
  18656. Expression.Constant(t15, typeof(TArg15))
  18657. )
  18658. );
  18659. }
  18660. /// <summary>
  18661. /// 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.
  18662. /// </summary>
  18663. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18664. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18665. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18666. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18667. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18668. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18669. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18670. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18671. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18672. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18673. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18674. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18675. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18676. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18677. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18678. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18679. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  18680. /// <param name="action">Action to convert to an asynchronous action.</param>
  18681. /// <returns>Asynchronous action.</returns>
  18682. /// <exception cref="ArgumentNullException">
  18683. /// <paramref name="action" /> is null.</exception>
  18684. 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)
  18685. {
  18686. if (provider == null)
  18687. throw new ArgumentNullException(nameof(provider));
  18688. if (action == null)
  18689. throw new ArgumentNullException(nameof(action));
  18690. #if CRIPPLED_REFLECTION
  18691. 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>>)));
  18692. #else
  18693. 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));
  18694. #endif
  18695. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  18696. Expression.Invoke(
  18697. Expression.Call(
  18698. null,
  18699. m,
  18700. Expression.Constant(provider, typeof(IQbservableProvider)),
  18701. action
  18702. ),
  18703. Expression.Constant(t1, typeof(TArg1)),
  18704. Expression.Constant(t2, typeof(TArg2)),
  18705. Expression.Constant(t3, typeof(TArg3)),
  18706. Expression.Constant(t4, typeof(TArg4)),
  18707. Expression.Constant(t5, typeof(TArg5)),
  18708. Expression.Constant(t6, typeof(TArg6)),
  18709. Expression.Constant(t7, typeof(TArg7)),
  18710. Expression.Constant(t8, typeof(TArg8)),
  18711. Expression.Constant(t9, typeof(TArg9)),
  18712. Expression.Constant(t10, typeof(TArg10)),
  18713. Expression.Constant(t11, typeof(TArg11)),
  18714. Expression.Constant(t12, typeof(TArg12)),
  18715. Expression.Constant(t13, typeof(TArg13)),
  18716. Expression.Constant(t14, typeof(TArg14)),
  18717. Expression.Constant(t15, typeof(TArg15)),
  18718. Expression.Constant(t16, typeof(TArg16))
  18719. )
  18720. );
  18721. }
  18722. /// <summary>
  18723. /// 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.
  18724. /// </summary>
  18725. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18726. /// <typeparam name="TArg1">The type of the first argument passed to the action.</typeparam>
  18727. /// <typeparam name="TArg2">The type of the second argument passed to the action.</typeparam>
  18728. /// <typeparam name="TArg3">The type of the third argument passed to the action.</typeparam>
  18729. /// <typeparam name="TArg4">The type of the fourth argument passed to the action.</typeparam>
  18730. /// <typeparam name="TArg5">The type of the fifth argument passed to the action.</typeparam>
  18731. /// <typeparam name="TArg6">The type of the sixth argument passed to the action.</typeparam>
  18732. /// <typeparam name="TArg7">The type of the seventh argument passed to the action.</typeparam>
  18733. /// <typeparam name="TArg8">The type of the eighth argument passed to the action.</typeparam>
  18734. /// <typeparam name="TArg9">The type of the ninth argument passed to the action.</typeparam>
  18735. /// <typeparam name="TArg10">The type of the tenth argument passed to the action.</typeparam>
  18736. /// <typeparam name="TArg11">The type of the eleventh argument passed to the action.</typeparam>
  18737. /// <typeparam name="TArg12">The type of the twelfth argument passed to the action.</typeparam>
  18738. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the action.</typeparam>
  18739. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the action.</typeparam>
  18740. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the action.</typeparam>
  18741. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the action.</typeparam>
  18742. /// <param name="action">Action to convert to an asynchronous action.</param>
  18743. /// <param name="scheduler">Scheduler to invoke the original action on.</param>
  18744. /// <returns>Asynchronous action.</returns>
  18745. /// <exception cref="ArgumentNullException">
  18746. /// <paramref name="action" /> or <paramref name="scheduler" /> is null.</exception>
  18747. 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)
  18748. {
  18749. if (provider == null)
  18750. throw new ArgumentNullException(nameof(provider));
  18751. if (action == null)
  18752. throw new ArgumentNullException(nameof(action));
  18753. if (scheduler == null)
  18754. throw new ArgumentNullException(nameof(scheduler));
  18755. #if CRIPPLED_REFLECTION
  18756. 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)));
  18757. #else
  18758. 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));
  18759. #endif
  18760. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<Unit>(
  18761. Expression.Invoke(
  18762. Expression.Call(
  18763. null,
  18764. m,
  18765. Expression.Constant(provider, typeof(IQbservableProvider)),
  18766. action,
  18767. Expression.Constant(scheduler, typeof(IScheduler))
  18768. ),
  18769. Expression.Constant(t1, typeof(TArg1)),
  18770. Expression.Constant(t2, typeof(TArg2)),
  18771. Expression.Constant(t3, typeof(TArg3)),
  18772. Expression.Constant(t4, typeof(TArg4)),
  18773. Expression.Constant(t5, typeof(TArg5)),
  18774. Expression.Constant(t6, typeof(TArg6)),
  18775. Expression.Constant(t7, typeof(TArg7)),
  18776. Expression.Constant(t8, typeof(TArg8)),
  18777. Expression.Constant(t9, typeof(TArg9)),
  18778. Expression.Constant(t10, typeof(TArg10)),
  18779. Expression.Constant(t11, typeof(TArg11)),
  18780. Expression.Constant(t12, typeof(TArg12)),
  18781. Expression.Constant(t13, typeof(TArg13)),
  18782. Expression.Constant(t14, typeof(TArg14)),
  18783. Expression.Constant(t15, typeof(TArg15)),
  18784. Expression.Constant(t16, typeof(TArg16))
  18785. )
  18786. );
  18787. }
  18788. /// <summary>
  18789. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  18790. /// </summary>
  18791. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18792. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18793. /// <param name="function">Function to convert to an asynchronous function.</param>
  18794. /// <returns>Asynchronous function.</returns>
  18795. /// <exception cref="ArgumentNullException">
  18796. /// <paramref name="function" /> is null.</exception>
  18797. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function)
  18798. {
  18799. if (provider == null)
  18800. throw new ArgumentNullException(nameof(provider));
  18801. if (function == null)
  18802. throw new ArgumentNullException(nameof(function));
  18803. #if CRIPPLED_REFLECTION
  18804. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>)));
  18805. #else
  18806. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  18807. #endif
  18808. return () => provider.CreateQuery<TResult>(
  18809. Expression.Invoke(
  18810. Expression.Call(
  18811. null,
  18812. m,
  18813. Expression.Constant(provider, typeof(IQbservableProvider)),
  18814. function
  18815. )
  18816. )
  18817. );
  18818. }
  18819. /// <summary>
  18820. /// 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.
  18821. /// </summary>
  18822. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18823. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18824. /// <param name="function">Function to convert to an asynchronous function.</param>
  18825. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  18826. /// <returns>Asynchronous function.</returns>
  18827. /// <exception cref="ArgumentNullException">
  18828. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  18829. public static Func<IQbservable<TResult>> ToAsync<TResult>(this IQbservableProvider provider, Expression<Func<TResult>> function, IScheduler scheduler)
  18830. {
  18831. if (provider == null)
  18832. throw new ArgumentNullException(nameof(provider));
  18833. if (function == null)
  18834. throw new ArgumentNullException(nameof(function));
  18835. if (scheduler == null)
  18836. throw new ArgumentNullException(nameof(scheduler));
  18837. #if CRIPPLED_REFLECTION
  18838. var m = InfoOf(() => Qbservable.ToAsync<TResult>(default(IQbservableProvider), default(Expression<Func<TResult>>), default(IScheduler)));
  18839. #else
  18840. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  18841. #endif
  18842. return () => provider.CreateQuery<TResult>(
  18843. Expression.Invoke(
  18844. Expression.Call(
  18845. null,
  18846. m,
  18847. Expression.Constant(provider, typeof(IQbservableProvider)),
  18848. function,
  18849. Expression.Constant(scheduler, typeof(IScheduler))
  18850. )
  18851. )
  18852. );
  18853. }
  18854. /// <summary>
  18855. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  18856. /// </summary>
  18857. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18858. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18859. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18860. /// <param name="function">Function to convert to an asynchronous function.</param>
  18861. /// <returns>Asynchronous function.</returns>
  18862. /// <exception cref="ArgumentNullException">
  18863. /// <paramref name="function" /> is null.</exception>
  18864. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function)
  18865. {
  18866. if (provider == null)
  18867. throw new ArgumentNullException(nameof(provider));
  18868. if (function == null)
  18869. throw new ArgumentNullException(nameof(function));
  18870. #if CRIPPLED_REFLECTION
  18871. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>)));
  18872. #else
  18873. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  18874. #endif
  18875. return (t1) => provider.CreateQuery<TResult>(
  18876. Expression.Invoke(
  18877. Expression.Call(
  18878. null,
  18879. m,
  18880. Expression.Constant(provider, typeof(IQbservableProvider)),
  18881. function
  18882. ),
  18883. Expression.Constant(t1, typeof(TArg1))
  18884. )
  18885. );
  18886. }
  18887. /// <summary>
  18888. /// 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.
  18889. /// </summary>
  18890. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18891. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18892. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18893. /// <param name="function">Function to convert to an asynchronous function.</param>
  18894. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  18895. /// <returns>Asynchronous function.</returns>
  18896. /// <exception cref="ArgumentNullException">
  18897. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  18898. public static Func<TArg1, IQbservable<TResult>> ToAsync<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TResult>> function, IScheduler scheduler)
  18899. {
  18900. if (provider == null)
  18901. throw new ArgumentNullException(nameof(provider));
  18902. if (function == null)
  18903. throw new ArgumentNullException(nameof(function));
  18904. if (scheduler == null)
  18905. throw new ArgumentNullException(nameof(scheduler));
  18906. #if CRIPPLED_REFLECTION
  18907. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TResult>>), default(IScheduler)));
  18908. #else
  18909. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  18910. #endif
  18911. return (t1) => provider.CreateQuery<TResult>(
  18912. Expression.Invoke(
  18913. Expression.Call(
  18914. null,
  18915. m,
  18916. Expression.Constant(provider, typeof(IQbservableProvider)),
  18917. function,
  18918. Expression.Constant(scheduler, typeof(IScheduler))
  18919. ),
  18920. Expression.Constant(t1, typeof(TArg1))
  18921. )
  18922. );
  18923. }
  18924. /// <summary>
  18925. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  18926. /// </summary>
  18927. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18928. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18929. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  18930. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18931. /// <param name="function">Function to convert to an asynchronous function.</param>
  18932. /// <returns>Asynchronous function.</returns>
  18933. /// <exception cref="ArgumentNullException">
  18934. /// <paramref name="function" /> is null.</exception>
  18935. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function)
  18936. {
  18937. if (provider == null)
  18938. throw new ArgumentNullException(nameof(provider));
  18939. if (function == null)
  18940. throw new ArgumentNullException(nameof(function));
  18941. #if CRIPPLED_REFLECTION
  18942. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>)));
  18943. #else
  18944. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  18945. #endif
  18946. return (t1, t2) => provider.CreateQuery<TResult>(
  18947. Expression.Invoke(
  18948. Expression.Call(
  18949. null,
  18950. m,
  18951. Expression.Constant(provider, typeof(IQbservableProvider)),
  18952. function
  18953. ),
  18954. Expression.Constant(t1, typeof(TArg1)),
  18955. Expression.Constant(t2, typeof(TArg2))
  18956. )
  18957. );
  18958. }
  18959. /// <summary>
  18960. /// 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.
  18961. /// </summary>
  18962. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  18963. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  18964. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  18965. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  18966. /// <param name="function">Function to convert to an asynchronous function.</param>
  18967. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  18968. /// <returns>Asynchronous function.</returns>
  18969. /// <exception cref="ArgumentNullException">
  18970. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  18971. public static Func<TArg1, TArg2, IQbservable<TResult>> ToAsync<TArg1, TArg2, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TResult>> function, IScheduler scheduler)
  18972. {
  18973. if (provider == null)
  18974. throw new ArgumentNullException(nameof(provider));
  18975. if (function == null)
  18976. throw new ArgumentNullException(nameof(function));
  18977. if (scheduler == null)
  18978. throw new ArgumentNullException(nameof(scheduler));
  18979. #if CRIPPLED_REFLECTION
  18980. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TResult>>), default(IScheduler)));
  18981. #else
  18982. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  18983. #endif
  18984. return (t1, t2) => provider.CreateQuery<TResult>(
  18985. Expression.Invoke(
  18986. Expression.Call(
  18987. null,
  18988. m,
  18989. Expression.Constant(provider, typeof(IQbservableProvider)),
  18990. function,
  18991. Expression.Constant(scheduler, typeof(IScheduler))
  18992. ),
  18993. Expression.Constant(t1, typeof(TArg1)),
  18994. Expression.Constant(t2, typeof(TArg2))
  18995. )
  18996. );
  18997. }
  18998. /// <summary>
  18999. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19000. /// </summary>
  19001. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19002. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19003. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19004. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19005. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19006. /// <param name="function">Function to convert to an asynchronous function.</param>
  19007. /// <returns>Asynchronous function.</returns>
  19008. /// <exception cref="ArgumentNullException">
  19009. /// <paramref name="function" /> is null.</exception>
  19010. public static Func<TArg1, TArg2, TArg3, IQbservable<TResult>> ToAsync<TArg1, TArg2, TArg3, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, TArg2, TArg3, TResult>> function)
  19011. {
  19012. if (provider == null)
  19013. throw new ArgumentNullException(nameof(provider));
  19014. if (function == null)
  19015. throw new ArgumentNullException(nameof(function));
  19016. #if CRIPPLED_REFLECTION
  19017. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>)));
  19018. #else
  19019. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19020. #endif
  19021. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19022. Expression.Invoke(
  19023. Expression.Call(
  19024. null,
  19025. m,
  19026. Expression.Constant(provider, typeof(IQbservableProvider)),
  19027. function
  19028. ),
  19029. Expression.Constant(t1, typeof(TArg1)),
  19030. Expression.Constant(t2, typeof(TArg2)),
  19031. Expression.Constant(t3, typeof(TArg3))
  19032. )
  19033. );
  19034. }
  19035. /// <summary>
  19036. /// 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.
  19037. /// </summary>
  19038. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19039. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19040. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19041. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19042. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19043. /// <param name="function">Function to convert to an asynchronous function.</param>
  19044. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19045. /// <returns>Asynchronous function.</returns>
  19046. /// <exception cref="ArgumentNullException">
  19047. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19048. 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)
  19049. {
  19050. if (provider == null)
  19051. throw new ArgumentNullException(nameof(provider));
  19052. if (function == null)
  19053. throw new ArgumentNullException(nameof(function));
  19054. if (scheduler == null)
  19055. throw new ArgumentNullException(nameof(scheduler));
  19056. #if CRIPPLED_REFLECTION
  19057. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TResult>>), default(IScheduler)));
  19058. #else
  19059. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  19060. #endif
  19061. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  19062. Expression.Invoke(
  19063. Expression.Call(
  19064. null,
  19065. m,
  19066. Expression.Constant(provider, typeof(IQbservableProvider)),
  19067. function,
  19068. Expression.Constant(scheduler, typeof(IScheduler))
  19069. ),
  19070. Expression.Constant(t1, typeof(TArg1)),
  19071. Expression.Constant(t2, typeof(TArg2)),
  19072. Expression.Constant(t3, typeof(TArg3))
  19073. )
  19074. );
  19075. }
  19076. /// <summary>
  19077. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19078. /// </summary>
  19079. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19080. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19081. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19082. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19083. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19084. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19085. /// <param name="function">Function to convert to an asynchronous function.</param>
  19086. /// <returns>Asynchronous function.</returns>
  19087. /// <exception cref="ArgumentNullException">
  19088. /// <paramref name="function" /> is null.</exception>
  19089. 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)
  19090. {
  19091. if (provider == null)
  19092. throw new ArgumentNullException(nameof(provider));
  19093. if (function == null)
  19094. throw new ArgumentNullException(nameof(function));
  19095. #if CRIPPLED_REFLECTION
  19096. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>)));
  19097. #else
  19098. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19099. #endif
  19100. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19101. Expression.Invoke(
  19102. Expression.Call(
  19103. null,
  19104. m,
  19105. Expression.Constant(provider, typeof(IQbservableProvider)),
  19106. function
  19107. ),
  19108. Expression.Constant(t1, typeof(TArg1)),
  19109. Expression.Constant(t2, typeof(TArg2)),
  19110. Expression.Constant(t3, typeof(TArg3)),
  19111. Expression.Constant(t4, typeof(TArg4))
  19112. )
  19113. );
  19114. }
  19115. /// <summary>
  19116. /// 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.
  19117. /// </summary>
  19118. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19119. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19120. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19121. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19122. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19123. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19124. /// <param name="function">Function to convert to an asynchronous function.</param>
  19125. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19126. /// <returns>Asynchronous function.</returns>
  19127. /// <exception cref="ArgumentNullException">
  19128. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19129. 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)
  19130. {
  19131. if (provider == null)
  19132. throw new ArgumentNullException(nameof(provider));
  19133. if (function == null)
  19134. throw new ArgumentNullException(nameof(function));
  19135. if (scheduler == null)
  19136. throw new ArgumentNullException(nameof(scheduler));
  19137. #if CRIPPLED_REFLECTION
  19138. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TResult>>), default(IScheduler)));
  19139. #else
  19140. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  19141. #endif
  19142. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  19143. Expression.Invoke(
  19144. Expression.Call(
  19145. null,
  19146. m,
  19147. Expression.Constant(provider, typeof(IQbservableProvider)),
  19148. function,
  19149. Expression.Constant(scheduler, typeof(IScheduler))
  19150. ),
  19151. Expression.Constant(t1, typeof(TArg1)),
  19152. Expression.Constant(t2, typeof(TArg2)),
  19153. Expression.Constant(t3, typeof(TArg3)),
  19154. Expression.Constant(t4, typeof(TArg4))
  19155. )
  19156. );
  19157. }
  19158. /// <summary>
  19159. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19160. /// </summary>
  19161. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19162. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19163. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19164. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19165. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19166. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19167. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19168. /// <param name="function">Function to convert to an asynchronous function.</param>
  19169. /// <returns>Asynchronous function.</returns>
  19170. /// <exception cref="ArgumentNullException">
  19171. /// <paramref name="function" /> is null.</exception>
  19172. 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)
  19173. {
  19174. if (provider == null)
  19175. throw new ArgumentNullException(nameof(provider));
  19176. if (function == null)
  19177. throw new ArgumentNullException(nameof(function));
  19178. #if CRIPPLED_REFLECTION
  19179. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>)));
  19180. #else
  19181. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19182. #endif
  19183. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19184. Expression.Invoke(
  19185. Expression.Call(
  19186. null,
  19187. m,
  19188. Expression.Constant(provider, typeof(IQbservableProvider)),
  19189. function
  19190. ),
  19191. Expression.Constant(t1, typeof(TArg1)),
  19192. Expression.Constant(t2, typeof(TArg2)),
  19193. Expression.Constant(t3, typeof(TArg3)),
  19194. Expression.Constant(t4, typeof(TArg4)),
  19195. Expression.Constant(t5, typeof(TArg5))
  19196. )
  19197. );
  19198. }
  19199. /// <summary>
  19200. /// 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.
  19201. /// </summary>
  19202. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19203. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19204. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19205. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19206. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19207. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19208. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19209. /// <param name="function">Function to convert to an asynchronous function.</param>
  19210. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19211. /// <returns>Asynchronous function.</returns>
  19212. /// <exception cref="ArgumentNullException">
  19213. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19214. 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)
  19215. {
  19216. if (provider == null)
  19217. throw new ArgumentNullException(nameof(provider));
  19218. if (function == null)
  19219. throw new ArgumentNullException(nameof(function));
  19220. if (scheduler == null)
  19221. throw new ArgumentNullException(nameof(scheduler));
  19222. #if CRIPPLED_REFLECTION
  19223. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TResult>>), default(IScheduler)));
  19224. #else
  19225. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  19226. #endif
  19227. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  19228. Expression.Invoke(
  19229. Expression.Call(
  19230. null,
  19231. m,
  19232. Expression.Constant(provider, typeof(IQbservableProvider)),
  19233. function,
  19234. Expression.Constant(scheduler, typeof(IScheduler))
  19235. ),
  19236. Expression.Constant(t1, typeof(TArg1)),
  19237. Expression.Constant(t2, typeof(TArg2)),
  19238. Expression.Constant(t3, typeof(TArg3)),
  19239. Expression.Constant(t4, typeof(TArg4)),
  19240. Expression.Constant(t5, typeof(TArg5))
  19241. )
  19242. );
  19243. }
  19244. /// <summary>
  19245. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19246. /// </summary>
  19247. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19248. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19249. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19250. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19251. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19252. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19253. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19254. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19255. /// <param name="function">Function to convert to an asynchronous function.</param>
  19256. /// <returns>Asynchronous function.</returns>
  19257. /// <exception cref="ArgumentNullException">
  19258. /// <paramref name="function" /> is null.</exception>
  19259. 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)
  19260. {
  19261. if (provider == null)
  19262. throw new ArgumentNullException(nameof(provider));
  19263. if (function == null)
  19264. throw new ArgumentNullException(nameof(function));
  19265. #if CRIPPLED_REFLECTION
  19266. var m = InfoOf(() => Qbservable.ToAsync<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, TArg4, TArg5, TArg6, TResult>>)));
  19267. #else
  19268. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19269. #endif
  19270. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19271. Expression.Invoke(
  19272. Expression.Call(
  19273. null,
  19274. m,
  19275. Expression.Constant(provider, typeof(IQbservableProvider)),
  19276. function
  19277. ),
  19278. Expression.Constant(t1, typeof(TArg1)),
  19279. Expression.Constant(t2, typeof(TArg2)),
  19280. Expression.Constant(t3, typeof(TArg3)),
  19281. Expression.Constant(t4, typeof(TArg4)),
  19282. Expression.Constant(t5, typeof(TArg5)),
  19283. Expression.Constant(t6, typeof(TArg6))
  19284. )
  19285. );
  19286. }
  19287. /// <summary>
  19288. /// 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.
  19289. /// </summary>
  19290. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19291. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19292. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19293. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19294. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19295. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19296. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19297. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19298. /// <param name="function">Function to convert to an asynchronous function.</param>
  19299. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19300. /// <returns>Asynchronous function.</returns>
  19301. /// <exception cref="ArgumentNullException">
  19302. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19303. 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)
  19304. {
  19305. if (provider == null)
  19306. throw new ArgumentNullException(nameof(provider));
  19307. if (function == null)
  19308. throw new ArgumentNullException(nameof(function));
  19309. if (scheduler == null)
  19310. throw new ArgumentNullException(nameof(scheduler));
  19311. #if CRIPPLED_REFLECTION
  19312. 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)));
  19313. #else
  19314. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  19315. #endif
  19316. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  19317. Expression.Invoke(
  19318. Expression.Call(
  19319. null,
  19320. m,
  19321. Expression.Constant(provider, typeof(IQbservableProvider)),
  19322. function,
  19323. Expression.Constant(scheduler, typeof(IScheduler))
  19324. ),
  19325. Expression.Constant(t1, typeof(TArg1)),
  19326. Expression.Constant(t2, typeof(TArg2)),
  19327. Expression.Constant(t3, typeof(TArg3)),
  19328. Expression.Constant(t4, typeof(TArg4)),
  19329. Expression.Constant(t5, typeof(TArg5)),
  19330. Expression.Constant(t6, typeof(TArg6))
  19331. )
  19332. );
  19333. }
  19334. /// <summary>
  19335. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19336. /// </summary>
  19337. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19338. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19339. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19340. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19341. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19342. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19343. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19344. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19345. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19346. /// <param name="function">Function to convert to an asynchronous function.</param>
  19347. /// <returns>Asynchronous function.</returns>
  19348. /// <exception cref="ArgumentNullException">
  19349. /// <paramref name="function" /> is null.</exception>
  19350. 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)
  19351. {
  19352. if (provider == null)
  19353. throw new ArgumentNullException(nameof(provider));
  19354. if (function == null)
  19355. throw new ArgumentNullException(nameof(function));
  19356. #if CRIPPLED_REFLECTION
  19357. 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>>)));
  19358. #else
  19359. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19360. #endif
  19361. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19362. Expression.Invoke(
  19363. Expression.Call(
  19364. null,
  19365. m,
  19366. Expression.Constant(provider, typeof(IQbservableProvider)),
  19367. function
  19368. ),
  19369. Expression.Constant(t1, typeof(TArg1)),
  19370. Expression.Constant(t2, typeof(TArg2)),
  19371. Expression.Constant(t3, typeof(TArg3)),
  19372. Expression.Constant(t4, typeof(TArg4)),
  19373. Expression.Constant(t5, typeof(TArg5)),
  19374. Expression.Constant(t6, typeof(TArg6)),
  19375. Expression.Constant(t7, typeof(TArg7))
  19376. )
  19377. );
  19378. }
  19379. /// <summary>
  19380. /// 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.
  19381. /// </summary>
  19382. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19383. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19384. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19385. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19386. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19387. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19388. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19389. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19390. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19391. /// <param name="function">Function to convert to an asynchronous function.</param>
  19392. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19393. /// <returns>Asynchronous function.</returns>
  19394. /// <exception cref="ArgumentNullException">
  19395. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19396. 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)
  19397. {
  19398. if (provider == null)
  19399. throw new ArgumentNullException(nameof(provider));
  19400. if (function == null)
  19401. throw new ArgumentNullException(nameof(function));
  19402. if (scheduler == null)
  19403. throw new ArgumentNullException(nameof(scheduler));
  19404. #if CRIPPLED_REFLECTION
  19405. 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)));
  19406. #else
  19407. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  19408. #endif
  19409. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  19410. Expression.Invoke(
  19411. Expression.Call(
  19412. null,
  19413. m,
  19414. Expression.Constant(provider, typeof(IQbservableProvider)),
  19415. function,
  19416. Expression.Constant(scheduler, typeof(IScheduler))
  19417. ),
  19418. Expression.Constant(t1, typeof(TArg1)),
  19419. Expression.Constant(t2, typeof(TArg2)),
  19420. Expression.Constant(t3, typeof(TArg3)),
  19421. Expression.Constant(t4, typeof(TArg4)),
  19422. Expression.Constant(t5, typeof(TArg5)),
  19423. Expression.Constant(t6, typeof(TArg6)),
  19424. Expression.Constant(t7, typeof(TArg7))
  19425. )
  19426. );
  19427. }
  19428. /// <summary>
  19429. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19430. /// </summary>
  19431. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19432. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19433. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19434. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19435. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19436. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19437. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19438. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19439. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19440. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19441. /// <param name="function">Function to convert to an asynchronous function.</param>
  19442. /// <returns>Asynchronous function.</returns>
  19443. /// <exception cref="ArgumentNullException">
  19444. /// <paramref name="function" /> is null.</exception>
  19445. 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)
  19446. {
  19447. if (provider == null)
  19448. throw new ArgumentNullException(nameof(provider));
  19449. if (function == null)
  19450. throw new ArgumentNullException(nameof(function));
  19451. #if CRIPPLED_REFLECTION
  19452. 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>>)));
  19453. #else
  19454. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19455. #endif
  19456. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19457. Expression.Invoke(
  19458. Expression.Call(
  19459. null,
  19460. m,
  19461. Expression.Constant(provider, typeof(IQbservableProvider)),
  19462. function
  19463. ),
  19464. Expression.Constant(t1, typeof(TArg1)),
  19465. Expression.Constant(t2, typeof(TArg2)),
  19466. Expression.Constant(t3, typeof(TArg3)),
  19467. Expression.Constant(t4, typeof(TArg4)),
  19468. Expression.Constant(t5, typeof(TArg5)),
  19469. Expression.Constant(t6, typeof(TArg6)),
  19470. Expression.Constant(t7, typeof(TArg7)),
  19471. Expression.Constant(t8, typeof(TArg8))
  19472. )
  19473. );
  19474. }
  19475. /// <summary>
  19476. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function on the specified scheduler.
  19477. /// </summary>
  19478. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19479. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19480. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19481. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19482. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19483. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19484. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19485. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19486. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19487. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19488. /// <param name="function">Function to convert to an asynchronous function.</param>
  19489. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19490. /// <returns>Asynchronous function.</returns>
  19491. /// <exception cref="ArgumentNullException">
  19492. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19493. 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)
  19494. {
  19495. if (provider == null)
  19496. throw new ArgumentNullException(nameof(provider));
  19497. if (function == null)
  19498. throw new ArgumentNullException(nameof(function));
  19499. if (scheduler == null)
  19500. throw new ArgumentNullException(nameof(scheduler));
  19501. #if CRIPPLED_REFLECTION
  19502. 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)));
  19503. #else
  19504. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  19505. #endif
  19506. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  19507. Expression.Invoke(
  19508. Expression.Call(
  19509. null,
  19510. m,
  19511. Expression.Constant(provider, typeof(IQbservableProvider)),
  19512. function,
  19513. Expression.Constant(scheduler, typeof(IScheduler))
  19514. ),
  19515. Expression.Constant(t1, typeof(TArg1)),
  19516. Expression.Constant(t2, typeof(TArg2)),
  19517. Expression.Constant(t3, typeof(TArg3)),
  19518. Expression.Constant(t4, typeof(TArg4)),
  19519. Expression.Constant(t5, typeof(TArg5)),
  19520. Expression.Constant(t6, typeof(TArg6)),
  19521. Expression.Constant(t7, typeof(TArg7)),
  19522. Expression.Constant(t8, typeof(TArg8))
  19523. )
  19524. );
  19525. }
  19526. /// <summary>
  19527. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19528. /// </summary>
  19529. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19530. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19531. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19532. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19533. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19534. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19535. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19536. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19537. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19538. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19539. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19540. /// <param name="function">Function to convert to an asynchronous function.</param>
  19541. /// <returns>Asynchronous function.</returns>
  19542. /// <exception cref="ArgumentNullException">
  19543. /// <paramref name="function" /> is null.</exception>
  19544. 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)
  19545. {
  19546. if (provider == null)
  19547. throw new ArgumentNullException(nameof(provider));
  19548. if (function == null)
  19549. throw new ArgumentNullException(nameof(function));
  19550. #if CRIPPLED_REFLECTION
  19551. 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>>)));
  19552. #else
  19553. 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));
  19554. #endif
  19555. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  19556. Expression.Invoke(
  19557. Expression.Call(
  19558. null,
  19559. m,
  19560. Expression.Constant(provider, typeof(IQbservableProvider)),
  19561. function
  19562. ),
  19563. Expression.Constant(t1, typeof(TArg1)),
  19564. Expression.Constant(t2, typeof(TArg2)),
  19565. Expression.Constant(t3, typeof(TArg3)),
  19566. Expression.Constant(t4, typeof(TArg4)),
  19567. Expression.Constant(t5, typeof(TArg5)),
  19568. Expression.Constant(t6, typeof(TArg6)),
  19569. Expression.Constant(t7, typeof(TArg7)),
  19570. Expression.Constant(t8, typeof(TArg8)),
  19571. Expression.Constant(t9, typeof(TArg9))
  19572. )
  19573. );
  19574. }
  19575. /// <summary>
  19576. /// 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.
  19577. /// </summary>
  19578. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19579. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19580. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19581. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19582. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19583. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19584. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19585. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19586. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19587. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19588. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19589. /// <param name="function">Function to convert to an asynchronous function.</param>
  19590. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19591. /// <returns>Asynchronous function.</returns>
  19592. /// <exception cref="ArgumentNullException">
  19593. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19594. 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)
  19595. {
  19596. if (provider == null)
  19597. throw new ArgumentNullException(nameof(provider));
  19598. if (function == null)
  19599. throw new ArgumentNullException(nameof(function));
  19600. if (scheduler == null)
  19601. throw new ArgumentNullException(nameof(scheduler));
  19602. #if CRIPPLED_REFLECTION
  19603. 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)));
  19604. #else
  19605. 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));
  19606. #endif
  19607. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  19608. Expression.Invoke(
  19609. Expression.Call(
  19610. null,
  19611. m,
  19612. Expression.Constant(provider, typeof(IQbservableProvider)),
  19613. function,
  19614. Expression.Constant(scheduler, typeof(IScheduler))
  19615. ),
  19616. Expression.Constant(t1, typeof(TArg1)),
  19617. Expression.Constant(t2, typeof(TArg2)),
  19618. Expression.Constant(t3, typeof(TArg3)),
  19619. Expression.Constant(t4, typeof(TArg4)),
  19620. Expression.Constant(t5, typeof(TArg5)),
  19621. Expression.Constant(t6, typeof(TArg6)),
  19622. Expression.Constant(t7, typeof(TArg7)),
  19623. Expression.Constant(t8, typeof(TArg8)),
  19624. Expression.Constant(t9, typeof(TArg9))
  19625. )
  19626. );
  19627. }
  19628. /// <summary>
  19629. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19630. /// </summary>
  19631. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19632. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19633. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19634. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19635. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19636. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19637. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19638. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19639. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19640. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19641. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19642. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19643. /// <param name="function">Function to convert to an asynchronous function.</param>
  19644. /// <returns>Asynchronous function.</returns>
  19645. /// <exception cref="ArgumentNullException">
  19646. /// <paramref name="function" /> is null.</exception>
  19647. 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)
  19648. {
  19649. if (provider == null)
  19650. throw new ArgumentNullException(nameof(provider));
  19651. if (function == null)
  19652. throw new ArgumentNullException(nameof(function));
  19653. #if CRIPPLED_REFLECTION
  19654. 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>>)));
  19655. #else
  19656. 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));
  19657. #endif
  19658. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  19659. Expression.Invoke(
  19660. Expression.Call(
  19661. null,
  19662. m,
  19663. Expression.Constant(provider, typeof(IQbservableProvider)),
  19664. function
  19665. ),
  19666. Expression.Constant(t1, typeof(TArg1)),
  19667. Expression.Constant(t2, typeof(TArg2)),
  19668. Expression.Constant(t3, typeof(TArg3)),
  19669. Expression.Constant(t4, typeof(TArg4)),
  19670. Expression.Constant(t5, typeof(TArg5)),
  19671. Expression.Constant(t6, typeof(TArg6)),
  19672. Expression.Constant(t7, typeof(TArg7)),
  19673. Expression.Constant(t8, typeof(TArg8)),
  19674. Expression.Constant(t9, typeof(TArg9)),
  19675. Expression.Constant(t10, typeof(TArg10))
  19676. )
  19677. );
  19678. }
  19679. /// <summary>
  19680. /// 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.
  19681. /// </summary>
  19682. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19683. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19684. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19685. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19686. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19687. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19688. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19689. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19690. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19691. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19692. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19693. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19694. /// <param name="function">Function to convert to an asynchronous function.</param>
  19695. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19696. /// <returns>Asynchronous function.</returns>
  19697. /// <exception cref="ArgumentNullException">
  19698. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19699. 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)
  19700. {
  19701. if (provider == null)
  19702. throw new ArgumentNullException(nameof(provider));
  19703. if (function == null)
  19704. throw new ArgumentNullException(nameof(function));
  19705. if (scheduler == null)
  19706. throw new ArgumentNullException(nameof(scheduler));
  19707. #if CRIPPLED_REFLECTION
  19708. 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)));
  19709. #else
  19710. 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));
  19711. #endif
  19712. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  19713. Expression.Invoke(
  19714. Expression.Call(
  19715. null,
  19716. m,
  19717. Expression.Constant(provider, typeof(IQbservableProvider)),
  19718. function,
  19719. Expression.Constant(scheduler, typeof(IScheduler))
  19720. ),
  19721. Expression.Constant(t1, typeof(TArg1)),
  19722. Expression.Constant(t2, typeof(TArg2)),
  19723. Expression.Constant(t3, typeof(TArg3)),
  19724. Expression.Constant(t4, typeof(TArg4)),
  19725. Expression.Constant(t5, typeof(TArg5)),
  19726. Expression.Constant(t6, typeof(TArg6)),
  19727. Expression.Constant(t7, typeof(TArg7)),
  19728. Expression.Constant(t8, typeof(TArg8)),
  19729. Expression.Constant(t9, typeof(TArg9)),
  19730. Expression.Constant(t10, typeof(TArg10))
  19731. )
  19732. );
  19733. }
  19734. /// <summary>
  19735. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19736. /// </summary>
  19737. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19738. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19739. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19740. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19741. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19742. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19743. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19744. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19745. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19746. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19747. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19748. /// <typeparam name="TArg11">The type of the eleventh 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. /// <returns>Asynchronous function.</returns>
  19752. /// <exception cref="ArgumentNullException">
  19753. /// <paramref name="function" /> is null.</exception>
  19754. 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)
  19755. {
  19756. if (provider == null)
  19757. throw new ArgumentNullException(nameof(provider));
  19758. if (function == null)
  19759. throw new ArgumentNullException(nameof(function));
  19760. #if CRIPPLED_REFLECTION
  19761. 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>>)));
  19762. #else
  19763. 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));
  19764. #endif
  19765. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  19766. Expression.Invoke(
  19767. Expression.Call(
  19768. null,
  19769. m,
  19770. Expression.Constant(provider, typeof(IQbservableProvider)),
  19771. function
  19772. ),
  19773. Expression.Constant(t1, typeof(TArg1)),
  19774. Expression.Constant(t2, typeof(TArg2)),
  19775. Expression.Constant(t3, typeof(TArg3)),
  19776. Expression.Constant(t4, typeof(TArg4)),
  19777. Expression.Constant(t5, typeof(TArg5)),
  19778. Expression.Constant(t6, typeof(TArg6)),
  19779. Expression.Constant(t7, typeof(TArg7)),
  19780. Expression.Constant(t8, typeof(TArg8)),
  19781. Expression.Constant(t9, typeof(TArg9)),
  19782. Expression.Constant(t10, typeof(TArg10)),
  19783. Expression.Constant(t11, typeof(TArg11))
  19784. )
  19785. );
  19786. }
  19787. /// <summary>
  19788. /// 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.
  19789. /// </summary>
  19790. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19791. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19792. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19793. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19794. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19795. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19796. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19797. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19798. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19799. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19800. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19801. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19802. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19803. /// <param name="function">Function to convert to an asynchronous function.</param>
  19804. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19805. /// <returns>Asynchronous function.</returns>
  19806. /// <exception cref="ArgumentNullException">
  19807. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19808. 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)
  19809. {
  19810. if (provider == null)
  19811. throw new ArgumentNullException(nameof(provider));
  19812. if (function == null)
  19813. throw new ArgumentNullException(nameof(function));
  19814. if (scheduler == null)
  19815. throw new ArgumentNullException(nameof(scheduler));
  19816. #if CRIPPLED_REFLECTION
  19817. 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)));
  19818. #else
  19819. 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));
  19820. #endif
  19821. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  19822. Expression.Invoke(
  19823. Expression.Call(
  19824. null,
  19825. m,
  19826. Expression.Constant(provider, typeof(IQbservableProvider)),
  19827. function,
  19828. Expression.Constant(scheduler, typeof(IScheduler))
  19829. ),
  19830. Expression.Constant(t1, typeof(TArg1)),
  19831. Expression.Constant(t2, typeof(TArg2)),
  19832. Expression.Constant(t3, typeof(TArg3)),
  19833. Expression.Constant(t4, typeof(TArg4)),
  19834. Expression.Constant(t5, typeof(TArg5)),
  19835. Expression.Constant(t6, typeof(TArg6)),
  19836. Expression.Constant(t7, typeof(TArg7)),
  19837. Expression.Constant(t8, typeof(TArg8)),
  19838. Expression.Constant(t9, typeof(TArg9)),
  19839. Expression.Constant(t10, typeof(TArg10)),
  19840. Expression.Constant(t11, typeof(TArg11))
  19841. )
  19842. );
  19843. }
  19844. /// <summary>
  19845. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19846. /// </summary>
  19847. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19848. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19849. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19850. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19851. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19852. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19853. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19854. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19855. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19856. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19857. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19858. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19859. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  19860. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19861. /// <param name="function">Function to convert to an asynchronous function.</param>
  19862. /// <returns>Asynchronous function.</returns>
  19863. /// <exception cref="ArgumentNullException">
  19864. /// <paramref name="function" /> is null.</exception>
  19865. 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)
  19866. {
  19867. if (provider == null)
  19868. throw new ArgumentNullException(nameof(provider));
  19869. if (function == null)
  19870. throw new ArgumentNullException(nameof(function));
  19871. #if CRIPPLED_REFLECTION
  19872. 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>>)));
  19873. #else
  19874. 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));
  19875. #endif
  19876. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  19877. Expression.Invoke(
  19878. Expression.Call(
  19879. null,
  19880. m,
  19881. Expression.Constant(provider, typeof(IQbservableProvider)),
  19882. function
  19883. ),
  19884. Expression.Constant(t1, typeof(TArg1)),
  19885. Expression.Constant(t2, typeof(TArg2)),
  19886. Expression.Constant(t3, typeof(TArg3)),
  19887. Expression.Constant(t4, typeof(TArg4)),
  19888. Expression.Constant(t5, typeof(TArg5)),
  19889. Expression.Constant(t6, typeof(TArg6)),
  19890. Expression.Constant(t7, typeof(TArg7)),
  19891. Expression.Constant(t8, typeof(TArg8)),
  19892. Expression.Constant(t9, typeof(TArg9)),
  19893. Expression.Constant(t10, typeof(TArg10)),
  19894. Expression.Constant(t11, typeof(TArg11)),
  19895. Expression.Constant(t12, typeof(TArg12))
  19896. )
  19897. );
  19898. }
  19899. /// <summary>
  19900. /// 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.
  19901. /// </summary>
  19902. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19903. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19904. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19905. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19906. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19907. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19908. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19909. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19910. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19911. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19912. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19913. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19914. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  19915. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19916. /// <param name="function">Function to convert to an asynchronous function.</param>
  19917. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  19918. /// <returns>Asynchronous function.</returns>
  19919. /// <exception cref="ArgumentNullException">
  19920. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  19921. 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)
  19922. {
  19923. if (provider == null)
  19924. throw new ArgumentNullException(nameof(provider));
  19925. if (function == null)
  19926. throw new ArgumentNullException(nameof(function));
  19927. if (scheduler == null)
  19928. throw new ArgumentNullException(nameof(scheduler));
  19929. #if CRIPPLED_REFLECTION
  19930. 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)));
  19931. #else
  19932. 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));
  19933. #endif
  19934. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  19935. Expression.Invoke(
  19936. Expression.Call(
  19937. null,
  19938. m,
  19939. Expression.Constant(provider, typeof(IQbservableProvider)),
  19940. function,
  19941. Expression.Constant(scheduler, typeof(IScheduler))
  19942. ),
  19943. Expression.Constant(t1, typeof(TArg1)),
  19944. Expression.Constant(t2, typeof(TArg2)),
  19945. Expression.Constant(t3, typeof(TArg3)),
  19946. Expression.Constant(t4, typeof(TArg4)),
  19947. Expression.Constant(t5, typeof(TArg5)),
  19948. Expression.Constant(t6, typeof(TArg6)),
  19949. Expression.Constant(t7, typeof(TArg7)),
  19950. Expression.Constant(t8, typeof(TArg8)),
  19951. Expression.Constant(t9, typeof(TArg9)),
  19952. Expression.Constant(t10, typeof(TArg10)),
  19953. Expression.Constant(t11, typeof(TArg11)),
  19954. Expression.Constant(t12, typeof(TArg12))
  19955. )
  19956. );
  19957. }
  19958. /// <summary>
  19959. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  19960. /// </summary>
  19961. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  19962. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  19963. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  19964. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  19965. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  19966. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  19967. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  19968. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  19969. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  19970. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  19971. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  19972. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  19973. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  19974. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  19975. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  19976. /// <param name="function">Function to convert to an asynchronous function.</param>
  19977. /// <returns>Asynchronous function.</returns>
  19978. /// <exception cref="ArgumentNullException">
  19979. /// <paramref name="function" /> is null.</exception>
  19980. 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)
  19981. {
  19982. if (provider == null)
  19983. throw new ArgumentNullException(nameof(provider));
  19984. if (function == null)
  19985. throw new ArgumentNullException(nameof(function));
  19986. #if CRIPPLED_REFLECTION
  19987. 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>>)));
  19988. #else
  19989. 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));
  19990. #endif
  19991. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  19992. Expression.Invoke(
  19993. Expression.Call(
  19994. null,
  19995. m,
  19996. Expression.Constant(provider, typeof(IQbservableProvider)),
  19997. function
  19998. ),
  19999. Expression.Constant(t1, typeof(TArg1)),
  20000. Expression.Constant(t2, typeof(TArg2)),
  20001. Expression.Constant(t3, typeof(TArg3)),
  20002. Expression.Constant(t4, typeof(TArg4)),
  20003. Expression.Constant(t5, typeof(TArg5)),
  20004. Expression.Constant(t6, typeof(TArg6)),
  20005. Expression.Constant(t7, typeof(TArg7)),
  20006. Expression.Constant(t8, typeof(TArg8)),
  20007. Expression.Constant(t9, typeof(TArg9)),
  20008. Expression.Constant(t10, typeof(TArg10)),
  20009. Expression.Constant(t11, typeof(TArg11)),
  20010. Expression.Constant(t12, typeof(TArg12)),
  20011. Expression.Constant(t13, typeof(TArg13))
  20012. )
  20013. );
  20014. }
  20015. /// <summary>
  20016. /// 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.
  20017. /// </summary>
  20018. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20019. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20020. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20021. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20022. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20023. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20024. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20025. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20026. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20027. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20028. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20029. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20030. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20031. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20032. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20033. /// <param name="function">Function to convert to an asynchronous function.</param>
  20034. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20035. /// <returns>Asynchronous function.</returns>
  20036. /// <exception cref="ArgumentNullException">
  20037. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20038. 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)
  20039. {
  20040. if (provider == null)
  20041. throw new ArgumentNullException(nameof(provider));
  20042. if (function == null)
  20043. throw new ArgumentNullException(nameof(function));
  20044. if (scheduler == null)
  20045. throw new ArgumentNullException(nameof(scheduler));
  20046. #if CRIPPLED_REFLECTION
  20047. 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)));
  20048. #else
  20049. 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));
  20050. #endif
  20051. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  20052. Expression.Invoke(
  20053. Expression.Call(
  20054. null,
  20055. m,
  20056. Expression.Constant(provider, typeof(IQbservableProvider)),
  20057. function,
  20058. Expression.Constant(scheduler, typeof(IScheduler))
  20059. ),
  20060. Expression.Constant(t1, typeof(TArg1)),
  20061. Expression.Constant(t2, typeof(TArg2)),
  20062. Expression.Constant(t3, typeof(TArg3)),
  20063. Expression.Constant(t4, typeof(TArg4)),
  20064. Expression.Constant(t5, typeof(TArg5)),
  20065. Expression.Constant(t6, typeof(TArg6)),
  20066. Expression.Constant(t7, typeof(TArg7)),
  20067. Expression.Constant(t8, typeof(TArg8)),
  20068. Expression.Constant(t9, typeof(TArg9)),
  20069. Expression.Constant(t10, typeof(TArg10)),
  20070. Expression.Constant(t11, typeof(TArg11)),
  20071. Expression.Constant(t12, typeof(TArg12)),
  20072. Expression.Constant(t13, typeof(TArg13))
  20073. )
  20074. );
  20075. }
  20076. /// <summary>
  20077. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20078. /// </summary>
  20079. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20080. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20081. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20082. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20083. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20084. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20085. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20086. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20087. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20088. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20089. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20090. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20091. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20092. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20093. /// <typeparam name="TArg14">The type of the fourteenth 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, 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)
  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, 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>>)));
  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(TArg11), typeof(TArg12), typeof(TArg13), typeof(TArg14), typeof(TResult));
  20109. #endif
  20110. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => 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. Expression.Constant(t11, typeof(TArg11)),
  20129. Expression.Constant(t12, typeof(TArg12)),
  20130. Expression.Constant(t13, typeof(TArg13)),
  20131. Expression.Constant(t14, typeof(TArg14))
  20132. )
  20133. );
  20134. }
  20135. /// <summary>
  20136. /// 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.
  20137. /// </summary>
  20138. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20139. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20140. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20141. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20142. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20143. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20144. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20145. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20146. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20147. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20148. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20149. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20150. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20151. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20152. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20153. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20154. /// <param name="function">Function to convert to an asynchronous function.</param>
  20155. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20156. /// <returns>Asynchronous function.</returns>
  20157. /// <exception cref="ArgumentNullException">
  20158. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20159. 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)
  20160. {
  20161. if (provider == null)
  20162. throw new ArgumentNullException(nameof(provider));
  20163. if (function == null)
  20164. throw new ArgumentNullException(nameof(function));
  20165. if (scheduler == null)
  20166. throw new ArgumentNullException(nameof(scheduler));
  20167. #if CRIPPLED_REFLECTION
  20168. 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)));
  20169. #else
  20170. 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));
  20171. #endif
  20172. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  20173. Expression.Invoke(
  20174. Expression.Call(
  20175. null,
  20176. m,
  20177. Expression.Constant(provider, typeof(IQbservableProvider)),
  20178. function,
  20179. Expression.Constant(scheduler, typeof(IScheduler))
  20180. ),
  20181. Expression.Constant(t1, typeof(TArg1)),
  20182. Expression.Constant(t2, typeof(TArg2)),
  20183. Expression.Constant(t3, typeof(TArg3)),
  20184. Expression.Constant(t4, typeof(TArg4)),
  20185. Expression.Constant(t5, typeof(TArg5)),
  20186. Expression.Constant(t6, typeof(TArg6)),
  20187. Expression.Constant(t7, typeof(TArg7)),
  20188. Expression.Constant(t8, typeof(TArg8)),
  20189. Expression.Constant(t9, typeof(TArg9)),
  20190. Expression.Constant(t10, typeof(TArg10)),
  20191. Expression.Constant(t11, typeof(TArg11)),
  20192. Expression.Constant(t12, typeof(TArg12)),
  20193. Expression.Constant(t13, typeof(TArg13)),
  20194. Expression.Constant(t14, typeof(TArg14))
  20195. )
  20196. );
  20197. }
  20198. /// <summary>
  20199. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20200. /// </summary>
  20201. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20202. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20203. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20204. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20205. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20206. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20207. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20208. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20209. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20210. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20211. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20212. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20213. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20214. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20215. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20216. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20217. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20218. /// <param name="function">Function to convert to an asynchronous function.</param>
  20219. /// <returns>Asynchronous function.</returns>
  20220. /// <exception cref="ArgumentNullException">
  20221. /// <paramref name="function" /> is null.</exception>
  20222. 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)
  20223. {
  20224. if (provider == null)
  20225. throw new ArgumentNullException(nameof(provider));
  20226. if (function == null)
  20227. throw new ArgumentNullException(nameof(function));
  20228. #if CRIPPLED_REFLECTION
  20229. 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>>)));
  20230. #else
  20231. 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));
  20232. #endif
  20233. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20234. Expression.Invoke(
  20235. Expression.Call(
  20236. null,
  20237. m,
  20238. Expression.Constant(provider, typeof(IQbservableProvider)),
  20239. function
  20240. ),
  20241. Expression.Constant(t1, typeof(TArg1)),
  20242. Expression.Constant(t2, typeof(TArg2)),
  20243. Expression.Constant(t3, typeof(TArg3)),
  20244. Expression.Constant(t4, typeof(TArg4)),
  20245. Expression.Constant(t5, typeof(TArg5)),
  20246. Expression.Constant(t6, typeof(TArg6)),
  20247. Expression.Constant(t7, typeof(TArg7)),
  20248. Expression.Constant(t8, typeof(TArg8)),
  20249. Expression.Constant(t9, typeof(TArg9)),
  20250. Expression.Constant(t10, typeof(TArg10)),
  20251. Expression.Constant(t11, typeof(TArg11)),
  20252. Expression.Constant(t12, typeof(TArg12)),
  20253. Expression.Constant(t13, typeof(TArg13)),
  20254. Expression.Constant(t14, typeof(TArg14)),
  20255. Expression.Constant(t15, typeof(TArg15))
  20256. )
  20257. );
  20258. }
  20259. /// <summary>
  20260. /// 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.
  20261. /// </summary>
  20262. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20263. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20264. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20265. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20266. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20267. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20268. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20269. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20270. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20271. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20272. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20273. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20274. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20275. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20276. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20277. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20278. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20279. /// <param name="function">Function to convert to an asynchronous function.</param>
  20280. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20281. /// <returns>Asynchronous function.</returns>
  20282. /// <exception cref="ArgumentNullException">
  20283. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20284. 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)
  20285. {
  20286. if (provider == null)
  20287. throw new ArgumentNullException(nameof(provider));
  20288. if (function == null)
  20289. throw new ArgumentNullException(nameof(function));
  20290. if (scheduler == null)
  20291. throw new ArgumentNullException(nameof(scheduler));
  20292. #if CRIPPLED_REFLECTION
  20293. 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)));
  20294. #else
  20295. 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));
  20296. #endif
  20297. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) => provider.CreateQuery<TResult>(
  20298. Expression.Invoke(
  20299. Expression.Call(
  20300. null,
  20301. m,
  20302. Expression.Constant(provider, typeof(IQbservableProvider)),
  20303. function,
  20304. Expression.Constant(scheduler, typeof(IScheduler))
  20305. ),
  20306. Expression.Constant(t1, typeof(TArg1)),
  20307. Expression.Constant(t2, typeof(TArg2)),
  20308. Expression.Constant(t3, typeof(TArg3)),
  20309. Expression.Constant(t4, typeof(TArg4)),
  20310. Expression.Constant(t5, typeof(TArg5)),
  20311. Expression.Constant(t6, typeof(TArg6)),
  20312. Expression.Constant(t7, typeof(TArg7)),
  20313. Expression.Constant(t8, typeof(TArg8)),
  20314. Expression.Constant(t9, typeof(TArg9)),
  20315. Expression.Constant(t10, typeof(TArg10)),
  20316. Expression.Constant(t11, typeof(TArg11)),
  20317. Expression.Constant(t12, typeof(TArg12)),
  20318. Expression.Constant(t13, typeof(TArg13)),
  20319. Expression.Constant(t14, typeof(TArg14)),
  20320. Expression.Constant(t15, typeof(TArg15))
  20321. )
  20322. );
  20323. }
  20324. /// <summary>
  20325. /// Converts the function into an asynchronous function. Each invocation of the resulting asynchronous function causes an invocation of the original synchronous function.
  20326. /// </summary>
  20327. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20328. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20329. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20330. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20331. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20332. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20333. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20334. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20335. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20336. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20337. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20338. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20339. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20340. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20341. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20342. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20343. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20344. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20345. /// <param name="function">Function to convert to an asynchronous function.</param>
  20346. /// <returns>Asynchronous function.</returns>
  20347. /// <exception cref="ArgumentNullException">
  20348. /// <paramref name="function" /> is null.</exception>
  20349. 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)
  20350. {
  20351. if (provider == null)
  20352. throw new ArgumentNullException(nameof(provider));
  20353. if (function == null)
  20354. throw new ArgumentNullException(nameof(function));
  20355. #if CRIPPLED_REFLECTION
  20356. 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>>)));
  20357. #else
  20358. 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));
  20359. #endif
  20360. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20361. Expression.Invoke(
  20362. Expression.Call(
  20363. null,
  20364. m,
  20365. Expression.Constant(provider, typeof(IQbservableProvider)),
  20366. function
  20367. ),
  20368. Expression.Constant(t1, typeof(TArg1)),
  20369. Expression.Constant(t2, typeof(TArg2)),
  20370. Expression.Constant(t3, typeof(TArg3)),
  20371. Expression.Constant(t4, typeof(TArg4)),
  20372. Expression.Constant(t5, typeof(TArg5)),
  20373. Expression.Constant(t6, typeof(TArg6)),
  20374. Expression.Constant(t7, typeof(TArg7)),
  20375. Expression.Constant(t8, typeof(TArg8)),
  20376. Expression.Constant(t9, typeof(TArg9)),
  20377. Expression.Constant(t10, typeof(TArg10)),
  20378. Expression.Constant(t11, typeof(TArg11)),
  20379. Expression.Constant(t12, typeof(TArg12)),
  20380. Expression.Constant(t13, typeof(TArg13)),
  20381. Expression.Constant(t14, typeof(TArg14)),
  20382. Expression.Constant(t15, typeof(TArg15)),
  20383. Expression.Constant(t16, typeof(TArg16))
  20384. )
  20385. );
  20386. }
  20387. /// <summary>
  20388. /// 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.
  20389. /// </summary>
  20390. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20391. /// <typeparam name="TArg1">The type of the first argument passed to the function.</typeparam>
  20392. /// <typeparam name="TArg2">The type of the second argument passed to the function.</typeparam>
  20393. /// <typeparam name="TArg3">The type of the third argument passed to the function.</typeparam>
  20394. /// <typeparam name="TArg4">The type of the fourth argument passed to the function.</typeparam>
  20395. /// <typeparam name="TArg5">The type of the fifth argument passed to the function.</typeparam>
  20396. /// <typeparam name="TArg6">The type of the sixth argument passed to the function.</typeparam>
  20397. /// <typeparam name="TArg7">The type of the seventh argument passed to the function.</typeparam>
  20398. /// <typeparam name="TArg8">The type of the eighth argument passed to the function.</typeparam>
  20399. /// <typeparam name="TArg9">The type of the ninth argument passed to the function.</typeparam>
  20400. /// <typeparam name="TArg10">The type of the tenth argument passed to the function.</typeparam>
  20401. /// <typeparam name="TArg11">The type of the eleventh argument passed to the function.</typeparam>
  20402. /// <typeparam name="TArg12">The type of the twelfth argument passed to the function.</typeparam>
  20403. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the function.</typeparam>
  20404. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the function.</typeparam>
  20405. /// <typeparam name="TArg15">The type of the fifteenth argument passed to the function.</typeparam>
  20406. /// <typeparam name="TArg16">The type of the sixteenth argument passed to the function.</typeparam>
  20407. /// <typeparam name="TResult">The type of the result returned by the function.</typeparam>
  20408. /// <param name="function">Function to convert to an asynchronous function.</param>
  20409. /// <param name="scheduler">Scheduler to invoke the original function on.</param>
  20410. /// <returns>Asynchronous function.</returns>
  20411. /// <exception cref="ArgumentNullException">
  20412. /// <paramref name="function" /> or <paramref name="scheduler" /> is null.</exception>
  20413. 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)
  20414. {
  20415. if (provider == null)
  20416. throw new ArgumentNullException(nameof(provider));
  20417. if (function == null)
  20418. throw new ArgumentNullException(nameof(function));
  20419. if (scheduler == null)
  20420. throw new ArgumentNullException(nameof(scheduler));
  20421. #if CRIPPLED_REFLECTION
  20422. 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)));
  20423. #else
  20424. 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));
  20425. #endif
  20426. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) => provider.CreateQuery<TResult>(
  20427. Expression.Invoke(
  20428. Expression.Call(
  20429. null,
  20430. m,
  20431. Expression.Constant(provider, typeof(IQbservableProvider)),
  20432. function,
  20433. Expression.Constant(scheduler, typeof(IScheduler))
  20434. ),
  20435. Expression.Constant(t1, typeof(TArg1)),
  20436. Expression.Constant(t2, typeof(TArg2)),
  20437. Expression.Constant(t3, typeof(TArg3)),
  20438. Expression.Constant(t4, typeof(TArg4)),
  20439. Expression.Constant(t5, typeof(TArg5)),
  20440. Expression.Constant(t6, typeof(TArg6)),
  20441. Expression.Constant(t7, typeof(TArg7)),
  20442. Expression.Constant(t8, typeof(TArg8)),
  20443. Expression.Constant(t9, typeof(TArg9)),
  20444. Expression.Constant(t10, typeof(TArg10)),
  20445. Expression.Constant(t11, typeof(TArg11)),
  20446. Expression.Constant(t12, typeof(TArg12)),
  20447. Expression.Constant(t13, typeof(TArg13)),
  20448. Expression.Constant(t14, typeof(TArg14)),
  20449. Expression.Constant(t15, typeof(TArg15)),
  20450. Expression.Constant(t16, typeof(TArg16))
  20451. )
  20452. );
  20453. }
  20454. /// <summary>
  20455. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20456. /// </summary>
  20457. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20458. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20459. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20460. /// <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>
  20461. /// <exception cref="ArgumentNullException">
  20462. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20463. /// <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>
  20464. #if PREFERASYNC
  20465. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20466. #endif
  20467. public static Func<IQbservable<Unit>> FromAsyncPattern(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  20468. {
  20469. if (provider == null)
  20470. throw new ArgumentNullException(nameof(provider));
  20471. if (begin == null)
  20472. throw new ArgumentNullException(nameof(begin));
  20473. if (end == null)
  20474. throw new ArgumentNullException(nameof(end));
  20475. #if CRIPPLED_REFLECTION
  20476. var m = InfoOf(() => Qbservable.FromAsyncPattern(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20477. #else
  20478. var m = (MethodInfo)MethodInfo.GetCurrentMethod();
  20479. #endif
  20480. return () => provider.CreateQuery<Unit>(
  20481. Expression.Invoke(
  20482. Expression.Call(
  20483. null,
  20484. m,
  20485. Expression.Constant(provider, typeof(IQbservableProvider)),
  20486. begin,
  20487. end
  20488. )
  20489. )
  20490. );
  20491. }
  20492. /// <summary>
  20493. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20494. /// </summary>
  20495. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20496. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20497. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20498. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20499. /// <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>
  20500. /// <exception cref="ArgumentNullException">
  20501. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20502. /// <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>
  20503. #if PREFERASYNC
  20504. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20505. #endif
  20506. public static Func<TArg1, IQbservable<Unit>> FromAsyncPattern<TArg1>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Action<IAsyncResult>>end)
  20507. {
  20508. if (provider == null)
  20509. throw new ArgumentNullException(nameof(provider));
  20510. if (begin == null)
  20511. throw new ArgumentNullException(nameof(begin));
  20512. if (end == null)
  20513. throw new ArgumentNullException(nameof(end));
  20514. #if CRIPPLED_REFLECTION
  20515. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20516. #else
  20517. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1));
  20518. #endif
  20519. return (t1) => provider.CreateQuery<Unit>(
  20520. Expression.Invoke(
  20521. Expression.Call(
  20522. null,
  20523. m,
  20524. Expression.Constant(provider, typeof(IQbservableProvider)),
  20525. begin,
  20526. end
  20527. ),
  20528. Expression.Constant(t1, typeof(TArg1))
  20529. )
  20530. );
  20531. }
  20532. /// <summary>
  20533. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20534. /// </summary>
  20535. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20536. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20537. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20538. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20539. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20540. /// <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>
  20541. /// <exception cref="ArgumentNullException">
  20542. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20543. /// <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>
  20544. #if PREFERASYNC
  20545. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20546. #endif
  20547. 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)
  20548. {
  20549. if (provider == null)
  20550. throw new ArgumentNullException(nameof(provider));
  20551. if (begin == null)
  20552. throw new ArgumentNullException(nameof(begin));
  20553. if (end == null)
  20554. throw new ArgumentNullException(nameof(end));
  20555. #if CRIPPLED_REFLECTION
  20556. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20557. #else
  20558. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2));
  20559. #endif
  20560. return (t1, t2) => provider.CreateQuery<Unit>(
  20561. Expression.Invoke(
  20562. Expression.Call(
  20563. null,
  20564. m,
  20565. Expression.Constant(provider, typeof(IQbservableProvider)),
  20566. begin,
  20567. end
  20568. ),
  20569. Expression.Constant(t1, typeof(TArg1)),
  20570. Expression.Constant(t2, typeof(TArg2))
  20571. )
  20572. );
  20573. }
  20574. /// <summary>
  20575. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20576. /// </summary>
  20577. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20578. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20579. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20580. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20581. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20582. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20583. /// <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>
  20584. /// <exception cref="ArgumentNullException">
  20585. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20586. /// <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>
  20587. #if PREFERASYNC
  20588. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20589. #endif
  20590. 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)
  20591. {
  20592. if (provider == null)
  20593. throw new ArgumentNullException(nameof(provider));
  20594. if (begin == null)
  20595. throw new ArgumentNullException(nameof(begin));
  20596. if (end == null)
  20597. throw new ArgumentNullException(nameof(end));
  20598. #if CRIPPLED_REFLECTION
  20599. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TArg3>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, TArg3, AsyncCallback, object, IAsyncResult>>), default(Expression<Action<IAsyncResult>>)));
  20600. #else
  20601. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3));
  20602. #endif
  20603. return (t1, t2, t3) => provider.CreateQuery<Unit>(
  20604. Expression.Invoke(
  20605. Expression.Call(
  20606. null,
  20607. m,
  20608. Expression.Constant(provider, typeof(IQbservableProvider)),
  20609. begin,
  20610. end
  20611. ),
  20612. Expression.Constant(t1, typeof(TArg1)),
  20613. Expression.Constant(t2, typeof(TArg2)),
  20614. Expression.Constant(t3, typeof(TArg3))
  20615. )
  20616. );
  20617. }
  20618. /// <summary>
  20619. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20620. /// </summary>
  20621. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20622. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20623. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20624. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20625. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20626. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20627. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20628. /// <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>
  20629. /// <exception cref="ArgumentNullException">
  20630. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20631. /// <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>
  20632. #if PREFERASYNC
  20633. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20634. #endif
  20635. 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)
  20636. {
  20637. if (provider == null)
  20638. throw new ArgumentNullException(nameof(provider));
  20639. if (begin == null)
  20640. throw new ArgumentNullException(nameof(begin));
  20641. if (end == null)
  20642. throw new ArgumentNullException(nameof(end));
  20643. #if CRIPPLED_REFLECTION
  20644. 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>>)));
  20645. #else
  20646. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4));
  20647. #endif
  20648. return (t1, t2, t3, t4) => provider.CreateQuery<Unit>(
  20649. Expression.Invoke(
  20650. Expression.Call(
  20651. null,
  20652. m,
  20653. Expression.Constant(provider, typeof(IQbservableProvider)),
  20654. begin,
  20655. end
  20656. ),
  20657. Expression.Constant(t1, typeof(TArg1)),
  20658. Expression.Constant(t2, typeof(TArg2)),
  20659. Expression.Constant(t3, typeof(TArg3)),
  20660. Expression.Constant(t4, typeof(TArg4))
  20661. )
  20662. );
  20663. }
  20664. /// <summary>
  20665. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20666. /// </summary>
  20667. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20668. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20669. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20670. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20671. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20672. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20673. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20674. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20675. /// <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>
  20676. /// <exception cref="ArgumentNullException">
  20677. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20678. /// <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>
  20679. #if PREFERASYNC
  20680. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20681. #endif
  20682. 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)
  20683. {
  20684. if (provider == null)
  20685. throw new ArgumentNullException(nameof(provider));
  20686. if (begin == null)
  20687. throw new ArgumentNullException(nameof(begin));
  20688. if (end == null)
  20689. throw new ArgumentNullException(nameof(end));
  20690. #if CRIPPLED_REFLECTION
  20691. 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>>)));
  20692. #else
  20693. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5));
  20694. #endif
  20695. return (t1, t2, t3, t4, t5) => provider.CreateQuery<Unit>(
  20696. Expression.Invoke(
  20697. Expression.Call(
  20698. null,
  20699. m,
  20700. Expression.Constant(provider, typeof(IQbservableProvider)),
  20701. begin,
  20702. end
  20703. ),
  20704. Expression.Constant(t1, typeof(TArg1)),
  20705. Expression.Constant(t2, typeof(TArg2)),
  20706. Expression.Constant(t3, typeof(TArg3)),
  20707. Expression.Constant(t4, typeof(TArg4)),
  20708. Expression.Constant(t5, typeof(TArg5))
  20709. )
  20710. );
  20711. }
  20712. /// <summary>
  20713. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20714. /// </summary>
  20715. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20716. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20717. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20718. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20719. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20720. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20721. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20722. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20723. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20724. /// <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>
  20725. /// <exception cref="ArgumentNullException">
  20726. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20727. /// <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>
  20728. #if PREFERASYNC
  20729. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20730. #endif
  20731. 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)
  20732. {
  20733. if (provider == null)
  20734. throw new ArgumentNullException(nameof(provider));
  20735. if (begin == null)
  20736. throw new ArgumentNullException(nameof(begin));
  20737. if (end == null)
  20738. throw new ArgumentNullException(nameof(end));
  20739. #if CRIPPLED_REFLECTION
  20740. 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>>)));
  20741. #else
  20742. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6));
  20743. #endif
  20744. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<Unit>(
  20745. Expression.Invoke(
  20746. Expression.Call(
  20747. null,
  20748. m,
  20749. Expression.Constant(provider, typeof(IQbservableProvider)),
  20750. begin,
  20751. end
  20752. ),
  20753. Expression.Constant(t1, typeof(TArg1)),
  20754. Expression.Constant(t2, typeof(TArg2)),
  20755. Expression.Constant(t3, typeof(TArg3)),
  20756. Expression.Constant(t4, typeof(TArg4)),
  20757. Expression.Constant(t5, typeof(TArg5)),
  20758. Expression.Constant(t6, typeof(TArg6))
  20759. )
  20760. );
  20761. }
  20762. /// <summary>
  20763. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20764. /// </summary>
  20765. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20766. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20767. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20768. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20769. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20770. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20771. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20772. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20773. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20774. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20775. /// <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>
  20776. /// <exception cref="ArgumentNullException">
  20777. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20778. /// <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>
  20779. #if PREFERASYNC
  20780. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20781. #endif
  20782. 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)
  20783. {
  20784. if (provider == null)
  20785. throw new ArgumentNullException(nameof(provider));
  20786. if (begin == null)
  20787. throw new ArgumentNullException(nameof(begin));
  20788. if (end == null)
  20789. throw new ArgumentNullException(nameof(end));
  20790. #if CRIPPLED_REFLECTION
  20791. 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>>)));
  20792. #else
  20793. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7));
  20794. #endif
  20795. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<Unit>(
  20796. Expression.Invoke(
  20797. Expression.Call(
  20798. null,
  20799. m,
  20800. Expression.Constant(provider, typeof(IQbservableProvider)),
  20801. begin,
  20802. end
  20803. ),
  20804. Expression.Constant(t1, typeof(TArg1)),
  20805. Expression.Constant(t2, typeof(TArg2)),
  20806. Expression.Constant(t3, typeof(TArg3)),
  20807. Expression.Constant(t4, typeof(TArg4)),
  20808. Expression.Constant(t5, typeof(TArg5)),
  20809. Expression.Constant(t6, typeof(TArg6)),
  20810. Expression.Constant(t7, typeof(TArg7))
  20811. )
  20812. );
  20813. }
  20814. /// <summary>
  20815. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20816. /// </summary>
  20817. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20818. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20819. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20820. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20821. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20822. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20823. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20824. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20825. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20826. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20827. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20828. /// <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>
  20829. /// <exception cref="ArgumentNullException">
  20830. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20831. /// <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>
  20832. #if PREFERASYNC
  20833. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20834. #endif
  20835. 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)
  20836. {
  20837. if (provider == null)
  20838. throw new ArgumentNullException(nameof(provider));
  20839. if (begin == null)
  20840. throw new ArgumentNullException(nameof(begin));
  20841. if (end == null)
  20842. throw new ArgumentNullException(nameof(end));
  20843. #if CRIPPLED_REFLECTION
  20844. 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>>)));
  20845. #else
  20846. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8));
  20847. #endif
  20848. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<Unit>(
  20849. Expression.Invoke(
  20850. Expression.Call(
  20851. null,
  20852. m,
  20853. Expression.Constant(provider, typeof(IQbservableProvider)),
  20854. begin,
  20855. end
  20856. ),
  20857. Expression.Constant(t1, typeof(TArg1)),
  20858. Expression.Constant(t2, typeof(TArg2)),
  20859. Expression.Constant(t3, typeof(TArg3)),
  20860. Expression.Constant(t4, typeof(TArg4)),
  20861. Expression.Constant(t5, typeof(TArg5)),
  20862. Expression.Constant(t6, typeof(TArg6)),
  20863. Expression.Constant(t7, typeof(TArg7)),
  20864. Expression.Constant(t8, typeof(TArg8))
  20865. )
  20866. );
  20867. }
  20868. /// <summary>
  20869. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20870. /// </summary>
  20871. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20872. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20873. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20874. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20875. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20876. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20877. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20878. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20879. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20880. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  20881. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20882. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20883. /// <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>
  20884. /// <exception cref="ArgumentNullException">
  20885. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20886. /// <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>
  20887. #if PREFERASYNC
  20888. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20889. #endif
  20890. 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)
  20891. {
  20892. if (provider == null)
  20893. throw new ArgumentNullException(nameof(provider));
  20894. if (begin == null)
  20895. throw new ArgumentNullException(nameof(begin));
  20896. if (end == null)
  20897. throw new ArgumentNullException(nameof(end));
  20898. #if CRIPPLED_REFLECTION
  20899. 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>>)));
  20900. #else
  20901. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TArg9));
  20902. #endif
  20903. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<Unit>(
  20904. Expression.Invoke(
  20905. Expression.Call(
  20906. null,
  20907. m,
  20908. Expression.Constant(provider, typeof(IQbservableProvider)),
  20909. begin,
  20910. end
  20911. ),
  20912. Expression.Constant(t1, typeof(TArg1)),
  20913. Expression.Constant(t2, typeof(TArg2)),
  20914. Expression.Constant(t3, typeof(TArg3)),
  20915. Expression.Constant(t4, typeof(TArg4)),
  20916. Expression.Constant(t5, typeof(TArg5)),
  20917. Expression.Constant(t6, typeof(TArg6)),
  20918. Expression.Constant(t7, typeof(TArg7)),
  20919. Expression.Constant(t8, typeof(TArg8)),
  20920. Expression.Constant(t9, typeof(TArg9))
  20921. )
  20922. );
  20923. }
  20924. /// <summary>
  20925. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20926. /// </summary>
  20927. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20928. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20929. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20930. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20931. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20932. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20933. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20934. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20935. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20936. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  20937. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  20938. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20939. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20940. /// <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>
  20941. /// <exception cref="ArgumentNullException">
  20942. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  20943. /// <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>
  20944. #if PREFERASYNC
  20945. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  20946. #endif
  20947. 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)
  20948. {
  20949. if (provider == null)
  20950. throw new ArgumentNullException(nameof(provider));
  20951. if (begin == null)
  20952. throw new ArgumentNullException(nameof(begin));
  20953. if (end == null)
  20954. throw new ArgumentNullException(nameof(end));
  20955. #if CRIPPLED_REFLECTION
  20956. 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>>)));
  20957. #else
  20958. 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));
  20959. #endif
  20960. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<Unit>(
  20961. Expression.Invoke(
  20962. Expression.Call(
  20963. null,
  20964. m,
  20965. Expression.Constant(provider, typeof(IQbservableProvider)),
  20966. begin,
  20967. end
  20968. ),
  20969. Expression.Constant(t1, typeof(TArg1)),
  20970. Expression.Constant(t2, typeof(TArg2)),
  20971. Expression.Constant(t3, typeof(TArg3)),
  20972. Expression.Constant(t4, typeof(TArg4)),
  20973. Expression.Constant(t5, typeof(TArg5)),
  20974. Expression.Constant(t6, typeof(TArg6)),
  20975. Expression.Constant(t7, typeof(TArg7)),
  20976. Expression.Constant(t8, typeof(TArg8)),
  20977. Expression.Constant(t9, typeof(TArg9)),
  20978. Expression.Constant(t10, typeof(TArg10))
  20979. )
  20980. );
  20981. }
  20982. /// <summary>
  20983. /// Converts a Begin/End invoke function pair into an asynchronous function.
  20984. /// </summary>
  20985. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  20986. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  20987. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  20988. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  20989. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  20990. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  20991. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  20992. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  20993. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  20994. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  20995. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  20996. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  20997. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  20998. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  20999. /// <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>
  21000. /// <exception cref="ArgumentNullException">
  21001. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21002. /// <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>
  21003. #if PREFERASYNC
  21004. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21005. #endif
  21006. 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)
  21007. {
  21008. if (provider == null)
  21009. throw new ArgumentNullException(nameof(provider));
  21010. if (begin == null)
  21011. throw new ArgumentNullException(nameof(begin));
  21012. if (end == null)
  21013. throw new ArgumentNullException(nameof(end));
  21014. #if CRIPPLED_REFLECTION
  21015. 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>>)));
  21016. #else
  21017. 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));
  21018. #endif
  21019. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<Unit>(
  21020. Expression.Invoke(
  21021. Expression.Call(
  21022. null,
  21023. m,
  21024. Expression.Constant(provider, typeof(IQbservableProvider)),
  21025. begin,
  21026. end
  21027. ),
  21028. Expression.Constant(t1, typeof(TArg1)),
  21029. Expression.Constant(t2, typeof(TArg2)),
  21030. Expression.Constant(t3, typeof(TArg3)),
  21031. Expression.Constant(t4, typeof(TArg4)),
  21032. Expression.Constant(t5, typeof(TArg5)),
  21033. Expression.Constant(t6, typeof(TArg6)),
  21034. Expression.Constant(t7, typeof(TArg7)),
  21035. Expression.Constant(t8, typeof(TArg8)),
  21036. Expression.Constant(t9, typeof(TArg9)),
  21037. Expression.Constant(t10, typeof(TArg10)),
  21038. Expression.Constant(t11, typeof(TArg11))
  21039. )
  21040. );
  21041. }
  21042. /// <summary>
  21043. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21044. /// </summary>
  21045. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21046. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21047. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21048. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21049. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21050. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21051. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21052. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21053. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21054. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21055. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21056. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21057. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21058. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21059. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21060. /// <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>
  21061. /// <exception cref="ArgumentNullException">
  21062. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21063. /// <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>
  21064. #if PREFERASYNC
  21065. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21066. #endif
  21067. 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)
  21068. {
  21069. if (provider == null)
  21070. throw new ArgumentNullException(nameof(provider));
  21071. if (begin == null)
  21072. throw new ArgumentNullException(nameof(begin));
  21073. if (end == null)
  21074. throw new ArgumentNullException(nameof(end));
  21075. #if CRIPPLED_REFLECTION
  21076. 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>>)));
  21077. #else
  21078. 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));
  21079. #endif
  21080. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<Unit>(
  21081. Expression.Invoke(
  21082. Expression.Call(
  21083. null,
  21084. m,
  21085. Expression.Constant(provider, typeof(IQbservableProvider)),
  21086. begin,
  21087. end
  21088. ),
  21089. Expression.Constant(t1, typeof(TArg1)),
  21090. Expression.Constant(t2, typeof(TArg2)),
  21091. Expression.Constant(t3, typeof(TArg3)),
  21092. Expression.Constant(t4, typeof(TArg4)),
  21093. Expression.Constant(t5, typeof(TArg5)),
  21094. Expression.Constant(t6, typeof(TArg6)),
  21095. Expression.Constant(t7, typeof(TArg7)),
  21096. Expression.Constant(t8, typeof(TArg8)),
  21097. Expression.Constant(t9, typeof(TArg9)),
  21098. Expression.Constant(t10, typeof(TArg10)),
  21099. Expression.Constant(t11, typeof(TArg11)),
  21100. Expression.Constant(t12, typeof(TArg12))
  21101. )
  21102. );
  21103. }
  21104. /// <summary>
  21105. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21106. /// </summary>
  21107. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21108. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21109. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21110. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21111. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21112. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21113. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21114. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21115. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21116. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21117. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21118. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21119. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21120. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21121. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21122. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21123. /// <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>
  21124. /// <exception cref="ArgumentNullException">
  21125. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21126. /// <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>
  21127. #if PREFERASYNC
  21128. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21129. #endif
  21130. 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)
  21131. {
  21132. if (provider == null)
  21133. throw new ArgumentNullException(nameof(provider));
  21134. if (begin == null)
  21135. throw new ArgumentNullException(nameof(begin));
  21136. if (end == null)
  21137. throw new ArgumentNullException(nameof(end));
  21138. #if CRIPPLED_REFLECTION
  21139. 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>>)));
  21140. #else
  21141. 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));
  21142. #endif
  21143. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<Unit>(
  21144. Expression.Invoke(
  21145. Expression.Call(
  21146. null,
  21147. m,
  21148. Expression.Constant(provider, typeof(IQbservableProvider)),
  21149. begin,
  21150. end
  21151. ),
  21152. Expression.Constant(t1, typeof(TArg1)),
  21153. Expression.Constant(t2, typeof(TArg2)),
  21154. Expression.Constant(t3, typeof(TArg3)),
  21155. Expression.Constant(t4, typeof(TArg4)),
  21156. Expression.Constant(t5, typeof(TArg5)),
  21157. Expression.Constant(t6, typeof(TArg6)),
  21158. Expression.Constant(t7, typeof(TArg7)),
  21159. Expression.Constant(t8, typeof(TArg8)),
  21160. Expression.Constant(t9, typeof(TArg9)),
  21161. Expression.Constant(t10, typeof(TArg10)),
  21162. Expression.Constant(t11, typeof(TArg11)),
  21163. Expression.Constant(t12, typeof(TArg12)),
  21164. Expression.Constant(t13, typeof(TArg13))
  21165. )
  21166. );
  21167. }
  21168. /// <summary>
  21169. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21170. /// </summary>
  21171. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21172. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21173. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21174. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21175. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21176. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21177. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21178. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21179. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21180. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21181. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21182. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21183. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21184. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21185. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  21186. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21187. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21188. /// <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>
  21189. /// <exception cref="ArgumentNullException">
  21190. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21191. /// <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>
  21192. #if PREFERASYNC
  21193. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21194. #endif
  21195. 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)
  21196. {
  21197. if (provider == null)
  21198. throw new ArgumentNullException(nameof(provider));
  21199. if (begin == null)
  21200. throw new ArgumentNullException(nameof(begin));
  21201. if (end == null)
  21202. throw new ArgumentNullException(nameof(end));
  21203. #if CRIPPLED_REFLECTION
  21204. 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>>)));
  21205. #else
  21206. 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));
  21207. #endif
  21208. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<Unit>(
  21209. Expression.Invoke(
  21210. Expression.Call(
  21211. null,
  21212. m,
  21213. Expression.Constant(provider, typeof(IQbservableProvider)),
  21214. begin,
  21215. end
  21216. ),
  21217. Expression.Constant(t1, typeof(TArg1)),
  21218. Expression.Constant(t2, typeof(TArg2)),
  21219. Expression.Constant(t3, typeof(TArg3)),
  21220. Expression.Constant(t4, typeof(TArg4)),
  21221. Expression.Constant(t5, typeof(TArg5)),
  21222. Expression.Constant(t6, typeof(TArg6)),
  21223. Expression.Constant(t7, typeof(TArg7)),
  21224. Expression.Constant(t8, typeof(TArg8)),
  21225. Expression.Constant(t9, typeof(TArg9)),
  21226. Expression.Constant(t10, typeof(TArg10)),
  21227. Expression.Constant(t11, typeof(TArg11)),
  21228. Expression.Constant(t12, typeof(TArg12)),
  21229. Expression.Constant(t13, typeof(TArg13)),
  21230. Expression.Constant(t14, typeof(TArg14))
  21231. )
  21232. );
  21233. }
  21234. /// <summary>
  21235. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21236. /// </summary>
  21237. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21238. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21239. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21240. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21241. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21242. /// <exception cref="ArgumentNullException">
  21243. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21244. /// <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>
  21245. #if PREFERASYNC
  21246. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21247. #endif
  21248. public static Func<IQbservable<TResult>> FromAsyncPattern<TResult>(this IQbservableProvider provider, Expression<Func<AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  21249. {
  21250. if (provider == null)
  21251. throw new ArgumentNullException(nameof(provider));
  21252. if (begin == null)
  21253. throw new ArgumentNullException(nameof(begin));
  21254. if (end == null)
  21255. throw new ArgumentNullException(nameof(end));
  21256. #if CRIPPLED_REFLECTION
  21257. var m = InfoOf(() => Qbservable.FromAsyncPattern<TResult>(default(IQbservableProvider), default(Expression<Func<AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21258. #else
  21259. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TResult));
  21260. #endif
  21261. return () => provider.CreateQuery<TResult>(
  21262. Expression.Invoke(
  21263. Expression.Call(
  21264. null,
  21265. m,
  21266. Expression.Constant(provider, typeof(IQbservableProvider)),
  21267. begin,
  21268. end
  21269. )
  21270. )
  21271. );
  21272. }
  21273. /// <summary>
  21274. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21275. /// </summary>
  21276. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21277. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21278. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21279. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21280. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21281. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21282. /// <exception cref="ArgumentNullException">
  21283. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21284. /// <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>
  21285. #if PREFERASYNC
  21286. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21287. #endif
  21288. public static Func<TArg1, IQbservable<TResult>> FromAsyncPattern<TArg1, TResult>(this IQbservableProvider provider, Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>> begin, Expression<Func<IAsyncResult, TResult>>end)
  21289. {
  21290. if (provider == null)
  21291. throw new ArgumentNullException(nameof(provider));
  21292. if (begin == null)
  21293. throw new ArgumentNullException(nameof(begin));
  21294. if (end == null)
  21295. throw new ArgumentNullException(nameof(end));
  21296. #if CRIPPLED_REFLECTION
  21297. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21298. #else
  21299. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TResult));
  21300. #endif
  21301. return (t1) => provider.CreateQuery<TResult>(
  21302. Expression.Invoke(
  21303. Expression.Call(
  21304. null,
  21305. m,
  21306. Expression.Constant(provider, typeof(IQbservableProvider)),
  21307. begin,
  21308. end
  21309. ),
  21310. Expression.Constant(t1, typeof(TArg1))
  21311. )
  21312. );
  21313. }
  21314. /// <summary>
  21315. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21316. /// </summary>
  21317. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21318. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21319. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21320. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21321. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21322. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21323. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21324. /// <exception cref="ArgumentNullException">
  21325. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21326. /// <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>
  21327. #if PREFERASYNC
  21328. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21329. #endif
  21330. 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)
  21331. {
  21332. if (provider == null)
  21333. throw new ArgumentNullException(nameof(provider));
  21334. if (begin == null)
  21335. throw new ArgumentNullException(nameof(begin));
  21336. if (end == null)
  21337. throw new ArgumentNullException(nameof(end));
  21338. #if CRIPPLED_REFLECTION
  21339. var m = InfoOf(() => Qbservable.FromAsyncPattern<TArg1, TArg2, TResult>(default(IQbservableProvider), default(Expression<Func<TArg1, TArg2, AsyncCallback, object, IAsyncResult>>), default(Expression<Func<IAsyncResult, TResult>>)));
  21340. #else
  21341. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TResult));
  21342. #endif
  21343. return (t1, t2) => provider.CreateQuery<TResult>(
  21344. Expression.Invoke(
  21345. Expression.Call(
  21346. null,
  21347. m,
  21348. Expression.Constant(provider, typeof(IQbservableProvider)),
  21349. begin,
  21350. end
  21351. ),
  21352. Expression.Constant(t1, typeof(TArg1)),
  21353. Expression.Constant(t2, typeof(TArg2))
  21354. )
  21355. );
  21356. }
  21357. /// <summary>
  21358. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21359. /// </summary>
  21360. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21361. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21362. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21363. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21364. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21365. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21366. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21367. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21368. /// <exception cref="ArgumentNullException">
  21369. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21370. /// <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>
  21371. #if PREFERASYNC
  21372. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21373. #endif
  21374. 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)
  21375. {
  21376. if (provider == null)
  21377. throw new ArgumentNullException(nameof(provider));
  21378. if (begin == null)
  21379. throw new ArgumentNullException(nameof(begin));
  21380. if (end == null)
  21381. throw new ArgumentNullException(nameof(end));
  21382. #if CRIPPLED_REFLECTION
  21383. 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>>)));
  21384. #else
  21385. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TResult));
  21386. #endif
  21387. return (t1, t2, t3) => provider.CreateQuery<TResult>(
  21388. Expression.Invoke(
  21389. Expression.Call(
  21390. null,
  21391. m,
  21392. Expression.Constant(provider, typeof(IQbservableProvider)),
  21393. begin,
  21394. end
  21395. ),
  21396. Expression.Constant(t1, typeof(TArg1)),
  21397. Expression.Constant(t2, typeof(TArg2)),
  21398. Expression.Constant(t3, typeof(TArg3))
  21399. )
  21400. );
  21401. }
  21402. /// <summary>
  21403. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21404. /// </summary>
  21405. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21406. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21407. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21408. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21409. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21410. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21411. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21412. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21413. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21414. /// <exception cref="ArgumentNullException">
  21415. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21416. /// <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>
  21417. #if PREFERASYNC
  21418. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21419. #endif
  21420. 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)
  21421. {
  21422. if (provider == null)
  21423. throw new ArgumentNullException(nameof(provider));
  21424. if (begin == null)
  21425. throw new ArgumentNullException(nameof(begin));
  21426. if (end == null)
  21427. throw new ArgumentNullException(nameof(end));
  21428. #if CRIPPLED_REFLECTION
  21429. 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>>)));
  21430. #else
  21431. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TResult));
  21432. #endif
  21433. return (t1, t2, t3, t4) => provider.CreateQuery<TResult>(
  21434. Expression.Invoke(
  21435. Expression.Call(
  21436. null,
  21437. m,
  21438. Expression.Constant(provider, typeof(IQbservableProvider)),
  21439. begin,
  21440. end
  21441. ),
  21442. Expression.Constant(t1, typeof(TArg1)),
  21443. Expression.Constant(t2, typeof(TArg2)),
  21444. Expression.Constant(t3, typeof(TArg3)),
  21445. Expression.Constant(t4, typeof(TArg4))
  21446. )
  21447. );
  21448. }
  21449. /// <summary>
  21450. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21451. /// </summary>
  21452. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21453. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21454. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21455. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21456. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21457. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21458. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21459. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21460. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21461. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21462. /// <exception cref="ArgumentNullException">
  21463. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21464. /// <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>
  21465. #if PREFERASYNC
  21466. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21467. #endif
  21468. 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)
  21469. {
  21470. if (provider == null)
  21471. throw new ArgumentNullException(nameof(provider));
  21472. if (begin == null)
  21473. throw new ArgumentNullException(nameof(begin));
  21474. if (end == null)
  21475. throw new ArgumentNullException(nameof(end));
  21476. #if CRIPPLED_REFLECTION
  21477. 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>>)));
  21478. #else
  21479. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TResult));
  21480. #endif
  21481. return (t1, t2, t3, t4, t5) => provider.CreateQuery<TResult>(
  21482. Expression.Invoke(
  21483. Expression.Call(
  21484. null,
  21485. m,
  21486. Expression.Constant(provider, typeof(IQbservableProvider)),
  21487. begin,
  21488. end
  21489. ),
  21490. Expression.Constant(t1, typeof(TArg1)),
  21491. Expression.Constant(t2, typeof(TArg2)),
  21492. Expression.Constant(t3, typeof(TArg3)),
  21493. Expression.Constant(t4, typeof(TArg4)),
  21494. Expression.Constant(t5, typeof(TArg5))
  21495. )
  21496. );
  21497. }
  21498. /// <summary>
  21499. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21500. /// </summary>
  21501. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21502. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21503. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21504. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21505. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21506. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21507. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21508. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21509. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21510. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21511. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21512. /// <exception cref="ArgumentNullException">
  21513. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21514. /// <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>
  21515. #if PREFERASYNC
  21516. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21517. #endif
  21518. 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)
  21519. {
  21520. if (provider == null)
  21521. throw new ArgumentNullException(nameof(provider));
  21522. if (begin == null)
  21523. throw new ArgumentNullException(nameof(begin));
  21524. if (end == null)
  21525. throw new ArgumentNullException(nameof(end));
  21526. #if CRIPPLED_REFLECTION
  21527. 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>>)));
  21528. #else
  21529. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TResult));
  21530. #endif
  21531. return (t1, t2, t3, t4, t5, t6) => provider.CreateQuery<TResult>(
  21532. Expression.Invoke(
  21533. Expression.Call(
  21534. null,
  21535. m,
  21536. Expression.Constant(provider, typeof(IQbservableProvider)),
  21537. begin,
  21538. end
  21539. ),
  21540. Expression.Constant(t1, typeof(TArg1)),
  21541. Expression.Constant(t2, typeof(TArg2)),
  21542. Expression.Constant(t3, typeof(TArg3)),
  21543. Expression.Constant(t4, typeof(TArg4)),
  21544. Expression.Constant(t5, typeof(TArg5)),
  21545. Expression.Constant(t6, typeof(TArg6))
  21546. )
  21547. );
  21548. }
  21549. /// <summary>
  21550. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21551. /// </summary>
  21552. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21553. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21554. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21555. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21556. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21557. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21558. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21559. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21560. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21561. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21562. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21563. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21564. /// <exception cref="ArgumentNullException">
  21565. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21566. /// <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>
  21567. #if PREFERASYNC
  21568. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21569. #endif
  21570. 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)
  21571. {
  21572. if (provider == null)
  21573. throw new ArgumentNullException(nameof(provider));
  21574. if (begin == null)
  21575. throw new ArgumentNullException(nameof(begin));
  21576. if (end == null)
  21577. throw new ArgumentNullException(nameof(end));
  21578. #if CRIPPLED_REFLECTION
  21579. 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>>)));
  21580. #else
  21581. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TResult));
  21582. #endif
  21583. return (t1, t2, t3, t4, t5, t6, t7) => provider.CreateQuery<TResult>(
  21584. Expression.Invoke(
  21585. Expression.Call(
  21586. null,
  21587. m,
  21588. Expression.Constant(provider, typeof(IQbservableProvider)),
  21589. begin,
  21590. end
  21591. ),
  21592. Expression.Constant(t1, typeof(TArg1)),
  21593. Expression.Constant(t2, typeof(TArg2)),
  21594. Expression.Constant(t3, typeof(TArg3)),
  21595. Expression.Constant(t4, typeof(TArg4)),
  21596. Expression.Constant(t5, typeof(TArg5)),
  21597. Expression.Constant(t6, typeof(TArg6)),
  21598. Expression.Constant(t7, typeof(TArg7))
  21599. )
  21600. );
  21601. }
  21602. /// <summary>
  21603. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21604. /// </summary>
  21605. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21606. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21607. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21608. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21609. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21610. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21611. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21612. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21613. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21614. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21615. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21616. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21617. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21618. /// <exception cref="ArgumentNullException">
  21619. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21620. /// <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>
  21621. #if PREFERASYNC
  21622. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21623. #endif
  21624. 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)
  21625. {
  21626. if (provider == null)
  21627. throw new ArgumentNullException(nameof(provider));
  21628. if (begin == null)
  21629. throw new ArgumentNullException(nameof(begin));
  21630. if (end == null)
  21631. throw new ArgumentNullException(nameof(end));
  21632. #if CRIPPLED_REFLECTION
  21633. 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>>)));
  21634. #else
  21635. var m = ((MethodInfo)MethodInfo.GetCurrentMethod()).MakeGenericMethod(typeof(TArg1), typeof(TArg2), typeof(TArg3), typeof(TArg4), typeof(TArg5), typeof(TArg6), typeof(TArg7), typeof(TArg8), typeof(TResult));
  21636. #endif
  21637. return (t1, t2, t3, t4, t5, t6, t7, t8) => provider.CreateQuery<TResult>(
  21638. Expression.Invoke(
  21639. Expression.Call(
  21640. null,
  21641. m,
  21642. Expression.Constant(provider, typeof(IQbservableProvider)),
  21643. begin,
  21644. end
  21645. ),
  21646. Expression.Constant(t1, typeof(TArg1)),
  21647. Expression.Constant(t2, typeof(TArg2)),
  21648. Expression.Constant(t3, typeof(TArg3)),
  21649. Expression.Constant(t4, typeof(TArg4)),
  21650. Expression.Constant(t5, typeof(TArg5)),
  21651. Expression.Constant(t6, typeof(TArg6)),
  21652. Expression.Constant(t7, typeof(TArg7)),
  21653. Expression.Constant(t8, typeof(TArg8))
  21654. )
  21655. );
  21656. }
  21657. /// <summary>
  21658. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21659. /// </summary>
  21660. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21661. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21662. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21663. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21664. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21665. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21666. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21667. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21668. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21669. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21670. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21671. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21672. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21673. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21674. /// <exception cref="ArgumentNullException">
  21675. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21676. /// <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>
  21677. #if PREFERASYNC
  21678. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21679. #endif
  21680. 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)
  21681. {
  21682. if (provider == null)
  21683. throw new ArgumentNullException(nameof(provider));
  21684. if (begin == null)
  21685. throw new ArgumentNullException(nameof(begin));
  21686. if (end == null)
  21687. throw new ArgumentNullException(nameof(end));
  21688. #if CRIPPLED_REFLECTION
  21689. 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>>)));
  21690. #else
  21691. 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));
  21692. #endif
  21693. return (t1, t2, t3, t4, t5, t6, t7, t8, t9) => provider.CreateQuery<TResult>(
  21694. Expression.Invoke(
  21695. Expression.Call(
  21696. null,
  21697. m,
  21698. Expression.Constant(provider, typeof(IQbservableProvider)),
  21699. begin,
  21700. end
  21701. ),
  21702. Expression.Constant(t1, typeof(TArg1)),
  21703. Expression.Constant(t2, typeof(TArg2)),
  21704. Expression.Constant(t3, typeof(TArg3)),
  21705. Expression.Constant(t4, typeof(TArg4)),
  21706. Expression.Constant(t5, typeof(TArg5)),
  21707. Expression.Constant(t6, typeof(TArg6)),
  21708. Expression.Constant(t7, typeof(TArg7)),
  21709. Expression.Constant(t8, typeof(TArg8)),
  21710. Expression.Constant(t9, typeof(TArg9))
  21711. )
  21712. );
  21713. }
  21714. /// <summary>
  21715. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21716. /// </summary>
  21717. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21718. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21719. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21720. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21721. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21722. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21723. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21724. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21725. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21726. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21727. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21728. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21729. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21730. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21731. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21732. /// <exception cref="ArgumentNullException">
  21733. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21734. /// <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>
  21735. #if PREFERASYNC
  21736. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21737. #endif
  21738. 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)
  21739. {
  21740. if (provider == null)
  21741. throw new ArgumentNullException(nameof(provider));
  21742. if (begin == null)
  21743. throw new ArgumentNullException(nameof(begin));
  21744. if (end == null)
  21745. throw new ArgumentNullException(nameof(end));
  21746. #if CRIPPLED_REFLECTION
  21747. 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>>)));
  21748. #else
  21749. 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));
  21750. #endif
  21751. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) => provider.CreateQuery<TResult>(
  21752. Expression.Invoke(
  21753. Expression.Call(
  21754. null,
  21755. m,
  21756. Expression.Constant(provider, typeof(IQbservableProvider)),
  21757. begin,
  21758. end
  21759. ),
  21760. Expression.Constant(t1, typeof(TArg1)),
  21761. Expression.Constant(t2, typeof(TArg2)),
  21762. Expression.Constant(t3, typeof(TArg3)),
  21763. Expression.Constant(t4, typeof(TArg4)),
  21764. Expression.Constant(t5, typeof(TArg5)),
  21765. Expression.Constant(t6, typeof(TArg6)),
  21766. Expression.Constant(t7, typeof(TArg7)),
  21767. Expression.Constant(t8, typeof(TArg8)),
  21768. Expression.Constant(t9, typeof(TArg9)),
  21769. Expression.Constant(t10, typeof(TArg10))
  21770. )
  21771. );
  21772. }
  21773. /// <summary>
  21774. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21775. /// </summary>
  21776. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21777. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21778. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21779. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21780. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21781. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21782. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21783. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21784. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21785. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21786. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21787. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21788. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21789. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21790. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21791. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21792. /// <exception cref="ArgumentNullException">
  21793. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21794. /// <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>
  21795. #if PREFERASYNC
  21796. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21797. #endif
  21798. 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)
  21799. {
  21800. if (provider == null)
  21801. throw new ArgumentNullException(nameof(provider));
  21802. if (begin == null)
  21803. throw new ArgumentNullException(nameof(begin));
  21804. if (end == null)
  21805. throw new ArgumentNullException(nameof(end));
  21806. #if CRIPPLED_REFLECTION
  21807. 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>>)));
  21808. #else
  21809. 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));
  21810. #endif
  21811. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) => provider.CreateQuery<TResult>(
  21812. Expression.Invoke(
  21813. Expression.Call(
  21814. null,
  21815. m,
  21816. Expression.Constant(provider, typeof(IQbservableProvider)),
  21817. begin,
  21818. end
  21819. ),
  21820. Expression.Constant(t1, typeof(TArg1)),
  21821. Expression.Constant(t2, typeof(TArg2)),
  21822. Expression.Constant(t3, typeof(TArg3)),
  21823. Expression.Constant(t4, typeof(TArg4)),
  21824. Expression.Constant(t5, typeof(TArg5)),
  21825. Expression.Constant(t6, typeof(TArg6)),
  21826. Expression.Constant(t7, typeof(TArg7)),
  21827. Expression.Constant(t8, typeof(TArg8)),
  21828. Expression.Constant(t9, typeof(TArg9)),
  21829. Expression.Constant(t10, typeof(TArg10)),
  21830. Expression.Constant(t11, typeof(TArg11))
  21831. )
  21832. );
  21833. }
  21834. /// <summary>
  21835. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21836. /// </summary>
  21837. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21838. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21839. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21840. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21841. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21842. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21843. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21844. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21845. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21846. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21847. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21848. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21849. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21850. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21851. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21852. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21853. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21854. /// <exception cref="ArgumentNullException">
  21855. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21856. /// <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>
  21857. #if PREFERASYNC
  21858. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21859. #endif
  21860. 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)
  21861. {
  21862. if (provider == null)
  21863. throw new ArgumentNullException(nameof(provider));
  21864. if (begin == null)
  21865. throw new ArgumentNullException(nameof(begin));
  21866. if (end == null)
  21867. throw new ArgumentNullException(nameof(end));
  21868. #if CRIPPLED_REFLECTION
  21869. 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>>)));
  21870. #else
  21871. 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));
  21872. #endif
  21873. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) => provider.CreateQuery<TResult>(
  21874. Expression.Invoke(
  21875. Expression.Call(
  21876. null,
  21877. m,
  21878. Expression.Constant(provider, typeof(IQbservableProvider)),
  21879. begin,
  21880. end
  21881. ),
  21882. Expression.Constant(t1, typeof(TArg1)),
  21883. Expression.Constant(t2, typeof(TArg2)),
  21884. Expression.Constant(t3, typeof(TArg3)),
  21885. Expression.Constant(t4, typeof(TArg4)),
  21886. Expression.Constant(t5, typeof(TArg5)),
  21887. Expression.Constant(t6, typeof(TArg6)),
  21888. Expression.Constant(t7, typeof(TArg7)),
  21889. Expression.Constant(t8, typeof(TArg8)),
  21890. Expression.Constant(t9, typeof(TArg9)),
  21891. Expression.Constant(t10, typeof(TArg10)),
  21892. Expression.Constant(t11, typeof(TArg11)),
  21893. Expression.Constant(t12, typeof(TArg12))
  21894. )
  21895. );
  21896. }
  21897. /// <summary>
  21898. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21899. /// </summary>
  21900. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21901. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21902. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21903. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21904. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21905. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21906. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21907. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21908. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21909. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21910. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21911. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21912. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21913. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21914. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21915. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21916. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21917. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21918. /// <exception cref="ArgumentNullException">
  21919. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21920. /// <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>
  21921. #if PREFERASYNC
  21922. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21923. #endif
  21924. 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)
  21925. {
  21926. if (provider == null)
  21927. throw new ArgumentNullException(nameof(provider));
  21928. if (begin == null)
  21929. throw new ArgumentNullException(nameof(begin));
  21930. if (end == null)
  21931. throw new ArgumentNullException(nameof(end));
  21932. #if CRIPPLED_REFLECTION
  21933. 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>>)));
  21934. #else
  21935. 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));
  21936. #endif
  21937. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) => provider.CreateQuery<TResult>(
  21938. Expression.Invoke(
  21939. Expression.Call(
  21940. null,
  21941. m,
  21942. Expression.Constant(provider, typeof(IQbservableProvider)),
  21943. begin,
  21944. end
  21945. ),
  21946. Expression.Constant(t1, typeof(TArg1)),
  21947. Expression.Constant(t2, typeof(TArg2)),
  21948. Expression.Constant(t3, typeof(TArg3)),
  21949. Expression.Constant(t4, typeof(TArg4)),
  21950. Expression.Constant(t5, typeof(TArg5)),
  21951. Expression.Constant(t6, typeof(TArg6)),
  21952. Expression.Constant(t7, typeof(TArg7)),
  21953. Expression.Constant(t8, typeof(TArg8)),
  21954. Expression.Constant(t9, typeof(TArg9)),
  21955. Expression.Constant(t10, typeof(TArg10)),
  21956. Expression.Constant(t11, typeof(TArg11)),
  21957. Expression.Constant(t12, typeof(TArg12)),
  21958. Expression.Constant(t13, typeof(TArg13))
  21959. )
  21960. );
  21961. }
  21962. /// <summary>
  21963. /// Converts a Begin/End invoke function pair into an asynchronous function.
  21964. /// </summary>
  21965. /// <param name="provider">Query provider used to construct the <see cref="IQbservable{T}"/> data source.</param>
  21966. /// <typeparam name="TArg1">The type of the first argument passed to the begin delegate.</typeparam>
  21967. /// <typeparam name="TArg2">The type of the second argument passed to the begin delegate.</typeparam>
  21968. /// <typeparam name="TArg3">The type of the third argument passed to the begin delegate.</typeparam>
  21969. /// <typeparam name="TArg4">The type of the fourth argument passed to the begin delegate.</typeparam>
  21970. /// <typeparam name="TArg5">The type of the fifth argument passed to the begin delegate.</typeparam>
  21971. /// <typeparam name="TArg6">The type of the sixth argument passed to the begin delegate.</typeparam>
  21972. /// <typeparam name="TArg7">The type of the seventh argument passed to the begin delegate.</typeparam>
  21973. /// <typeparam name="TArg8">The type of the eighth argument passed to the begin delegate.</typeparam>
  21974. /// <typeparam name="TArg9">The type of the ninth argument passed to the begin delegate.</typeparam>
  21975. /// <typeparam name="TArg10">The type of the tenth argument passed to the begin delegate.</typeparam>
  21976. /// <typeparam name="TArg11">The type of the eleventh argument passed to the begin delegate.</typeparam>
  21977. /// <typeparam name="TArg12">The type of the twelfth argument passed to the begin delegate.</typeparam>
  21978. /// <typeparam name="TArg13">The type of the thirteenth argument passed to the begin delegate.</typeparam>
  21979. /// <typeparam name="TArg14">The type of the fourteenth argument passed to the begin delegate.</typeparam>
  21980. /// <typeparam name="TResult">The type of the result returned by the end delegate.</typeparam>
  21981. /// <param name="begin">The delegate that begins the asynchronous operation.</param>
  21982. /// <param name="end">The delegate that ends the asynchronous operation.</param>
  21983. /// <returns>Function that can be used to start the asynchronous operation and retrieve the result as an observable sequence.</returns>
  21984. /// <exception cref="ArgumentNullException">
  21985. /// <paramref name="begin" /> or <paramref name="end" /> is null.</exception>
  21986. /// <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>
  21987. #if PREFERASYNC
  21988. [Obsolete(Constants_Linq.USE_TASK_FROMASYNCPATTERN)]
  21989. #endif
  21990. 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)
  21991. {
  21992. if (provider == null)
  21993. throw new ArgumentNullException(nameof(provider));
  21994. if (begin == null)
  21995. throw new ArgumentNullException(nameof(begin));
  21996. if (end == null)
  21997. throw new ArgumentNullException(nameof(end));
  21998. #if CRIPPLED_REFLECTION
  21999. 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>>)));
  22000. #else
  22001. 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));
  22002. #endif
  22003. return (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) => provider.CreateQuery<TResult>(
  22004. Expression.Invoke(
  22005. Expression.Call(
  22006. null,
  22007. m,
  22008. Expression.Constant(provider, typeof(IQbservableProvider)),
  22009. begin,
  22010. end
  22011. ),
  22012. Expression.Constant(t1, typeof(TArg1)),
  22013. Expression.Constant(t2, typeof(TArg2)),
  22014. Expression.Constant(t3, typeof(TArg3)),
  22015. Expression.Constant(t4, typeof(TArg4)),
  22016. Expression.Constant(t5, typeof(TArg5)),
  22017. Expression.Constant(t6, typeof(TArg6)),
  22018. Expression.Constant(t7, typeof(TArg7)),
  22019. Expression.Constant(t8, typeof(TArg8)),
  22020. Expression.Constant(t9, typeof(TArg9)),
  22021. Expression.Constant(t10, typeof(TArg10)),
  22022. Expression.Constant(t11, typeof(TArg11)),
  22023. Expression.Constant(t12, typeof(TArg12)),
  22024. Expression.Constant(t13, typeof(TArg13)),
  22025. Expression.Constant(t14, typeof(TArg14))
  22026. )
  22027. );
  22028. }
  22029. }
  22030. }
  22031. #pragma warning restore 1591